Browse Source

Merge pull request #14792 from Chocobo1/qnotify

Fix D-Bus Notification `desktop-entry` field
adaptive-webui-19844
Chocobo1 4 years ago committed by GitHub
parent
commit
31d84100cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/base/bittorrent/session.cpp
  2. 2
      src/base/bittorrent/torrentimpl.cpp
  3. 19
      src/gui/mainwindow.cpp
  4. 4
      src/gui/qtnotify/notifications.cpp
  5. 18
      src/gui/qtnotify/notifications.h
  6. 2
      src/gui/qtnotify/notifications.xml

7
src/base/bittorrent/session.cpp

@ -3766,14 +3766,13 @@ void Session::updateSeedingLimitTimer()
} }
} }
void Session::handleTorrentShareLimitChanged(TorrentImpl *const torrent) void Session::handleTorrentShareLimitChanged(TorrentImpl *const)
{ {
updateSeedingLimitTimer(); updateSeedingLimitTimer();
} }
void Session::handleTorrentNameChanged(TorrentImpl *const torrent) void Session::handleTorrentNameChanged(TorrentImpl *const)
{ {
Q_UNUSED(torrent);
} }
void Session::handleTorrentSavePathChanged(TorrentImpl *const torrent) void Session::handleTorrentSavePathChanged(TorrentImpl *const torrent)
@ -4653,11 +4652,11 @@ void Session::handleSessionStatsAlert(const lt::session_stats_alert *p)
m_status.diskWriteQueue = stats[m_metricIndices.peer.numPeersDownDisk]; m_status.diskWriteQueue = stats[m_metricIndices.peer.numPeersDownDisk];
m_status.peersCount = stats[m_metricIndices.peer.numPeersConnected]; m_status.peersCount = stats[m_metricIndices.peer.numPeersConnected];
const int64_t numBlocksRead = stats[m_metricIndices.disk.numBlocksRead];
m_cacheStatus.totalUsedBuffers = stats[m_metricIndices.disk.diskBlocksInUse]; m_cacheStatus.totalUsedBuffers = stats[m_metricIndices.disk.diskBlocksInUse];
m_cacheStatus.jobQueueLength = stats[m_metricIndices.disk.queuedDiskJobs]; m_cacheStatus.jobQueueLength = stats[m_metricIndices.disk.queuedDiskJobs];
#if (LIBTORRENT_VERSION_NUM < 20000) #if (LIBTORRENT_VERSION_NUM < 20000)
const int64_t numBlocksRead = stats[m_metricIndices.disk.numBlocksRead];
const int64_t numBlocksCacheHits = stats[m_metricIndices.disk.numBlocksCacheHits]; const int64_t numBlocksCacheHits = stats[m_metricIndices.disk.numBlocksCacheHits];
m_cacheStatus.readRatio = static_cast<qreal>(numBlocksCacheHits) / std::max<int64_t>((numBlocksCacheHits + numBlocksRead), 1); m_cacheStatus.readRatio = static_cast<qreal>(numBlocksCacheHits) / std::max<int64_t>((numBlocksCacheHits + numBlocksRead), 1);
#endif #endif

2
src/base/bittorrent/torrentimpl.cpp

