Browse Source
0.106fd546d
Remove CChainParams::NetworkID() (jtimon)cc97210
Add fTestnetToBeDeprecatedFieldRPC to CChainParams (jtimon)e11712d
Move checkpoint data selection to chainparams (jtimon)6de50c3
qt: add network-specific style object (Wladimir J. van der Laan)
Wladimir J. van der Laan
10 years ago
14 changed files with 222 additions and 156 deletions
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2014 The Bitcoin developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "networkstyle.h" |
||||
|
||||
#include "guiconstants.h" |
||||
|
||||
#include <QApplication> |
||||
|
||||
static const struct { |
||||
const char *networkId; |
||||
const char *appName; |
||||
const char *appIcon; |
||||
const char *titleAddText; |
||||
const char *splashImage; |
||||
} network_styles[] = { |
||||
{"main", QAPP_APP_NAME_DEFAULT, ":/icons/bitcoin", "", ":/images/splash"}, |
||||
{"test", QAPP_APP_NAME_TESTNET, ":/icons/bitcoin_testnet", QT_TRANSLATE_NOOP("SplashScreen", "[testnet]"), ":/images/splash_testnet"}, |
||||
{"regtest", QAPP_APP_NAME_TESTNET, ":/icons/bitcoin_testnet", "[regtest]", ":/images/splash_testnet"} |
||||
}; |
||||
static const unsigned network_styles_count = sizeof(network_styles)/sizeof(*network_styles); |
||||
|
||||
// titleAddText needs to be const char* for tr()
|
||||
NetworkStyle::NetworkStyle(const QString &appName, const QString &appIcon, const char *titleAddText, const QString &splashImage): |
||||
appName(appName), |
||||
appIcon(appIcon), |
||||
titleAddText(qApp->translate("SplashScreen", titleAddText)), |
||||
splashImage(splashImage) |
||||
{ |
||||
} |
||||
|
||||
const NetworkStyle *NetworkStyle::instantiate(const QString &networkId) |
||||
{ |
||||
for (unsigned x=0; x<network_styles_count; ++x) |
||||
{ |
||||
if (networkId == network_styles[x].networkId) |
||||
{ |
||||
return new NetworkStyle( |
||||
network_styles[x].appName, |
||||
network_styles[x].appIcon, |
||||
network_styles[x].titleAddText, |
||||
network_styles[x].splashImage); |
||||
} |
||||
} |
||||
return 0; |
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2014 The Bitcoin developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef H_NETWORKSTYLE |
||||
#define H_NETWORKSTYLE |
||||
|
||||
#include <QIcon> |
||||
#include <QPixmap> |
||||
#include <QString> |
||||
|
||||
/* Coin network-specific GUI style information */ |
||||
class NetworkStyle |
||||
{ |
||||
public: |
||||
/** Get style associated with provided BIP70 network id, or 0 if not known */ |
||||
static const NetworkStyle *instantiate(const QString &networkId); |
||||
|
||||
const QString &getAppName() const { return appName; } |
||||
const QIcon &getAppIcon() const { return appIcon; } |
||||
const QString &getTitleAddText() const { return titleAddText; } |
||||
const QPixmap &getSplashImage() const { return splashImage; } |
||||
|
||||
private: |
||||
NetworkStyle(const QString &appName, const QString &appIcon, const char *titleAddText, const QString &splashImage); |
||||
|
||||
QString appName; |
||||
QIcon appIcon; |
||||
QString titleAddText; |
||||
QPixmap splashImage; |
||||
}; |
||||
|
||||
#endif // H_NETWORKSTYLE
|
Loading…
Reference in new issue