From: Manuel Nickschas Date: Thu, 19 Nov 2009 17:40:26 +0000 (+0100) Subject: Add a new statusbar widget for displaying CoreConnection's state X-Git-Tag: 0.6-beta1~164 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=cba75e911d78fd3250b25c94e4ad1aa1c4207ecf Add a new statusbar widget for displaying CoreConnection's state Having this in one widget encapsulates the functionality from MainWin. --- diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index 59d3ce8b..a4bda523 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -28,6 +28,7 @@ set(SOURCES chatviewsettings.cpp columnhandleitem.cpp coreconfigwizard.cpp + coreconnectionstatuswidget.cpp coreinfodlg.cpp debugbufferviewoverlay.cpp debugconsole.cpp @@ -72,6 +73,7 @@ set(MOC_HDRS chatviewsearchcontroller.h columnhandleitem.h coreconfigwizard.h + coreconnectionstatuswidget.h coreinfodlg.h debugbufferviewoverlay.h debugconsole.h diff --git a/src/qtui/coreconnectionstatuswidget.cpp b/src/qtui/coreconnectionstatuswidget.cpp new file mode 100644 index 00000000..11321b54 --- /dev/null +++ b/src/qtui/coreconnectionstatuswidget.cpp @@ -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 index 00000000..fd2c10a5 --- /dev/null +++ b/src/qtui/coreconnectionstatuswidget.h @@ -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 + +#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 diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 94bd517f..6871ae01 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -56,6 +56,7 @@ #include "clientbufferviewmanager.h" #include "clientignorelistmanager.h" #include "coreconnection.h" +#include "coreconnectionstatuswidget.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()), - msgProcessorStatusWidget(new MsgProcessorStatusWidget()), + _msgProcessorStatusWidget(new MsgProcessorStatusWidget(this)), + _coreConnectionStatusWidget(new CoreConnectionStatusWidget(Client::coreConnection(), this)), _titleSetter(this), _awayLog(0), _layoutLoaded(false) @@ -624,7 +626,11 @@ void MainWin::setupTitleSetter() { void MainWin::setupStatusBar() { // MessageProcessor progress - statusBar()->addPermanentWidget(msgProcessorStatusWidget); + statusBar()->addPermanentWidget(_msgProcessorStatusWidget); + + // Connection state + _coreConnectionStatusWidget->update(); + statusBar()->addPermanentWidget(_coreConnectionStatusWidget); // Core Lag: updateLagIndicator(); @@ -715,11 +721,11 @@ void MainWin::setConnectedState() { 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()) { - 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 &))); } diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 7379f964..966ee0ca 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -42,6 +42,7 @@ class BufferHotListFilter; class BufferView; class BufferViewConfig; class ClientBufferViewConfig; +class CoreConnectionStatusWidget; class BufferViewDock; class BufferWidget; class InputWidget; @@ -160,7 +161,8 @@ class MainWin QLabel *coreLagLabel; QLabel *sslLabel; - MsgProcessorStatusWidget *msgProcessorStatusWidget; + MsgProcessorStatusWidget *_msgProcessorStatusWidget; + CoreConnectionStatusWidget *_coreConnectionStatusWidget; TitleSetter _titleSetter; diff --git a/src/qtui/ui/coreconnectionstatuswidget.ui b/src/qtui/ui/coreconnectionstatuswidget.ui new file mode 100644 index 00000000..f9e72e01 --- /dev/null +++ b/src/qtui/ui/coreconnectionstatuswidget.ui @@ -0,0 +1,51 @@ + + + CoreConnectionStatusWidget + + + + 0 + 0 + 402 + 34 + + + + Form + + + + 0 + + + + + Message + + + + + + + + 0 + 0 + + + + 24 + + + + + + + + + + + + + + +