X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fdockmanagernotificationbackend.cpp;h=9e54ee31ccbde7cdf288e260489374a61c7e8878;hp=08a9baef02a34a88c8301fad37a57e34b75bf94c;hb=c1cf157116de7fc3da96203aa6f03c38c7ebb650;hpb=30b159cb876a9495de42e9a3e70ca050516f0805 diff --git a/src/qtui/dockmanagernotificationbackend.cpp b/src/qtui/dockmanagernotificationbackend.cpp index 08a9baef..9e54ee31 100644 --- a/src/qtui/dockmanagernotificationbackend.cpp +++ b/src/qtui/dockmanagernotificationbackend.cpp @@ -20,18 +20,19 @@ #include "dockmanagernotificationbackend.h" -#include #include #include +#include #include "client.h" +#include "clientbacklogmanager.h" #include "clientsettings.h" #include "coreconnection.h" -#include "clientbacklogmanager.h" #include "util.h" -DockManagerNotificationBackend::DockManagerNotificationBackend(QObject *parent) - : AbstractNotificationBackend(parent), _bus(QDBusConnection::sessionBus()) +DockManagerNotificationBackend::DockManagerNotificationBackend(QObject* parent) + : AbstractNotificationBackend(parent) + , _bus(QDBusConnection::sessionBus()) { NotificationSettings notificationSettings; _enabled = notificationSettings.value("DockManager/Enabled", false).toBool(); @@ -40,13 +41,25 @@ DockManagerNotificationBackend::DockManagerNotificationBackend(QObject *parent) _dock = new QDBusInterface("net.launchpad.DockManager", "/net/launchpad/DockManager", "net.launchpad.DockManager", _bus, this); if (_dock->isValid()) { - _bus.connect("net.launchpad.DockManager", "/net/launchpad/DockManager", "net.launchpad.DockManager", "ItemAdded", this, SLOT(itemAdded(QDBusObjectPath))); - } else { + _bus.connect("net.launchpad.DockManager", + "/net/launchpad/DockManager", + "net.launchpad.DockManager", + "ItemAdded", + this, + SLOT(itemAdded(QDBusObjectPath))); + } + else { // evil implementations (awn) use fd.o _dock = new QDBusInterface("org.freedesktop.DockManager", "/org/freedesktop/DockManager", "org.freedesktop.DockManager", _bus, this); if (_dock->isValid()) { - _bus.connect("org.freedesktop.DockManager", "/org/freedesktop/DockManager", "org.freedesktop.DockManager", "ItemAdded", this, SLOT(itemAdded(QDBusObjectPath))); - } else { + _bus.connect("org.freedesktop.DockManager", + "/org/freedesktop/DockManager", + "org.freedesktop.DockManager", + "ItemAdded", + this, + SLOT(itemAdded(QDBusObjectPath))); + } + else { _available = _enabled = false; return; } @@ -55,11 +68,13 @@ DockManagerNotificationBackend::DockManagerNotificationBackend(QObject *parent) itemAdded(QDBusObjectPath()); - connect(Client::coreConnection(), &CoreConnection::progressValueChanged, this, selectOverload(&DockManagerNotificationBackend::updateProgress)); + connect(Client::coreConnection(), + &CoreConnection::progressValueChanged, + this, + selectOverload(&DockManagerNotificationBackend::updateProgress)); connect(Client::coreConnection(), &CoreConnection::synchronized, this, &DockManagerNotificationBackend::synchronized); } - void DockManagerNotificationBackend::itemAdded(QDBusObjectPath p) { Q_UNUSED(p); @@ -68,7 +83,7 @@ void DockManagerNotificationBackend::itemAdded(QDBusObjectPath p) return; // stupid implementations (awn; kde?) use wrong casing of PID, but proper type - QDBusReply > paths = _dock->call("GetItemsByPid", (int)QCoreApplication::applicationPid()); + QDBusReply> paths = _dock->call("GetItemsByPid", (int)QCoreApplication::applicationPid()); if (!paths.isValid()) { // stupid implementations (i.e. docky) use uint, but proper casing paths = _dock->call("GetItemsByPID", (unsigned int)QCoreApplication::applicationPid()); @@ -77,21 +92,20 @@ void DockManagerNotificationBackend::itemAdded(QDBusObjectPath p) return; } } - if (paths.value().count() == 0) { // no icon for this instance + if (paths.value().count() == 0) { // no icon for this instance return; } - QString path = paths.value()[0].path(); // no sense in using multiple icons for one instance + QString path = paths.value()[0].path(); // no sense in using multiple icons for one instance _item = new QDBusInterface("org.freedesktop.DockManager", path, "org.freedesktop.DockItem", _bus, this); } - void DockManagerNotificationBackend::updateProgress(int progress) { if (!_enabled || !_item) return; - CoreConnection *c = Client::instance()->coreConnection(); + CoreConnection* c = Client::instance()->coreConnection(); int perc = 0; if (c->progressMaximum() == c->progressMinimum()) perc = 0; @@ -103,7 +117,6 @@ void DockManagerNotificationBackend::updateProgress(int progress) _item->call("UpdateDockItem", args); } - void DockManagerNotificationBackend::updateProgress(int done, int total) { if (!_enabled || !_item) @@ -113,7 +126,8 @@ void DockManagerNotificationBackend::updateProgress(int done, int total) if (done == total) { disconnect(Client::backlogManager(), nullptr, this, nullptr); perc = -1; - } else + } + else perc = (done * 100) / total; QHash args; @@ -121,14 +135,15 @@ void DockManagerNotificationBackend::updateProgress(int done, int total) _item->call("UpdateDockItem", args); } - void DockManagerNotificationBackend::synchronized() { - connect(Client::backlogManager(), &ClientBacklogManager::updateProgress, this, selectOverload(&DockManagerNotificationBackend::updateProgress)); + connect(Client::backlogManager(), + &ClientBacklogManager::updateProgress, + this, + selectOverload(&DockManagerNotificationBackend::updateProgress)); } - -void DockManagerNotificationBackend::notify(const Notification ¬ification) +void DockManagerNotificationBackend::notify(const Notification& notification) { if (!_enabled || !_item) { return; @@ -143,7 +158,6 @@ void DockManagerNotificationBackend::notify(const Notification ¬ification) _item->call("UpdateDockItem", args); } - void DockManagerNotificationBackend::close(uint notificationId) { Q_UNUSED(notificationId); @@ -156,8 +170,7 @@ void DockManagerNotificationBackend::close(uint notificationId) _item->call("UpdateDockItem", args); } - -void DockManagerNotificationBackend::enabledChanged(const QVariant &v) +void DockManagerNotificationBackend::enabledChanged(const QVariant& v) { _enabled = v.toBool(); @@ -169,47 +182,42 @@ void DockManagerNotificationBackend::enabledChanged(const QVariant &v) } } - -SettingsPage *DockManagerNotificationBackend::createConfigWidget() const +SettingsPage* DockManagerNotificationBackend::createConfigWidget() const { return new ConfigWidget(_available); } - /***************************************************************************/ -DockManagerNotificationBackend::ConfigWidget::ConfigWidget(bool enabled, QWidget *parent) +DockManagerNotificationBackend::ConfigWidget::ConfigWidget(bool enabled, QWidget* parent) : SettingsPage("Internal", "DockManagerNotification", parent) { - auto *layout = new QHBoxLayout(this); + auto* layout = new QHBoxLayout(this); layout->addWidget(enabledBox = new QCheckBox(tr("Mark dockmanager entry"), this)); enabledBox->setVisible(enabled); connect(enabledBox, &QAbstractButton::toggled, this, &ConfigWidget::widgetChanged); } - void DockManagerNotificationBackend::ConfigWidget::widgetChanged() { bool changed = enabled != enabledBox->isChecked(); - if (changed != hasChanged()) setChangedState(changed); + if (changed != hasChanged()) + setChangedState(changed); } - bool DockManagerNotificationBackend::ConfigWidget::hasDefaults() const { return true; } - void DockManagerNotificationBackend::ConfigWidget::defaults() { enabledBox->setChecked(false); widgetChanged(); } - void DockManagerNotificationBackend::ConfigWidget::load() { NotificationSettings s; @@ -219,7 +227,6 @@ void DockManagerNotificationBackend::ConfigWidget::load() setChangedState(false); } - void DockManagerNotificationBackend::ConfigWidget::save() { NotificationSettings s;