Skip to content

Commit 73c4817

Browse files
authored
Merge pull request #2117 from cyrossignol/gui
gui: Refresh overview page design
2 parents fc44792 + 77f2226 commit 73c4817

File tree

93 files changed

+1784
-1132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1784
-1132
lines changed

src/Makefile.qt.include

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ RES_ICONS = \
306306
qt/res/icons/connect2.svg \
307307
qt/res/icons/connect3.svg \
308308
qt/res/icons/connect4.svg \
309+
qt/res/icons/dark_mode.svg \
310+
qt/res/icons/dark_mode_active.svg \
309311
qt/res/icons/debugwindow.png \
310312
qt/res/icons/edit.png \
311313
qt/res/icons/editcopy.png \
@@ -316,6 +318,10 @@ RES_ICONS = \
316318
qt/res/icons/gridcoin.ico \
317319
qt/res/icons/gridcoin_testnet.ico \
318320
qt/res/icons/key.png \
321+
qt/res/icons/light_mode.svg \
322+
qt/res/icons/light_mode_active.svg \
323+
qt/res/icons/menu.svg \
324+
qt/res/icons/menu_active.svg \
319325
qt/res/icons/message.svg \
320326
qt/res/icons/qrcode.png \
321327
qt/res/icons/quit.png \
@@ -340,6 +346,8 @@ RES_ICONS = \
340346
qt/res/icons/warning.svg \
341347
qt/res/icons/white_and_red_x.svg \
342348
qt/res/icons/www.png \
349+
qt/res/icons/icons_light/settings.svg \
350+
qt/res/icons/icons_light/settings_action_needed.svg \
343351
qt/res/icons/icons_light/sidebar_favorites_active.svg \
344352
qt/res/icons/icons_light/sidebar_favorites_inactive.svg \
345353
qt/res/icons/icons_light/sidebar_history_active.svg \
@@ -352,6 +360,8 @@ RES_ICONS = \
352360
qt/res/icons/icons_light/sidebar_receive_inactive.svg \
353361
qt/res/icons/icons_light/sidebar_send_active.svg \
354362
qt/res/icons/icons_light/sidebar_send_inactive.svg \
363+
qt/res/icons/icons_light/sidebar_settings_active.svg \
364+
qt/res/icons/icons_light/sidebar_settings_inactive.svg \
355365
qt/res/icons/icons_light/sidebar_unlocked_active.svg \
356366
qt/res/icons/icons_light/sidebar_unlocked_inactive.svg \
357367
qt/res/icons/icons_light/sidebar_voting_active.svg \
@@ -378,6 +388,7 @@ RES_ICONS = \
378388
qt/res/icons/icons_light/status_sync_done.svg \
379389
qt/res/icons/icons_light/status_sync_stalled.svg \
380390
qt/res/icons/icons_light/status_sync_syncing.svg \
391+
qt/res/icons/icons_dark/settings_action_needed.svg \
381392
qt/res/icons/icons_dark/sidebar_favorites_active.svg \
382393
qt/res/icons/icons_dark/sidebar_favorites_inactive.svg \
383394
qt/res/icons/icons_dark/sidebar_history_active.svg \
@@ -390,6 +401,8 @@ RES_ICONS = \
390401
qt/res/icons/icons_dark/sidebar_receive_inactive.svg \
391402
qt/res/icons/icons_dark/sidebar_send_active.svg \
392403
qt/res/icons/icons_dark/sidebar_send_inactive.svg \
404+
qt/res/icons/icons_dark/sidebar_settings_active.svg \
405+
qt/res/icons/icons_dark/sidebar_settings_inactive.svg \
393406
qt/res/icons/icons_dark/sidebar_unlocked_active.svg \
394407
qt/res/icons/icons_dark/sidebar_unlocked_inactive.svg \
395408
qt/res/icons/icons_dark/sidebar_voting_active.svg \

src/main.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,6 @@ void GlobalStatus::SetGlobalStatus(bool force)
191191

192192
errors.clear();
193193

