133 lines
5 KiB
Diff
133 lines
5 KiB
Diff
From 0168ee68b484995ed9398d31004dd80678ac7e37 Mon Sep 17 00:00:00 2001
|
|
From: Kai Uwe Broulik <kde@privat.broulik.de>
|
|
Date: Tue, 5 Aug 2025 12:57:00 +0200
|
|
Subject: [PATCH] Close USB device added notification when devicenotifier pops
|
|
up
|
|
|
|
The device notification is supposed to be super quick feedback that
|
|
"something" got detected. Once it has been identified as storage
|
|
device (disks spun up and what not), devicenotifier will show up
|
|
and then you have two popups.
|
|
---
|
|
applets/devicenotifier/CMakeLists.txt | 1 +
|
|
applets/devicenotifier/devicefiltercontrol.cpp | 14 ++++++++++++++
|
|
applets/devicenotifier/devicefiltercontrol.h | 1 +
|
|
applets/devicenotifier/qml/main.qml | 1 +
|
|
devicenotifications/devicenotifications.cpp | 8 ++++++++
|
|
devicenotifications/devicenotifications.h | 3 +++
|
|
6 files changed, 28 insertions(+)
|
|
|
|
diff --git a/applets/devicenotifier/CMakeLists.txt b/applets/devicenotifier/CMakeLists.txt
|
|
index d87964dc46d..fa415837e68 100644
|
|
--- a/applets/devicenotifier/CMakeLists.txt
|
|
+++ b/applets/devicenotifier/CMakeLists.txt
|
|
@@ -31,6 +31,7 @@ plasma_add_applet(org.kde.plasma.devicenotifier
|
|
|
|
target_link_libraries(org.kde.plasma.devicenotifier
|
|
PRIVATE
|
|
+ Qt::DBus
|
|
Qt::Qml
|
|
Plasma::Plasma
|
|
KF6::Solid
|
|
diff --git a/applets/devicenotifier/devicefiltercontrol.cpp b/applets/devicenotifier/devicefiltercontrol.cpp
|
|
index dfdb51a4304..f585eb2f063 100644
|
|
--- a/applets/devicenotifier/devicefiltercontrol.cpp
|
|
+++ b/applets/devicenotifier/devicefiltercontrol.cpp
|
|
@@ -11,9 +11,14 @@
|
|
#include "devicecontrol.h"
|
|
#include "devicestatemonitor_p.h"
|
|
|
|
+#include <QDBusConnection>
|
|
+#include <QDBusMessage>
|
|
+
|
|
#include <Solid/Device>
|
|
#include <Solid/OpticalDrive>
|
|
|
|
+using namespace Qt::Literals::StringLiterals;
|
|
+
|
|
DeviceFilterControl::DeviceFilterControl(QObject *parent)
|
|
: QSortFilterProxyModel(parent)
|
|
, m_filterType(Removable)
|
|
@@ -54,6 +59,15 @@ void DeviceFilterControl::unmountAllRemovables()
|
|
qCDebug(APPLETS::DEVICENOTIFIER) << "Device Filter Control: unmount all removables function finished";
|
|
}
|
|
|
|
+void DeviceFilterControl::dismissUsbDeviceAddedNotification()
|
|
+{
|
|
+ QDBusMessage msg = QDBusMessage::createMethodCall(u"org.kde.kded6"_s,
|
|
+ u"/modules/devicenotifications"_s,
|
|
+ u"org.kde.plasma.devicenotifications"_s,
|
|
+ u"dismissUsbDeviceAdded"_s);
|
|
+ QDBusConnection::sessionBus().call(msg, QDBus::NoBlock);
|
|
+}
|
|
+
|
|
QBindable<QString> DeviceFilterControl::bindableLastUdi()
|
|
{
|
|
return &m_lastUdi;
|
|
diff --git a/applets/devicenotifier/devicefiltercontrol.h b/applets/devicenotifier/devicefiltercontrol.h
|
|
index e4c0a321657..fa6266fb197 100644
|
|
--- a/applets/devicenotifier/devicefiltercontrol.h
|
|
+++ b/applets/devicenotifier/devicefiltercontrol.h
|
|
@@ -41,6 +41,7 @@ public:
|
|
Q_ENUM(DevicesType)
|
|
|
|
Q_INVOKABLE void unmountAllRemovables();
|
|
+ Q_INVOKABLE void dismissUsbDeviceAddedNotification();
|
|
|
|
explicit DeviceFilterControl(QObject *parent = nullptr);
|
|
~DeviceFilterControl() override;
|
|
diff --git a/applets/devicenotifier/qml/main.qml b/applets/devicenotifier/qml/main.qml
|
|
index 7fcd76a6d16..c7fe6e6197d 100644
|
|
--- a/applets/devicenotifier/qml/main.qml
|
|
+++ b/applets/devicenotifier/qml/main.qml
|
|
@@ -35,6 +35,7 @@ PlasmoidItem {
|
|
onLastUdiChanged: {
|
|
if (lastDeviceAdded) {
|
|
if (Plasmoid.configuration.popupOnNewDevice) {
|
|
+ filterModel.dismissUsbDeviceAddedNotification();
|
|
devicenotifier.expanded = true;
|
|
fullRepresentationItem.spontaneousOpen = true;
|
|
}
|
|
diff --git a/devicenotifications/devicenotifications.cpp b/devicenotifications/devicenotifications.cpp
|
|
index 71ae0ff340e..196e28ca948 100644
|
|
--- a/devicenotifications/devicenotifications.cpp
|
|
+++ b/devicenotifications/devicenotifications.cpp
|
|
@@ -323,6 +323,14 @@ void KdedDeviceNotifications::setupWaylandOutputListener()
|
|
wl_callback_add_listener(syncCallback, &syncCallbackListener, this);
|
|
}
|
|
|
|
+void KdedDeviceNotifications::dismissUsbDeviceAdded()
|
|
+{
|
|
+ if (m_usbDeviceAddedNotification) {
|
|
+ m_usbDeviceAddedNotification->close();
|
|
+ m_usbDeviceAddedNotification = nullptr;
|
|
+ }
|
|
+}
|
|
+
|
|
void KdedDeviceNotifications::notifyOutputAdded()
|
|
{
|
|
if (m_deviceAddedTimer.isActive()) {
|
|
diff --git a/devicenotifications/devicenotifications.h b/devicenotifications/devicenotifications.h
|
|
index ab7e6b3ff9b..75005193287 100644
|
|
--- a/devicenotifications/devicenotifications.h
|
|
+++ b/devicenotifications/devicenotifications.h
|
|
@@ -77,6 +77,7 @@ private:
|
|
class KdedDeviceNotifications : public KDEDModule
|
|
{
|
|
Q_OBJECT
|
|
+ Q_CLASSINFO("D-Bus Interface", "org.kde.plasma.devicenotifications")
|
|
|
|
public:
|
|
KdedDeviceNotifications(QObject *parent, const QVariantList &args);
|
|
@@ -84,6 +85,8 @@ public:
|
|
|
|
void setupWaylandOutputListener();
|
|
|
|
+ Q_SCRIPTABLE void dismissUsbDeviceAdded();
|
|
+
|
|
private:
|
|
void notifyOutputAdded();
|
|
void notifyOutputRemoved();
|
|
--
|
|
GitLab
|
|
|