[PC-BSD Commits] r16255 - pcbsd/current/src-qt4/life-preserver

svn at pcbsd.org svn at pcbsd.org
Thu Apr 5 10:10:30 PDT 2012


Author: kris
Date: 2012-04-05 17:10:30 +0000 (Thu, 05 Apr 2012)
New Revision: 16255

Modified:
   pcbsd/current/src-qt4/life-preserver/lifePreserverMain.cpp
   pcbsd/current/src-qt4/life-preserver/lifePreserverMain.h
   pcbsd/current/src-qt4/life-preserver/main.cpp
Log:

Add option to disable life-preserver from starting at login, can be
enabled / disabled per-user



Modified: pcbsd/current/src-qt4/life-preserver/lifePreserverMain.cpp
===================================================================
--- pcbsd/current/src-qt4/life-preserver/lifePreserverMain.cpp	2012-04-05 16:46:36 UTC (rev 16254)
+++ pcbsd/current/src-qt4/life-preserver/lifePreserverMain.cpp	2012-04-05 17:10:30 UTC (rev 16255)
@@ -51,6 +51,9 @@
    qDebug("Application starting...");
    setWindowIcon(QIcon(QString::fromUtf8(":/images/images/lifepreserver.png")));
 
+   QSettings settings("PCBSD", "LifePreserver");
+   runAtStart = settings.value("autostart", true).toBool();
+
    aniStep=0;
    curActive=false;
    failedBackups=false;
@@ -81,6 +84,7 @@
    // See if we need to start a backup now
    QString cronscript = LIFEPRESERVERPATH + "/scripts/check-backups.sh &";
    system(cronscript.toLatin1());
+
 }
 
 void lifePreserver::slotTrayAnimation()
@@ -376,6 +380,11 @@
    quitAction = new QAction(tr("&Quit"), this);
    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
 
+   autoStartAction = new QAction(tr("&Start at login"), this);
+   autoStartAction->setCheckable(true);
+   autoStartAction->setChecked(runAtStart);
+   connect(autoStartAction, SIGNAL(triggered()), this, SLOT(slotToggleRunAtStart()));
+
 }
 
 void lifePreserver::createTrayIcon()
@@ -384,6 +393,8 @@
    trayIconMenu->addAction(minimizeAction);
    trayIconMenu->addAction(restoreAction);
    trayIconMenu->addSeparator();
+   trayIconMenu->addAction(autoStartAction);
+   trayIconMenu->addSeparator();
    trayIconMenu->addAction(quitAction);
 
    trayIcon = new QSystemTrayIcon(this);
@@ -447,3 +458,19 @@
 {
    slotTrayActivated(QSystemTrayIcon::Trigger);
 }
+
+
+void lifePreserver::slotToggleRunAtStart()
+{
+   QSettings settings("PCBSD", "LifePreserver");
+   bool autoRun = settings.value("autostart", true).toBool();
+   if ( autoRun )
+      runAtStart = false;
+   else
+      runAtStart = true;
+
+   settings.setValue("autostart", runAtStart);
+
+   // Update check state
+   createActions();
+}

Modified: pcbsd/current/src-qt4/life-preserver/lifePreserverMain.h
===================================================================
--- pcbsd/current/src-qt4/life-preserver/lifePreserverMain.h	2012-04-05 16:46:36 UTC (rev 16254)
+++ pcbsd/current/src-qt4/life-preserver/lifePreserverMain.h	2012-04-05 17:10:30 UTC (rev 16255)
@@ -52,6 +52,7 @@
    void slotScanPreserversForChanges();
    void slotTrayActivated(QSystemTrayIcon::ActivationReason reason);
    void slotTrayAnimation();
+   void slotToggleRunAtStart();
 
 private:
    lifePreserverWizard *lpw;
@@ -60,6 +61,7 @@
    QAction *minimizeAction;
    QAction *restoreAction;
    QAction *quitAction;
+   QAction *autoStartAction;
    QMenu *trayIconMenu;
    QString getPreserverLastBackup(QString host);
    QString getPreserverFrequency(QString host);
@@ -70,6 +72,7 @@
    void loadPreserverFromConf(QString connectHost);
    bool failedBackups;
    bool curActive;
+   bool runAtStart;
    int aniStep;
 
 signals:

Modified: pcbsd/current/src-qt4/life-preserver/main.cpp
===================================================================
--- pcbsd/current/src-qt4/life-preserver/main.cpp	2012-04-05 16:46:36 UTC (rev 16254)
+++ pcbsd/current/src-qt4/life-preserver/main.cpp	2012-04-05 17:10:30 UTC (rev 16255)
@@ -2,6 +2,7 @@
 #include <qlocale.h>
 #include <qtsingleapplication.h>
 #include <QDebug>
+#include <QSettings>
 #include "preserver.h"
 #include "externals.h"
 #include "lifePreserverMain.h"
@@ -29,6 +30,15 @@
     a.installTranslator( &translator );
     qDebug() << "Locale:" << langCode;
 
+    // Check if we should not open
+    if ( (a.arguments().size() > 2) && a.arguments().at(2) == "-autostart" ) {
+       QSettings settings("PCBSD", "LifePreserver");
+       if ( ! settings.value("autostart", true).toBool() ) {
+	  qDebug() << "Life-Preserver autostart is diabled! Run without -autostart flag!";
+	  exit(1);
+       }
+    }
+
     m = new lifePreserver(); 
     w = new lifePreserverWelcome(); 
 	



More information about the Commits mailing list