Skip to content

Commit

Permalink
gui: Update about logo icon to denote chain type
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pablomartin4btc committed Aug 25, 2024
1 parent dcfbf3c commit 5556860
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,17 @@ int GuiMain(int argc, char* argv[])
SetupUIArgs(gArgs);
std::string error;
if (!gArgs.ParseParameters(argc, argv, error)) {
int nMBoxIcon = QMessageBox::Critical;
InitError(strprintf(Untranslated("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, PACKAGE_NAME,
QMessageBox mBox(static_cast<QMessageBox::Icon>(nMBoxIcon), PACKAGE_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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,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)
{
Expand Down Expand Up @@ -920,7 +920,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);
}

Expand Down
23 changes: 20 additions & 3 deletions src/qt/utilitydialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include <qt/guiutil.h>

#include <qt/networkstyle.h>

#include <clientversion.h>
#include <common/args.h>
#include <init.h>
Expand All @@ -29,7 +31,7 @@
#include <QVBoxLayout>

/** "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)
{
Expand All @@ -39,8 +41,8 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :

if (about)
{
setWindowTitle(tr("About %1").arg(PACKAGE_NAME));

this->setAboutWindowTitle(networkStyle);
this->setChainTypeIconOnAboutLogo(networkStyle);
std::string licenseInfo = LicenseInfo();
/// HTML-format the license message from the core
QString licenseInfoHTML = QString::fromStdString(LicenseInfo());
Expand Down Expand Up @@ -135,6 +137,21 @@ void HelpMessageDialog::on_okButton_accepted()
close();
}

void HelpMessageDialog::setAboutWindowTitle(const NetworkStyle* networkStyle)
{
QString aboutTitle = tr("About %1").arg(PACKAGE_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):
Expand Down
6 changes: 5 additions & 1 deletion src/qt/utilitydialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <QDialog>
#include <QWidget>

class NetworkStyle;

QT_BEGIN_NAMESPACE
class QMainWindow;
QT_END_NAMESPACE
Expand All @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 5556860

Please sign in to comment.