Skip to content

Commit 5556860

Browse files
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.
1 parent dcfbf3c commit 5556860

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

src/qt/bitcoin.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,17 @@ int GuiMain(int argc, char* argv[])
539539
SetupUIArgs(gArgs);
540540
std::string error;
541541
if (!gArgs.ParseParameters(argc, argv, error)) {
542+
int nMBoxIcon = QMessageBox::Critical;
542543
InitError(strprintf(Untranslated("Error parsing command line arguments: %s"), error));
543544
// Create a message box, because the gui has neither been created nor has subscribed to core signals
544-
QMessageBox::critical(nullptr, PACKAGE_NAME,
545+
QMessageBox mBox(static_cast<QMessageBox::Icon>(nMBoxIcon), PACKAGE_NAME,
545546
// message cannot be translated because translations have not been initialized
546547
QString::fromStdString("Error parsing command line arguments: %1.").arg(QString::fromStdString(error)));
548+
mBox.setTextFormat(Qt::PlainText);
549+
if (gArgs.GetChainTypeString() != "main") {
550+
mBox.setWindowIcon(NetworkStyle::instantiate(gArgs.GetChainType())->getTrayAndWindowIcon());
551+
}
552+
mBox.exec();
547553
return EXIT_FAILURE;
548554
}
549555

src/qt/bitcoingui.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
103103
updateWindowTitle();
104104

105105
rpcConsole = new RPCConsole(node, _platformStyle, nullptr);
106-
helpMessageDialog = new HelpMessageDialog(this, false);
106+
helpMessageDialog = new HelpMessageDialog(this, false, m_network_style);
107107
#ifdef ENABLE_WALLET
108108
if(enableWallet)
109109
{
@@ -920,7 +920,7 @@ void BitcoinGUI::aboutClicked()
920920
if(!clientModel)
921921
return;
922922

923-
auto dlg = new HelpMessageDialog(this, /*about=*/true);
923+
auto dlg = new HelpMessageDialog(this, /*about=*/true, m_network_style);
924924
GUIUtil::ShowModalDialogAsynchronously(dlg);
925925
}
926926

src/qt/utilitydialog.cpp

+20-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#include <qt/guiutil.h>
1414

15+
#include <qt/networkstyle.h>
16+
1517
#include <clientversion.h>
1618
#include <common/args.h>
1719
#include <init.h>
@@ -29,7 +31,7 @@
2931
#include <QVBoxLayout>
3032

3133
/** "Help message" or "About" dialog box */
32-
HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
34+
HelpMessageDialog::HelpMessageDialog(QWidget* parent, bool about, const NetworkStyle* networkStyle) :
3335
QDialog(parent, GUIUtil::dialog_flags),
3436
ui(new Ui::HelpMessageDialog)
3537
{
@@ -39,8 +41,8 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
3941

4042
if (about)
4143
{
42-
setWindowTitle(tr("About %1").arg(PACKAGE_NAME));
43-
44+
this->setAboutWindowTitle(networkStyle);
45+
this->setChainTypeIconOnAboutLogo(networkStyle);
4446
std::string licenseInfo = LicenseInfo();
4547
/// HTML-format the license message from the core
4648
QString licenseInfoHTML = QString::fromStdString(LicenseInfo());
@@ -135,6 +137,21 @@ void HelpMessageDialog::on_okButton_accepted()
135137
close();
136138
}
137139

140+
void HelpMessageDialog::setAboutWindowTitle(const NetworkStyle* networkStyle)
141+
{
142+
QString aboutTitle = tr("About %1").arg(PACKAGE_NAME);
143+
if (networkStyle && Params().GetChainType() != ChainType::MAIN) {
144+
aboutTitle.append(" " + networkStyle->getTitleAddText());
145+
}
146+
setWindowTitle(aboutTitle);
147+
}
148+
149+
void HelpMessageDialog::setChainTypeIconOnAboutLogo(const NetworkStyle* networkStyle)
150+
{
151+
const QSize requiredSize(1024, 1024);
152+
if (networkStyle) ui->aboutLogo->setPixmap(networkStyle->getAppIcon().pixmap(requiredSize));
153+
}
154+
138155

139156
/** "Shutdown" window */
140157
ShutdownWindow::ShutdownWindow(QWidget *parent, Qt::WindowFlags f):

src/qt/utilitydialog.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <QDialog>
99
#include <QWidget>
1010

11+
class NetworkStyle;
12+
1113
QT_BEGIN_NAMESPACE
1214
class QMainWindow;
1315
QT_END_NAMESPACE
@@ -22,7 +24,7 @@ class HelpMessageDialog : public QDialog
2224
Q_OBJECT
2325

2426
public:
25-
explicit HelpMessageDialog(QWidget *parent, bool about);
27+
explicit HelpMessageDialog(QWidget* parent, bool about, const NetworkStyle* networkStyle = nullptr);
2628
~HelpMessageDialog();
2729

2830
void printToConsole();
@@ -31,6 +33,8 @@ class HelpMessageDialog : public QDialog
3133
private:
3234
Ui::HelpMessageDialog *ui;
3335
QString text;
36+
void setAboutWindowTitle(const NetworkStyle* networkStyle = nullptr);
37+
void setChainTypeIconOnAboutLogo(const NetworkStyle* networkStyle = nullptr);
3438

3539
private Q_SLOTS:
3640
void on_okButton_accepted();

0 commit comments

Comments
 (0)