@ -1887,7 +1887,7 @@ void TorrentImpl::handleFileCompletedAlert(const lt::file_completed_alert *p)
} }
#if (LIBTORRENT_VERSION_NUM >= 20003) #if (LIBTORRENT_VERSION_NUM >= 20003)
void TorrentImpl::handleFilePrioAlert(const lt::file_prio_alert *p) void TorrentImpl::handleFilePrioAlert(const lt::file_prio_alert *)
{ {
if (m_nativeHandle.need_save_resume_data()) if (m_nativeHandle.need_save_resume_data())
m_session->handleTorrentNeedSaveResumeData(this); m_session->handleTorrentNeedSaveResumeData(this);

19
src/gui/mainwindow.cpp

@ -1664,11 +1664,14 @@ void MainWindow::reloadTorrentStats(const QVector<BitTorrent::Torrent *> &torren
void MainWindow::showNotificationBaloon(const QString &title, const QString &msg) const void MainWindow::showNotificationBaloon(const QString &title, const QString &msg) const
{ {
if (!isNotificationsEnabled()) return; if (!isNotificationsEnabled())
return;
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB) #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
org::freedesktop::Notifications notifications("org.freedesktop.Notifications", OrgFreedesktopNotificationsInterface notifications(QLatin1String("org.freedesktop.Notifications")
"/org/freedesktop/Notifications", , QLatin1String("/org/freedesktop/Notifications")
QDBusConnection::sessionBus()); , QDBusConnection::sessionBus());
// Testing for 'notifications.isValid()' isn't helpful here. // Testing for 'notifications.isValid()' isn't helpful here.
// If the notification daemon is configured to run 'as needed' // If the notification daemon is configured to run 'as needed'
// the above check can be false if the daemon wasn't started // the above check can be false if the daemon wasn't started
@ -1678,10 +1681,10 @@ void MainWindow::showNotificationBaloon(const QString &title, const QString &msg
// some inactivity shuts it down. Other DEs, like GNOME, choose // some inactivity shuts it down. Other DEs, like GNOME, choose
// to start their daemons at the session startup and have it sit // to start their daemons at the session startup and have it sit
// idling for the whole session. // idling for the whole session.
QVariantMap hints; const QVariantMap hints {{QLatin1String("desktop-entry"), QLatin1String("org.qbittorrent.qBittorrent")}};
hints["desktop-entry"] = "qBittorrent"; QDBusPendingReply<uint> reply = notifications.Notify(QLatin1String("qBittorrent"), 0
QDBusPendingReply<uint> reply = notifications.Notify("qBittorrent", 0, "qbittorrent", title, , QLatin1String("qbittorrent"), title, msg, {}, hints, getNotificationTimeout());
msg, QStringList(), hints, getNotificationTimeout());
reply.waitForFinished(); reply.waitForFinished();
if (!reply.isError()) if (!reply.isError())
return; return;

4
src/gui/qtnotify/notifications.cpp

@ -1,8 +1,8 @@
/* /*
* This file was generated by qdbusxml2cpp version 0.7 * This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -p notifications.h:notifications.cpp notifications.xml * Command line was: qdbusxml2cpp -p notifications.h:notifications.cpp notifications.xml
* *
* qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). * qdbusxml2cpp is Copyright (C) 2020 The Qt Company Ltd.
* *
* This is an auto-generated file. * This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments * This file may have been hand-edited. Look for HAND-EDIT comments

18
src/gui/qtnotify/notifications.h

@ -1,15 +1,15 @@
/* /*
* This file was generated by qdbusxml2cpp version 0.7 * This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -p notifications.h:notifications.cpp notifications.xml * Command line was: qdbusxml2cpp -p notifications.h:notifications.cpp notifications.xml
* *
* qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). * qdbusxml2cpp is Copyright (C) 2020 The Qt Company Ltd.
* *
* This is an auto-generated file. * This is an auto-generated file.
* Do not edit! All changes made to it will be lost. * Do not edit! All changes made to it will be lost.
*/ */
#ifndef NOTIFICATIONS_H_1301681398 #ifndef NOTIFICATIONS_H
#define NOTIFICATIONS_H_1301681398 #define NOTIFICATIONS_H
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QByteArray> #include <QtCore/QByteArray>
@ -40,24 +40,24 @@ public Q_SLOTS: // METHODS
{ {
QList<QVariant> argumentList; QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id); argumentList << QVariant::fromValue(id);
return asyncCallWithArgumentList(QLatin1String("CloseNotification"), argumentList); return asyncCallWithArgumentList(QStringLiteral("CloseNotification"), argumentList);
} }
inline QDBusPendingReply<QStringList> GetCapabilities() inline QDBusPendingReply<QStringList> GetCapabilities()
{ {
QList<QVariant> argumentList; QList<QVariant> argumentList;
return asyncCallWithArgumentList(QLatin1String("GetCapabilities"), argumentList); return asyncCallWithArgumentList(QStringLiteral("GetCapabilities"), argumentList);
} }
inline QDBusPendingReply<QString, QString, QString, QString> GetServerInformation() inline QDBusPendingReply<QString, QString, QString, QString> GetServerInformation()
{ {
QList<QVariant> argumentList; QList<QVariant> argumentList;
return asyncCallWithArgumentList(QLatin1String("GetServerInformation"), argumentList); return asyncCallWithArgumentList(QStringLiteral("GetServerInformation"), argumentList);
} }
inline QDBusReply<QString> GetServerInformation(QString &return_vendor, QString &return_version, QString &return_spec_version) inline QDBusReply<QString> GetServerInformation(QString &return_vendor, QString &return_version, QString &return_spec_version)
{ {
QList<QVariant> argumentList; QList<QVariant> argumentList;
QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("GetServerInformation"), argumentList); QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetServerInformation"), argumentList);
if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 4) { if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 4) {
return_vendor = qdbus_cast<QString>(reply.arguments().at(1)); return_vendor = qdbus_cast<QString>(reply.arguments().at(1));
return_version = qdbus_cast<QString>(reply.arguments().at(2)); return_version = qdbus_cast<QString>(reply.arguments().at(2));
@ -70,7 +70,7 @@ public Q_SLOTS: // METHODS
{ {
QList<QVariant> argumentList; QList<QVariant> argumentList;
argumentList << QVariant::fromValue(app_name) << QVariant::fromValue(id) << QVariant::fromValue(icon) << QVariant::fromValue(summary) << QVariant::fromValue(body) << QVariant::fromValue(actions) << QVariant::fromValue(hints) << QVariant::fromValue(timeout); argumentList << QVariant::fromValue(app_name) << QVariant::fromValue(id) << QVariant::fromValue(icon) << QVariant::fromValue(summary) << QVariant::fromValue(body) << QVariant::fromValue(actions) << QVariant::fromValue(hints) << QVariant::fromValue(timeout);
return asyncCallWithArgumentList(QLatin1String("Notify"), argumentList); return asyncCallWithArgumentList(QStringLiteral("Notify"), argumentList);
} }
Q_SIGNALS: // SIGNALS Q_SIGNALS: // SIGNALS

2
src/gui/qtnotify/notifications.xml

@ -22,7 +22,7 @@
<arg name="body" type="s" direction="in"/> <arg name="body" type="s" direction="in"/>
<arg name="actions" type="as" direction="in"/> <arg name="actions" type="as" direction="in"/>
<arg name="hints" type="a{sv}" direction="in"/> <arg name="hints" type="a{sv}" direction="in"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.In6" value="QVariantMap"/> <annotation name="org.qtproject.QtDBus.QtTypeName.In6" value="QVariantMap"/>
<arg name="timeout" type="i" direction="in"/> <arg name="timeout" type="i" direction="in"/>
<arg name="return_id" type="u" direction="out"/> <arg name="return_id" type="u" direction="out"/>
</method> </method>

Loading…
Cancel
Save