Add a new statusbar widget for displaying CoreConnection's state
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 19 Nov 2009 17:40:26 +0000 (18:40 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 28 Nov 2009 23:39:41 +0000 (00:39 +0100)
Having this in one widget encapsulates the functionality from MainWin.

src/qtui/CMakeLists.txt
src/qtui/coreconnectionstatuswidget.cpp [new file with mode: 0644]
src/qtui/coreconnectionstatuswidget.h [new file with mode: 0644]
src/qtui/mainwin.cpp
src/qtui/mainwin.h
src/qtui/ui/coreconnectionstatuswidget.ui [new file with mode: 0644]

index 59d3ce8..a4bda52 100644 (file)
@@ -28,6 +28,7 @@ set(SOURCES
     chatviewsettings.cpp
     columnhandleitem.cpp
     coreconfigwizard.cpp
     chatviewsettings.cpp
     columnhandleitem.cpp
     coreconfigwizard.cpp
+    coreconnectionstatuswidget.cpp
     coreinfodlg.cpp
     debugbufferviewoverlay.cpp
     debugconsole.cpp
     coreinfodlg.cpp
     debugbufferviewoverlay.cpp
     debugconsole.cpp
@@ -72,6 +73,7 @@ set(MOC_HDRS
     chatviewsearchcontroller.h
     columnhandleitem.h
     coreconfigwizard.h
     chatviewsearchcontroller.h
     columnhandleitem.h
     coreconfigwizard.h
+    coreconnectionstatuswidget.h
     coreinfodlg.h
     debugbufferviewoverlay.h
     debugconsole.h
     coreinfodlg.h
     debugbufferviewoverlay.h
     debugconsole.h
diff --git a/src/qtui/coreconnectionstatuswidget.cpp b/src/qtui/coreconnectionstatuswidget.cpp
new file mode 100644 (file)
index 0000000..11321b5
--- /dev/null
@@ -0,0 +1,57 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by the Quassel Project                             *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) version 3.                                           *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "coreconnectionstatuswidget.h"
+
+#include "client.h"
+#include "coreconnection.h"
+#include "iconloader.h"
+
+CoreConnectionStatusWidget::CoreConnectionStatusWidget(CoreConnection *connection, QWidget *parent)
+  : QWidget(parent),
+  _coreConnection(connection)
+{
+  ui.setupUi(this);
+  update();
+
+  connect(coreConnection(), SIGNAL(progressTextChanged(QString)), ui.messageLabel, SLOT(setText(QString)));
+  connect(coreConnection(), SIGNAL(progressValueChanged(int)), ui.progressBar, SLOT(setValue(int)));
+  connect(coreConnection(), SIGNAL(progressRangeChanged(int, int)), ui.progressBar, SLOT(setRange(int, int)));
+  connect(coreConnection(), SIGNAL(progressRangeChanged(int, int)), this, SLOT(progressRangeChanged(int, int)));
+}
+
+void CoreConnectionStatusWidget::update() {
+  CoreConnection *conn = coreConnection();
+  if(conn->progressMaximum() >= 0) {
+    ui.progressBar->setMinimum(conn->progressMinimum());
+    ui.progressBar->setMaximum(conn->progressMaximum());
+    ui.progressBar->setValue(conn->progressValue());
+    ui.progressBar->show();
+  } else
+    ui.progressBar->hide();
+
+  ui.messageLabel->setText(conn->progressText());
+
+}
+
+void CoreConnectionStatusWidget::progressRangeChanged(int min, int max) {
+  Q_UNUSED(min)
+  ui.progressBar->setVisible(max >= 0);
+}
diff --git a/src/qtui/coreconnectionstatuswidget.h b/src/qtui/coreconnectionstatuswidget.h
new file mode 100644 (file)
index 0000000..fd2c10a
--- /dev/null
@@ -0,0 +1,49 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by the Quassel Project                             *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) version 3.                                           *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef CORECONNECTIONSTATUSWIDGET_H
+#define CORECONNECTIONSTATUSWIDGET_H
+
+#include <QWidget>
+
+#include "ui_coreconnectionstatuswidget.h"
+
+class CoreConnection;
+
+class CoreConnectionStatusWidget : public QWidget {
+  Q_OBJECT
+
+public:
+  CoreConnectionStatusWidget(CoreConnection *connection, QWidget *parent = 0);
+
+  inline CoreConnection *coreConnection() const { return _coreConnection; }
+
+public slots:
+  void update();
+private slots:
+  void progressRangeChanged(int min, int max);
+
+private:
+  Ui::CoreConnectionStatusWidget ui;
+
+  CoreConnection *_coreConnection;
+};
+
+#endif // CORECONNECTIONSTATUSWIDGET_H
index 94bd517..6871ae0 100644 (file)
@@ -56,6 +56,7 @@
 #include "clientbufferviewmanager.h"
 #include "clientignorelistmanager.h"
 #include "coreconnection.h"
 #include "clientbufferviewmanager.h"
 #include "clientignorelistmanager.h"
 #include "coreconnection.h"
+#include "coreconnectionstatuswidget.h"
 #include "coreinfodlg.h"
 #include "contextmenuactionprovider.h"
 #include "debugbufferviewoverlay.h"
 #include "coreinfodlg.h"
 #include "contextmenuactionprovider.h"
 #include "debugbufferviewoverlay.h"
@@ -124,7 +125,8 @@ MainWin::MainWin(QWidget *parent)
 #endif
     coreLagLabel(new QLabel()),
     sslLabel(new QLabel()),
 #endif
     coreLagLabel(new QLabel()),
     sslLabel(new QLabel()),
-    msgProcessorStatusWidget(new MsgProcessorStatusWidget()),
+    _msgProcessorStatusWidget(new MsgProcessorStatusWidget(this)),
+    _coreConnectionStatusWidget(new CoreConnectionStatusWidget(Client::coreConnection(), this)),
     _titleSetter(this),
     _awayLog(0),
     _layoutLoaded(false)
     _titleSetter(this),
     _awayLog(0),
     _layoutLoaded(false)
@@ -624,7 +626,11 @@ void MainWin::setupTitleSetter() {
 
 void MainWin::setupStatusBar() {
   // MessageProcessor progress
 
 void MainWin::setupStatusBar() {
   // MessageProcessor progress
-  statusBar()->addPermanentWidget(msgProcessorStatusWidget);
+  statusBar()->addPermanentWidget(_msgProcessorStatusWidget);
+
+  // Connection state
+  _coreConnectionStatusWidget->update();
+  statusBar()->addPermanentWidget(_coreConnectionStatusWidget);
 
   // Core Lag:
   updateLagIndicator();
 
   // Core Lag:
   updateLagIndicator();
@@ -715,11 +721,11 @@ void MainWin::setConnectedState() {
       action->setVisible(!Client::internalCore());
   }
 
       action->setVisible(!Client::internalCore());
   }
 
-  disconnect(Client::backlogManager(), SIGNAL(updateProgress(int, int)), msgProcessorStatusWidget, SLOT(setProgress(int, int)));
+  disconnect(Client::backlogManager(), SIGNAL(updateProgress(int, int)), _msgProcessorStatusWidget, SLOT(setProgress(int, int)));
   disconnect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
   disconnect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
   if(!Client::internalCore()) {
   disconnect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
   disconnect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
   if(!Client::internalCore()) {
-    connect(Client::backlogManager(), SIGNAL(updateProgress(int, int)), msgProcessorStatusWidget, SLOT(setProgress(int, int)));
+    connect(Client::backlogManager(), SIGNAL(updateProgress(int, int)), _msgProcessorStatusWidget, SLOT(setProgress(int, int)));
     connect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
     connect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
   }
     connect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
     connect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &)));
   }
