Skip to content

Commit

Permalink
Revert "fix: Stuck in dbus data acquisition"
Browse files Browse the repository at this point in the history
This reverts commit 70a2ea3.
  • Loading branch information
FeiWang1119 committed Sep 6, 2024
1 parent 5178e54 commit 936aeab
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions panels/dock/clipboarditem/clipboarditem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#include <QGuiApplication>
#include <QBuffer>
#include <QDBusServiceWatcher>
#include <QDBusConnectionInterface>

DGUI_USE_NAMESPACE

Expand All @@ -31,34 +29,17 @@ static DDBusSender clipboardDbus()
.interface(clipboardInterface);
}

static QDBusServiceWatcher dbusWatcher(clipboardService, QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForOwnerChange);

ClipboardItem::ClipboardItem(QObject *parent)
: DApplet(parent)
, m_visible(true)
, m_clipboardVisible(false)
{
QDBusConnection::sessionBus().connect(clipboardService, clipboardPath, clipboardInterface,
"clipboardVisibleChanged", this, SLOT(onClipboardVisibleChanged(bool)));

auto func = [this](){
QDBusInterface clipboardInter(clipboardService, clipboardPath, clipboardInterface, QDBusConnection::sessionBus());
if (clipboardInter.isValid()) {
m_clipboardVisible = clipboardInter.property("clipboardVisible").toBool();
}
};
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(clipboardService)) {
func();
QDBusInterface clipboardInter(clipboardService, clipboardPath, clipboardInterface, QDBusConnection::sessionBus());
if (clipboardInter.isValid()) {
m_clipboardVisible = clipboardInter.property("clipboardVisible").toBool();
}

connect(&dbusWatcher, &QDBusServiceWatcher::serviceRegistered, this, [this, func](){
func();
});

connect(&dbusWatcher, &QDBusServiceWatcher::serviceUnregistered, this, [this](){
m_clipboardVisible = false;
});
}

void ClipboardItem::toggleClipboard()
Expand Down

0 comments on commit 936aeab

Please sign in to comment.