Browse Source

v_white theme: support scrollbar style

Le Tan 8 years ago
parent
commit
8e48b43cda

+ 8 - 0
src/resources/themes/v_white/down.svg

@@ -0,0 +1,8 @@
+<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
+ <g>
+  <title>Layer 1</title>
+  <g transform="null" id="svg_1">
+   <polygon points="128,192 256,320 384,192  " id="svg_2" fill="#333333"/>
+  </g>
+ </g>
+</svg>

+ 8 - 0
src/resources/themes/v_white/down_disabled.svg

@@ -0,0 +1,8 @@
+<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
+ <g>
+  <title>Layer 1</title>
+  <g transform="null" id="svg_1">
+   <polygon points="128,192 256,320 384,192  " id="svg_2" fill="#C0C0C0"/>
+  </g>
+ </g>
+</svg>

+ 8 - 0
src/resources/themes/v_white/left.svg

@@ -0,0 +1,8 @@
+<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
+ <g>
+  <title>Layer 1</title>
+  <g transform="rotate(90 255.99999999999997,256.00000000000006) " id="svg_1">
+   <polygon points="128,192 256,320 384,192  " id="svg_2" fill="#333333"/>
+  </g>
+ </g>
+</svg>

+ 8 - 0
src/resources/themes/v_white/left_disabled.svg

@@ -0,0 +1,8 @@
+<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
+ <g>
+  <title>Layer 1</title>
+  <g transform="rotate(90 255.99999999999997,256.00000000000006) " id="svg_1">
+   <polygon points="128,192 256,320 384,192  " id="svg_2" fill="#C0C0C0"/>
+  </g>
+ </g>
+</svg>

+ 8 - 0
src/resources/themes/v_white/right.svg

@@ -0,0 +1,8 @@
+<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
+ <g>
+  <title>Layer 1</title>
+  <g transform="rotate(-90 256.00000000000006,256) " id="svg_1">
+   <polygon fill="#333333" id="svg_2" points="128,192 256,320 384,192  "/>
+  </g>
+ </g>
+</svg>

+ 8 - 0
src/resources/themes/v_white/right_disabled.svg

@@ -0,0 +1,8 @@
+<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
+ <g>
+  <title>Layer 1</title>
+  <g transform="rotate(-90 256.00000000000006,256) " id="svg_1">
+   <polygon fill="#C0C0C0" id="svg_2" points="128,192 256,320 384,192  "/>
+  </g>
+ </g>
+</svg>

+ 8 - 0
src/resources/themes/v_white/up.svg

@@ -0,0 +1,8 @@
+<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
+ <g>
+  <title>Layer 1</title>
+  <g transform="rotate(180 255.99999999999997,256) " id="svg_1">
+   <polygon points="128,192 256,320 384,192  " id="svg_2" fill="#333333"/>
+  </g>
+ </g>
+</svg>

+ 8 - 0
src/resources/themes/v_white/up_disabled.svg

@@ -0,0 +1,8 @@
+<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
+ <g>
+  <title>Layer 1</title>
+  <g transform="rotate(180 255.99999999999997,256) " id="svg_1">
+   <polygon points="128,192 256,320 384,192  " id="svg_2" fill="#C0C0C0"/>
+  </g>
+ </g>
+</svg>

+ 8 - 1
src/resources/themes/v_white/v_white.palette

@@ -67,6 +67,12 @@ danger_icon_fg=@danger_red
 item_icon_fg=@icon_fg
 title_icon_fg=@icon_fg
 
+; VVimIndicator.
+vim_indicator_key_label_fg=@base_fg
+vim_indicator_key_label_bg=@base_bg
+vim_indicator_mode_label_fg=@base_fg
+vim_indicator_cmd_edit_pending_bg=@selected_bg
+
 [widgets]
 ; Widget color attributes.
 
@@ -240,7 +246,8 @@ statusbar_bg=@main_bg
 ; ScrollBar.
 scrollbar_bg=#EEEEEE
 scrollbar_handle_bg=#D0D0D0
-scrollbar_addline_bg=#E0E0E0
+scrollbar_handle_hover_bg=@hover_bg
+scrollbar_handle_pressed_bg=@pressed_bg
 
 ; VEditWindow.
 editwindow_corner_icon_fg=@icon_fg

+ 174 - 0
src/resources/themes/v_white/v_white.qss

@@ -478,6 +478,18 @@ QLabel[MenuSeparator="true"] {
     border-top: 1px solid @menu_separator_bg
 }
 
