From 52df0969e22249e6758714eec9e5afd7d4fe9b83 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Thu, 17 Jul 2008 00:07:49 +0200 Subject: [PATCH] first version of core info dialog --- src/client/CMakeLists.txt | 1 + src/client/clientcoreinfo.h | 47 ++++++++++++++++++++++ src/common/CMakeLists.txt | 1 + src/common/coreinfo.h | 43 ++++++++++++++++++++ src/common/signalproxy.h | 1 + src/core/CMakeLists.txt | 2 + src/core/core.cpp | 10 ++--- src/core/core.h | 4 +- src/core/corecoreinfo.cpp | 41 +++++++++++++++++++ src/core/corecoreinfo.h | 47 ++++++++++++++++++++++ src/core/coresession.cpp | 4 ++ src/core/coresession.h | 2 + src/qtui/CMakeLists.txt | 3 ++ src/qtui/coreinfodlg.cpp | 40 +++++++++++++++++++ src/qtui/coreinfodlg.h | 43 ++++++++++++++++++++ src/qtui/mainwin.cpp | 7 ++++ src/qtui/mainwin.h | 1 + src/qtui/ui/coreinfodlg.ui | 79 +++++++++++++++++++++++++++++++++++++ src/qtui/ui/mainwin.ui | 10 +++++ 19 files changed, 380 insertions(+), 6 deletions(-) create mode 100644 src/client/clientcoreinfo.h create mode 100644 src/common/coreinfo.h create mode 100644 src/core/corecoreinfo.cpp create mode 100644 src/core/corecoreinfo.h create mode 100644 src/qtui/coreinfodlg.cpp create mode 100644 src/qtui/coreinfodlg.h create mode 100644 src/qtui/ui/coreinfodlg.ui diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 6877a0b7..5f4baeb0 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -25,6 +25,7 @@ set(MOC_HDRS buffermodel.h client.h clientbacklogmanager.h + clientcoreinfo.h clientirclisthelper.h clientsyncer.h irclistmodel.h diff --git a/src/client/clientcoreinfo.h b/src/client/clientcoreinfo.h new file mode 100644 index 00000000..7846039c --- /dev/null +++ b/src/client/clientcoreinfo.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * Copyright (C) 2005-08 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 CLIENTCOREINFO_H +#define CLIENTCOREINFO_H + +#include "coreinfo.h" + +/* + * Yes this name is somewhat stupid... but it fits the general naming scheme + * which is prefixing client specific sync objects with "Client"... ;) + */ +class ClientCoreInfo : public CoreInfo { + Q_OBJECT + +public: + ClientCoreInfo(QObject *parent = 0) : CoreInfo(parent) {} + + inline virtual const QMetaObject *syncMetaObject() const { return &CoreInfo::staticMetaObject; } + + inline QVariant &operator[](const QString &key) { return _coreData[key]; } + +public slots: + inline virtual void setCoreData(const QVariantMap &data) { _coreData = data; } + +private: + QVariantMap _coreData; +}; + +#endif //CLIENTCOREINFO_H diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index f725398e..880ccc99 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -27,6 +27,7 @@ set(MOC_HDRS buffersyncer.h bufferviewconfig.h bufferviewmanager.h + coreinfo.h identity.h ircchannel.h irclisthelper.h diff --git a/src/common/coreinfo.h b/src/common/coreinfo.h new file mode 100644 index 00000000..e7b92442 --- /dev/null +++ b/src/common/coreinfo.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (C) 2005-08 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 COREINFO_H +#define COREINFO_H + +#include "syncableobject.h" + +/* + * gather various informations about the core. + */ + +class CoreInfo : public SyncableObject { + Q_OBJECT + + Q_PROPERTY(QVariantMap coreData READ coreData WRITE setCoreData STORED false) + +public: + CoreInfo(QObject *parent = 0) : SyncableObject(parent) {} + +public slots: + virtual inline QVariantMap coreData() const { return QVariantMap(); } + virtual inline void setCoreData(const QVariantMap &) {} +}; + +#endif //COREINFO_H diff --git a/src/common/signalproxy.h b/src/common/signalproxy.h index 15acc886..b39e7ca8 100644 --- a/src/common/signalproxy.h +++ b/src/common/signalproxy.h @@ -160,6 +160,7 @@ private: public: void dumpSyncMap(SyncableObject *object); + inline int peerCount() const { return _peers.size(); } private: // Hash of used QIODevices diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c80336cc..a7bbbd2f 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -13,6 +13,7 @@ set(SOURCES corebacklogmanager.cpp corebufferviewconfig.cpp corebufferviewmanager.cpp + corecoreinfo.cpp coreirclisthelper.cpp corenetwork.cpp coresession.cpp @@ -33,6 +34,7 @@ set(MOC_HDRS corebacklogmanager.h corebufferviewconfig.h corebufferviewmanager.h + corecoreinfo.h coreirclisthelper.h corenetwork.h coresession.h diff --git a/src/core/core.cpp b/src/core/core.cpp index 0f652d0c..f4fadd4c 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -48,7 +48,7 @@ void Core::destroy() { } Core::Core() : storage(0) { - startTime = QDateTime::currentDateTime(); // for uptime :) + _startTime = QDateTime::currentDateTime(); // for uptime :) // Register storage backends here! registerStorageBackend(new SqliteStorage(this)); @@ -423,14 +423,14 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { reply["CoreBuild"] = 860; // FIXME legacy reply["ProtocolVersion"] = Global::protocolVersion; // TODO: Make the core info configurable - int uptime = startTime.secsTo(QDateTime::currentDateTime()); + int uptime = startTime().secsTo(QDateTime::currentDateTime()); int updays = uptime / 86400; uptime %= 86400; int uphours = uptime / 3600; uptime %= 3600; int upmins = uptime / 60; reply["CoreInfo"] = tr("Quassel Core Version %1
" - "Built: %2
" - "Up %3d%4h%5m (since %6)").arg(Global::quasselVersion).arg(Global::quasselBuildDate) - .arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime.toString(Qt::TextDate)); + "Built: %2
" + "Up %3d%4h%5m (since %6)").arg(Global::quasselVersion).arg(Global::quasselBuildDate) + .arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime().toString(Qt::TextDate)); #ifndef QT_NO_OPENSSL SslServer *sslServer = qobject_cast(&server); diff --git a/src/core/core.h b/src/core/core.h index 1288ae01..e6da7aba 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -282,6 +282,8 @@ class Core : public QObject { */ static QHash bufferLastSeenMsgIds(UserId user); + const QDateTime &startTime() const { return _startTime; } + public slots: //! Make storage data persistent /** \note This method is threadsafe. @@ -336,7 +338,7 @@ class Core : public QObject { QHash _storageBackends; - QDateTime startTime; + QDateTime _startTime; bool configured; diff --git a/src/core/corecoreinfo.cpp b/src/core/corecoreinfo.cpp new file mode 100644 index 00000000..495de45e --- /dev/null +++ b/src/core/corecoreinfo.cpp @@ -0,0 +1,41 @@ +/*************************************************************************** + * Copyright (C) 2005-08 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 "corecoreinfo.h" + +#include "core.h" +#include "coresession.h" +#include "global.h" +#include "signalproxy.h" + +CoreCoreInfo::CoreCoreInfo(CoreSession *parent) + : CoreInfo(parent), + _coreSession(parent) +{ +} + +QVariantMap CoreCoreInfo::coreData() const { + QVariantMap data; + data["quasselVersion"] = Global::quasselVersion; + data["quasselBuildDate"] = Global::quasselBuildDate; + data["startTime"] = Core::instance()->startTime(); + data["sessionConnectedClients"] = _coreSession->signalProxy()->peerCount(); + return data; +} diff --git a/src/core/corecoreinfo.h b/src/core/corecoreinfo.h new file mode 100644 index 00000000..e3eecd8c --- /dev/null +++ b/src/core/corecoreinfo.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * Copyright (C) 2005-08 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 CORECOREINFO_H +#define CORECOREINFO_H + +#include "coreinfo.h" + +class CoreSession; + +/* + * Yes this name is somewhat stupid... but it fits the general naming scheme + * which is prefixing core specific sync objects with "Core"... ;) + */ +class CoreCoreInfo : public CoreInfo { + Q_OBJECT + +public: + CoreCoreInfo(CoreSession *parent); + + inline virtual const QMetaObject *syncMetaObject() const { return &CoreInfo::staticMetaObject; } + +public slots: + virtual QVariantMap coreData() const; + +private: + CoreSession *_coreSession; +}; + +#endif //CORECOREINFO_H diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index bbb78b3f..2956d88c 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -48,6 +48,7 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) _backlogManager(new CoreBacklogManager(this)), _bufferViewManager(new CoreBufferViewManager(_signalProxy, this)), _ircListHelper(new CoreIrcListHelper(this)), + _coreInfo(this), scriptEngine(new QScriptEngine(this)) { @@ -93,6 +94,9 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) // init IrcListHelper; p->synchronize(ircListHelper()); + // init CoreInfo; + p->synchronize(&_coreInfo); + // Restore session state if(restoreState) restoreSessionState(); diff --git a/src/core/coresession.h b/src/core/coresession.h index 737e15c3..7144fe2b 100644 --- a/src/core/coresession.h +++ b/src/core/coresession.h @@ -24,6 +24,7 @@ #include #include +#include "corecoreinfo.h" #include "message.h" class BufferSyncer; @@ -189,6 +190,7 @@ private: CoreBacklogManager *_backlogManager; CoreBufferViewManager *_bufferViewManager; CoreIrcListHelper *_ircListHelper; + CoreCoreInfo _coreInfo; QScriptEngine *scriptEngine; diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index 1bb30fea..e7525bfc 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -10,6 +10,7 @@ set(SOURCES channellistdlg.cpp coreconfigwizard.cpp coreconnectdlg.cpp + coreinfodlg.cpp debugconsole.cpp inputwidget.cpp jumpkeyhandler.cpp @@ -31,6 +32,7 @@ set(MOC_HDRS channellistdlg.h coreconfigwizard.h coreconnectdlg.h + coreinfodlg.h debugconsole.h inputwidget.h jumpkeyhandler.h @@ -69,6 +71,7 @@ set(FORMS coreconfigwizardstorageselectionpage.ui coreconfigwizardsyncpage.ui coreconnectdlg.ui + coreinfodlg.ui debugconsole.ui inputwidget.ui mainwin.ui diff --git a/src/qtui/coreinfodlg.cpp b/src/qtui/coreinfodlg.cpp new file mode 100644 index 00000000..29e60485 --- /dev/null +++ b/src/qtui/coreinfodlg.cpp @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2005-08 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 "coreinfodlg.h" + +#include "client.h" +#include "signalproxy.h" + +CoreInfoDlg::CoreInfoDlg(QWidget *parent) + : QDialog(parent), + _coreInfo(this) +{ + ui.setupUi(this); + connect(&_coreInfo, SIGNAL(initDone()), this, SLOT(coreInfoAvailable())); + Client::signalProxy()->synchronize(&_coreInfo); +} + +void CoreInfoDlg::coreInfoAvailable() { + ui.labelCoreVersion->setText(_coreInfo["quasselVersion"].toString()); + ui.labelUptime->setText(_coreInfo["startTime"].toString()); + ui.labelClientCount->setNum(_coreInfo["sessionConnectedClients"].toInt()); + // data["quasselBuildDate"] = Global::quasselBuildDate; +} diff --git a/src/qtui/coreinfodlg.h b/src/qtui/coreinfodlg.h new file mode 100644 index 00000000..f9698aae --- /dev/null +++ b/src/qtui/coreinfodlg.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (C) 2005-08 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 COREINFODLG_H +#define COREINFODLG_H + +#include "ui_coreinfodlg.h" +#include + +#include "clientcoreinfo.h"; + +class CoreInfoDlg : public QDialog { + Q_OBJECT + +public: + CoreInfoDlg(QWidget *parent = 0); + +public slots: + void coreInfoAvailable(); + +private: + Ui::CoreInfoDlg ui; + ClientCoreInfo _coreInfo; +}; + +#endif //COREINFODLG_H diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index bf806b7b..e3dece21 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -28,6 +28,7 @@ #include "channellistdlg.h" #include "client.h" #include "clientbacklogmanager.h" +#include "coreinfodlg.h" #include "coreconnectdlg.h" #include "networkmodel.h" #include "buffermodel.h" @@ -162,6 +163,7 @@ MainWin::~MainWin() { void MainWin::setupMenus() { connect(ui.actionConnectCore, SIGNAL(triggered()), this, SLOT(showCoreConnectionDlg())); connect(ui.actionDisconnectCore, SIGNAL(triggered()), Client::instance(), SLOT(disconnectFromCore())); + connect(ui.actionCoreInfo, SIGNAL(triggered()), this, SLOT(showCoreInfoDlg())); connect(ui.actionQuit, SIGNAL(triggered()), QCoreApplication::instance(), SLOT(quit())); connect(ui.actionSettingsDlg, SIGNAL(triggered()), this, SLOT(showSettingsDlg())); // connect(ui.actionDebug_Console, SIGNAL(triggered()), this, SLOT(showDebugConsole())); @@ -494,6 +496,11 @@ void MainWin::showChannelList(NetworkId netId) { channelListDlg->show(); } +void MainWin::showCoreInfoDlg() { + CoreInfoDlg dlg(this); + dlg.exec(); +} + void MainWin::showSettingsDlg() { settingsDlg->show(); } diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 721cc3e9..1c5521e2 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -77,6 +77,7 @@ class MainWin : public QMainWindow { void removeBufferView(int bufferViewConfigId); void receiveMessage(const Message &msg); void showChannelList(NetworkId netId = NetworkId()); + void showCoreInfoDlg(); void showSettingsDlg(); void on_actionEditNetworks_triggered(); void on_actionManageViews_triggered(); diff --git a/src/qtui/ui/coreinfodlg.ui b/src/qtui/ui/coreinfodlg.ui new file mode 100644 index 00000000..45fa14d5 --- /dev/null +++ b/src/qtui/ui/coreinfodlg.ui @@ -0,0 +1,79 @@ + + CoreInfoDlg + + + + 0 + 0 + 284 + 137 + + + + Core Information + + + + + + + + Version: + + + + + + + <core version> + + + + + + + Uptime: + + + + + + + Connected Clients: + + + + + + + <connected clients> + + + + + + + <core uptime> + + + + + + + + + Qt::Vertical + + + + 20 + 28 + + + + + + + + + diff --git a/src/qtui/ui/mainwin.ui b/src/qtui/ui/mainwin.ui index 6fd7abd0..9b77edf6 100644 --- a/src/qtui/ui/mainwin.ui +++ b/src/qtui/ui/mainwin.ui @@ -58,6 +58,7 @@ + @@ -312,6 +313,15 @@ Edit &Networks... + + + + :/16x16/actions/oxygen/16x16/actions/help-about.png:/16x16/actions/oxygen/16x16/actions/help-about.png + + + Core Info + + -- 2.20.1