[PC-BSD Commits] r4948 - pcbsd/trunk/lifePreserver

svn at pcbsd.org svn at pcbsd.org
Wed Nov 11 07:23:37 PST 2009


Author: kris
Date: 2009-11-11 07:23:37 -0800 (Wed, 11 Nov 2009)
New Revision: 4948

Modified:
   pcbsd/trunk/lifePreserver/lifePreserverMain.cpp
   pcbsd/trunk/lifePreserver/lifePreserverMain.h
   pcbsd/trunk/lifePreserver/lifePreserverMain.ui
   pcbsd/trunk/lifePreserver/preserver.cpp
Log:

Updated life-preserver, switched us to a QMainWindow to provide a menu bar, which makes the UI feel more consistent,
also improved user feedback



Modified: pcbsd/trunk/lifePreserver/lifePreserverMain.cpp
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverMain.cpp	2009-11-11 14:13:51 UTC (rev 4947)
+++ pcbsd/trunk/lifePreserver/lifePreserverMain.cpp	2009-11-11 15:23:37 UTC (rev 4948)
@@ -30,6 +30,7 @@
 #include <QFile>
 #include <QDebug>
 #include <QTimer>
+#include <QMenu>
 
 #include <kmenu.h>
 
@@ -52,17 +53,38 @@
    setWindowIcon(QIcon(QString::fromUtf8(":/images/images/lifepreserver.png")));
    loadPreservers();
 
-   connect(pushQuit, SIGNAL( clicked() ), this, SLOT(slotPushQuitClicked() ) );
-   connect(pushNewPreserver, SIGNAL( clicked() ), this, SLOT(slotPushNewPreserverClicked() ) );
-   connect(pushRemovePreserver, SIGNAL( clicked() ), this, SLOT(slotPushRemovePreserverClicked() ) );
-   connect(pushEditPreserver, SIGNAL( clicked() ), this, SLOT(slotPushEditPreserverClicked() ) );
+   treePreservers->setContextMenuPolicy( Qt::CustomContextMenu);
+   connect( treePreservers, SIGNAL(customContextMenuRequested (const QPoint & ) ), this, SLOT(slotContextMenuPreserver() ) );
+
    connect(pushPreserverStart, SIGNAL( clicked() ), this, SLOT(slotPushPreserverStartClicked() ) );
    treePreservers->resizeColumnToContents(0);
 
+   // Connect our menu actions
+   connect(action_Quit, SIGNAL( triggered(bool) ), this, SLOT(slotPushQuitClicked() ) );
+   connect(action_New_Preserver, SIGNAL( triggered(bool) ), this, SLOT(slotPushNewPreserverClicked() ) );
+   connect(action_Edit, SIGNAL( triggered(bool) ), this, SLOT(slotPushEditPreserverClicked() ) );
+   connect(action_Remove, SIGNAL( triggered(bool) ), this, SLOT(slotPushRemovePreserverClicked() ) );
+
    // Start monitoring for changes
    QTimer::singleShot(5000, this, SLOT(slotScanPreserversForChanges() ) );
 }
 
