Skip to content

Commit 036f070

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 8fa10ed commit 036f070

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
@@ -529,11 +529,17 @@ int GuiMain(int argc, char* argv[])
529529
SetupUIArgs(gArgs);
530530
std::string error;
531531
if (!gArgs.ParseParameters(argc, argv, error)) {
532+
int nMBoxIcon = QMessageBox::Critical;
532533
InitError(Untranslated(strprintf("Error parsing command line arguments: %s", error)));
533534
// Create a message box, because the gui has neither been created nor has subscribed to core signals
534-
QMessageBox::critical(nullptr, CLIENT_NAME,
535+
QMessageBox mBox(static_cast<QMessageBox::Icon>(nMBoxIcon), CLIENT_NAME,
535536
// message cannot be translated because translations have not been initialized
536537
QString::fromStdString("Error parsing command line arguments: %1.").arg(QString::fromStdString(error)));
538+
mBox.setTextFormat(Qt::PlainText);
539+
if (gArgs.GetChainTypeString() != "main") {
540+
mBox.setWindowIcon(NetworkStyle::instantiate(gArgs.GetChainType())->getTrayAndWindowIcon());
541+
}
542+
mBox.exec();
537543
return EXIT_FAILURE;
538544
}
539545

src/qt/bitcoingui.cpp

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

107107
rpcConsole = new RPCConsole(node, _platformStyle, nullptr);
108-
helpMessageDialog = new HelpMessageDialog(this, false);
108+
helpMessageDialog = new HelpMessageDialog(this, false, m_network_style);
109109
#ifdef ENABLE_WALLET
110110
if(enableWallet)
111111
{
@@ -936,7 +936,7 @@ void BitcoinGUI::aboutClicked()
936936
if(!clientModel)
937937
return;
938938

939-
auto dlg = new HelpMessageDialog(this, /*about=*/true);
939+
auto dlg = new HelpMessageDialog(this, /*about=*/true, m_network_style);
940940
GUIUtil::ShowModalDialogAsynchronously(dlg);
941941
}
942942

src/qt/utilitydialog.cpp

+20-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#include <qt/guiutil.h>
1212

13+
#include <qt/networkstyle.h>
14+
1315
#include <clientversion.h>
1416
#include <common/args.h>
1517
#include <init.h>
@@ -27,7 +29,7 @@
2729
#include <QVBoxLayout>
2830

2931
/** "Help message" or "About" dialog box */
30-
HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
32+
HelpMessageDialog::HelpMessageDialog(QWidget* parent, bool about, const NetworkStyle* networkStyle) :
3133
QDialog(parent, GUIUtil::dialog_flags),
3234
ui(new Ui::HelpMessageDialog)
3335
{
@@ -37,8 +39,8 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
3739

3840
if (about)
3941
{
40-
setWindowTitle(tr("About %1").arg(CLIENT_NAME));
41-
42+
this->setAboutWindowTitle(networkStyle);
43+
this->setChainTypeIconOnAboutLogo(networkStyle);
4244
std::string licenseInfo = LicenseInfo();
4345
/// HTML-format the license message from the core
4446
QString licenseInfoHTML = QString::fromStdString(LicenseInfo());
@@ -137,6 +139,21 @@ void HelpMessageDialog::on_okButton_accepted()
137139
close();
138140
}
139141

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

141158
/** "Shutdown" window */
142159
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)