5 #include <QApplication>
19 #include <QMessageBox>
20 #if QT_VERSION < 0x050000
25 #include <QTranslator>
26 #include <QLibraryInfo>
32 #if defined(BITCOIN_NEED_QT_PLUGINS) && !defined(_BITCOIN_QT_PLUGINS_INCLUDED)
33 #define _BITCOIN_QT_PLUGINS_INCLUDED
36 Q_IMPORT_PLUGIN(qcncodecs)
37 Q_IMPORT_PLUGIN(qjpcodecs)
38 Q_IMPORT_PLUGIN(qtwcodecs)
39 Q_IMPORT_PLUGIN(qkrcodecs)
40 Q_IMPORT_PLUGIN(qtaccessiblewidgets)
44 Q_DECLARE_METATYPE(
bool*)
50 static
bool ThreadSafeMessageBox(const
std::
string& message, const
std::
string& caption,
unsigned int style)
58 QMetaObject::invokeMethod(guiref,
"message",
60 Q_ARG(QString, QString::fromStdString(caption)),
61 Q_ARG(QString, QString::fromStdString(message)),
62 Q_ARG(
unsigned int, style),
68 printf(
"%s: %s\n", caption.c_str(), message.c_str());
69 fprintf(stderr,
"%s: %s\n", caption.c_str(), message.c_str());
74 static bool ThreadSafeAskFee(
int64 nFeeRequired)
84 Q_ARG(qint64, nFeeRequired),
85 Q_ARG(
bool*, &payFee));
90 static void InitMessage(
const std::string &message)
94 splashref->showMessage(QString::fromStdString(message), Qt::AlignBottom|Qt::AlignHCenter, QColor(55,55,55));
95 qApp->processEvents();
97 printf(
"init message: %s\n", message.c_str());
103 static std::string Translate(
const char* psz)
105 return QCoreApplication::translate(
"bitcoin-core", psz).toStdString();
110 static void handleRunawayException(std::exception *e)
113 QMessageBox::critical(0,
"Runaway exception", BitcoinGUI::tr(
"A fatal error occurred. Feathercoin can no longer continue safely and will quit.") + QString(
"\n\n") + QString::fromStdString(
strMiscWarning));
117 #ifndef BITCOIN_QT_TEST
118 int main(
int argc,
char *argv[])
123 #if QT_VERSION < 0x050000
125 QTextCodec::setCodecForTr(QTextCodec::codecForName(
"UTF-8"));
126 QTextCodec::setCodecForCStrings(QTextCodec::codecForTr());
129 Q_INIT_RESOURCE(bitcoin);
130 QApplication app(argc, argv);
133 qRegisterMetaType< bool* >();
145 if (!boost::filesystem::is_directory(
GetDataDir(
false)))
149 QMessageBox::critical(0,
"Feathercoin",
150 QString(
"Error: Specified data directory \"%1\" does not exist.").
arg(QString::fromStdString(
mapArgs[
"-datadir"])));
157 QApplication::setOrganizationName(
"Feathercoin");
158 QApplication::setOrganizationDomain(
"feathercoin.com");
160 QApplication::setApplicationName(
"Feathercoin-Qt-testnet");
162 QApplication::setApplicationName(
"Feathercoin-Qt");
168 QString lang_territory = QString::fromStdString(
GetArg(
"-lang", QLocale::system().
name().toStdString()));
169 QString lang = lang_territory;
171 lang.truncate(lang_territory.lastIndexOf(
'_'));
173 QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
179 if (qtTranslatorBase.load(
"qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
180 app.installTranslator(&qtTranslatorBase);
183 if (qtTranslator.load(
"qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
184 app.installTranslator(&qtTranslator);
187 if (translatorBase.load(lang,
":/translations/"))
188 app.installTranslator(&translatorBase);
191 if (translator.load(lang_territory,
":/translations/"))
192 app.installTranslator(&translator);
220 splash.setAutoFillBackground(
true);
225 app.setQuitOnLastWindowClosed(
false);
236 boost::thread_group threadGroup;
241 QTimer* pollShutdownTimer =
new QTimer(guiref);
242 QObject::connect(pollShutdownTimer, SIGNAL(timeout()), guiref, SLOT(detectShutdown()));
243 pollShutdownTimer->start(200);
254 splash.finish(&window);
264 window.
addWallet(
"~Default", walletModel);
271 window.showMinimized();
280 QObject::connect(paymentServer, SIGNAL(receivedURI(QString)), &window, SLOT(handleURI(QString)));
281 QTimer::singleShot(100, paymentServer, SLOT(uiReady()));
292 threadGroup.interrupt_all();
293 threadGroup.join_all();
298 threadGroup.interrupt_all();
299 threadGroup.join_all();
303 }
catch (std::exception& e) {
304 handleRunawayException(&e);
306 handleRunawayException(NULL);
310 #endif // BITCOIN_QT_TEST
const boost::filesystem::path & GetDataDir(bool fNetSpecific)
Value help(const Array ¶ms, bool fHelp)
class for the splashscreen with information of the running client
bool setCurrentWallet(const QString &name)
int main(int argc, char *argv[])
Qt::ConnectionType blockingGUIThreadConnection()
Get connection type to call object slot in GUI thread with invokeMethod.
bool GetStartOnSystemStartup()
Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text repre...
Force blocking, modal message box dialog (not just OS notification)
void setIcon(const QIcon &icon)
static int64 nMinTxFee
Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) ...
static bool ipcSendCommandLine()
void setClientModel(ClientModel *clientModel)
Set the client model.
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
static MacDockIconHandler * instance()
boost::signals2::signal< std::string(const char *psz)> Translate
Translate a message to the native language of the user.
CClientUIInterface uiInterface
bool AppInit2(boost::thread_group &threadGroup)
Initialize bitcoin.
boost::signals2::signal< bool(int64 nFeeRequired), boost::signals2::last_value< bool > > ThreadSafeAskFee
Ask the user whether they want to pay a fee or not.
bool addWallet(const QString &name, WalletModel *walletModel)
Set the wallet model.
void PrintExceptionContinue(std::exception *pex, const char *pszThread)
void ParseParameters(int argc, const char *const argv[])
Model for Bitcoin network client.
void showOrPrint()
Show message box or print help message to standard output, based on operating system.
void ReadConfigFile(map< string, string > &mapSettingsRet, map< string, vector< string > > &mapMultiSettingsRet)
Interface from Qt to configuration data structure for Bitcoin client.
Interface to Bitcoin wallet from Qt view code.
Help message for Bitcoin-Qt, shown with –help.
boost::signals2::signal< bool(const std::string &message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeMessageBox
Show message box.
bool SetStartOnSystemStartup(bool fAutoStart)
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
map< string, vector< string > > mapMultiArgs
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
map< string, string > mapArgs