X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fqtui.cpp;h=d19692cad79dcc93c44679718f1e9215a6a51814;hp=d1c23ca00ead2e740ecbb16457868b169649655c;hb=1f32c327ade7db3a1760b49508fb34aa10e98044;hpb=e1f500a5f5b510d16e9eaf76a24a9aea98fac86c diff --git a/src/qtui/qtui.cpp b/src/qtui/qtui.cpp index d1c23ca0..d19692ca 100644 --- a/src/qtui/qtui.cpp +++ b/src/qtui/qtui.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,30 +20,43 @@ #include "qtui.h" +#include "abstractnotificationbackend.h" #include "actioncollection.h" +#include "buffermodel.h" #include "chatlinemodel.h" +#include "contextmenuactionprovider.h" #include "mainwin.h" -#include "abstractnotificationbackend.h" #include "qtuimessageprocessor.h" #include "qtuisettings.h" #include "qtuistyle.h" +#include "toolbaractionprovider.h" #include "types.h" #include "util.h" QHash QtUi::_actionCollections; -MainWin *QtUi::_mainWin = 0; + +#ifdef Q_WS_X11 +# include +#endif + +QPointer QtUi::_instance = 0; +QPointer QtUi::_mainWin = 0; QList QtUi::_notificationBackends; QList QtUi::_notifications; QtUiStyle *QtUi::_style = 0; -QtUi::QtUi() : AbstractUi() { - if(_style != 0) { +QtUi::QtUi() : GraphicalUi() { + if(_instance != 0) { qWarning() << "QtUi has been instantiated again!"; return; } + _instance = this; + + setContextMenuActionProvider(new ContextMenuActionProvider(this)); + setToolBarActionProvider(new ToolBarActionProvider(this)); QtUiSettings uiSettings; - loadTranslation(uiSettings.value("Locale", QLocale::system()).value()); + Quassel::loadTranslation(uiSettings.value("Locale", QLocale::system()).value()); _mainWin = new MainWin(); _style = new QtUiStyle; @@ -90,6 +103,7 @@ void QtUi::disconnectedFromCore() { void QtUi::registerNotificationBackend(AbstractNotificationBackend *backend) { if(!_notificationBackends.contains(backend)) { _notificationBackends.append(backend); + instance()->connect(backend, SIGNAL(activated(uint)), SLOT(notificationActivated(uint))); } } @@ -121,10 +135,9 @@ void QtUi::closeNotification(uint notificationId) { if((*i).notificationId == notificationId) { foreach(AbstractNotificationBackend *backend, _notificationBackends) backend->close(notificationId); - _notifications.erase(i); + i = _notifications.erase(i); break; - } - ++i; + } else ++i; } } @@ -134,9 +147,8 @@ void QtUi::closeNotifications(BufferId bufferId) { if(!bufferId.isValid() || (*i).bufferId == bufferId) { foreach(AbstractNotificationBackend *backend, _notificationBackends) backend->close((*i).notificationId); - _notifications.erase(i); - } - ++i; + i = _notifications.erase(i); + } else ++i; } } @@ -144,3 +156,30 @@ const QList &QtUi::activeNotification return _notifications; } +void QtUi::notificationActivated(uint notificationId) { + if(notificationId != 0) { + QList::iterator i = _notifications.begin(); + while(i != _notifications.end()) { + if((*i).notificationId == notificationId) { + BufferId bufId = (*i).bufferId; + if(bufId.isValid()) + Client::bufferModel()->switchToBuffer(bufId); + _notifications.erase(i); + break; + } else ++i; + } + } + +#ifdef Q_WS_X11 + // Bypass focus stealing prevention + QX11Info::setAppUserTime(QX11Info::appTime()); +#endif + + if(_mainWin->windowState() & Qt::WindowMinimized) { + // restore + _mainWin->setWindowState((_mainWin->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); + _mainWin->show(); + } + _mainWin->raise(); + _mainWin->activateWindow(); +}