+// Slot which brings up a context menu for the preserver
+void lifePreserver::slotContextMenuPreserver()
+{
+  if (treePreservers->currentColumn() == -1)
+  {
+     return;
+  }
+
+  QMenu *popup = new QMenu();
+  popup->addAction( tr("Edit"), this, SLOT(slotPushEditPreserverClicked()));
+  popup->addSeparator();
+  popup->addAction( tr("Remove"), this, SLOT(slotPushRemovePreserverClicked()));
+  popup->exec( QCursor::pos() );
+
+}
+
 // Slot which monitors for changes in our preservers
 void lifePreserver::slotScanPreserversForChanges()
 {
@@ -92,9 +114,9 @@
 void lifePreserver::slotCurrentTreePreserverChanged(QTreeWidgetItem *curItem)
 {
    QString host = curItem->text(0);
-   pushEditPreserver->setEnabled(true);
-   pushRemovePreserver->setEnabled(true);
    pushPreserverStart->setEnabled(true);
+   action_Edit->setEnabled(true);
+   action_Remove->setEnabled(true);
 
    PRESERVER myPreserver(host);
    int pid = myPreserver.getPID();
@@ -190,9 +212,9 @@
    disconnect(treePreservers, SIGNAL( currentItemChanged ( QTreeWidgetItem *, QTreeWidgetItem *) ), 0, 0 );
    treePreservers->clear();
 
-   pushEditPreserver->setEnabled(false);
-   pushRemovePreserver->setEnabled(false);
    pushPreserverStart->setEnabled(false);
+   action_Edit->setEnabled(false);
+   action_Remove->setEnabled(false);
 
    QDir confdir;
    confdir.setPath(LIFEPRESERVERSDIR);

Modified: pcbsd/trunk/lifePreserver/lifePreserverMain.h
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverMain.h	2009-11-11 14:13:51 UTC (rev 4947)
+++ pcbsd/trunk/lifePreserver/lifePreserverMain.h	2009-11-11 15:23:37 UTC (rev 4948)
@@ -16,12 +16,12 @@
 /* KDE */
 #include <kmenu.h>
 
-class lifePreserver : public QDialog, private Ui::lifePreserver
+class lifePreserver : public QMainWindow, private Ui::lifePreserver
 {
         Q_OBJECT
 
 public:
-        lifePreserver() : QDialog()
+        lifePreserver() : QMainWindow()
         {
           setupUi(this);
         }
@@ -40,6 +40,7 @@
    void slotCurrentTreePreserverChanged(QTreeWidgetItem *curItem);
    void loadPreservers();
    void slotScanPreserversForChanges();
+   void slotContextMenuPreserver();
 
 private:
    lifePreserverWizard *lpw;

Modified: pcbsd/trunk/lifePreserver/lifePreserverMain.ui
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverMain.ui	2009-11-11 14:13:51 UTC (rev 4947)
+++ pcbsd/trunk/lifePreserver/lifePreserverMain.ui	2009-11-11 15:23:37 UTC (rev 4948)
@@ -1,13 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
  <class>lifePreserver</class>
- <widget class="QDialog" name="lifePreserver">
+ <widget class="QMainWindow" name="lifePreserver">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>650</width>
-    <height>340</height>
+    <width>708</width>
+    <height>302</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -17,149 +17,144 @@
    <iconset resource="lPreserve.qrc">
     <normaloff>:/images/images/lifepreserver.png</normaloff>:/images/images/lifepreserver.png</iconset>
   </property>
-  <layout class="QGridLayout" name="gridLayout">
-   <item row="0" column="0">
-    <widget class="QTreeWidget" name="treePreservers">
-     <property name="showDropIndicator" stdset="0">
-      <bool>false</bool>
-     </property>
-     <property name="rootIsDecorated">
-      <bool>false</bool>
-     </property>
-     <attribute name="headerDefaultSectionSize">
-      <number>120</number>
-     </attribute>
-     <attribute name="headerStretchLastSection">
-      <bool>true</bool>
-     </attribute>
-     <column>
-      <property name="text">
-       <string>Preserver Name</string>
+  <widget class="QWidget" name="centralwidget">
+   <layout class="QGridLayout" name="gridLayout">
+    <item row="0" column="0">
+     <widget class="QTreeWidget" name="treePreservers">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
       </property>
-     </column>
-     <column>
-      <property name="text">
-       <string>Last Backup</string>
+      <property name="showDropIndicator" stdset="0">
+       <bool>false</bool>
       </property>
-     </column>
-     <column>
-      <property name="text">
-       <string>Frequency</string>
+      <property name="rootIsDecorated">
+       <bool>false</bool>
       </property>
-     </column>
-     <column>
-      <property name="text">
-       <string>Status</string>
-      </property>
-     </column>
-    </widget>
-   </item>
-   <item row="1" column="0">
-    <layout class="QHBoxLayout" name="horizontalLayout_2">
-     <item>
-      <widget class="QPushButton" name="pushNewPreserver">
+      <attribute name="headerDefaultSectionSize">
+       <number>120</number>
+      </attribute>
+      <attribute name="headerStretchLastSection">
+       <bool>true</bool>
+      </attribute>
+      <column>
        <property name="text">
-        <string>&amp;New</string>
+        <string>Preserver Name</string>
        </property>
-       <property name="icon">
-        <iconset resource="lPreserve.qrc">
-         <normaloff>:/images/images/list-add.png</normaloff>:/images/images/list-add.png</iconset>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="pushEditPreserver">
+      </column>
+      <column>
        <property name="text">
-        <string>&amp;Edit</string>
+        <string>Last Backup</string>
        </property>
-       <property name="icon">
-        <iconset resource="lPreserve.qrc">
-         <normaloff>:/images/images/configure.png</normaloff>:/images/images/configure.png</iconset>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="pushRemovePreserver">
+      </column>
+      <column>
        <property name="text">
-        <string>&amp;Remove</string>
+        <string>Frequency</string>
        </property>
-       <property name="icon">
-        <iconset resource="lPreserve.qrc">
-         <normaloff>:/images/images/list-remove.png</normaloff>:/images/images/list-remove.png</iconset>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer name="horizontalSpacer_2">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>18</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <widget class="QPushButton" name="pushPreserverStart">
+      </column>
+      <column>
        <property name="text">
-        <string>Start</string>
+        <string>Status</string>
        </property>
-       <property name="icon">
-        <iconset resource="lPreserve.qrc">
-         <normaloff>:/images/images/system-run.png</normaloff>:/images/images/system-run.png</iconset>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-   <item row="2" column="0">
-    <spacer name="verticalSpacer">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeType">
-      <enum>QSizePolicy::Fixed</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>278</width>
-       <height>18</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="3" column="0">
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <item>
-      <spacer name="horizontalSpacer">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>348</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <widget class="QPushButton" name="pushQuit">
-       <property name="text">
-        <string>&amp;Quit</string>
-       </property>
-       <property name="icon">
-        <iconset resource="lPreserve.qrc">
-         <normaloff>:/images/images/application-exit.png</normaloff>:/images/images/application-exit.png</iconset>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-  </layout>
+      </column>
+     </widget>
+    </item>
+    <item row="1" column="0">
+     <layout class="QHBoxLayout" name="horizontalLayout_2">
+      <item>
+       <spacer name="horizontalSpacer_2">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>18</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item>
+       <widget class="QPushButton" name="pushPreserverStart">
+        <property name="text">
+         <string>Start</string>
+        </property>
+        <property name="icon">
+         <iconset resource="lPreserve.qrc">
+          <normaloff>:/images/images/system-run.png</normaloff>:/images/images/system-run.png</iconset>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </item>
+    <item row="2" column="0">
+     <spacer name="verticalSpacer">
+      <property name="orientation">
+       <enum>Qt::Vertical</enum>
+      </property>
+      <property name="sizeType">
+       <enum>QSizePolicy::Fixed</enum>
+      </property>
+      <property name="sizeHint" stdset="0">
+       <size>
+        <width>697</width>
+        <height>13</height>
+       </size>
+      </property>
+     </spacer>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>708</width>
+     <height>24</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menu_File">
+    <property name="title">
+     <string>&amp;File</string>
+    </property>
+    <addaction name="action_New_Preserver"/>
+    <addaction name="separator"/>
+    <addaction name="action_Quit"/>
+   </widget>
+   <widget class="QMenu" name="menu_Preservers">
+    <property name="title">
+     <string>&amp;Preservers</string>
+    </property>
+    <addaction name="action_Edit"/>
+    <addaction name="separator"/>
+    <addaction name="action_Remove"/>
+   </widget>
+   <addaction name="menu_File"/>
+   <addaction name="menu_Preservers"/>
+  </widget>
+  <action name="action_New_Preserver">
+   <property name="text">
+    <string>&amp;New Preserver</string>
+   </property>
+  </action>
+  <action name="action_Quit">
+   <property name="text">
+    <string>&amp;Quit</string>
+   </property>
+  </action>
+  <action name="action_Edit">
+   <property name="text">
+    <string>&amp;Edit</string>
+   </property>
+  </action>
+  <action name="action_Remove">
+   <property name="text">
+    <string>&amp;Remove</string>
+   </property>
+  </action>
  </widget>
  <resources>
   <include location="lPreserve.qrc"/>

Modified: pcbsd/trunk/lifePreserver/preserver.cpp
===================================================================
--- pcbsd/trunk/lifePreserver/preserver.cpp	2009-11-11 14:13:51 UTC (rev 4947)
+++ pcbsd/trunk/lifePreserver/preserver.cpp	2009-11-11 15:23:37 UTC (rev 4948)
@@ -199,7 +199,7 @@
 // Function which returns the last backup status + date
 QString PRESERVER::getLastBackup()
 {
-   QString result = "Unknown";
+   QString result = tr("No Previous Backup");
 
    // Read in the result file
    QFile pidFile( LIFEPRESERVERSDIR + "/" + connectHost + "/last-result" );
@@ -251,7 +251,7 @@
 // Function which returns the cron status of this backup for end user display
 QString PRESERVER::getFrequency()
 {
-  QString schedule = "Unknown";
+  QString schedule = tr("Disabled");
   QString hour, day;
   int tmpnum;
   bool ok;



More information about the Commits mailing list