index 7379f96..966ee0c 100644 (file)
@@ -42,6 +42,7 @@ class BufferHotListFilter;
 class BufferView;
 class BufferViewConfig;
 class ClientBufferViewConfig;
 class BufferView;
 class BufferViewConfig;
 class ClientBufferViewConfig;
+class CoreConnectionStatusWidget;
 class BufferViewDock;
 class BufferWidget;
 class InputWidget;
 class BufferViewDock;
 class BufferWidget;
 class InputWidget;
@@ -160,7 +161,8 @@ class MainWin
 
     QLabel *coreLagLabel;
     QLabel *sslLabel;
 
     QLabel *coreLagLabel;
     QLabel *sslLabel;
-    MsgProcessorStatusWidget *msgProcessorStatusWidget;
+    MsgProcessorStatusWidget *_msgProcessorStatusWidget;
+    CoreConnectionStatusWidget *_coreConnectionStatusWidget;
 
     TitleSetter _titleSetter;
 
 
     TitleSetter _titleSetter;
 
diff --git a/src/qtui/ui/coreconnectionstatuswidget.ui b/src/qtui/ui/coreconnectionstatuswidget.ui
new file mode 100644 (file)
index 0000000..f9e72e0
--- /dev/null
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CoreConnectionStatusWidget</class>
+ <widget class="QWidget" name="CoreConnectionStatusWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>402</width>
+    <height>34</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QHBoxLayout" name="horizontalLayout">
+   <property name="margin">
+    <number>0</number>
+   </property>
+   <item>
+    <widget class="QLabel" name="messageLabel">
+     <property name="text">
+      <string>Message</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QProgressBar" name="progressBar">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="value">
+      <number>24</number>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLabel" name="sslLabel">
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>