some tweaks to the coreinfo dialog
authorMarcus Eggenberger <egs@quassel-irc.org>
Wed, 16 Jul 2008 22:36:24 +0000 (00:36 +0200)
committerMarcus Eggenberger <egs@quassel-irc.org>
Wed, 16 Jul 2008 22:36:24 +0000 (00:36 +0200)
src/qtui/coreinfodlg.cpp
src/qtui/coreinfodlg.h
src/qtui/ui/coreinfodlg.ui

index 29e6048..a5ea7d6 100644 (file)
@@ -34,7 +34,20 @@ CoreInfoDlg::CoreInfoDlg(QWidget *parent)
 
 void CoreInfoDlg::coreInfoAvailable() {
   ui.labelCoreVersion->setText(_coreInfo["quasselVersion"].toString());
-  ui.labelUptime->setText(_coreInfo["startTime"].toString());
+  ui.labelCoreBuildDate->setText(_coreInfo["quasselBuildDate"].toString());
   ui.labelClientCount->setNum(_coreInfo["sessionConnectedClients"].toInt());
-  // data["quasselBuildDate"] = Global::quasselBuildDate;
+  updateUptime();
+  startTimer(1000);
+}
+
+void CoreInfoDlg::updateUptime() {
+  QDateTime startTime = _coreInfo["startTime"].toDateTime();
+  
+  int uptime = startTime.secsTo(QDateTime::currentDateTime());
+  int updays = uptime / 86400; uptime %= 86400;
+  int uphours = uptime / 3600; uptime %= 3600;
+  int upmins = uptime / 60; uptime %= 60;
+
+  QString uptimeText = QString("%1 Day(s) %2:%3:%4 (since %5)").arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(uptime,2,10,QChar('0')).arg(startTime.toString(Qt::TextDate));
+  ui.labelUptime->setText(uptimeText);
 }
index f9698aa..1c3ee37 100644 (file)
@@ -35,6 +35,13 @@ public:
 public slots:
   void coreInfoAvailable();
 
+protected:
+  virtual void timerEvent(QTimerEvent *) { updateUptime(); }
+
+private slots:
+  void on_closeButton_clicked() { reject(); }
+  void updateUptime();
+
 private:
   Ui::CoreInfoDlg ui;
   ClientCoreInfo _coreInfo;
index 45fa14d..975defd 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>284</width>
-    <height>137</height>
+    <width>282</width>
+    <height>174</height>
    </rect>
   </property>
   <property name="windowTitle" >
        </property>
       </widget>
      </item>
-     <item row="1" column="0" >
+     <item row="2" column="0" >
       <widget class="QLabel" name="label_4" >
        <property name="text" >
         <string>Uptime:</string>
        </property>
       </widget>
      </item>
-     <item row="2" column="0" >
+     <item row="3" column="0" >
       <widget class="QLabel" name="label_3" >
        <property name="text" >
         <string>Connected Clients:</string>
        </property>
       </widget>
      </item>
-     <item row="2" column="1" >
+     <item row="3" column="1" >
       <widget class="QLabel" name="labelClientCount" >
        <property name="text" >
         <string>&lt;connected clients></string>
        </property>
       </widget>
      </item>
-     <item row="1" column="1" >
+     <item row="2" column="1" >
       <widget class="QLabel" name="labelUptime" >
        <property name="text" >
         <string>&lt;core uptime></string>
        </property>
       </widget>
      </item>
+     <item row="1" column="0" >
+      <widget class="QLabel" name="label" >
+       <property name="text" >
+        <string>Build date:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1" >
+      <widget class="QLabel" name="labelCoreBuildDate" >
+       <property name="text" >
+        <string>&lt;build date></string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QGridLayout" name="gridLayout_2" >
+     <item row="0" column="1" >
+      <widget class="QPushButton" name="closeButton" >
+       <property name="text" >
+        <string>Close</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="0" >
+      <spacer name="horizontalSpacer" >
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0" >
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item row="0" column="2" >
+      <spacer name="horizontalSpacer_2" >
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0" >
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
     </layout>
    </item>
    <item>
      <property name="sizeHint" stdset="0" >
       <size>
        <width>20</width>
-       <height>28</height>
+       <height>0</height>
       </size>
      </property>
     </spacer>