]> vaikene.ee Git - evaf/blobdiff - src/libs/Common/app.cpp
Added iApp::exec() function, which enters the Qt event loop and runs the application.
[evaf] / src / libs / Common / app.cpp
index 21818f9ebe7d1e67e1e6eff9c911ac17bd22efdf..60ee5bf698d00b809e6050bd2b6f17c9b4f8d76c 100644 (file)
@@ -274,6 +274,14 @@ QString const App::xmlFileName() const
     return mXmlFile;
 }
 
+int App::exec()
+{
+    setReady(true);
+    int rval = QCoreApplication::exec();
+    setReady(false);
+    return rval;
+}
+
 void App::restart()
 {
     QCoreApplication::exit(RC_Restart);
@@ -283,3 +291,15 @@ void App::quit(bool err)
 {
     QCoreApplication::exit(err ? RC_Error : RC_Quit);
 }
+
+void App::setReady(bool value)
+{
+    if (mReady != value) {
+        mReady = value;
+        iEventQueue::instance()->broadcastEvent(new Event(mReady ? mEvReady : mEvTerminating));
+        if (mReady)
+            emit ready();
+        else
+            emit terminating();
+    }
+}