From f8ea0dd6459856f2df18ca2ad532d49432a087dd Mon Sep 17 00:00:00 2001 From: Laser9un Date: Fri, 29 Nov 2019 16:16:50 +0200 Subject: [PATCH 1/1] Add selectable Qt GUI Styles 1. Default: -qtstyle=0 2. Vertical: -qtstyle=1 3. Vertical-grey: -qtstyle=2 --- src/qt/bitcoingui.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++++---- src/qt/bitcoingui.h | 4 +- 2 files changed, 77 insertions(+), 8 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 15c8075..db888a8 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -101,17 +101,74 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): setUnifiedTitleAndToolBarOnMac(true); QApplication::setAttribute(Qt::AA_DontShowIconsInMenus); #endif + + int nQtStyle = GetArg("-qtstyle", 0); + if(nQtStyle < 0) nQtStyle = 0; + + if(!nQtStyle) { + resize(850, 550); + qApp->setStyleSheet(""); + } else if(nQtStyle == 1) { + resize(850, 525); +#ifndef Q_OS_MAC + qApp->setStyleSheet("QToolBar QToolButton { text-align: center; width: 100%; \ + padding-left: 5px; padding-right: 5px; padding-top: 2px; padding-bottom: 2px; \ + margin-top: 2px; } \ + QToolBar QToolButton:hover { font-weight: bold; } \ + #toolbar { border: none; height: 100%; min-width: 150px; max-width: 150px; } \ + QMenuBar { min-height: 20px; }"); +#else + qApp->setStyleSheet("QToolBar QToolButton { text-align: center; width: 100%; \ + padding-left: 5px; padding-right: 5px; padding-top: 2px; padding-bottom: 2px; \ + margin-top: 2px; } \ + QToolBar QToolButton:hover { font-weight: bold; background-color: transparent; } \ + #toolbar { border: none; height: 100%; min-width: 150px; max-width: 150px; }"); +#endif + } else { + resize(850, 525); +#ifndef Q_OS_MAC + qApp->setStyleSheet("QToolBar QToolButton { text-align: center; width: 100%; \ + color: white; background-color: grey; padding-left: 5px; padding-right: 5px; \ + padding-top: 2px; padding-bottom: 2px; margin-top: 2px; } \ + QToolBar QToolButton:hover { font-weight: bold; \ + background-color: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 2, \ + stop: 0 #808080, stop: 1 #d2d2d2); } \ + #toolbar { border: none; height: 100%; min-width: 150px; max-width: 150px; \ + background-color: grey; } \ + QMenuBar { color: white; background-color: grey; } \ + QMenuBar::item { color: white; background-color: grey; \ + padding-top: 6px; padding-bottom: 6px; \ + padding-left: 10px; padding-right: 10px; } \ + QMenuBar::item:selected { background-color: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 2, \ + stop: 0 #808080, stop: 1 #d2d2d2); } \ + QMenu { border: 1px solid; color: black; background-color: grey; } \ + QMenu::item { background-color: grey; } \ + QMenu::item:disabled { color: gray; } \ + QMenu::item:enabled:selected { color: white; background-color: grey; } \ + QMenu::separator { height: 4px; }"); +#else + qApp->setStyleSheet("QToolBar QToolButton { text-align: center; width: 100%; \ + color: white; padding-left: 5px; padding-right: 5px; \ + padding-top: 2px; padding-bottom: 2px; margin-top: 2px; } \ + QToolBar QToolButton:hover { font-weight: bold; \ + background-color: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 2, \ + stop: 0 #808080, stop: 1 #d2d2d2); } \ + #toolbar { border: none; height: 100%; min-width: 150px; max-width: 150px; \ + background-color: grey; }"); +#endif + } + // Accept D&D of URIs setAcceptDrops(true); // Create actions for the toolbar, menu bar and tray/dock icon - createActions(); + createActions(nQtStyle); // Create application menu bar createMenuBar(); // Create the toolbars - createToolBars(); + createToolBars(nQtStyle); // Create the tray icon (or setup the dock icon) createTrayIcon(); @@ -237,7 +294,7 @@ BitcoinGUI::~BitcoinGUI() delete signVerifyMessageDialog; } -void BitcoinGUI::createActions() +void BitcoinGUI::createActions(int nQtStyle) { QActionGroup *tabGroup = new QActionGroup(this); @@ -407,10 +464,22 @@ void BitcoinGUI::createMenuBar() help->addAction(aboutQtAction); } -void BitcoinGUI::createToolBars() +void BitcoinGUI::createToolBars(int nQtStyle) { - QToolBar *toolbar = addToolBar(tr("Tabs toolbar")); - toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + QToolBar *toolbar = addToolBar(tr("Primary tool bar")); + toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + toolbar->setMovable(false); + toolbar->setIconSize(QSize(32, 32)); + + if(!nQtStyle) { + toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + } else { + toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + toolbar->setObjectName("toolbar"); + addToolBar(Qt::LeftToolBarArea, toolbar); + toolbar->setOrientation(Qt::Vertical); + } + toolbar->addAction(overviewAction); toolbar->addAction(sendCoinsAction); toolbar->addAction(receiveCoinsAction); diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 20eb7ca..f4e72b3 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -119,11 +119,11 @@ private: QMovie *syncIconMovie; /** Create the main UI actions. */ - void createActions(); + void createActions(int nQtStyle); /** Create the menu bar and sub-menus. */ void createMenuBar(); /** Create the toolbars */ - void createToolBars(); + void createToolBars(int nQtStyle); /** Create system tray (notification) icon */ void createTrayIcon(); -- 1.7.1