Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gui: option to hide text in toolbar #1030

Merged
merged 3 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,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);
Q_EMIT updateIconsOnlyToolbar(fToolbarIconsOnly);
break;
case MapPortUPnP: // core option - can be changed on-the-fly
settings.setValue("fUseUPnP", value.toBool());
MapPort(value.toBool());
Expand Down
3 changes: 3 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 All @@ -112,6 +114,7 @@ class OptionsModel : public QAbstractListModel
void coinControlFeaturesChanged(bool);
void customFeeFeaturesChanged(bool);
void hideTrayIconChanged(bool);
void updateIconsOnlyToolbar(bool);
};

#endif // RAVEN_QT_OPTIONSMODEL_H
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
90 changes: 63 additions & 27 deletions src/qt/ravengui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,36 +581,54 @@ 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);
label->setStyleSheet(".QLabel{background-color: transparent;}");
labelToolbar = new QLabel();
labelToolbar->setContentsMargins(0,0,0,50);
labelToolbar->setAlignment(Qt::AlignLeft);

if(IconsOnly) {
labelToolbar->setPixmap(QPixmap::fromImage(QImage(":/icons/rvntext")));
}
else {
labelToolbar->setPixmap(QPixmap::fromImage(QImage(":/icons/ravencointext")));
}
labelToolbar->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);
toolbar->addAction(overviewAction);
toolbar->addAction(sendCoinsAction);
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
toolbar->addAction(createAssetAction);
toolbar->addAction(transferAssetAction);
toolbar->addAction(manageAssetAction);
// toolbar->addAction(messagingAction);
// toolbar->addAction(votingAction);
toolbar->addAction(restrictedAssetAction);
m_toolbar = new QToolBar();
m_toolbar->setStyle(style());
m_toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
m_toolbar->setMovable(false);

if(IconsOnly) {
m_toolbar->setMaximumWidth(65);
m_toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
}
else {
m_toolbar->setMinimumWidth(labelToolbar->width());
m_toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
}
m_toolbar->addAction(overviewAction);
m_toolbar->addAction(sendCoinsAction);
m_toolbar->addAction(receiveCoinsAction);
m_toolbar->addAction(historyAction);
m_toolbar->addAction(createAssetAction);
m_toolbar->addAction(transferAssetAction);
m_toolbar->addAction(manageAssetAction);
// m_toolbar->addAction(messagingAction);
// m_toolbar->addAction(votingAction);
m_toolbar->addAction(restrictedAssetAction);

QString openSansFontString = "font: normal 22pt \"Open Sans\";";
QString normalString = "font: normal 22pt \"Arial\";";
Expand All @@ -629,22 +647,22 @@ void RavenGUI::createToolBars()
".QToolButton:hover {background: none; background-color: none; border: none; color: %3;} "
".QToolButton:disabled {color: gray;}";

toolbar->setStyleSheet(tbStyleSheet.arg(platformStyle->ToolBarNotSelectedTextColor().name(),
m_toolbar->setStyleSheet(tbStyleSheet.arg(platformStyle->ToolBarNotSelectedTextColor().name(),
platformStyle->ToolBarSelectedTextColor().name(),
platformStyle->DarkOrangeColor().name(), stringToUse));

toolbar->setOrientation(Qt::Vertical);
toolbar->setIconSize(QSize(40, 40));
m_toolbar->setOrientation(Qt::Vertical);
m_toolbar->setIconSize(QSize(40, 40));

QLayout* lay = toolbar->layout();
QLayout* lay = m_toolbar->layout();
for(int i = 0; i < lay->count(); ++i)
lay->itemAt(i)->setAlignment(Qt::AlignLeft);

overviewAction->setChecked(true);

QVBoxLayout* ravenLabelLayout = new QVBoxLayout(toolbarWidget);
ravenLabelLayout->addWidget(label);
ravenLabelLayout->addWidget(toolbar);
ravenLabelLayout->addWidget(labelToolbar);
ravenLabelLayout->addWidget(m_toolbar);
ravenLabelLayout->setDirection(QBoxLayout::TopToBottom);
ravenLabelLayout->addStretch(1);

Expand Down Expand Up @@ -894,6 +912,20 @@ void RavenGUI::createToolBars()
}
}

void RavenGUI::updateIconsOnlyToolbar(bool IconsOnly)
{
if(IconsOnly) {
labelToolbar->setPixmap(QPixmap::fromImage(QImage(":/icons/rvntext")));
m_toolbar->setMaximumWidth(65);
m_toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
}
else {
labelToolbar->setPixmap(QPixmap::fromImage(QImage(":/icons/ravencointext")));
m_toolbar->setMinimumWidth(labelToolbar->width());
m_toolbar->setMaximumWidth(255);
m_toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
}
}
void RavenGUI::setClientModel(ClientModel *_clientModel)
{
this->clientModel = _clientModel;
Expand Down Expand Up @@ -941,6 +973,10 @@ void RavenGUI::setClientModel(ClientModel *_clientModel)

// Init the currency display from settings
this->onCurrencyChange(optionsModel->getDisplayCurrencyIndex());

// Signal to update toolbar on iconsonly checkbox clicked.
connect(optionsModel, SIGNAL(updateIconsOnlyToolbar(bool)), this, SLOT(updateIconsOnlyToolbar(bool)));

}
} else {
// Disable possibility to show main window via action
Expand Down
7 changes: 7 additions & 0 deletions src/qt/ravengui.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ class RavenGUI : public QMainWindow
QLabel *labelVersionUpdate = nullptr;
QNetworkAccessManager* networkVersionManager = nullptr;
QNetworkRequest* versionRequest = nullptr;

QLabel *labelToolbar = nullptr;
QToolBar *m_toolbar = nullptr;

/** RVN END */

QSystemTrayIcon *trayIcon = nullptr;
Expand Down Expand Up @@ -220,6 +224,9 @@ public Q_SLOTS:

void getLatestVersion();

/** IconsOnly true/false and updates toolbar accordingly. */
void updateIconsOnlyToolbar(bool);

#ifdef ENABLE_WALLET
/** Set the encryption status as shown in the UI.
@param[in] status current encryption status
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.