From 8958311b9f05fc65cdf9e528db8b4b32a94eb24a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Thu, 17 Nov 2011 09:44:03 +0200 Subject: [PATCH] Added iApp::exec() function, which enters the Qt event loop and runs the application. * Sets the application ready; * Calls QCoreApplication::exec(); * Sets the application back to not ready. Changed main application to use the iApp::exec() instead of QApplication::exec(). --- src/libs/Common/app.cpp | 20 ++++++++++++++++++++ src/libs/Common/app.h | 9 ++++++++- src/libs/Common/iapp.h | 9 +++++++++ src/libs/Common/version.h | 4 ++-- src/main/CLI/main.cpp | 2 +- src/main/CLI/version.h | 4 ++-- src/main/GUI/main.cpp | 2 +- 7 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/libs/Common/app.cpp b/src/libs/Common/app.cpp index 21818f9..60ee5bf 100644 --- a/src/libs/Common/app.cpp +++ b/src/libs/Common/app.cpp @@ -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(); + } +} diff --git a/src/libs/Common/app.h b/src/libs/Common/app.h index 8fb0dca..34f7a5d 100644 --- a/src/libs/Common/app.h +++ b/src/libs/Common/app.h @@ -61,6 +61,8 @@ public: virtual QString const xmlFileName() const; + virtual int exec(); + virtual void restart(); virtual void quit(bool err = false); @@ -82,7 +84,7 @@ public: virtual QString const qtPluginsDir() const; -private: +private: // Members /// Flag indicating that the eVaf application is ready bool mReady; @@ -123,6 +125,11 @@ private: uint mEvReady; uint mEvTerminating; + +private: // Methods + + void setReady(bool value); + }; } // namespace eVaf::Common::Internal diff --git a/src/libs/Common/iapp.h b/src/libs/Common/iapp.h index 098abaf..31390e3 100644 --- a/src/libs/Common/iapp.h +++ b/src/libs/Common/iapp.h @@ -129,6 +129,15 @@ public: */ virtual QString const xmlFileName() const = 0; + /** + * Enters the main event loop of the Qt application. + * @return Value returned by the Qt application + * + * This function enters the event loop of the Qt application. Use this function to start event handling + * instead of calling QCoreApplication::exec() or QApplication::exec() functions directly. + */ + virtual int exec() = 0; + /** * Requests the eVaf application to restart. * diff --git a/src/libs/Common/version.h b/src/libs/Common/version.h index 5feecd6..30d4175 100644 --- a/src/libs/Common/version.h +++ b/src/libs/Common/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,3,6 +#define VER_FILE_VERSION 0,1,4,7 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.3.6\0" +#define VER_FILE_VERSION_STR "0.1.4.7\0" /** * Module/library name (shall end with \0) diff --git a/src/main/CLI/main.cpp b/src/main/CLI/main.cpp index 4e8fe7e..0c3cbb6 100644 --- a/src/main/CLI/main.cpp +++ b/src/main/CLI/main.cpp @@ -281,7 +281,7 @@ int main(int argc, char ** argv) // Run the application EVAF_INFO("Running %s", VER_MODULE_NAME_STR); - rval = app.exec(); + rval = Common::iApp::instance()->exec(); quit = rval != Common::iApp::RC_Restart; diff --git a/src/main/CLI/version.h b/src/main/CLI/version.h index 25d61e2..17994d6 100644 --- a/src/main/CLI/version.h +++ b/src/main/CLI/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,1,2 +#define VER_FILE_VERSION 0,1,2,3 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.1.2\0" +#define VER_FILE_VERSION_STR "0.1.2.3\0" /** * Module/library name (shall end with \0) diff --git a/src/main/GUI/main.cpp b/src/main/GUI/main.cpp index c30e7ad..f0e765f 100644 --- a/src/main/GUI/main.cpp +++ b/src/main/GUI/main.cpp @@ -409,7 +409,7 @@ int main(int argc, char ** argv) // Run the application EVAF_INFO("Running %s", VER_MODULE_NAME_STR); - rval = app.exec(); + rval = Common::iApp::instance()->exec(); quit = rval != Common::iApp::RC_Restart; -- 2.45.0