+VVimIndicator QLabel[VimIndicatorKeyLabel="true"] {
+    font: bold;
+    color: @vim_indicator_key_label_fg;
+    background: @vim_indicator_key_label_bg;
+}
+
+VVimIndicator QLabel[VimIndicatorModeLabel="true"] {
+    padding: 0px 2px 0px 2px;
+    font: bold;
+    color: @vim_indicator_mode_label_fg;
+    /* background color will be controlled by the code. */
+}
 /* End QLabel */
 
 /* QLineEdit */
@@ -494,6 +506,8 @@ QLineEdit[VimCommandLine="true"] {
     padding: 0px;
     margin: 0px;
     border: none;
+    color: @lineedit_fg;
+    background: @lineedit_bg;
 }
 /* End QLineEdit */
 
@@ -548,6 +562,30 @@ QTabBar::close-button:focus {
     image: url(close.svg);
     background-color: @tabbar_closebutton_focus_bg;
 }
+
+QTabBar::scroller {
+    width: 20px;
+}
+
+QTabBar QToolButton {
+    border: none;
+}
+
+QTabBar QToolButton::right-arrow:enabled {
+    image: url(right.svg);
+}
+
+QTabBar QToolButton::left-arrow:enabled {
+    image: url(left.svg);
+}
+
+QTabBar QToolButton::right-arrow:disabled {
+    image: url(right_disabled.svg);
+}
+
+QTabBar QToolButton::left-arrow:disabled {
+    image: url(left_disabled.svg);
+}
 /* End QTabBar */
 
 VSelectorItemWidget QLabel[SelectorItemShortcutLabel="true"] {
@@ -699,3 +737,139 @@ QDialog {
     color: @base_fg;
     background: @base_bg;
 }
+
+/* QScrollBar */
+QScrollBar:vertical {
+    background: @scrollbar_bg;
+    width: 20px;
+    margin: 20px 0px 20px 0px;
+    padding: 0px 2px 0px 2px;
+    border: none;
+}
+
+QScrollBar::handle:vertical {
+    background: @scrollbar_handle_bg;
+    min-height: 20px;
+}
+
+QScrollBar::handle:vertical:hover {
+    background: @scrollbar_handle_hover_bg;
+}
+
+QScrollBar::handle:vertical:pressed {
+    background: @scrollbar_handle_pressed_bg;
+}
+
+QScrollBar::add-line:vertical {
+    border: none;
+    background: @scrollbar_bg;
+    width: 20px;
+    height: 20px;
+    subcontrol-position: bottom;
+    subcontrol-origin: margin;
+}
+
+QScrollBar::add-line:vertical:hover {
+    background: @scrollbar_handle_hover_bg;
+}
+
+QScrollBar::add-line:vertical:pressed {
+    background: @scrollbar_handle_pressed_bg;
+}
+
+QScrollBar::sub-line:vertical {
+    border: none;
+    background: @scrollbar_bg;
+    width: 20px;
+    height: 20px;
+    subcontrol-position: top;
+    subcontrol-origin: margin;
+}
+
+QScrollBar::sub-line:vertical:hover {
+    background: @scrollbar_handle_hover_bg;
+}
+
+QScrollBar::sub-line:vertical:pressed {
+    background: @scrollbar_handle_pressed_bg;
+}
+
+QScrollBar::down-arrow:vertical {
+    image: url(down.svg);
+    width: 20px;
+    height: 20px;
+}
+
+QScrollBar::up-arrow:vertical {
+    image: url(up.svg);
+    width: 20px;
+    height: 20px;
+}
+
+QScrollBar:horizontal {
+    background: @scrollbar_bg;
+    height: 20px;
+    margin: 0px 20px 0px 20px;
+    padding: 2px 0px 2px 0px;
+    border: none;
+}
+
+QScrollBar::handle:horizontal {
+    background: @scrollbar_handle_bg;
+    min-width: 20px;
+}
+
+QScrollBar::handle:horizontal:hover {
+    background: @scrollbar_handle_hover_bg;
+}
+
+QScrollBar::handle:horizontal:pressed {
+    background: @scrollbar_handle_pressed_bg;
+}
+
+QScrollBar::add-line:horizontal {
+    border: none;
+    background: @scrollbar_bg;
+    width: 20px;
+    height: 20px;
+    subcontrol-position: right;
+    subcontrol-origin: margin;
+}
+
+QScrollBar::add-line:horizontal:hover {
+    background: @scrollbar_handle_hover_bg;
+}
+
+QScrollBar::add-line:horizontal:pressed {
+    background: @scrollbar_handle_pressed_bg;
+}
+
+QScrollBar::sub-line:horizontal {
+    border: none;
+    background: @scrollbar_bg;
+    width: 20px;
+    height: 20px;
+    subcontrol-position: left;
+    subcontrol-origin: margin;
+}
+
+QScrollBar::sub-line:horizontal:hover {
+    background: @scrollbar_handle_hover_bg;
+}
+
+QScrollBar::sub-line:horizontal:pressed {
+    background: @scrollbar_handle_pressed_bg;
+}
+
+QScrollBar::right-arrow:horizontal {
+    image: url(right.svg);
+    width: 20px;
+    height: 20px;
+}
+
+QScrollBar::left-arrow:horizontal {
+    image: url(left.svg);
+    width: 20px;
+    height: 20px;
+}
+/* End QScrollBar */

+ 16 - 8
src/veditwindow.cpp

@@ -516,6 +516,11 @@ void VEditWindow::updateTabStatus(int p_index)
 
 void VEditWindow::updateTabInfo(int p_index)
 {
+    static QIcon editModified = VIconUtils::tabBarSpecialIcon(":/resources/icons/editing_modified.svg");
+    static QIcon edit = VIconUtils::tabBarIcon(":/resources/icons/editing.svg");
+    static QIcon readModified = VIconUtils::tabBarSpecialIcon(":/resources/icons/reading_modified.svg");
+    static QIcon read = VIconUtils::tabBarIcon(":/resources/icons/reading.svg");
+
     VEditTab *editor = getTab(p_index);
     const VFile *file = editor->getFile();
     bool editMode = editor->isEditMode();
@@ -525,11 +530,9 @@ void VEditWindow::updateTabInfo(int p_index)
 
     QIcon icon;
     if (editMode) {
-        icon = editor->isModified() ? VIconUtils::tabBarSpecialIcon(":/resources/icons/editing_modified.svg")
-                                    : VIconUtils::tabBarIcon(":/resources/icons/editing.svg");
+        icon = editor->isModified() ? editModified : edit;
     } else {
-        icon = editor->isModified() ? VIconUtils::tabBarSpecialIcon(":/resources/icons/reading_modified.svg")
-                                    : VIconUtils::tabBarIcon(":/resources/icons/reading.svg");
+        icon = editor->isModified() ? readModified : read;
     }
 
     setTabIcon(p_index, icon);
@@ -968,12 +971,17 @@ void VEditWindow::connectEditTab(const VEditTab *p_tab)
 
 void VEditWindow::setCurrentWindow(bool p_current)
 {
+    static QIcon menuCur = VIconUtils::editWindowCornerIcon(":/resources/icons/corner_menu_cur.svg");
+    static QIcon tablistCur = VIconUtils::editWindowCornerIcon(":/resources/icons/corner_tablist_cur.svg");
+    static QIcon menu = VIconUtils::editWindowCornerInactiveIcon(":/resources/icons/corner_menu.svg");
+    static QIcon tablist = VIconUtils::editWindowCornerInactiveIcon(":/resources/icons/corner_tablist.svg");
+
     if (p_current) {
-        rightBtn->setIcon(VIconUtils::editWindowCornerIcon(":/resources/icons/corner_menu_cur.svg"));
-        leftBtn->setIcon(VIconUtils::editWindowCornerIcon(":/resources/icons/corner_tablist_cur.svg"));
+        rightBtn->setIcon(menuCur);
+        leftBtn->setIcon(tablistCur);
     } else {
-        rightBtn->setIcon(VIconUtils::editWindowCornerInactiveIcon(":/resources/icons/corner_menu.svg"));
-        leftBtn->setIcon(VIconUtils::editWindowCornerInactiveIcon(":/resources/icons/corner_tablist.svg"));
+        rightBtn->setIcon(menu);
+        leftBtn->setIcon(tablist);
     }
 }
 

+ 0 - 4
src/vmainwindow.cpp

@@ -506,8 +506,6 @@ void VMainWindow::initEditToolBar(QSize p_iconSize)
 
     m_editToolBar->addAction(codeBlockAct);
 
-    m_editToolBar->addSeparator();
-
     // Insert link.
     QAction *insetLinkAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/link.svg"),
                                         tr("Insert Link\t%1").arg(VUtils::getShortcutText("Ctrl+L")),
@@ -668,13 +666,11 @@ void VMainWindow::initFileToolBar(QSize p_iconSize)
 
     fileToolBar->addAction(newRootDirAct);
     fileToolBar->addAction(newNoteAct);
-    fileToolBar->addSeparator();
     fileToolBar->addAction(noteInfoAct);
     fileToolBar->addAction(deleteNoteAct);
     fileToolBar->addAction(editNoteAct);
     fileToolBar->addAction(saveExitAct);
     fileToolBar->addAction(saveNoteAct);
-    fileToolBar->addSeparator();
 }
 
 void VMainWindow::initMenuBar()

+ 8 - 0
src/vnote.qrc

@@ -151,5 +151,13 @@
         <file>resources/themes/v_white/branch_more.svg</file>
         <file>resources/themes/v_white/branch_open.svg</file>
         <file>resources/themes/v_white/line.svg</file>
+        <file>resources/themes/v_white/down.svg</file>
+        <file>resources/themes/v_white/left.svg</file>
+        <file>resources/themes/v_white/right.svg</file>
+        <file>resources/themes/v_white/up.svg</file>
+        <file>resources/themes/v_white/left_disabled.svg</file>
+        <file>resources/themes/v_white/right_disabled.svg</file>
+        <file>resources/themes/v_white/down_disabled.svg</file>
+        <file>resources/themes/v_white/up_disabled.svg</file>
     </qresource>
 </RCC>

+ 8 - 7
src/vvimindicator.cpp

@@ -13,9 +13,12 @@
 #include "vconfigmanager.h"
 #include "vbuttonwithwidget.h"
 #include "vedittab.h"
+#include "vpalette.h"
 
 extern VConfigManager *g_config;
 
+extern VPalette *g_palette;
+
 VVimIndicator::VVimIndicator(QWidget *p_parent)
     : QWidget(p_parent), m_vim(NULL)
 {
@@ -99,6 +102,7 @@ void VVimIndicator::setupUI()
     m_cmdLineEdit->hide();
 
     m_modeLabel = new QLabel(this);
+    m_modeLabel->setProperty("VimIndicatorModeLabel", true);
 
     QTreeWidget *regTree = new QTreeWidget(this);
     regTree->setColumnCount(2);
@@ -133,6 +137,7 @@ void VVimIndicator::setupUI()
             this, &VVimIndicator::updateMarksTree);
 
     m_keyLabel = new QLabel(this);
+    m_keyLabel->setProperty("VimIndicatorKeyLabel", true);
     QFontMetrics metric(font());
     m_keyLabel->setMinimumWidth(metric.width('A') * 5);
 
@@ -268,9 +273,7 @@ void VVimIndicator::update(const VVim *p_vim, const VEditTab *p_editTab)
         pendingKeys = p_vim->getPendingKeys();
     }
 
