[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r1910: Emit a running() signal from the Vidalia QApplication object (in trunk: . src)



Author: edmanm
Date: 2007-09-05 23:51:07 -0400 (Wed, 05 Sep 2007)
New Revision: 1910

Modified:
   trunk/
   trunk/src/main.cpp
   trunk/src/vidalia.cpp
   trunk/src/vidalia.h
Log:
 r2127@adrastea:  edmanm | 2007-09-04 22:09:27 -0400
 Emit a running() signal from the Vidalia QApplication object when the
 application has started and the main event loop is running.



Property changes on: trunk
___________________________________________________________________
 svk:merge ticket from /vidalia/local/trunk [r2127] on 54b3572a-7227-0410-958f-53ecd705b71a

Modified: trunk/src/main.cpp
===================================================================
--- trunk/src/main.cpp	2007-09-06 03:50:59 UTC (rev 1909)
+++ trunk/src/main.cpp	2007-09-06 03:51:07 UTC (rev 1910)
@@ -122,7 +122,7 @@
   MainWindow mainWin;
 
   /* Run Vidalia */
-  int ret = vidalia.exec();
+  int ret = vidalia.run();
 
   /* Vidalia exited, so cleanup our pidfile and return */
   QFile::remove(pidfile);

Modified: trunk/src/vidalia.cpp
===================================================================
--- trunk/src/vidalia.cpp	2007-09-06 03:50:59 UTC (rev 1909)
+++ trunk/src/vidalia.cpp	2007-09-06 03:51:07 UTC (rev 1910)
@@ -26,6 +26,7 @@
  */
 
 #include <QDir>
+#include <QTimer>
 #include <QTextStream>
 #include <QStyleFactory>
 #include <util/string.h>
@@ -127,6 +128,24 @@
   delete _torControl;
 }
 
+/** Enters the main event loop and waits until exit() is called. The signal
+ * running() will be emitted when the event loop has started. */
+int
+Vidalia::run()
+{
+  QTimer::singleShot(0, vApp, SLOT(onEventLoopStarted()));
+  return vApp->exec();
+}
+
+/** Called when the application's main event loop has started. This method
+ * will emit the running() signal to indicate that the application's event
+ * loop is running. */
+void
+Vidalia::onEventLoopStarted()
+{
+  emit running();
+}
+
 #if defined(Q_OS_WIN)
 /** On Windows, we need to catch the WM_QUERYENDSESSION message
  * so we know that it is time to shutdown. */

Modified: trunk/src/vidalia.h
===================================================================
--- trunk/src/vidalia.h	2007-09-06 03:50:59 UTC (rev 1909)
+++ trunk/src/vidalia.h	2007-09-06 03:51:07 UTC (rev 1910)
@@ -99,12 +99,19 @@
 
   /** Writes <b>msg</b> with severity <b>level</b> to Vidalia's log. */
   static Log::LogMessage log(Log::LogLevel level, QString msg);
-
+ 
+  /** Enters the main event loop and waits until exit() is called. The signal
+   * running() will be emitted when the event loop has started. */
+  static int run();
+  
 public slots:
   /** Shows the specified help topic, or the default if empty. */
   static void help(QString topic = QString());
 
 signals:
+  /** Emitted when the application is running and the main event loop has
+   * started. */ 
+  void running();
   /** Signals that the application needs to shutdown now. */
   void shutdown();
 
@@ -114,6 +121,12 @@
   bool winEventFilter(MSG *msg, long *result);
 #endif
 
+private slots:
+  /** Called when the application's main event loop has started. This method
+   * will emit the running() signal to indicate that the application's event
+   * loop is running. */
+  void onEventLoopStarted();
+  
 private:
   /** Catches debugging messages from Qt and sends them to 
    * Vidalia's logs. */