More polishing of D-Bus notifications.

This commit is contained in:
Martin Rotter 2015-07-29 06:38:17 +02:00
parent 77c6fdeac3
commit d0ab2b4374
3 changed files with 11 additions and 5 deletions

View File

@ -19,6 +19,7 @@
Added:
<ul>
<li><b>Key used for proxy/feed password coding is now stored in separate file. This file lies in the same directory as configuration file. If your use password-protected proxy/feeds, then make sure that NOBODY gets access to that file and your DB file in the same time.</b></li>
<li>Notifications on Linux now supports D-Bus "org.freedesktop.Notifications" service. User must have enabled "modern & fancy notifications" for this to work. If D-Bus service is not available, then feature falls back to RSS Guard custom popup notifications.</li>
</ul>
Fixed:
<ul>

View File

@ -88,7 +88,7 @@
<item row="0" column="1">
<widget class="QStackedWidget" name="m_stackedSettings">
<property name="currentIndex">
<number>1</number>
<number>3</number>
</property>
<widget class="QWidget" name="m_pageGeneral">
<layout class="QFormLayout" name="formLayout_5">
@ -638,7 +638,7 @@ Authors of this application are NOT responsible for lost data.</string>
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="m_grpNotifications">
<property name="title">
<string>Fancy &amp;&amp; modern popup notifications</string>
<string>Fancy &amp;&amp; modern popup notifications (This uses OS native notifications via D-Bus if available.)</string>
</property>
<property name="checkable">
<bool>true</bool>
@ -1289,7 +1289,7 @@ Authors of this application are NOT responsible for lost data.</string>
<item>
<widget class="QTabWidget" name="m_tabFeedsMessages">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="m_tabFeeds">
<attribute name="title">

View File

@ -82,6 +82,8 @@ void Notification::notify(const QString &text, const QString &title, const QIcon
m_icon = icon.pixmap(NOTIFICATION_ICON_SIZE, NOTIFICATION_ICON_SIZE);
#if defined(Q_OS_LINUX)
// On Linux, we try to send notification to session notification D-Bus service
// if it exists.
if (m_dBusInterface->isValid()) {
QVariantMap hints;
hints["image-path"] = ""; // "application-exit";
@ -104,8 +106,10 @@ void Notification::notify(const QString &text, const QString &title, const QIcon
// Message was sent, notification should display.
m_dBusActiveNotification = response.arguments().at(0).toUInt();
}
return;
}
#else
if (m_clickTarget != NULL && m_clickSlot != NULL) {
// Connect invokation target.
connect(this, SIGNAL(clicked()), m_clickTarget, m_clickSlot, Qt::QueuedConnection);
@ -118,7 +122,6 @@ void Notification::notify(const QString &text, const QString &title, const QIcon
QTimer::singleShot(0, this, SLOT(repaint()));
m_timerId = startTimer(10000);
#endif
}
void Notification::notify(const QString &text, const QString &title, QSystemTrayIcon::MessageIcon icon,
@ -142,11 +145,13 @@ void Notification::cancel() {
}
}
#if defined(Q_OS_LINUX)
void Notification::notificationClosed(uint id, uint reason) {
if (m_clickTarget != NULL && m_clickSlot != NULL && m_dBusActiveNotification == id && reason == 2) {
QMetaObject::invokeMethod(m_clickTarget, m_clickSlot);
}
}
#endif
void Notification::updateGeometries() {
// Calculate width and height of notification with given icon and text.