-    QString style = QString("QLabel { padding: 0px 2px 0px 2px; font: bold; background-color: %1; }")
-                           .arg(modeBackgroundColor(mode));
-    m_modeLabel->setStyleSheet(style);
+    m_modeLabel->setStyleSheet(QString("background: %1;").arg(modeBackgroundColor(mode)));
     m_modeLabel->setText(modeToString(mode));
 
     m_regBtn->setText(curRegName);
@@ -279,9 +282,7 @@ void VVimIndicator::update(const VVim *p_vim, const VEditTab *p_editTab)
                               .arg(lastUsedMark.isNull() ? QChar(' ') : lastUsedMark);
     m_markBtn->setText(markText);
 
-    QString keyText = QString("<span style=\"font-weight:bold; color: %1;\">%2</span>")
-                             .arg("#15AE67").arg(pendingKeys);
-    m_keyLabel->setText(keyText);
+    m_keyLabel->setText(pendingKeys);
 }
 
 void VVimIndicator::updateRegistersTree(QWidget *p_widget)
@@ -550,7 +551,7 @@ void VVimCmdLineEdit::setRegisterPending(bool p_pending)
 {
     if (p_pending && !m_registerPending) {
         // Going to pending.
-        setStyleSheet("QLineEdit { background: #D6EACE }");
+        setStyleSheet(QString("background: %1;").arg(g_palette->color("vim_indicator_cmd_edit_pending_bg")));
     } else if (!p_pending && m_registerPending) {
         // Leaving pending.
         setStyleSheet(m_originStyleSheet);