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: Refresh overview page design #2117

Merged
merged 5 commits into from
May 2, 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
13 changes: 13 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ RES_ICONS = \
qt/res/icons/connect2.svg \
qt/res/icons/connect3.svg \
qt/res/icons/connect4.svg \
qt/res/icons/dark_mode.svg \
qt/res/icons/dark_mode_active.svg \
qt/res/icons/debugwindow.png \
qt/res/icons/edit.png \
qt/res/icons/editcopy.png \
Expand All @@ -316,6 +318,10 @@ RES_ICONS = \
qt/res/icons/gridcoin.ico \
qt/res/icons/gridcoin_testnet.ico \
qt/res/icons/key.png \
qt/res/icons/light_mode.svg \
qt/res/icons/light_mode_active.svg \
qt/res/icons/menu.svg \
qt/res/icons/menu_active.svg \
qt/res/icons/message.svg \
qt/res/icons/qrcode.png \
qt/res/icons/quit.png \
Expand All @@ -340,6 +346,8 @@ RES_ICONS = \
qt/res/icons/warning.svg \
qt/res/icons/white_and_red_x.svg \
qt/res/icons/www.png \
qt/res/icons/icons_light/settings.svg \
qt/res/icons/icons_light/settings_action_needed.svg \
qt/res/icons/icons_light/sidebar_favorites_active.svg \
qt/res/icons/icons_light/sidebar_favorites_inactive.svg \
qt/res/icons/icons_light/sidebar_history_active.svg \
Expand All @@ -352,6 +360,8 @@ RES_ICONS = \
qt/res/icons/icons_light/sidebar_receive_inactive.svg \
qt/res/icons/icons_light/sidebar_send_active.svg \
qt/res/icons/icons_light/sidebar_send_inactive.svg \
qt/res/icons/icons_light/sidebar_settings_active.svg \
qt/res/icons/icons_light/sidebar_settings_inactive.svg \
qt/res/icons/icons_light/sidebar_unlocked_active.svg \
qt/res/icons/icons_light/sidebar_unlocked_inactive.svg \
qt/res/icons/icons_light/sidebar_voting_active.svg \
Expand All @@ -378,6 +388,7 @@ RES_ICONS = \
qt/res/icons/icons_light/status_sync_done.svg \
qt/res/icons/icons_light/status_sync_stalled.svg \
qt/res/icons/icons_light/status_sync_syncing.svg \
qt/res/icons/icons_dark/settings_action_needed.svg \
qt/res/icons/icons_dark/sidebar_favorites_active.svg \
qt/res/icons/icons_dark/sidebar_favorites_inactive.svg \
qt/res/icons/icons_dark/sidebar_history_active.svg \
Expand All @@ -390,6 +401,8 @@ RES_ICONS = \
qt/res/icons/icons_dark/sidebar_receive_inactive.svg \
qt/res/icons/icons_dark/sidebar_send_active.svg \
qt/res/icons/icons_dark/sidebar_send_inactive.svg \
qt/res/icons/icons_dark/sidebar_settings_active.svg \
qt/res/icons/icons_dark/sidebar_settings_inactive.svg \
qt/res/icons/icons_dark/sidebar_unlocked_active.svg \
qt/res/icons/icons_dark/sidebar_unlocked_inactive.svg \
qt/res/icons/icons_dark/sidebar_voting_active.svg \
Expand Down
15 changes: 8 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,6 @@ void GlobalStatus::SetGlobalStatus(bool force)

errors.clear();

std::string Alerts = GetWarnings("statusbar");

if (!Alerts.empty())
{
errors += _("Alert: ") + Alerts + "; ";
}

if (difficulty < 0.1)
{
errors += _("Low difficulty!; ");
Expand Down Expand Up @@ -3057,6 +3050,14 @@ string GetWarnings(string strFor)
}
}

const GlobalStatus::globalStatusType status = g_GlobalStatus.GetGlobalStatus();

if (!strStatusBar.empty() && !status.errors.empty()) {
strStatusBar += "; ";
}

strStatusBar += status.errors;