194-
std::string Alerts = GetWarnings("statusbar");
195-
196-
if (!Alerts.empty())
197-
{
198-
errors += _("Alert: ") + Alerts + "; ";
199-
}
200-
201194
if (difficulty < 0.1)
202195
{
203196
errors += _("Low difficulty!; ");
@@ -3057,6 +3050,14 @@ string GetWarnings(string strFor)
30573050
}
30583051
}
30593052

3053+
const GlobalStatus::globalStatusType status = g_GlobalStatus.GetGlobalStatus();
3054+
3055+
if (!strStatusBar.empty() && !status.errors.empty()) {
3056+
strStatusBar += "; ";
3057+
}
3058+
3059+
strStatusBar += status.errors;
3060+
30603061
if (strFor == "statusbar")
30613062
return strStatusBar;
30623063
assert(!"GetWarnings() : invalid parameter");

src/qt/bitcoin.qrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
<file alias="receive_light_active">res/icons/icons_light/sidebar_receive_active.svg</file>
4949
<file alias="send_light">res/icons/icons_light/sidebar_send_inactive.svg</file>
5050
<file alias="send_light_active">res/icons/icons_light/sidebar_send_active.svg</file>
51+
<file alias="settings_light">res/icons/icons_light/sidebar_settings_inactive.svg</file>
52+
<file alias="settings_light_active">res/icons/icons_light/sidebar_settings_active.svg</file>
5153
<file alias="voting_light">res/icons/icons_light/sidebar_voting_inactive.svg</file>
5254
<file alias="voting_light_active">res/icons/icons_light/sidebar_voting_active.svg</file>
5355

@@ -88,6 +90,8 @@
8890
<!-- Controls -->
8991
<file alias="light_chevron_down">res/icons/icons_light/chevron_down.svg</file>
9092
<file alias="light_chevron_up">res/icons/icons_light/chevron_up.svg</file>
93+
<file alias="light_settings">res/icons/icons_light/settings.svg</file>
94+
<file alias="light_settings_action_needed">res/icons/icons_light/settings_action_needed.svg</file>
9195

9296
<!--********************************************************************
9397
Dark theme
@@ -108,6 +112,8 @@
108112
<file alias="receive_dark_active">res/icons/icons_dark/sidebar_receive_active.svg</file>
109113
<file alias="send_dark">res/icons/icons_dark/sidebar_send_inactive.svg</file>
110114
<file alias="send_dark_active">res/icons/icons_dark/sidebar_send_active.svg</file>
115+
<file alias="settings_dark">res/icons/icons_dark/sidebar_settings_inactive.svg</file>
116+
<file alias="settings_dark_active">res/icons/icons_dark/sidebar_settings_active.svg</file>
111117
<file alias="voting_dark">res/icons/icons_dark/sidebar_voting_inactive.svg</file>
112118
<file alias="voting_dark_active">res/icons/icons_dark/sidebar_voting_active.svg</file>
113119

@@ -148,6 +154,7 @@
148154
<!-- Controls -->
149155
<file alias="dark_chevron_down">res/icons/icons_dark/chevron_down.svg</file>
150156
<file alias="dark_chevron_up">res/icons/icons_dark/chevron_up.svg</file>
157+
<file alias="dark_settings_action_needed">res/icons/icons_dark/settings_action_needed.svg</file>
151158

152159
<file alias="tx_pos_ss">res/icons/tx_pos_ss.svg</file>
153160
<file alias="tx_por">res/icons/tx_por.svg</file>
@@ -162,6 +169,13 @@
162169
<file alias="tx_contract_beacon">res/icons/tx_contract_beacon.svg</file>
163170
<file alias="tx_contract_voting">res/icons/tx_contract_voting.svg</file>
164171
<file alias="message">res/icons/message.svg</file>
172+
<file alias="menu">res/icons/menu.svg</file>
173+
<file alias="menu_active">res/icons/menu_active.svg</file>
174+
<file alias="dark_mode">res/icons/dark_mode.svg</file>
175+
<file alias="dark_mode_active">res/icons/dark_mode_active.svg</file>
176+
<file alias="light_mode">res/icons/light_mode.svg</file>
177+
<file alias="light_mode_active">res/icons/light_mode_active.svg</file>
178+
165179
</qresource>
166180
<qresource prefix="/images">
167181
<file alias="splash">res/images/splash3.png</file>

