PIVX Core  5.6.99
P2P Digital Currency
networkstyle.cpp
Go to the documentation of this file.
1 // Copyright (c) 2014 The Bitcoin developers
2 // Copyright (c) 2017-2019 The PIVX Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include "networkstyle.h"
7 
8 #include "guiconstants.h"
9 
10 #include <QApplication>
11 
12 static const struct {
13  const char* networkId;
14  const char* appName;
15  const char* appIcon;
16  const char* titleAddText;
17  const char* splashImage;
18 } network_styles[] = {
19  {"main", QAPP_APP_NAME_DEFAULT, ":/icons/bitcoin", "", ":/bg-splash-png"},
20  {"test", QAPP_APP_NAME_TESTNET, ":/icons/bitcoin_testnet", QT_TRANSLATE_NOOP("SplashScreen", "[testnet]"), ":/bg-splash-png"},
21  {"regtest", QAPP_APP_NAME_TESTNET, ":/icons/bitcoin_regtest", "[regtest]", ":/bg-splash-png"}};
22 static const unsigned network_styles_count = sizeof(network_styles) / sizeof(*network_styles);
23 
24 // titleAddText needs to be const char* for tr()
25 NetworkStyle::NetworkStyle(const QString& appName, const QString& appIcon, const char* titleAddText, const QString& splashImage) : appName(appName),
27  titleAddText(qApp->translate("SplashScreen", titleAddText)),
29 {
30 }
31 
33 {
34  for (unsigned x = 0; x < network_styles_count; ++x) {
35  if (networkId == network_styles[x].networkId) {
36  return new NetworkStyle(
37  network_styles[x].appName,
38  network_styles[x].appIcon,
39  network_styles[x].titleAddText,
40  network_styles[x].splashImage);
41  }
42  }
43  return 0;
44 }
QString appName
Definition: networkstyle.h:27
static const NetworkStyle * instantiate(const QString &networkId)
Get style associated with provided network id, or 0 if not known.
QPixmap splashImage
Definition: networkstyle.h:30
NetworkStyle(const QString &appName, const QString &appIcon, const char *titleAddText, const QString &splashImage)
QString titleAddText
Definition: networkstyle.h:29
#define QAPP_APP_NAME_TESTNET
Definition: guiconstants.h:55
#define QAPP_APP_NAME_DEFAULT
Definition: guiconstants.h:54
const char * appName
const char * splashImage
const char * appIcon
const char * titleAddText
const char * networkId