add export functionality for address book / receiving addresses
[novacoin.git] / src / qt / bitcoin.cpp
index a71c348..78a20c5 100644 (file)
@@ -3,14 +3,16 @@
  */
 #include "bitcoingui.h"
 #include "clientmodel.h"
-#include "util.h"
+#include "walletmodel.h"
+
+#include "headers.h"
 #include "init.h"
-#include "main.h"
-#include "externui.h"
 
 #include <QApplication>
 #include <QMessageBox>
 #include <QThread>
+#include <QLocale>
+#include <QTranslator>
 
 // Need a global reference for the notifications to find the GUI
 BitcoinGUI *guiref;
@@ -57,9 +59,8 @@ bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindo
         return true;
     bool payFee = false;
 
-    /* Call slot on GUI thread.
-       If called from another thread, use a blocking QueuedConnection.
-     */
+    // Call slot on GUI thread.
+    // If called from another thread, use a blocking QueuedConnection.
     Qt::ConnectionType connectionType = Qt::DirectConnection;
     if(QThread::currentThread() != QCoreApplication::instance()->thread())
     {
@@ -97,26 +98,38 @@ std::string _(const char* psz)
 
 int main(int argc, char *argv[])
 {
+    Q_INIT_RESOURCE(bitcoin);
     QApplication app(argc, argv);
+
+    // Load language file for system locale
+    QString locale = QLocale::system().name();
+    QTranslator translator;
+    translator.load("bitcoin_"+locale);
+    app.installTranslator(&translator);
+
     app.setQuitOnLastWindowClosed(false);
 
     try
     {
         if(AppInit2(argc, argv))
         {
-            BitcoinGUI window;
-            ClientModel model;
-            guiref = &window;
-            window.setModel(&model);
-
-            window.show();
-
-            int retval = app.exec();
-
-            guiref = 0;
+            {
+                // Put this in a block, so that BitcoinGUI is cleaned up properly before
+                // calling shutdown.
+                BitcoinGUI window;
+                ClientModel clientModel(pwalletMain);
+                WalletModel walletModel(pwalletMain);
+                guiref = &window;
+                window.setClientModel(&clientModel);
+                window.setWalletModel(&walletModel);
+
+                window.show();
+
+                app.exec();
+
+                guiref = 0;
+            }
             Shutdown(NULL);
-
-            return retval;
         }
         else
         {
@@ -127,4 +140,5 @@ int main(int argc, char *argv[])
     } catch (...) {
         PrintException(NULL, "Runaway exception");
     }
+    return 0;
 }