From 42cdbd1ae0618f70d1af540f2bd799ecab058e09 Mon Sep 17 00:00:00 2001 From: fdov Date: Tue, 25 May 2021 23:59:47 +0200 Subject: [PATCH] gui: option to hide text in toolbar Add option to only show icons in toolbar. Closes #478 --- src/qt/forms/optionsdialog.ui | 12 +++++++++++- src/qt/optionsdialog.cpp | 2 ++ src/qt/optionsmodel.cpp | 11 +++++++++++ src/qt/optionsmodel.h | 2 ++ src/qt/raven.qrc | 1 + src/qt/ravengui.cpp | 26 ++++++++++++++++++++++---- src/qt/res/icons/rvntext.png | Bin 0 -> 1283 bytes 7 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 src/qt/res/icons/rvntext.png diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 054236a8d6..11baa0ff98 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -20,7 +20,7 @@ - 4 + 3 @@ -541,6 +541,16 @@ + + + + Only show toolbar icons. No text. + + + &Icons only + + + diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index a1b7776004..da72fafa27 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -176,6 +176,7 @@ void OptionsDialog::setModel(OptionsModel *_model) connect(ui->thirdPartyTxUrls, SIGNAL(textChanged(const QString &)), this, SLOT(showRestartWarning())); connect(ui->ipfsUrl, SIGNAL(textChanged(const QString &)), this, SLOT(showRestartWarning())); connect(ui->darkModeCheckBox, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning())); + connect(ui->toolbarIconsOnly, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning())); } void OptionsDialog::setMapper() @@ -216,6 +217,7 @@ void OptionsDialog::setMapper() mapper->addMapping(ui->currencyUnitIndex, OptionsModel::DisplayCurrencyIndex); mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls); mapper->addMapping(ui->ipfsUrl, OptionsModel::IpfsUrl); + mapper->addMapping(ui->toolbarIconsOnly, OptionsModel::ToolbarIconsOnly); } void OptionsDialog::setOkButtonState(bool fState) diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 4944f4c6bc..aed9dc0bf6 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -70,6 +70,10 @@ void OptionsModel::Init(bool resetSettings) settings.setValue("fMinimizeOnClose", false); fMinimizeOnClose = settings.value("fMinimizeOnClose").toBool(); + if (!settings.contains("fToolbarIconsOnly")) + settings.setValue("fToolbarIconsOnly", false); + fToolbarIconsOnly = settings.value("fToolbarIconsOnly").toBool(); + // Display if (!settings.contains("nDisplayUnit")) settings.setValue("nDisplayUnit", RavenUnits::RVN); @@ -232,6 +236,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const return fHideTrayIcon; case MinimizeToTray: return fMinimizeToTray; + case ToolbarIconsOnly: + return fToolbarIconsOnly; case MapPortUPnP: #ifdef USE_UPNP return settings.value("fUseUPnP"); @@ -323,6 +329,11 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in fMinimizeToTray = value.toBool(); settings.setValue("fMinimizeToTray", fMinimizeToTray); break; + case ToolbarIconsOnly: + fToolbarIconsOnly = value.toBool(); + settings.setValue("fToolbarIconsOnly", fToolbarIconsOnly); + setRestartRequired(true); + break; case MapPortUPnP: // core option - can be changed on-the-fly settings.setValue("fUseUPnP", value.toBool()); MapPort(value.toBool()); diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 5db6e02ab9..d2c22ea133 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -31,6 +31,7 @@ class OptionsModel : public QAbstractListModel StartAtStartup, // bool HideTrayIcon, // bool MinimizeToTray, // bool + ToolbarIconsOnly, // bool MapPortUPnP, // bool MinimizeOnClose, // bool ProxyUse, // bool @@ -88,6 +89,7 @@ class OptionsModel : public QAbstractListModel bool fHideTrayIcon; bool fMinimizeToTray; bool fMinimizeOnClose; + bool fToolbarIconsOnly; QString language; int nDisplayUnit; int nDisplayCurrencyIndex; diff --git a/src/qt/raven.qrc b/src/qt/raven.qrc index 26b8ff2886..b5e164c6df 100644 --- a/src/qt/raven.qrc +++ b/src/qt/raven.qrc @@ -72,6 +72,7 @@ res/icons/asset_transfer.png res/icons/asset_transfer_selected.png res/icons/ravencointext.png + res/icons/rvntext.png res/icons/restricted_asset.png res/icons/restricted_asset_selected.png diff --git a/src/qt/ravengui.cpp b/src/qt/ravengui.cpp index 0d78d8f67c..8bc2b05043 100644 --- a/src/qt/ravengui.cpp +++ b/src/qt/ravengui.cpp @@ -581,8 +581,11 @@ void RavenGUI::createToolBars() { if(walletFrame) { + QSettings settings; + bool IconsOnly = settings.value("fToolbarIconsOnly", false).toBool(); + /** RVN START */ - // Create the orange background and the vertical tool bar + // Create the background and the vertical tool bar QWidget* toolbarWidget = new QWidget(); QString widgetStyleSheet = ".QWidget {background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 1 %2);}"; @@ -590,17 +593,32 @@ void RavenGUI::createToolBars() toolbarWidget->setStyleSheet(widgetStyleSheet.arg(platformStyle->LightBlueColor().name(), platformStyle->DarkBlueColor().name())); QLabel* label = new QLabel(); - label->setPixmap(QPixmap::fromImage(QImage(":/icons/ravencointext"))); label->setContentsMargins(0,0,0,50); + + if(IconsOnly) { + label->setPixmap(QPixmap::fromImage(QImage(":/icons/rvntext"))); + label->setAlignment(Qt::AlignLeft); + } + else { + label->setPixmap(QPixmap::fromImage(QImage(":/icons/ravencointext"))); + } label->setStyleSheet(".QLabel{background-color: transparent;}"); + /** RVN END */ QToolBar *toolbar = new QToolBar(); toolbar->setStyle(style()); - toolbar->setMinimumWidth(label->width()); toolbar->setContextMenuPolicy(Qt::PreventContextMenu); toolbar->setMovable(false); - toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + + if(IconsOnly) { + toolbar->setMaximumWidth(65); + toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); + } + else { + toolbar->setMinimumWidth(label->width()); + toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + } toolbar->addAction(overviewAction); toolbar->addAction(sendCoinsAction); toolbar->addAction(receiveCoinsAction); diff --git a/src/qt/res/icons/rvntext.png b/src/qt/res/icons/rvntext.png new file mode 100644 index 0000000000000000000000000000000000000000..108ae142d4ae8a0f41c206be48e005d9c05ed94f GIT binary patch literal 1283 zcmV+e1^oJnP)e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00e7EL_t(o!{wMuXkJAW$A9N* z^4UBZ8jZzQeH1}mhz-*Epea5UF0^2^ijI$H18&V7oLmb_1=8*<;&Mi4-9wa&YYP!=lsu{GXs|@NovzS zG*hBXOFA#pZfy-laegxYYqB-lC-#tc|+c33cv&2S13_x zfCk`tU_Ed|(kB^f{0dAa>j96KX^Z{-y#Rb=W(xXN1LIy_4(uyq-qpaE*Vhy>2FzrX zX%}Jw7`iFq8 z%YnP38{KacWxZWu-~H~h4Zv1OE2}QJ)0b`;906(S0*1?g`x8O^oSA(evHoFK(q+KA zk``SI!LJ08g?`WI{}8AREV!=3d>sz+$>3z4i;BQDA722j1zx-ug0FJ^X<#739mau= z{SD)`dS0Gy*S6T2VE@C2a=o_2v|?H)rTxU?c+W8(d(3 zK{FeO*v2APa3AoU$NeJE8zVzas$C~(ZN|7HbX^W?N}bXN{jkfT&r;!O9q>*L%N6Ovj=%##cC zV9cw*m@^5&Bz3qeXF@$jv%SE34$oR(LwI$}p*I7Khj3pX{O>ojGYfFjehE0|^?G-K zB)?asalG4OC%_d!B9o`AQ+{1dCo>)HHY1h5Jhj#Yu+bw#9k5Z-J;4pLBEbg&-Z9{s z2%bHD$Tb1m{M5Z8$ifaS)Z>boeF1#n*XVjbQ)U(-a~t&ZGKulc5j=fCOkV}G2b(!+ zX2T2oxb$4`AkqSCuh`-ar!Yh`NAUax{1{|=yBy}jb7X#%SbYfC;x5?$vCnAsq(BZxx(dtR2LXkU}G!g((EcbBAM1m7*e tdZ#57%2+deBJM0l0g`&c=VdNc`Wryk>t|6kG4TKZ002ovPDHLkV1gnhQFj0U literal 0 HcmV?d00001