From 036f070e3b775cb6c1e3abac11212609e5e7979c Mon Sep 17 00:00:00 2001 From: pablomartin4btc Date: Sun, 24 Sep 2023 20:44:38 -0300 Subject: [PATCH] gui: Update about logo icon to denote chain type Adding the networkStyle parameter to the HelpMessageDialog creator on utilitydialog, updating all calls where its instance is being created from bitcoingui.cpp. In the object itself, use this new parameter object to build the about window title and set the icon of the about logo widget. Also, set th correct chain type icon at the very beginning of GuiMain() where command line arguments were validated and most of the app settings were not initialised yet. --- src/qt/bitcoin.cpp | 8 +++++++- src/qt/bitcoingui.cpp | 4 ++-- src/qt/utilitydialog.cpp | 23 ++++++++++++++++++++--- src/qt/utilitydialog.h | 6 +++++- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index eaaa9fc6fd5..a20419cbea4 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -529,11 +529,17 @@ int GuiMain(int argc, char* argv[]) SetupUIArgs(gArgs); std::string error; if (!gArgs.ParseParameters(argc, argv, error)) { + int nMBoxIcon = QMessageBox::Critical; InitError(Untranslated(strprintf("Error parsing command line arguments: %s", error))); // Create a message box, because the gui has neither been created nor has subscribed to core signals - QMessageBox::critical(nullptr, CLIENT_NAME, + QMessageBox mBox(static_cast(nMBoxIcon), CLIENT_NAME, // message cannot be translated because translations have not been initialized QString::fromStdString("Error parsing command line arguments: %1.").arg(QString::fromStdString(error))); + mBox.setTextFormat(Qt::PlainText); + if (gArgs.GetChainTypeString() != "main") { + mBox.setWindowIcon(NetworkStyle::instantiate(gArgs.GetChainType())->getTrayAndWindowIcon()); + } + mBox.exec(); return EXIT_FAILURE; } diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index f899a524f45..3aec6dd6771 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -105,7 +105,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty updateWindowTitle(); rpcConsole = new RPCConsole(node, _platformStyle, nullptr); - helpMessageDialog = new HelpMessageDialog(this, false); + helpMessageDialog = new HelpMessageDialog(this, false, m_network_style); #ifdef ENABLE_WALLET if(enableWallet) { @@ -936,7 +936,7 @@ void BitcoinGUI::aboutClicked() if(!clientModel) return; - auto dlg = new HelpMessageDialog(this, /*about=*/true); + auto dlg = new HelpMessageDialog(this, /*about=*/true, m_network_style); GUIUtil::ShowModalDialogAsynchronously(dlg); } diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index 86c37704078..de388604a1f 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -10,6 +10,8 @@ #include +#include + #include #include #include @@ -27,7 +29,7 @@ #include /** "Help message" or "About" dialog box */ -HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : +HelpMessageDialog::HelpMessageDialog(QWidget* parent, bool about, const NetworkStyle* networkStyle) : QDialog(parent, GUIUtil::dialog_flags), ui(new Ui::HelpMessageDialog) { @@ -37,8 +39,8 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : if (about) { - setWindowTitle(tr("About %1").arg(CLIENT_NAME)); - + this->setAboutWindowTitle(networkStyle); + this->setChainTypeIconOnAboutLogo(networkStyle); std::string licenseInfo = LicenseInfo(); /// HTML-format the license message from the core QString licenseInfoHTML = QString::fromStdString(LicenseInfo()); @@ -137,6 +139,21 @@ void HelpMessageDialog::on_okButton_accepted() close(); } +void HelpMessageDialog::setAboutWindowTitle(const NetworkStyle* networkStyle) +{ + QString aboutTitle = tr("About %1").arg(CLIENT_NAME); + if (networkStyle && Params().GetChainType() != ChainType::MAIN) { + aboutTitle.append(" " + networkStyle->getTitleAddText()); + } + setWindowTitle(aboutTitle); +} + +void HelpMessageDialog::setChainTypeIconOnAboutLogo(const NetworkStyle* networkStyle) +{ + const QSize requiredSize(1024, 1024); + if (networkStyle) ui->aboutLogo->setPixmap(networkStyle->getAppIcon().pixmap(requiredSize)); +} + /** "Shutdown" window */ ShutdownWindow::ShutdownWindow(QWidget *parent, Qt::WindowFlags f): diff --git a/src/qt/utilitydialog.h b/src/qt/utilitydialog.h index d2a5d5f67f2..3aca4f114f6 100644 --- a/src/qt/utilitydialog.h +++ b/src/qt/utilitydialog.h @@ -8,6 +8,8 @@ #include #include +class NetworkStyle; + QT_BEGIN_NAMESPACE class QMainWindow; QT_END_NAMESPACE @@ -22,7 +24,7 @@ class HelpMessageDialog : public QDialog Q_OBJECT public: - explicit HelpMessageDialog(QWidget *parent, bool about); + explicit HelpMessageDialog(QWidget* parent, bool about, const NetworkStyle* networkStyle = nullptr); ~HelpMessageDialog(); void printToConsole(); @@ -31,6 +33,8 @@ class HelpMessageDialog : public QDialog private: Ui::HelpMessageDialog *ui; QString text; + void setAboutWindowTitle(const NetworkStyle* networkStyle = nullptr); + void setChainTypeIconOnAboutLogo(const NetworkStyle* networkStyle = nullptr); private Q_SLOTS: void on_okButton_accepted();