Skip to content

Commit 46749eb

Browse files
committed
Testchains: Qt: Simplify network/chain styles and add a default purple
...for unkown chains
1 parent c0c1e38 commit 46749eb

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/qt/bitcoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ int main(int argc, char *argv[])
666666
PaymentServer::ipcParseCommandLine(*node, argc, argv);
667667
#endif
668668

669-
QScopedPointer<const NetworkStyle> networkStyle(NetworkStyle::instantiate(QString::fromStdString(Params().NetworkIDString())));
669+
QScopedPointer<const NetworkStyle> networkStyle(NetworkStyle::instantiate(Params().NetworkIDString()));
670670
assert(!networkStyle.isNull());
671671
// Allow for separate UI settings for testnets
672672
QApplication::setApplicationName(networkStyle->getAppName());

src/qt/networkstyle.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66

77
#include <qt/guiconstants.h>
88

9+
#include <chainparamsbase.h>
10+
#include <tinyformat.h>
11+
912
#include <QApplication>
1013

1114
static const struct {
1215
const char *networkId;
1316
const char *appName;
1417
const int iconColorHueShift;
1518
const int iconColorSaturationReduction;
16-
const char *titleAddText;
1719
} network_styles[] = {
18-
{"main", QAPP_APP_NAME_DEFAULT, 0, 0, ""},
19-
{"test", QAPP_APP_NAME_TESTNET, 70, 30, QT_TRANSLATE_NOOP("SplashScreen", "[testnet]")},
20-
{"regtest", QAPP_APP_NAME_TESTNET, 160, 30, "[regtest]"}
20+
{"main", QAPP_APP_NAME_DEFAULT, 0, 0},
21+
{"test", QAPP_APP_NAME_TESTNET, 70, 30},
22+
{"regtest", QAPP_APP_NAME_TESTNET, 160, 30}
2123
};
2224
static const unsigned network_styles_count = sizeof(network_styles)/sizeof(*network_styles);
2325

@@ -75,8 +77,9 @@ NetworkStyle::NetworkStyle(const QString &_appName, const int iconColorHueShift,
7577
trayAndWindowIcon = QIcon(pixmap.scaled(QSize(256,256)));
7678
}
7779

78-
const NetworkStyle *NetworkStyle::instantiate(const QString &networkId)
80+
const NetworkStyle* NetworkStyle::instantiate(const std::string& networkId)
7981
{
82+
std::string titleAddText = networkId == CBaseChainParams::MAIN ? "" : strprintf("[%s]", networkId);
8083
for (unsigned x=0; x<network_styles_count; ++x)
8184
{
8285
if (networkId == network_styles[x].networkId)
@@ -85,8 +88,8 @@ const NetworkStyle *NetworkStyle::instantiate(const QString &networkId)
8588
network_styles[x].appName,
8689
network_styles[x].iconColorHueShift,
8790
network_styles[x].iconColorSaturationReduction,
88-
network_styles[x].titleAddText);
91+
titleAddText.c_str());
8992
}
9093
}
91-
return 0;
94+
return new NetworkStyle(strprintf("%s-%s", QAPP_APP_NAME_DEFAULT, networkId).c_str(), 250, 30, titleAddText.c_str());
9295
}

src/qt/networkstyle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class NetworkStyle
1414
{
1515
public:
1616
/** Get style associated with provided BIP70 network id, or 0 if not known */
17-
static const NetworkStyle *instantiate(const QString &networkId);
17+
static const NetworkStyle* instantiate(const std::string& networkId);
1818

1919
const QString &getAppName() const { return appName; }
2020
const QIcon &getAppIcon() const { return appIcon; }

0 commit comments

Comments
 (0)