Browse Source

fix styles

Le Tan 4 years ago
parent
commit
3b03fd2189

+ 7 - 1
src/data/extra/themes/moonlight/interface.qss

@@ -152,8 +152,14 @@ QToolBar::separator {
     background-color: @widgets#qtoolbar#separator#bg;
 }
 
-QToolBarExtension {
+QToolBarExtension#qt_toolbar_ext_button {
     background-color: @widgets#qtoolbar#extension#bg;
+    margin: 30px;
+}
+
+QToolBarExtension#qt_toolbar_ext_button:hover {
+    background-color: @widgets#qtoolbar#extension#hover#bg;
+    margin: 30px;
 }
 
 /* QToolButton */

+ 4 - 1
src/data/extra/themes/moonlight/palette.json

@@ -302,7 +302,10 @@
                 "bg" : "@widgets#separator#bg"
             },
             "extension" : {
-                "bg" : "@base#normal#fg"
+                "bg" : "@base#normal#border",
+                "hover" : {
+                    "bg" : "@base#hover#bg"
+                }
             }
         },
         "qtoolbutton" : {

+ 7 - 1
src/data/extra/themes/pure/interface.qss

@@ -152,8 +152,14 @@ QToolBar::separator {
     background-color: @widgets#qtoolbar#separator#bg;
 }
 
-QToolBarExtension {
+QToolBarExtension#qt_toolbar_ext_button {
     background-color: @widgets#qtoolbar#extension#bg;
+    margin: 30px;
+}
+
+QToolBarExtension#qt_toolbar_ext_button:hover {
+    background-color: @widgets#qtoolbar#extension#hover#bg;
+    margin: 30px;
 }
 
 /* QToolButton */

+ 4 - 1
src/data/extra/themes/pure/palette.json

@@ -298,7 +298,10 @@
                 "bg" : "@widgets#separator#bg"
             },
             "extension" : {
-                "bg" : "@base#normal#fg"
+                "bg" : "@base#normal#border",
+                "hover" : {
+                    "bg" : "@base#hover#bg"
+                }
             }
         },
         "qtoolbutton" : {

+ 2 - 1
src/utils/widgetutils.cpp

@@ -415,5 +415,6 @@ void WidgetUtils::selectBaseName(QLineEdit *p_lineEdit)
 
 void WidgetUtils::setContentsMargins(QLayout *p_layout)
 {
-    p_layout->setContentsMargins(CONTENTS_MARGIN, CONTENTS_MARGIN, CONTENTS_MARGIN, CONTENTS_MARGIN);
+    // Use 0 bottom margin to align dock widgets with the content area.
+    p_layout->setContentsMargins(CONTENTS_MARGIN, CONTENTS_MARGIN, CONTENTS_MARGIN, 0);
 }

+ 0 - 6
src/widgets/markdownviewwindow.cpp

@@ -251,12 +251,6 @@ void MarkdownViewWindow::handleBufferChangedInternal(const QSharedPointer<FileOp
 void MarkdownViewWindow::setupToolBar()
 {
     auto toolBar = createToolBar(this);
-
-    const auto &editorConfig = ConfigMgr::getInst().getEditorConfig();
-
-    const int iconSize = editorConfig.getToolBarIconSize();
-    toolBar->setIconSize(QSize(iconSize, iconSize));
-
     addToolBar(toolBar);
 
     addAction(toolBar, ViewWindowToolBarHelper::EditReadDiscard);

+ 8 - 9
src/widgets/outlinepopup.cpp

@@ -14,11 +14,6 @@ OutlinePopup::OutlinePopup(QToolButton *p_btn, QWidget *p_parent)
       m_button(p_btn)
 {
     setupUI();
-
-    connect(this, &QMenu::aboutToShow,
-            this, [this]() {
-                m_viewer->setFocus();
-            });
 }
 
 void OutlinePopup::setupUI()
@@ -41,8 +36,12 @@ void OutlinePopup::showEvent(QShowEvent* p_event)
 {
     QMenu::showEvent(p_event);
 
-    const auto p = pos();
-    const auto btnRect = m_button->geometry();
-    // Move it to right-aligned.
-    move(p.x() + btnRect.width() - geometry().width(), p.y());
+    m_viewer->setFocus();
+
+    // Move it to be right-aligned.
+    if (m_button->isVisible()) {
+        const auto p = pos();
+        const auto btnRect = m_button->geometry();
+        move(p.x() + btnRect.width() - geometry().width(), p.y());
+    }
 }

+ 0 - 4
src/widgets/textviewwindow.cpp

@@ -60,10 +60,6 @@ void TextViewWindow::setupUI()
 void TextViewWindow::setupToolBar()
 {
     auto toolBar = createToolBar(this);
-    const auto &editorConfig = ConfigMgr::getInst().getEditorConfig();
-    const int iconSize = editorConfig.getToolBarIconSize();
-    toolBar->setIconSize(QSize(iconSize, iconSize));
-
     addToolBar(toolBar);
 
     addAction(toolBar, ViewWindowToolBarHelper::Save);

+ 10 - 0
src/widgets/viewwindow.cpp

@@ -1146,6 +1146,16 @@ QToolBar *ViewWindow::createToolBar(QWidget *p_parent)
 {
     auto toolBar = new QToolBar(p_parent);
     toolBar->setProperty(PropertyDefs::c_viewWindowToolBar, true);
+
+    const auto &editorConfig = ConfigMgr::getInst().getEditorConfig();
+    const int iconSize = editorConfig.getToolBarIconSize();
+    toolBar->setIconSize(QSize(iconSize, iconSize));
+
+    /*
+    auto extBtn = toolBar->findChild<QToolButton *>(QLatin1String("qt_toolbar_ext_button"));
+    Q_ASSERT(extBtn);
+    */
+
     return toolBar;
 }