src/qt/bitcoingui.cpp

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,23 +206,15 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
206206

207207
signVerifyMessageDialog = new SignVerifyMessageDialog(this);
208208

209-
QVBoxLayout *centralVbox = new QVBoxLayout(this);
210-
centralVbox->setContentsMargins(0, 0, 0, 0);
211-
centralVbox->setSpacing(0);
212-
centralVbox->addWidget(appMenuBar);
213-
214209
centralWidget = new QStackedWidget(this);
215210
centralWidget->addWidget(overviewPage);
216211
centralWidget->addWidget(transactionsPage);
217212
centralWidget->addWidget(addressBookPage);
218213
centralWidget->addWidget(receiveCoinsPage);
219214
centralWidget->addWidget(sendCoinsPage);
220215
centralWidget->addWidget(votingPage);
221-
centralVbox->addWidget(centralWidget);
222216

223-
QWidget* centralWidgetWrapper = new QWidget(this);
224-
centralWidgetWrapper->setLayout(centralVbox);
225-
setCentralWidget(centralWidgetWrapper);
217+
setCentralWidget(centralWidget);
226218

227219
// Create status bar
228220
statusBar();
@@ -532,13 +524,15 @@ void BitcoinGUI::createMenuBar()
532524
#ifdef Q_OS_MAC
533525
// Create a decoupled menu bar on Mac which stays even if the window is closed
534526
appMenuBar = new QMenuBar();
527+
QMenu *file = appMenuBar->addMenu(tr("&File"));
535528
#else
536-
// Get the main window's menu bar on other platforms
537-
appMenuBar = menuBar();
529+
// Windows and Linux: collapse the main application's menu bar into a menu
530+
// button. On macOS, we'll continue to use the system's separate menu bar.
531+
appMenuBar = new QMenu();
532+
QMenu *file = appMenuBar;
538533
#endif
539534

540535
// Configure the menus
541-
QMenu *file = appMenuBar->addMenu(tr("&File"));
542536
file->addAction(backupWalletAction);
543537
file->addAction(exportAction);
544538
file->addAction(signMessageAction);
@@ -553,7 +547,9 @@ void BitcoinGUI::createMenuBar()
553547
file->addAction(resetblockchainAction);
554548

555549
file->addSeparator();
550+
#ifdef Q_OS_MAC
556551
file->addAction(quitAction);
552+
#endif
557553

558554
QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
559555
settings->addAction(encryptWalletAction);
@@ -581,20 +577,64 @@ void BitcoinGUI::createMenuBar()
581577
help->addAction(diagnosticsAction);
582578
help->addSeparator();
583579
help->addAction(aboutAction);
580+
581+
#ifndef Q_OS_MAC
582+
file->addSeparator();
583+
file->addAction(quitAction);
584+
#endif
584585
}
585586