if (strFor == "statusbar")
return strStatusBar;
assert(!"GetWarnings() : invalid parameter");
Expand Down
14 changes: 14 additions & 0 deletions src/qt/bitcoin.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<file alias="receive_light_active">res/icons/icons_light/sidebar_receive_active.svg</file>
<file alias="send_light">res/icons/icons_light/sidebar_send_inactive.svg</file>
<file alias="send_light_active">res/icons/icons_light/sidebar_send_active.svg</file>
<file alias="settings_light">res/icons/icons_light/sidebar_settings_inactive.svg</file>
<file alias="settings_light_active">res/icons/icons_light/sidebar_settings_active.svg</file>
<file alias="voting_light">res/icons/icons_light/sidebar_voting_inactive.svg</file>
<file alias="voting_light_active">res/icons/icons_light/sidebar_voting_active.svg</file>

Expand Down Expand Up @@ -88,6 +90,8 @@
<!-- Controls -->
<file alias="light_chevron_down">res/icons/icons_light/chevron_down.svg</file>
<file alias="light_chevron_up">res/icons/icons_light/chevron_up.svg</file>
<file alias="light_settings">res/icons/icons_light/settings.svg</file>
<file alias="light_settings_action_needed">res/icons/icons_light/settings_action_needed.svg</file>

<!--********************************************************************
Dark theme
Expand All @@ -108,6 +112,8 @@
<file alias="receive_dark_active">res/icons/icons_dark/sidebar_receive_active.svg</file>
<file alias="send_dark">res/icons/icons_dark/sidebar_send_inactive.svg</file>
<file alias="send_dark_active">res/icons/icons_dark/sidebar_send_active.svg</file>
<file alias="settings_dark">res/icons/icons_dark/sidebar_settings_inactive.svg</file>
<file alias="settings_dark_active">res/icons/icons_dark/sidebar_settings_active.svg</file>
<file alias="voting_dark">res/icons/icons_dark/sidebar_voting_inactive.svg</file>
<file alias="voting_dark_active">res/icons/icons_dark/sidebar_voting_active.svg</file>

Expand Down Expand Up @@ -148,6 +154,7 @@
<!-- Controls -->
<file alias="dark_chevron_down">res/icons/icons_dark/chevron_down.svg</file>
<file alias="dark_chevron_up">res/icons/icons_dark/chevron_up.svg</file>
<file alias="dark_settings_action_needed">res/icons/icons_dark/settings_action_needed.svg</file>

<file alias="tx_pos_ss">res/icons/tx_pos_ss.svg</file>
<file alias="tx_por">res/icons/tx_por.svg</file>
Expand All @@ -162,6 +169,13 @@
<file alias="tx_contract_beacon">res/icons/tx_contract_beacon.svg</file>
<file alias="tx_contract_voting">res/icons/tx_contract_voting.svg</file>
<file alias="message">res/icons/message.svg</file>
<file alias="menu">res/icons/menu.svg</file>
<file alias="menu_active">res/icons/menu_active.svg</file>
<file alias="dark_mode">res/icons/dark_mode.svg</file>
<file alias="dark_mode_active">res/icons/dark_mode_active.svg</file>
<file alias="light_mode">res/icons/light_mode.svg</file>
<file alias="light_mode_active">res/icons/light_mode_active.svg</file>

</qresource>
<qresource prefix="/images">
<file alias="splash">res/images/splash3.png</file>
Expand Down
90 changes: 75 additions & 15 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,23 +206,15 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):

signVerifyMessageDialog = new SignVerifyMessageDialog(this);

QVBoxLayout *centralVbox = new QVBoxLayout(this);
centralVbox->setContentsMargins(0, 0, 0, 0);
centralVbox->setSpacing(0);
centralVbox->addWidget(appMenuBar);

centralWidget = new QStackedWidget(this);
centralWidget->addWidget(overviewPage);
centralWidget->addWidget(transactionsPage);
centralWidget->addWidget(addressBookPage);
centralWidget->addWidget(receiveCoinsPage);
centralWidget->addWidget(sendCoinsPage);
centralWidget->addWidget(votingPage);
centralVbox->addWidget(centralWidget);

QWidget* centralWidgetWrapper = new QWidget(this);
centralWidgetWrapper->setLayout(centralVbox);
setCentralWidget(centralWidgetWrapper);
setCentralWidget(centralWidget);

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

