X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Findicatornotificationbackend.cpp;h=281fe98b3f068c0d2f17b9c7ae97766dbbe1b72c;hp=f4bc3ae7010242e0e6f2e1dbc143f10139a91b7d;hb=62c360e674f17146c6c52e874e854e24bab643b3;hpb=3304dd3e19807ba4358c9d65fbf61b980d317b68 diff --git a/src/qtui/indicatornotificationbackend.cpp b/src/qtui/indicatornotificationbackend.cpp index f4bc3ae7..281fe98b 100644 --- a/src/qtui/indicatornotificationbackend.cpp +++ b/src/qtui/indicatornotificationbackend.cpp @@ -21,15 +21,19 @@ #include "indicatornotificationbackend.h" #include -#include +#include #include "client.h" #include "clientsettings.h" +#include "iconloader.h" #include "mainwin.h" #include "networkmodel.h" #include "qtui.h" -class Indicator : public QIndicate::IndicatorMessage { +#define STR(x) #x +#define XSTR(x) STR(x) + +class Indicator : public QIndicate::Indicator { public: uint lastNotificationId; }; @@ -38,14 +42,17 @@ IndicatorNotificationBackend::IndicatorNotificationBackend(QObject *parent) : AbstractNotificationBackend(parent) { NotificationSettings notificationSettings; - _enabled = notificationSettings.value("Indicator/Enabled", true).toBool(); + _enabled = notificationSettings.value("Indicator/Enabled", false).toBool(); notificationSettings.notify("Indicator/Enabled", this, SLOT(enabledChanged(const QVariant &))); _server = QIndicate::Server::defaultInstance(); - _server->setType("message.im"); - _server->setDesktopFile(DESKTOP_FILE); - connect(_server, SIGNAL(serverDisplay()), QtUi::mainWindow(), SLOT(forceActivated())); + _server->setType("message.irc"); + QString desktopFile = QString("%1/%2.desktop") + .arg(XSTR(XDG_APPS_INSTALL_DIR)) + .arg(QCoreApplication::applicationFilePath().section('/', -1)); + _server->setDesktopFile(desktopFile); + connect(_server, SIGNAL(serverDisplay()), SLOT(activateMainWidget())); if (_enabled) { _server->show(); @@ -56,6 +63,10 @@ IndicatorNotificationBackend::~IndicatorNotificationBackend() { qDeleteAll(_indicatorHash); } +void IndicatorNotificationBackend::activateMainWidget() { + GraphicalUi::activateMainWidget(); +} + void IndicatorNotificationBackend::notify(const Notification ¬ification) { if(!_enabled) { return; @@ -68,29 +79,32 @@ void IndicatorNotificationBackend::notify(const Notification ¬ification) { if(!indicator) { indicator = new Indicator; _indicatorHash.insert(bufferId, indicator); + connect(indicator, SIGNAL(display(QIndicate::Indicator*)), + SLOT(indicatorDisplayed(QIndicate::Indicator*))); } indicator->lastNotificationId = notification.notificationId; BufferInfo::Type type = Client::networkModel()->bufferType(bufferId); - QString sender; + QString name; if (type == BufferInfo::QueryBuffer) { - sender = notification.sender; + name = notification.sender; } else { - sender = QString("%1 (%2)") + name = QString("%1 (%2)") .arg(Client::networkModel()->bufferName(bufferId)) .arg(notification.sender); } - indicator->setProperty("sender", sender); + indicator->setNameProperty(name); - indicator->setProperty("time", QTime::currentTime()); + indicator->setTimeProperty(QDateTime::currentDateTime()); QModelIndex index = Client::networkModel()->bufferIndex(bufferId); QVariant icon = QtUi::style()->bufferViewItemData(index, Qt::DecorationRole); if (icon.canConvert()) { QImage image = icon.value().toImage(); - indicator->setProperty("icon", image); + indicator->setIconProperty(image); } + indicator->setDrawAttentionProperty(true); indicator->show(); } @@ -126,6 +140,11 @@ void IndicatorNotificationBackend::enabledChanged(const QVariant &v) { } } +void IndicatorNotificationBackend::indicatorDisplayed(QIndicate::Indicator *_indicator) { + Indicator *indicator = static_cast(_indicator); + emit activated(indicator->lastNotificationId); +} + SettingsPage *IndicatorNotificationBackend::createConfigWidget() const { return new ConfigWidget(); } @@ -136,6 +155,8 @@ IndicatorNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "IndicatorNotification", parent) { ui.setupUi(this); + // FIXME find proper icon (this one is used by the plasmoid as well) + ui.enabled->setIcon(SmallIcon("mail-message-new")); connect(ui.enabled, SIGNAL(toggled(bool)), SLOT(widgetChanged())); }