[PC-BSD Commits] r18538 - pcbsd/current/src-qt4/warden-gui

svn at pcbsd.org svn at pcbsd.org
Wed Aug 22 06:26:10 PDT 2012


Author: kris
Date: 2012-08-22 13:26:10 +0000 (Wed, 22 Aug 2012)
New Revision: 18538

Modified:
   pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp
   pcbsd/current/src-qt4/warden-gui/dialogwarden.h
   pcbsd/current/src-qt4/warden-gui/main.cpp
   pcbsd/current/src-qt4/warden-gui/warden-gui.pro
Log:

Make warden only opt a single instance at once

Submitted by: Josh Smith (joshms@)


Modified: pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp	2012-08-22 13:09:57 UTC (rev 18537)
+++ pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp	2012-08-22 13:26:10 UTC (rev 18538)
@@ -1705,3 +1705,11 @@
    }
 
 }
+
+void dialogWarden::slotSingleInstance()
+{
+  this->hide();
+  this->showNormal();
+  this->activateWindow();
+  this->raise();
+}

Modified: pcbsd/current/src-qt4/warden-gui/dialogwarden.h
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogwarden.h	2012-08-22 13:09:57 UTC (rev 18537)
+++ pcbsd/current/src-qt4/warden-gui/dialogwarden.h	2012-08-22 13:26:10 UTC (rev 18538)
@@ -24,6 +24,7 @@
     void programInit();
 
 public slots:
+    void slotSingleInstance();
 
 private slots:
     void helpAbout();

Modified: pcbsd/current/src-qt4/warden-gui/main.cpp
===================================================================
--- pcbsd/current/src-qt4/warden-gui/main.cpp	2012-08-22 13:09:57 UTC (rev 18537)
+++ pcbsd/current/src-qt4/warden-gui/main.cpp	2012-08-22 13:26:10 UTC (rev 18538)
@@ -1,12 +1,15 @@
 #include <QApplication>
 #include <QDebug>
 #include <QTranslator>
+#include <qtsingleapplication.h>
 #include <err.h>
 #include "dialogwarden.h"
 
 int main( int argc, char ** argv )
 {
-    QApplication a(argc, argv, TRUE);
+    QtSingleApplication a(argc, argv);
+    if ( a.isRunning() )
+      return !(a.sendMessage("show"));
 
     QTranslator translator;
     QLocale mylocale;
@@ -21,6 +24,7 @@
     dialogWarden *w = new dialogWarden();
     w->programInit();
     w->show();
+    QObject::connect(&a, SIGNAL(messageReceived(const QString&)), w, SLOT(slotSingleInstance()) );
     a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
     return a.exec();
 }

Modified: pcbsd/current/src-qt4/warden-gui/warden-gui.pro
===================================================================
--- pcbsd/current/src-qt4/warden-gui/warden-gui.pro	2012-08-22 13:09:57 UTC (rev 18537)
+++ pcbsd/current/src-qt4/warden-gui/warden-gui.pro	2012-08-22 13:26:10 UTC (rev 18538)
@@ -3,7 +3,7 @@
 
 CONFIG	+= qt warn_on release
 
-LIBS    += -lpcbsd
+LIBS    += -lpcbsd -lQtSolutions_SingleApplication-head
 INCLUDEPATH+= ../../../pcbsd/current/src-qt4/libpcbsd/
 
 HEADERS += dialogwarden.h dialogconfig.h dialogimport.h dialogworking.h dialogdisplayoutput.h wizardNewJail.h dialogEditIP.h



More information about the Commits mailing list