From 9bb1e377323247ce65e70f2506f096098969d19e Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Sun, 4 Jan 2009 16:48:55 +0100 Subject: [PATCH] Removing core related items from menu and statusbar --- src/client/client.cpp | 2 ++ src/client/client.h | 2 ++ src/qtui/mainwin.cpp | 36 ++++++++++++++++++++++++++++++------ src/qtui/mainwin.h | 4 ++++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/client/client.cpp b/src/client/client.cpp index 52a2d13f..ffecf7fa 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -81,6 +81,7 @@ Client::Client(QObject *parent) _messageProcessor(0), _connectedToCore(false), _syncedToCore(false), + _internalCore(false), _debugLog(&_debugLogBuffer) { _signalProxy->synchronize(_ircListHelper); @@ -275,6 +276,7 @@ void Client::setConnectedToCore(AccountId id, QIODevice *socket) { socket->setParent(0); signalProxy()->addPeer(socket); } + _internalCore = !socket; _connectedToCore = true; setCurrentCoreAccount(id); } diff --git a/src/client/client.h b/src/client/client.h index 362b5233..fb5247d8 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -108,6 +108,7 @@ public: static bool isConnected(); static bool isSynced(); + static inline bool internalCore() { return instance()->_internalCore; } static void userInput(BufferInfo bufferInfo, QString message); @@ -211,6 +212,7 @@ private: ClientMode clientMode; bool _connectedToCore, _syncedToCore; + bool _internalCore; QHash _networks; QHash _identities; diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 034991ba..431dacd7 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -243,10 +243,18 @@ void MainWin::setupMenus() { ActionCollection *coll = QtUi::actionCollection("General"); _fileMenu = menuBar()->addMenu(tr("&File")); - _fileMenu->addAction(coll->action("ConnectCore")); - _fileMenu->addAction(coll->action("DisconnectCore")); - _fileMenu->addAction(coll->action("CoreInfo")); - _fileMenu->addSeparator(); + + static const QStringList coreActions = QStringList() + << "ConnectCore" << "DisconnectCore" << "CoreInfo"; + + QAction *coreAction; + foreach(QString actionName, coreActions) { + coreAction = coll->action(actionName); + _fileMenu->addAction(coreAction); + flagRemoteCoreOnly(coreAction); + } + flagRemoteCoreOnly(_fileMenu->addSeparator()); + _networksMenu = _fileMenu->addMenu(tr("&Networks")); _networksMenu->addAction(coll->action("ConfigureNetworks")); _networksMenu->addSeparator(); @@ -452,12 +460,14 @@ void MainWin::setupStatusBar() { // Core Lag: updateLagIndicator(0); statusBar()->addPermanentWidget(coreLagLabel); + coreLagLabel->hide(); connect(Client::signalProxy(), SIGNAL(lagUpdated(int)), this, SLOT(updateLagIndicator(int))); // SSL indicator connect(Client::instance(), SIGNAL(securedConnection()), this, SLOT(securedConnection())); sslLabel->setPixmap(QPixmap()); statusBar()->addPermanentWidget(sslLabel); + sslLabel->hide(); _viewMenu->addSeparator(); QAction *showStatusbar = QtUi::actionCollection("General")->action("ToggleStatusBar"); @@ -529,14 +539,25 @@ void MainWin::connectedToCore() { void MainWin::setConnectedState() { ActionCollection *coll = QtUi::actionCollection("General"); - //ui.menuCore->setEnabled(true); + coll->action("ConnectCore")->setEnabled(false); coll->action("DisconnectCore")->setEnabled(true); coll->action("CoreInfo")->setEnabled(true); + + foreach(QAction *action, _fileMenu->actions()) { + if(isRemoteCoreOnly(action)) + action->setVisible(!Client::internalCore()); + } + // _viewMenu->setEnabled(true); - statusBar()->showMessage(tr("Connected to core.")); + if(!Client::internalCore()) + statusBar()->showMessage(tr("Connected to core.")); + if(sslLabel->width() == 0) sslLabel->setPixmap(SmallIcon("security-low")); + + sslLabel->setVisible(!Client::internalCore()); + coreLagLabel->setVisible(!Client::internalCore()); updateIcon(); } @@ -592,6 +613,8 @@ void MainWin::setDisconnectedState() { //_viewMenu->setEnabled(false); statusBar()->showMessage(tr("Not connected to core.")); sslLabel->setPixmap(QPixmap()); + sslLabel->hide(); + coreLagLabel->hide(); updateIcon(); } @@ -835,3 +858,4 @@ void MainWin::saveStateToSessionSettings(SessionSettings & s) void MainWin::showStatusBarMessage(const QString &message) { statusBar()->showMessage(message, 10000); } + diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 670bcaf1..a20a8afc 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -68,6 +68,10 @@ class MainWin inline QSystemTrayIcon *systemTrayIcon() const; virtual bool event(QEvent *event); + + static void flagRemoteCoreOnly(QObject *object) { object->setProperty("REMOTE_CORE_ONLY", true); } + static bool isRemoteCoreOnly(QObject *object) { return object->property("REMOTE_CORE_ONLY").toBool(); } + public slots: void saveStateToSession(const QString &sessionId); void saveStateToSessionSettings(SessionSettings &s); -- 2.20.1