From 2ea980a77cc28374a55aa1fdce953f9b570e0857 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 18 Dec 2013 09:45:36 +0100 Subject: [PATCH] qt: Treat regtest as testnet No need to do anything special in the GUI for regtest mode, but do treat it at testnet not mainnet to prevent confusion. --- src/qt/bitcoin.cpp | 9 +++++---- src/qt/clientmodel.cpp | 7 +++++-- src/qt/clientmodel.h | 4 ++-- src/qt/forms/rpcconsole.ui | 24 +++++++++++++++--------- src/qt/rpcconsole.cpp | 2 +- src/qt/splashscreen.cpp | 7 +++---- src/qt/splashscreen.h | 2 +- 7 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index b74452d4c..122cf9b0b 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -197,9 +197,10 @@ int main(int argc, char *argv[]) // Application identification (must be set before OptionsModel is initialized, // as it is used to locate QSettings) + bool isaTestNet = TestNet() || RegTest(); QApplication::setOrganizationName("Bitcoin"); QApplication::setOrganizationDomain("bitcoin.org"); - if (TestNet()) // Separate UI settings for testnet + if (isaTestNet) // Separate UI settings for testnets QApplication::setApplicationName("Bitcoin-Qt-testnet"); else QApplication::setApplicationName("Bitcoin-Qt"); @@ -230,7 +231,7 @@ int main(int argc, char *argv[]) PaymentServer* paymentServer = new PaymentServer(&app); // User language is set up: pick a data directory - Intro::pickDataDirectory(TestNet()); + Intro::pickDataDirectory(isaTestNet); // Install global event filter that makes sure that long tooltips can be word-wrapped app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app)); @@ -258,7 +259,7 @@ int main(int argc, char *argv[]) return 1; } - SplashScreen splash(QPixmap(), 0); + SplashScreen splash(QPixmap(), 0, isaTestNet); if (GetBoolArg("-splash", true) && !GetBoolArg("-min", false)) { splash.show(); @@ -280,7 +281,7 @@ int main(int argc, char *argv[]) boost::thread_group threadGroup; - BitcoinGUI window(TestNet(), 0); + BitcoinGUI window(isaTestNet, 0); guiref = &window; QTimer* pollShutdownTimer = new QTimer(guiref); diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index c64e411bc..f273b9ea4 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -123,9 +123,12 @@ void ClientModel::updateAlert(const QString &hash, int status) emit alertsChanged(getStatusBarWarnings()); } -bool ClientModel::isTestNet() const +QString ClientModel::getNetworkName() const { - return TestNet(); + QString netname(QString::fromStdString(Params().DataDir())); + if(netname.isEmpty()) + netname = "main"; + return netname; } bool ClientModel::inInitialBlockDownload() const diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index 05e841252..ca735f14c 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -46,8 +46,8 @@ public: double getVerificationProgress() const; QDateTime getLastBlockDate() const; - //! Return true if client connected to testnet - bool isTestNet() const; + //! Return network (main, testnet3, regtest) + QString getNetworkName() const; //! Return true if core is doing initial block download bool inInitialBlockDownload() const; //! Return true if core is importing blocks diff --git a/src/qt/forms/rpcconsole.ui b/src/qt/forms/rpcconsole.ui index 83e51b275..69504f315 100644 --- a/src/qt/forms/rpcconsole.ui +++ b/src/qt/forms/rpcconsole.ui @@ -172,14 +172,14 @@ - + - Number of connections + Name - + IBeamCursor @@ -195,19 +195,25 @@ - + - On testnet + Number of connections - - - false + + + IBeamCursor - + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index d43cdc7e5..a8470572d 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -284,7 +284,7 @@ void RPCConsole::setClientModel(ClientModel *model) ui->buildDate->setText(model->formatBuildDate()); ui->startupTime->setText(model->formatClientStartupTime()); - ui->isTestNet->setChecked(model->isTestNet()); + ui->networkName->setText(model->getNetworkName()); } } diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index 4528c3477..6fb834c04 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -4,14 +4,13 @@ #include "splashscreen.h" -#include "chainparams.h" #include "clientversion.h" #include "util.h" #include #include -SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) : +SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTestNet) : QSplashScreen(pixmap, f) { // set reference point, paddings @@ -32,7 +31,7 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) : // load the bitmap for writing some text over it QPixmap newPixmap; - if(TestNet()) { + if(isTestNet) { newPixmap = QPixmap(":/images/splash_testnet"); } else { @@ -72,7 +71,7 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) : pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText); // draw testnet string if testnet is on - if(TestNet()) { + if(isTestNet) { QFont boldFont = QFont(font, 10*fontFactor); boldFont.setWeight(QFont::Bold); pixPaint.setFont(boldFont); diff --git a/src/qt/splashscreen.h b/src/qt/splashscreen.h index ddf040593..070e376c9 100644 --- a/src/qt/splashscreen.h +++ b/src/qt/splashscreen.h @@ -14,7 +14,7 @@ class SplashScreen : public QSplashScreen Q_OBJECT public: - explicit SplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = 0); + explicit SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTestNet); }; #endif // SPLASHSCREEN_H