projects
/
quassel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
using the extended away icon for away state as proposed by jussi01
[quassel.git]
/
src
/
qtui
/
mainwin.cpp
diff --git
a/src/qtui/mainwin.cpp
b/src/qtui/mainwin.cpp
index
431dacd
..
db0860c
100644
(file)
--- a/
src/qtui/mainwin.cpp
+++ b/
src/qtui/mainwin.cpp
@@
-1,5
+1,5
@@
/***************************************************************************
/***************************************************************************
- * Copyright (C) 2005-0
8
by the Quassel Project *
+ * Copyright (C) 2005-0
9
by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-41,6
+41,7
@@
#include "chatmonitorview.h"
#include "chatview.h"
#include "client.h"
#include "chatmonitorview.h"
#include "chatview.h"
#include "client.h"
+#include "clientsyncer.h"
#include "clientbacklogmanager.h"
#include "coreinfodlg.h"
#include "coreconnectdlg.h"
#include "clientbacklogmanager.h"
#include "coreinfodlg.h"
#include "coreconnectdlg.h"
@@
-115,20
+116,6
@@
MainWin::MainWin(QWidget *parent)
installEventFilter(new JumpKeyHandler(this));
installEventFilter(new JumpKeyHandler(this));
-#ifndef HAVE_KDE
- QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this));
- QtUi::registerNotificationBackend(new SystrayNotificationBackend(this));
-# ifdef HAVE_PHONON
- QtUi::registerNotificationBackend(new PhononNotificationBackend(this));
-# endif
-# ifdef HAVE_DBUS
- QtUi::registerNotificationBackend(new DesktopNotificationBackend(this));
-# endif
-
-#else /* HAVE_KDE */
- QtUi::registerNotificationBackend(new KNotificationBackend(this));
-#endif /* HAVE_KDE */
-
QtUiApplication* app = qobject_cast<QtUiApplication*> qApp;
connect(app, SIGNAL(saveStateToSession(const QString&)), SLOT(saveStateToSession(const QString&)));
connect(app, SIGNAL(saveStateToSessionSettings(SessionSettings&)), SLOT(saveStateToSessionSettings(SessionSettings&)));
QtUiApplication* app = qobject_cast<QtUiApplication*> qApp;
connect(app, SIGNAL(saveStateToSession(const QString&)), SLOT(saveStateToSession(const QString&)));
connect(app, SIGNAL(saveStateToSessionSettings(SessionSettings&)), SLOT(saveStateToSessionSettings(SessionSettings&)));
@@
-157,7
+144,6
@@
void MainWin::init() {
setupActions();
setupBufferWidget();
setupMenus();
setupActions();
setupBufferWidget();
setupMenus();
- setupViews();
setupTopicWidget();
setupChatMonitor();
setupNickWidget();
setupTopicWidget();
setupChatMonitor();
setupNickWidget();
@@
-166,6
+152,20
@@
void MainWin::init() {
setupSystray();
setupTitleSetter();
setupSystray();
setupTitleSetter();
+#ifndef HAVE_KDE
+ QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this));
+ QtUi::registerNotificationBackend(new SystrayNotificationBackend(this));
+# ifdef HAVE_PHONON
+ QtUi::registerNotificationBackend(new PhononNotificationBackend(this));
+# endif
+# ifdef HAVE_DBUS
+ QtUi::registerNotificationBackend(new DesktopNotificationBackend(this));
+# endif
+
+#else /* HAVE_KDE */
+ QtUi::registerNotificationBackend(new KNotificationBackend(this));
+#endif /* HAVE_KDE */
+
// restore mainwin state
restoreState(s.value("MainWinState").toByteArray());
// restore mainwin state
restoreState(s.value("MainWinState").toByteArray());
@@
-175,7
+175,11
@@
void MainWin::init() {
setDisconnectedState(); // Disable menus and stuff
show();
setDisconnectedState(); // Disable menus and stuff
show();
- showCoreConnectionDlg(true); // autoconnect if appropriate
+ if(Quassel::runMode() != Quassel::Monolithic) {
+ showCoreConnectionDlg(true); // autoconnect if appropriate
+ } else {
+ startInternalCore();
+ }
}
MainWin::~MainWin() {
}
MainWin::~MainWin() {
@@
-298,24
+302,20
@@
void MainWin::setupBufferWidget() {
setCentralWidget(_bufferWidget);
}
setCentralWidget(_bufferWidget);
}
-void MainWin::setupViews() {
- addBufferView();
-}
-
void MainWin::addBufferView(int bufferViewConfigId) {
addBufferView(Client::bufferViewManager()->bufferViewConfig(bufferViewConfigId));
}
void MainWin::addBufferView(BufferViewConfig *config) {
void MainWin::addBufferView(int bufferViewConfigId) {
addBufferView(Client::bufferViewManager()->bufferViewConfig(bufferViewConfigId));
}
void MainWin::addBufferView(BufferViewConfig *config) {
- BufferViewDock *dock;
- if(config)
- dock = new BufferViewDock(config, this);
- else
- dock = new BufferViewDock(this);
+ if(!config)
+ return;
+
+ BufferViewDock *dock = new BufferViewDock(config, this);
//create the view and initialize it's filter
BufferView *view = new BufferView(dock);
view->setFilteredModel(Client::bufferModel(), config);
//create the view and initialize it's filter
BufferView *view = new BufferView(dock);
view->setFilteredModel(Client::bufferModel(), config);
+ view->installEventFilter(_inputWidget->inputLine()); // for key presses
view->show();
Client::bufferModel()->synchronizeView(view);
view->show();
Client::bufferModel()->synchronizeView(view);
@@
-415,20
+415,20
@@
void MainWin::setupInputWidget() {
VerticalDock *dock = new VerticalDock(tr("Inputline"), this);
dock->setObjectName("InputDock");
VerticalDock *dock = new VerticalDock(tr("Inputline"), this);
dock->setObjectName("InputDock");
-
InputWidget *
inputWidget = new InputWidget(dock);
- dock->setWidget(inputWidget);
+
_
inputWidget = new InputWidget(dock);
+ dock->setWidget(
_
inputWidget);
addDockWidget(Qt::BottomDockWidgetArea, dock);
_viewMenu->addAction(dock->toggleViewAction());
dock->toggleViewAction()->setText(tr("Show Input Line"));
addDockWidget(Qt::BottomDockWidgetArea, dock);
_viewMenu->addAction(dock->toggleViewAction());
dock->toggleViewAction()->setText(tr("Show Input Line"));
- inputWidget->setModel(Client::bufferModel());
- inputWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
+
_
inputWidget->setModel(Client::bufferModel());
+
_
inputWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
- _bufferWidget->setFocusProxy(inputWidget);
+ _bufferWidget->setFocusProxy(
_
inputWidget);
- inputWidget->inputLine()->installEventFilter(_bufferWidget);
+
_
inputWidget->inputLine()->installEventFilter(_bufferWidget);
}
void MainWin::setupTopicWidget() {
}
void MainWin::setupTopicWidget() {
@@
-458,13
+458,12
@@
void MainWin::setupStatusBar() {
connect(Client::messageProcessor(), SIGNAL(progressUpdated(int, int)), msgProcessorStatusWidget, SLOT(setProgress(int, int)));
// Core Lag:
connect(Client::messageProcessor(), SIGNAL(progressUpdated(int, int)), msgProcessorStatusWidget, SLOT(setProgress(int, int)));
// Core Lag:
- updateLagIndicator(
0
);
+ updateLagIndicator();
statusBar()->addPermanentWidget(coreLagLabel);
coreLagLabel->hide();
connect(Client::signalProxy(), SIGNAL(lagUpdated(int)), this, SLOT(updateLagIndicator(int)));
// SSL indicator
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();
sslLabel->setPixmap(QPixmap());
statusBar()->addPermanentWidget(sslLabel);
sslLabel->hide();
@@
-510,10
+509,8
@@
void MainWin::setupSystray() {
}
#ifndef Q_WS_MAC
}
#ifndef Q_WS_MAC
- connect(systemTrayIcon(), SIGNAL(activated( QSystemTrayIcon::ActivationReason )),
- this, SLOT(systrayActivated( QSystemTrayIcon::ActivationReason )));
+ connect(systemTrayIcon(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systrayActivated(QSystemTrayIcon::ActivationReason)));
#endif
#endif
-
}
void MainWin::changeEvent(QEvent *event) {
}
void MainWin::changeEvent(QEvent *event) {
@@
-521,8
+518,8
@@
void MainWin::changeEvent(QEvent *event) {
if(windowState() & Qt::WindowMinimized) {
QtUiSettings s;
if(s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnMinimize").toBool()) {
if(windowState() & Qt::WindowMinimized) {
QtUiSettings s;
if(s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnMinimize").toBool()) {
-
toggleVisibilit
y();
-
event->ignore
();
+
hideToTra
y();
+
event->accept
();
}
}
}
}
}
}
@@
-553,8
+550,11
@@
void MainWin::setConnectedState() {
if(!Client::internalCore())
statusBar()->showMessage(tr("Connected to core."));
if(!Client::internalCore())
statusBar()->showMessage(tr("Connected to core."));
- if(sslLabel->width() == 0)
+ if(Client::signalProxy()->isSecure()) {
+ sslLabel->setPixmap(SmallIcon("security-high"));
+ } else {
sslLabel->setPixmap(SmallIcon("security-low"));
sslLabel->setPixmap(SmallIcon("security-low"));
+ }
sslLabel->setVisible(!Client::internalCore());
coreLagLabel->setVisible(!Client::internalCore());
sslLabel->setVisible(!Client::internalCore());
coreLagLabel->setVisible(!Client::internalCore());
@@
-574,13
+574,12
@@
void MainWin::saveLayout() {
}
void MainWin::updateLagIndicator(int lag) {
}
void MainWin::updateLagIndicator(int lag) {
- coreLagLabel->setText(QString(tr("Core Lag: %1 msec")).arg(lag));
-}
-
-
-void MainWin::securedConnection() {
- // todo: make status bar entry
- sslLabel->setPixmap(SmallIcon("security-high"));
+ QString text = tr("Core Lag: %1");
+ if(lag == -1)
+ text = text.arg('-');
+ else
+ text = text.arg("%1 msec").arg(lag);
+ coreLagLabel->setText(text);
}
void MainWin::disconnectedFromCore() {
}
void MainWin::disconnectedFromCore() {
@@
-614,10
+613,18
@@
void MainWin::setDisconnectedState() {
statusBar()->showMessage(tr("Not connected to core."));
sslLabel->setPixmap(QPixmap());
sslLabel->hide();
statusBar()->showMessage(tr("Not connected to core."));
sslLabel->setPixmap(QPixmap());
sslLabel->hide();
+ updateLagIndicator();
coreLagLabel->hide();
updateIcon();
}
coreLagLabel->hide();
updateIcon();
}
+void MainWin::startInternalCore() {
+ ClientSyncer *syncer = new ClientSyncer();
+ Client::registerClientSyncer(syncer);
+ connect(syncer, SIGNAL(syncFinished()), syncer, SLOT(deleteLater()), Qt::QueuedConnection);
+ syncer->useInternalCore();
+}
+
void MainWin::showCoreConnectionDlg(bool autoConnect) {
CoreConnectDlg(autoConnect, this).exec();
}
void MainWin::showCoreConnectionDlg(bool autoConnect) {
CoreConnectDlg(autoConnect, this).exec();
}
@@
-674,8
+681,10
@@
void MainWin::showShortcutsDlg() {
void MainWin::closeEvent(QCloseEvent *event) {
QtUiSettings s;
void MainWin::closeEvent(QCloseEvent *event) {
QtUiSettings s;
- if(s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnClose").toBool()) {
- toggleVisibility();
+ QtUiApplication* app = qobject_cast<QtUiApplication*> qApp;
+ Q_ASSERT(app);
+ if(!app->aboutToQuit() && s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnClose").toBool()) {
+ hideToTray();
event->ignore();
} else {
event->accept();
event->ignore();
} else {
event->accept();
@@
-683,36
+692,32
@@
void MainWin::closeEvent(QCloseEvent *event) {
}
}
}
}
-void MainWin::systrayActivated(
QSystemTrayIcon::ActivationReason activationReason) {
+void MainWin::systrayActivated(QSystemTrayIcon::ActivationReason activationReason) {
if(activationReason == QSystemTrayIcon::Trigger) {
if(activationReason == QSystemTrayIcon::Trigger) {
- toggle
Visibilit
y();
+ toggle
MinimizedToTra
y();
}
}
}
}
-void MainWin::toggleVisibility() {
- if(isHidden() /*|| !isActiveWindow()*/) {
- show();
- if(isMinimized()) {
- if(isMaximized())
- showMaximized();
- else
- showNormal();
- }
+void MainWin::hideToTray() {
+ if(!systemTrayIcon()->isSystemTrayAvailable()) {
+ qWarning() << Q_FUNC_INFO << "was called with no SystemTray available!";
+ return;
+ }
- raise();
- activateWindow();
- // setFocus(); //Qt::ActiveWindowFocusReason
+ clearFocus();
+ hide();
+ systemTrayIcon()->show();
+}
+void MainWin::toggleMinimizedToTray() {
+ if(windowState() & Qt::WindowMinimized) {
+ // restore
+ setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
+ show();
+ raise();
} else {
} else {
- if(systemTrayIcon()->isSystemTrayAvailable ()) {
- clearFocus();
- hide();
- if(!systemTrayIcon()->isVisible()) {
- systemTrayIcon()->show();
- }
- } else {
- lower();
- }
+ setWindowState(windowState() & ~Qt::WindowActive | Qt::WindowMinimized);
+ hideToTray();
}
}
}
}