// Configure the menus
QMenu *file = appMenuBar->addMenu(tr("&File"));
file->addAction(backupWalletAction);
file->addAction(exportAction);
file->addAction(signMessageAction);
Expand All @@ -553,7 +547,9 @@ void BitcoinGUI::createMenuBar()
file->addAction(resetblockchainAction);

file->addSeparator();
#ifdef Q_OS_MAC
file->addAction(quitAction);
#endif

QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
settings->addAction(encryptWalletAction);
Expand Down Expand Up @@ -581,20 +577,64 @@ void BitcoinGUI::createMenuBar()
help->addAction(diagnosticsAction);
help->addSeparator();
help->addAction(aboutAction);

#ifndef Q_OS_MAC
file->addSeparator();
file->addAction(quitAction);
#endif
}

void BitcoinGUI::createToolBars()
{
ClickLabel *logoLabel = new ClickLabel();
logoLabel->setObjectName("toolbarLogoLabel");
QSizePolicy logoLabelSizePolicy = logoLabel->sizePolicy();
logoLabelSizePolicy.setHorizontalStretch(2);
logoLabel->setSizePolicy(logoLabelSizePolicy);
connect(logoLabel, SIGNAL(clicked()), this, SLOT(websiteClicked()));

QHBoxLayout *logoWrapperLayout = new QHBoxLayout();
logoWrapperLayout->setContentsMargins(2, 0, 2, 0);
logoWrapperLayout->setSpacing(0);

QWidget *logoWrapper = new QWidget();
logoWrapper->setObjectName("toolbarLogoWrapper");
logoWrapper->setLayout(logoWrapperLayout);

#ifndef Q_OS_MAC
// Windows and Linux: collapse the main application's menu bar into a menu
// button. On macOS, we'll continue to use the system's separate menu bar.
QPushButton *menuButton = new QPushButton();
menuButton->setObjectName("toolbarMenuButton");
menuButton->setToolTip(tr("Open menu."));
menuButton->setMenu(appMenuBar);
QSizePolicy menuButtonSizePolicy = menuButton->sizePolicy();
menuButtonSizePolicy.setHorizontalStretch(1);
menuButton->setSizePolicy(menuButtonSizePolicy);
logoWrapperLayout->addWidget(menuButton);
logoWrapperLayout->setAlignment(menuButton, Qt::AlignHCenter | Qt::AlignVCenter);
#else
logoWrapperLayout->addStretch(1);
#endif

logoWrapperLayout->addWidget(logoLabel);

QPushButton *themeToggleButton = new QPushButton();
themeToggleButton->setObjectName("themeToggleButton");
themeToggleButton->setToolTip(tr("Toggle light/dark mode."));
QSizePolicy themeToggleButtonSizePolicy = themeToggleButton->sizePolicy();
themeToggleButtonSizePolicy.setHorizontalStretch(1);
themeToggleButton->setSizePolicy(themeToggleButtonSizePolicy);
connect(themeToggleButton, SIGNAL(clicked()), this, SLOT(themeToggled()));
logoWrapperLayout->addWidget(themeToggleButton);
logoWrapperLayout->setAlignment(themeToggleButton, Qt::AlignHCenter | Qt::AlignVCenter);

QWidget *boincLabelSpacer = new QWidget();
boincLabelSpacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

ClickLabel *boincLabel = new ClickLabel();
boincLabel->setObjectName("toolbarBoincLabel");
connect(logoLabel, SIGNAL(clicked()), this, SLOT(boincClicked()));
connect(boincLabel, SIGNAL(clicked()), this, SLOT(boincClicked()));

// "Tabs" toolbar (vertical, aligned on left side of overview screen).
QToolBar *toolbar = addToolBar("Tabs toolbar");
Expand All @@ -607,7 +647,7 @@ void BitcoinGUI::createToolBars()
// Setting a taller height than the rendered icon provides additional
// padding between the icon and the button text:
toolbar->setIconSize(GRC::ScaleSize(this, 16, 24));
toolbar->addWidget(logoLabel);
toolbar->addWidget(logoWrapper);
toolbar->addAction(overviewAction);
toolbar->addAction(sendCoinsAction);
toolbar->addAction(receiveCoinsAction);
Expand Down Expand Up @@ -635,6 +675,10 @@ void BitcoinGUI::createToolBars()
statusBar()->addWidget(testnetLabel);
}