586587
void BitcoinGUI::createToolBars()
587588
{
588589
ClickLabel *logoLabel = new ClickLabel();
589590
logoLabel->setObjectName("toolbarLogoLabel");
591+
QSizePolicy logoLabelSizePolicy = logoLabel->sizePolicy();
592+
logoLabelSizePolicy.setHorizontalStretch(2);
593+
logoLabel->setSizePolicy(logoLabelSizePolicy);
590594
connect(logoLabel, SIGNAL(clicked()), this, SLOT(websiteClicked()));
591595

596+
QHBoxLayout *logoWrapperLayout = new QHBoxLayout();
597+
logoWrapperLayout->setContentsMargins(2, 0, 2, 0);
598+
logoWrapperLayout->setSpacing(0);
599+
600+
QWidget *logoWrapper = new QWidget();
601+
logoWrapper->setObjectName("toolbarLogoWrapper");
602+
logoWrapper->setLayout(logoWrapperLayout);
603+
604+
#ifndef Q_OS_MAC
605+
// Windows and Linux: collapse the main application's menu bar into a menu
606+
// button. On macOS, we'll continue to use the system's separate menu bar.
607+
QPushButton *menuButton = new QPushButton();
608+
menuButton->setObjectName("toolbarMenuButton");
609+
menuButton->setToolTip(tr("Open menu."));
610+
menuButton->setMenu(appMenuBar);
611+
QSizePolicy menuButtonSizePolicy = menuButton->sizePolicy();
612+
menuButtonSizePolicy.setHorizontalStretch(1);
613+
menuButton->setSizePolicy(menuButtonSizePolicy);
614+
logoWrapperLayout->addWidget(menuButton);
615+
logoWrapperLayout->setAlignment(menuButton, Qt::AlignHCenter | Qt::AlignVCenter);
616+
#else
617+
logoWrapperLayout->addStretch(1);
618+
#endif
619+
620+
logoWrapperLayout->addWidget(logoLabel);
621+
622+
QPushButton *themeToggleButton = new QPushButton();
623+
themeToggleButton->setObjectName("themeToggleButton");
624+
themeToggleButton->setToolTip(tr("Toggle light/dark mode."));
625+
QSizePolicy themeToggleButtonSizePolicy = themeToggleButton->sizePolicy();
626+
themeToggleButtonSizePolicy.setHorizontalStretch(1);
627+
themeToggleButton->setSizePolicy(themeToggleButtonSizePolicy);
628+
connect(themeToggleButton, SIGNAL(clicked()), this, SLOT(themeToggled()));
629+
logoWrapperLayout->addWidget(themeToggleButton);
630+
logoWrapperLayout->setAlignment(themeToggleButton, Qt::AlignHCenter | Qt::AlignVCenter);
631+
592632
QWidget *boincLabelSpacer = new QWidget();
593633
boincLabelSpacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
594634

595635
ClickLabel *boincLabel = new ClickLabel();
596636
boincLabel->setObjectName("toolbarBoincLabel");
597-
connect(logoLabel, SIGNAL(clicked()), this, SLOT(boincClicked()));
637+
connect(boincLabel, SIGNAL(clicked()), this, SLOT(boincClicked()));
598638

599639
// "Tabs" toolbar (vertical, aligned on left side of overview screen).
600640
QToolBar *toolbar = addToolBar("Tabs toolbar");
@@ -607,7 +647,7 @@ void BitcoinGUI::createToolBars()
607647
// Setting a taller height than the rendered icon provides additional
608648
// padding between the icon and the button text:
609649
toolbar->setIconSize(GRC::ScaleSize(this, 16, 24));
610-
toolbar->addWidget(logoLabel);
650+
toolbar->addWidget(logoWrapper);
611651
toolbar->addAction(overviewAction);
612652
toolbar->addAction(sendCoinsAction);
613653
toolbar->addAction(receiveCoinsAction);
@@ -635,6 +675,10 @@ void BitcoinGUI::createToolBars()
635675
statusBar()->addWidget(testnetLabel);
636676
}
637677

678+
statusbarAlertsLabel = new QLabel();
679+
statusBar()->addWidget(statusbarAlertsLabel);
680+
statusBar()->layout()->setAlignment(statusbarAlertsLabel, Qt::AlignLeft | Qt::AlignVCenter);
681+
638682
frameBlocks->setContentsMargins(0,0,0,0);
639683

640684
QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
@@ -844,6 +888,11 @@ void BitcoinGUI::optionsClicked()
844888
dlg.exec();
845889
}
846890

891+
void BitcoinGUI::themeToggled()
892+
{
893+
clientModel->getOptionsModel()->setCurrentStyle(sSheet == "light" ? "dark" : "light");
894+
}
895+
847896
void BitcoinGUI::openConfigClicked()
848897
{
849898
boost::filesystem::path pathConfig = GetConfigFile();
@@ -923,7 +972,6 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
923972
return;
924973
}
925974

