Skip to content

Commit

Permalink
gui: option to hide text in toolbar
Browse files Browse the repository at this point in the history
Add option to only show icons in toolbar.

Closes RavenProject#478
  • Loading branch information
fdoving committed May 25, 2021
1 parent 4ffcf23 commit 42cdbd1
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 5 deletions.
12 changes: 11 additions & 1 deletion src/qt/forms/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>4</number>
<number>3</number>
</property>
<widget class="QWidget" name="tabMain">
<attribute name="title">
Expand Down Expand Up @@ -541,6 +541,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="toolbarIconsOnly">
<property name="statusTip">
<string>Only show toolbar icons. No text.</string>
</property>
<property name="text">
<string>&amp;Icons only</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_Window">
<property name="orientation">
Expand Down
2 changes: 2 additions & 0 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 2 additions & 0 deletions src/qt/optionsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class OptionsModel : public QAbstractListModel
StartAtStartup, // bool
HideTrayIcon, // bool
MinimizeToTray, // bool
ToolbarIconsOnly, // bool
MapPortUPnP, // bool
MinimizeOnClose, // bool
ProxyUse, // bool
Expand Down Expand Up @@ -88,6 +89,7 @@ class OptionsModel : public QAbstractListModel
bool fHideTrayIcon;
bool fMinimizeToTray;
bool fMinimizeOnClose;
bool fToolbarIconsOnly;
QString language;
int nDisplayUnit;
int nDisplayCurrencyIndex;
Expand Down
1 change: 1 addition & 0 deletions src/qt/raven.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<file alias="asset_transfer">res/icons/asset_transfer.png</file>
<file alias="asset_transfer_selected">res/icons/asset_transfer_selected.png</file>
<file alias="ravencointext">res/icons/ravencointext.png</file>
<file alias="rvntext">res/icons/rvntext.png</file>
<file alias="restricted_asset">res/icons/restricted_asset.png</file>
<file alias="restricted_asset_selected">res/icons/restricted_asset_selected.png</file>
</qresource>
Expand Down
26 changes: 22 additions & 4 deletions src/qt/ravengui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,26 +581,44 @@ 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);}";

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);
Expand Down
Binary file added src/qt/res/icons/rvntext.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 42cdbd1

Please sign in to comment.