statusbarAlertsLabel = new QLabel();
statusBar()->addWidget(statusbarAlertsLabel);
statusBar()->layout()->setAlignment(statusbarAlertsLabel, Qt::AlignLeft | Qt::AlignVCenter);

frameBlocks->setContentsMargins(0,0,0,0);

QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
Expand Down Expand Up @@ -844,6 +888,11 @@ void BitcoinGUI::optionsClicked()
dlg.exec();
}

void BitcoinGUI::themeToggled()
{
clientModel->getOptionsModel()->setCurrentStyle(sSheet == "light" ? "dark" : "light");
}

void BitcoinGUI::openConfigClicked()
{
boost::filesystem::path pathConfig = GetConfigFile();
Expand Down Expand Up @@ -923,7 +972,6 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
return;
}

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

QDateTime lastBlockDate = clientModel->getLastBlockDate();
Expand Down Expand Up @@ -1469,6 +1517,18 @@ void BitcoinGUI::updateGlobalStatus()
{
overviewPage->updateGlobalStatus();
setNumConnections(clientModel->getNumConnections());

QString warnings = clientModel->getStatusBarWarnings();

if (!warnings.isEmpty())
{
statusbarAlertsLabel->setText(warnings);
statusbarAlertsLabel->setVisible(true);
}
else
{
statusbarAlertsLabel->setVisible(false);
}
}
catch(std::runtime_error &e)
{
Expand Down
9 changes: 9 additions & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,21 @@ class BitcoinGUI : public QMainWindow
SignVerifyMessageDialog *signVerifyMessageDialog;
std::unique_ptr<QMessageBox> updateMessageDialog;

QLabel *statusbarAlertsLabel;
QLabel *labelEncryptionIcon;
QLabel *labelStakingIcon;
QLabel *labelConnectionsIcon;
QLabel *labelBlocksIcon;
QLabel *labelScraperIcon;
QLabel *labelBeaconIcon;

// Windows and Linux: collapse the main application's menu bar into a menu
// button. On macOS, we'll continue to use the system's separate menu bar.
#ifdef Q_OS_MAC
QMenuBar *appMenuBar;
#else
QMenu *appMenuBar;
#endif
QAction *overviewAction;
QAction *historyAction;
QAction *quitAction;
Expand Down Expand Up @@ -210,6 +217,8 @@ private slots:

/** Show configuration dialog */
void optionsClicked();
/** Switch the active light/dark theme */
void themeToggled();
/** Show researcher/beacon configuration dialog */
void researcherClicked();
/** Show about dialog */
Expand Down
21 changes: 21 additions & 0 deletions src/qt/bitcoinunits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,27 @@ QString BitcoinUnits::formatWithUnit(int unit, qint64 amount, bool plussign)
return format(unit, amount, plussign) + QString(" ") + name(unit);
}

QString BitcoinUnits::formatOverviewRounded(qint64 amount)
{
if (amount < factor(BTC)) {
return format(BTC, amount);
}

qint64 round_scale = 10;
qint64 amount_temp = amount / factor(BTC);

while (amount_temp /= 10) {
round_scale *= 10;
}

round_scale = std::min(round_scale, factor(BTC) / 100);

// Rounds half-down to avoid over-representing the amount:
const qint64 rounded_amount = static_cast<double>(amount) / round_scale;

return format(BTC, rounded_amount * round_scale);
}

bool BitcoinUnits::parse(int unit, const QString &value, qint64 *val_out)
{
if(!valid(unit) || value.isEmpty())
Expand Down
2 changes: 2 additions & 0 deletions src/qt/bitcoinunits.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class BitcoinUnits: public QAbstractListModel
static QString format(int unit, qint64 amount, bool plussign=false);
//! Format as string (with unit)
static QString formatWithUnit(int unit, qint64 amount, bool plussign=false);
//! Format as a rounded string approximation for overview presentation
static QString formatOverviewRounded(qint64 amount);
//! Parse string to coin amount
static bool parse(int unit, const QString &value, qint64 *val_out);
///@}
Expand Down
Loading