2 * W.J. van der Laan 2011
4 #include "bitcoingui.h"
5 #include "clientmodel.h"
10 #include <QApplication>
11 #include <QMessageBox>
14 #include <QTranslator>
16 // Need a global reference for the notifications to find the GUI
19 int MyMessageBox(const std::string& message, const std::string& caption, int style, wxWindow* parent, int x, int y)
21 // Message from main thread
24 guiref->error(QString::fromStdString(caption),
25 QString::fromStdString(message));
29 QMessageBox::critical(0, QString::fromStdString(caption),
30 QString::fromStdString(message),
31 QMessageBox::Ok, QMessageBox::Ok);
36 int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style, wxWindow* parent, int x, int y)
38 // Message from network thread
41 QMetaObject::invokeMethod(guiref, "error", Qt::QueuedConnection,
42 Q_ARG(QString, QString::fromStdString(caption)),
43 Q_ARG(QString, QString::fromStdString(message)));
47 printf("%s: %s\n", caption.c_str(), message.c_str());
48 fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
53 bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent)
57 if(nFeeRequired < MIN_TX_FEE || nFeeRequired <= nTransactionFee || fDaemon)
61 // Call slot on GUI thread.
62 // If called from another thread, use a blocking QueuedConnection.
63 Qt::ConnectionType connectionType = Qt::DirectConnection;
64 if(QThread::currentThread() != QCoreApplication::instance()->thread())
66 connectionType = Qt::BlockingQueuedConnection;
69 QMetaObject::invokeMethod(guiref, "askFee", connectionType,
70 Q_ARG(qint64, nFeeRequired),
71 Q_ARG(bool*, &payFee));
76 void CalledSetStatusBar(const std::string& strText, int nField)
78 // Only used for built-in mining, which is disabled, simple ignore
81 void UIThreadCall(boost::function0<void> fn)
83 // Only used for built-in mining, which is disabled, simple ignore
86 void MainFrameRepaint()
91 Translate string to current locale using Qt.
93 std::string _(const char* psz)
95 return QCoreApplication::translate("bitcoin-core", psz).toStdString();
98 int main(int argc, char *argv[])
100 Q_INIT_RESOURCE(bitcoin);
101 QApplication app(argc, argv);
103 // Load language file for system locale
104 QString locale = QLocale::system().name();
105 QTranslator translator;
106 translator.load("bitcoin_"+locale);
107 app.installTranslator(&translator);
109 app.setQuitOnLastWindowClosed(false);
113 if(AppInit2(argc, argv))
116 ClientModel model(pwalletMain);
118 window.setModel(&model);
122 int retval = app.exec();
133 } catch (std::exception& e) {
134 PrintException(&e, "Runaway exception");
136 PrintException(NULL, "Runaway exception");