5 #if defined(HAVE_CONFIG_H)
35 #include <boost/filesystem/operations.hpp>
36 #include <QApplication>
37 #include <QLibraryInfo>
39 #include <QMessageBox>
42 #include <QTranslator>
45 #if defined(QT_STATICPLUGIN)
47 #if QT_VERSION < 0x050000
48 Q_IMPORT_PLUGIN(qcncodecs)
49 Q_IMPORT_PLUGIN(qjpcodecs)
50 Q_IMPORT_PLUGIN(qtwcodecs)
51 Q_IMPORT_PLUGIN(qkrcodecs)
52 Q_IMPORT_PLUGIN(qtaccessiblewidgets)
54 Q_IMPORT_PLUGIN(AccessibleFactory)
55 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
59 #if QT_VERSION < 0x050000
64 Q_DECLARE_METATYPE(
bool*)
76 return QCoreApplication::translate(
"bitcoin-core", psz).toStdString();
80 static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTranslator, QTranslator &translatorBase, QTranslator &translator)
85 QApplication::removeTranslator(&qtTranslatorBase);
86 QApplication::removeTranslator(&qtTranslator);
87 QApplication::removeTranslator(&translatorBase);
88 QApplication::removeTranslator(&translator);
92 QString lang_territory = QLocale::system().name();
94 QString lang_territory_qsettings = settings.value(
"language",
"").toString();
95 if(!lang_territory_qsettings.isEmpty())
96 lang_territory = lang_territory_qsettings;
98 lang_territory = QString::fromStdString(
GetArg(
"-lang", lang_territory.toStdString()));
101 QString lang = lang_territory;
102 lang.truncate(lang_territory.lastIndexOf(
'_'));
109 if (qtTranslatorBase.load(
"qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
110 QApplication::installTranslator(&qtTranslatorBase);
113 if (qtTranslator.load(
"qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
114 QApplication::installTranslator(&qtTranslator);
117 if (translatorBase.load(lang,
":/translations/"))
118 QApplication::installTranslator(&translatorBase);
121 if (translator.load(lang_territory,
":/translations/"))
122 QApplication::installTranslator(&translator);
126 #if QT_VERSION < 0x050000
133 void DebugMessageHandler(QtMsgType type,
const QMessageLogContext& context,
const QString &msg)
137 LogPrint(
"qt",
"GUI: %s\n", qPrintable(msg));
175 void createPaymentServer();
223 #include "bitcoin.moc"
240 LogPrintf(
"Running AppInit2 in thread\n");
250 }
catch (std::exception& e) {
261 LogPrintf(
"Running Shutdown in thread\n");
267 }
catch (std::exception& e) {
280 pollShutdownTimer(0),
287 setQuitOnLastWindowClosed(
false);
301 delete paymentServer;
309 void BitcoinApplication::createPaymentServer()
332 splash->setAttribute(Qt::WA_DeleteOnClose);
350 connect(
this, SIGNAL(
stopThread()), executor, SLOT(deleteLater()));
370 window->removeAllWallets();
386 LogPrintf(
"Initialization result: %i\n", retval);
406 window->addWallet(
"~Default", walletModel);
407 window->setCurrentWallet(
"~Default");
428 connect(
window, SIGNAL(receivedURI(QString)),
429 paymentServer, SLOT(handleURIOrFile(QString)));
430 connect(paymentServer, SIGNAL(message(QString,QString,
unsigned int)),
431 window, SLOT(message(QString,QString,
unsigned int)));
432 QTimer::singleShot(100, paymentServer, SLOT(uiReady()));
441 LogPrintf(
"Shutdown result: %i\n", retval);
447 QMessageBox::critical(0,
"Runaway exception", BitcoinGUI::tr(
"A fatal error occurred. Bitcoin can no longer continue safely and will quit.") + QString(
"\n\n") + message);
459 #ifndef BITCOIN_QT_TEST
460 int main(
int argc,
char *argv[])
471 #if QT_VERSION < 0x050000
473 QTextCodec::setCodecForTr(QTextCodec::codecForName(
"UTF-8"));
474 QTextCodec::setCodecForCStrings(QTextCodec::codecForTr());
477 Q_INIT_RESOURCE(bitcoin);
480 #if QT_VERSION > 0x050100
482 QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
485 QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
489 qRegisterMetaType< bool* >();
500 QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
501 initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
519 if (!boost::filesystem::is_directory(
GetDataDir(
false)))
521 QMessageBox::critical(0, QObject::tr(
"Bitcoin"),
522 QObject::tr(
"Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(
mapArgs[
"-datadir"])));
527 }
catch(std::exception &e) {
528 QMessageBox::critical(0, QObject::tr(
"Bitcoin"),
529 QObject::tr(
"Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what()));
541 QMessageBox::critical(0, QObject::tr(
"Bitcoin"), QObject::tr(
"Error: Invalid combination of -regtest and -testnet."));
556 initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
570 app.createPaymentServer();
576 #if QT_VERSION < 0x050000
580 #if defined(Q_OS_WIN)
582 qApp->installNativeEventFilter(
new WinShutdownMonitor());
597 string strWarningText =
"This software is EXPERIMENTAL software for TESTNET TRANSACTIONS only. USE ON MAINNET AT YOUR OWN RISK.\n\n";
598 strWarningText +=
"The protocol and transaction processing rules for Mastercoin are still under active development and are subject to change in future.\n\n";
599 strWarningText +=
"Master Core should be considered an alpha-level product, and you use it at your own risk. Neither the Mastercoin Foundation nor the Master Core developers assumes any responsibility for funds misplaced, mishandled, lost, or misallocated.\n\n";
600 strWarningText +=
"Further, please note that this installation of Master Core should be viewed as EXPERIMENTAL. Your wallet data may be lost, deleted, or corrupted, with or without warning due to bugs or glitches. Please take caution.\n\n";
601 strWarningText +=
"This software is provided open-source at no cost. You are responsible for knowing the law in your country and determining if your use of this software contravenes any local laws.\n\n";
602 strWarningText +=
"DO NOT use wallet(s) with any significant amount of any property/currency while testing!";
603 QString warningText = QString::fromStdString(strWarningText);
604 QMessageBox warningDialog;
605 warningDialog.setIcon(QMessageBox::Warning);
606 warningDialog.setWindowTitle(
"WARNING - Experimental Software");
607 warningDialog.setText(warningText);
608 warningDialog.setStandardButtons(QMessageBox::No|QMessageBox::Yes);
609 warningDialog.setDefaultButton(QMessageBox::Yes);
610 warningDialog.setButtonText( QMessageBox::No,
"Exit" );
611 warningDialog.setButtonText( QMessageBox::Yes,
"Acknowledge + Continue" );
612 if(warningDialog.exec() == QMessageBox::No)
623 #if defined(Q_OS_WIN) && QT_VERSION >= 0x050000
624 WinShutdownMonitor::registerShutdownBlockReason(QObject::tr(
"Bitcoin Core didn't yet exit safely..."), (HWND)app.
getMainWinId());
630 catch (std::exception& e) {
640 #endif // BITCOIN_QT_TEST
OptionsModel * optionsModel
const boost::filesystem::path & GetDataDir(bool fNetSpecific)
CClientUIInterface uiInterface
void createWindow(bool isaTestNet)
Create main window.
Value help(const Array ¶ms, bool fHelp)
void shutdownResult(int retval)
class for the splashscreen with information of the running client
Class encapsulating Bitcoin Core startup and shutdown.
BitcoinApplication(int &argc, char **argv)
void handleRunawayException(const QString &message)
Handle runaway exceptions. Shows a message box with the problem and quits the program.
int main(int argc, char *argv[])
void requestInitialize()
Request core initialization.
bool SelectParamsFromCommandLine()
Looks for -regtest or -testnet and then calls SelectParams as appropriate.
static void showShutdownWindow(BitcoinGUI *window)
"Shutdown" window
void requestedInitialize()
static bool ipcParseCommandLine(int argc, char *argv[])
static bool ipcSendCommandLine()
static void InitMessage(const std::string &message)
void setClientModel(ClientModel *clientModel)
Set the client model.
void shutdownResult(int retval)
void SubstituteFonts()
Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text repre...
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
boost::signals2::signal< std::string(const char *psz)> Translate
Translate a message to the native language of the user.
static int LogPrint(const char *category, const char *format)
Main Bitcoin application object.
void createSplashScreen(bool isaTestNet)
Create splash screen.
int getReturnValue()
Get process return value.
bool AppInit2(boost::thread_group &threadGroup)
Initialize bitcoin.
static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTranslator, QTranslator &translatorBase, QTranslator &translator)
Set up translations.
void splashFinished(QWidget *window)
void initializeResult(int retval)
WId getMainWinId() const
Get window identifier of QMainWindow (BitcoinGUI)
static std::string Translate(const char *psz)
void PrintExceptionContinue(std::exception *pex, const char *pszThread)
void ParseParameters(int argc, const char *const argv[])
Model for Bitcoin network client.
void DebugMessageHandler(QtMsgType type, const char *msg)
void requestShutdown()
Request core shutdown.
void createOptionsModel()
Create options model.
void initializeResult(int retval)
#define QAPP_APP_NAME_DEFAULT
void ReadConfigFile(map< string, string > &mapSettingsRet, map< string, vector< string > > &mapMultiSettingsRet)
static const int TOOLTIP_WRAP_THRESHOLD
Interface from Qt to configuration data structure for Bitcoin client.
const CChainParams & Params()
Return the currently selected parameters.
Interface to Bitcoin wallet from Qt view code.
static void pickDataDirectory()
Determine data directory.
#define QAPP_APP_NAME_TESTNET
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
"Help message" dialog box
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
static void LoadRootCAs(X509_STORE *store=NULL)
map< string, vector< string > > mapMultiArgs
void runawayException(const QString &message)
boost::thread_group threadGroup
virtual Network NetworkID() const =0
ClientModel * clientModel
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
map< string, string > mapArgs
void handleRunawayException(std::exception *e)
Pass fatal exception message to UI thread.
QTimer * pollShutdownTimer
void StartDummyRPCThread()