926-
QString strStatusBarWarnings = clientModel->getStatusBarWarnings();
927975
QString tooltip(tr("Processed %n block(s) of transaction history.", "", count));
928976

929977
QDateTime lastBlockDate = clientModel->getLastBlockDate();
@@ -1469,6 +1517,18 @@ void BitcoinGUI::updateGlobalStatus()
14691517
{
14701518
overviewPage->updateGlobalStatus();
14711519
setNumConnections(clientModel->getNumConnections());
1520+
1521+
QString warnings = clientModel->getStatusBarWarnings();
1522+
1523+
if (!warnings.isEmpty())
1524+
{
1525+
statusbarAlertsLabel->setText(warnings);
1526+
statusbarAlertsLabel->setVisible(true);
1527+
}
1528+
else
1529+
{
1530+
statusbarAlertsLabel->setVisible(false);
1531+
}
14721532
}
14731533
catch(std::runtime_error &e)
14741534
{

src/qt/bitcoingui.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,21 @@ class BitcoinGUI : public QMainWindow
8686
SignVerifyMessageDialog *signVerifyMessageDialog;
8787
std::unique_ptr<QMessageBox> updateMessageDialog;
8888

89+
QLabel *statusbarAlertsLabel;
8990
QLabel *labelEncryptionIcon;
9091
QLabel *labelStakingIcon;
9192
QLabel *labelConnectionsIcon;
9293
QLabel *labelBlocksIcon;
9394
QLabel *labelScraperIcon;
9495
QLabel *labelBeaconIcon;
9596

97+
// Windows and Linux: collapse the main application's menu bar into a menu
98+
// button. On macOS, we'll continue to use the system's separate menu bar.
99+
#ifdef Q_OS_MAC
96100
QMenuBar *appMenuBar;
101+
#else
102+
QMenu *appMenuBar;
103+
#endif
97104
QAction *overviewAction;
98105
QAction *historyAction;
99106
QAction *quitAction;
@@ -210,6 +217,8 @@ private slots:
210217

211218
/** Show configuration dialog */
212219
void optionsClicked();
220+
/** Switch the active light/dark theme */
221+
void themeToggled();
213222
/** Show researcher/beacon configuration dialog */
214223
void researcherClicked();
215224
/** Show about dialog */

src/qt/bitcoinunits.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,27 @@ QString BitcoinUnits::formatWithUnit(int unit, qint64 amount, bool plussign)
117117
return format(unit, amount, plussign) + QString(" ") + name(unit);
118118
}
119119

120+
QString BitcoinUnits::formatOverviewRounded(qint64 amount)
121+
{
122+
if (amount < factor(BTC)) {
123+
return format(BTC, amount);
124+
}
125+
126+
qint64 round_scale = 10;
127+
qint64 amount_temp = amount / factor(BTC);
128+
129+
while (amount_temp /= 10) {
130+
round_scale *= 10;
131+
}
132+
133+
round_scale = std::min(round_scale, factor(BTC) / 100);
134+
135+
// Rounds half-down to avoid over-representing the amount:
136+
const qint64 rounded_amount = static_cast<double>(amount) / round_scale;
137+
138+
return format(BTC, rounded_amount * round_scale);
139+
}
140+
120141
bool BitcoinUnits::parse(int unit, const QString &value, qint64 *val_out)
121142
{
122143
if(!valid(unit) || value.isEmpty())

src/qt/bitcoinunits.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class BitcoinUnits: public QAbstractListModel
4444
static QString format(int unit, qint64 amount, bool plussign=false);
4545
//! Format as string (with unit)
4646
static QString formatWithUnit(int unit, qint64 amount, bool plussign=false);
47+
//! Format as a rounded string approximation for overview presentation
48+
static QString formatOverviewRounded(qint64 amount);
4749
//! Parse string to coin amount
4850
static bool parse(int unit, const QString &value, qint64 *val_out);
4951
///@}

0 commit comments

Comments
 (0)