Skip to content

Commit

Permalink
chore: [dbus]Adapt DBus interface (#545)
Browse files Browse the repository at this point in the history
Change the DBus interface names for V25.

Log: Adapt DBus interface.
  • Loading branch information
re2zero authored Dec 13, 2024
1 parent f39783e commit 0f384d4
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 114 deletions.
25 changes: 10 additions & 15 deletions src/common/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <DInputDialog>
#include <DImageButton>
#include <DWidgetUtil>
#include <DWindowManagerHelper>
#ifdef DTKCORE_CLASS_DConfigFile
#include <DConfig>
#endif
Expand Down Expand Up @@ -1053,11 +1054,9 @@ MainWindow::MainWindow(QWidget *parent)

#endif

m_pWMDBus = new QDBusInterface("com.deepin.WMSwitcher", "/com/deepin/WMSwitcher", "com.deepin.WMSwitcher", QDBusConnection::sessionBus());
QDBusReply<QString> reply_string = m_pWMDBus->call("CurrentWM");
m_bIsWM = reply_string.value().contains("deepin wm");
m_bIsWM = DWindowManagerHelper::instance()->hasBlurWindow();
m_pCommHintWid->setWM(m_bIsWM);
connect(m_pWMDBus, SIGNAL(WMChanged(QString)), this, SLOT(slotWMChanged(QString)));
connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasBlurWindowChanged, this, &MainWindow::slotWMChanged);
m_pAnimationlable = new AnimationLabel(this, this);
m_pAnimationlable->setWM(m_bIsWM);

Expand Down Expand Up @@ -1089,8 +1088,8 @@ MainWindow::MainWindow(QWidget *parent)
m_pDBus = new QDBusInterface("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::systemBus());
connect(m_pDBus, SIGNAL(PrepareForSleep(bool)), this, SLOT(sleepStateChanged(bool)));

QDBusConnection::sessionBus().connect("com.deepin.dde.shutdownFront", "/com/deepin/dde/lockFront",
"com.deepin.dde.lockFront", "Visible", this,
QDBusConnection::sessionBus().connect("org.deepin.dde.ShutdownFront1", "/org/deepin/dde/lockFront1",
"org.deepin.dde.lockFront1", "Visible", this,
SLOT(lockStateChanged(bool)));

m_pMovieWidget = new MovieWidget(this);
Expand Down Expand Up @@ -3527,13 +3526,9 @@ void MainWindow::slotVolumeChanged(int nVolume)
}
}

void MainWindow::slotWMChanged(QString msg)
void MainWindow::slotWMChanged()
{
if (msg.contains("deepin metacity")) {
m_bIsWM = false;
} else {
m_bIsWM = true;
}
m_bIsWM = DWindowManagerHelper::instance()->hasBlurWindow();

m_pAnimationlable->setWM(m_bIsWM);
m_pCommHintWid->setWM(m_bIsWM);
Expand Down Expand Up @@ -3568,12 +3563,12 @@ void MainWindow::exitMircast()
QString MainWindow::cpuHardwareByDBus()
{
QString validFrequency = "CurrentSpeed";
QDBusInterface systemInfoInterface("com.deepin.daemon.SystemInfo",
"/com/deepin/daemon/SystemInfo",
QDBusInterface systemInfoInterface("org.deepin.dde.SystemInfo1",
"/org/deepin/dde/SystemInfo1",
"org.freedesktop.DBus.Properties",
QDBusConnection::sessionBus());
qDebug() << "systemInfoInterface.isValid: " << systemInfoInterface.isValid();
QDBusMessage replyCpu = systemInfoInterface.call("Get", "com.deepin.daemon.SystemInfo", "CPUHardware");
QDBusMessage replyCpu = systemInfoInterface.call("Get", "org.deepin.dde.SystemInfo1", "CPUHardware");
QList<QVariant> outArgsCPU = replyCpu.arguments();
if (outArgsCPU.count()) {
QString CPUHardware = outArgsCPU.at(0).value<QDBusVariant>().variant().toString();
Expand Down
3 changes: 1 addition & 2 deletions src/common/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public slots:
* @brief 音量改变槽函数
*/
void slotVolumeChanged(int nVolume);
void slotWMChanged(QString msg);
void slotWMChanged();
void slotMediaError();
/**
* @brief slotUpdateMircastState 更新投屏状态槽函数
Expand Down Expand Up @@ -582,7 +582,6 @@ protected slots:
MovieWidget *m_pMovieWidget;
MircastShowWidget *m_pMircastShowWidget; ///投屏展示界面
qint64 m_nFullscreenTime; ///全屏操作间隔时间
QDBusInterface *m_pWMDBus {nullptr}; ///窗口特效dbus接口
bool m_bIsWM {true}; ///是否开启窗口特效
bool m_isSettingMiniMode{false}; ///mini mode setting status
Qt::WindowStates m_preMiniWindowState {Qt::WindowNoState}; ///window state before mini mode
Expand Down
19 changes: 7 additions & 12 deletions src/common/platform/platform_mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <DSettingsWidgetFactory>
#include <DLineEdit>
#include <DFileDialog>
#include <DWindowManagerHelper>
#include <X11/cursorfont.h>
#include <X11/Xlib.h>
#include "moviewidget.h"
Expand Down Expand Up @@ -1091,11 +1092,9 @@ Platform_MainWindow::Platform_MainWindow(QWidget *parent)

#endif

m_pWMDBus = new QDBusInterface("com.deepin.WMSwitcher", "/com/deepin/WMSwitcher", "com.deepin.WMSwitcher", QDBusConnection::sessionBus());
QDBusReply<QString> reply_string = m_pWMDBus->call("CurrentWM");
m_bIsWM = reply_string.value().contains("deepin wm");
m_bIsWM = DWindowManagerHelper::instance()->hasBlurWindow();
m_pCommHintWid->setWM(m_bIsWM);
connect(m_pWMDBus, SIGNAL(WMChanged(QString)), this, SLOT(slotWMChanged(QString)));
connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasBlurWindowChanged, this, &Platform_MainWindow::slotWMChanged);

m_pAnimationlable = new Platform_AnimationLabel(this, this);
m_pAnimationlable->setWM(m_bIsWM);
Expand Down Expand Up @@ -1133,8 +1132,8 @@ Platform_MainWindow::Platform_MainWindow(QWidget *parent)
m_pDBus = new QDBusInterface("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::systemBus());
connect(m_pDBus, SIGNAL(PrepareForSleep(bool)), this, SLOT(sleepStateChanged(bool)));

QDBusConnection::sessionBus().connect("com.deepin.dde.shutdownFront", "/com/deepin/dde/lockFront",
"com.deepin.dde.lockFront", "Visible", this,
QDBusConnection::sessionBus().connect("org.deepin.dde.ShutdownFront1", "/org/deepin/dde/lockFront1",
"org.deepin.dde.lockFront1", "Visible", this,
SLOT(lockStateChanged(bool)));

m_pMovieWidget = new MovieWidget(this);
Expand Down Expand Up @@ -3526,13 +3525,9 @@ void Platform_MainWindow::slotVolumeChanged(int nVolume)
}
}

void Platform_MainWindow::slotWMChanged(QString msg)
void Platform_MainWindow::slotWMChanged()
{
if (msg.contains("deepin metacity")) {
m_bIsWM = false;
} else {
m_bIsWM = true;
}
m_bIsWM = DWindowManagerHelper::instance()->hasBlurWindow();

m_pAnimationlable->setWM(m_bIsWM);
m_pCommHintWid->setWM(m_bIsWM);
Expand Down
2 changes: 1 addition & 1 deletion src/common/platform/platform_mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public slots:
* @brief 音量改变槽函数
*/
void slotVolumeChanged(int nVolume);
void slotWMChanged(QString msg);
void slotWMChanged();
/**
* @brief slotUpdateMircastState 更新投屏状态槽函数
* @param state 投屏状态
Expand Down
20 changes: 10 additions & 10 deletions src/common/volumemonitoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ void VolumeMonitoring::stop()

void VolumeMonitoring::timeoutSlot()
{
QVariant v = DBusUtils::redDBusProperty("com.deepin.daemon.Audio", "/com/deepin/daemon/Audio",
"com.deepin.daemon.Audio", "SinkInputs");
QVariant v = DBusUtils::redDBusProperty("org.deepin.dde.Audio1", "/org/deepin/dde/Audio1",
"org.deepin.dde.Audio1", "SinkInputs");

if (!v.isValid())
return;
Expand All @@ -62,8 +62,8 @@ void VolumeMonitoring::timeoutSlot()

QString sinkInputPath;
for (auto curPath : allSinkInputsList) {
QVariant nameV = DBusUtils::redDBusProperty("com.deepin.daemon.Audio", curPath.path(),
"com.deepin.daemon.Audio.SinkInput", "Name");
QVariant nameV = DBusUtils::redDBusProperty("org.deepin.dde.Audio1", curPath.path(),
"org.deepin.dde.Audio1.SinkInput", "Name");

QString movieStr = QObject::tr("Movie");
if (!nameV.isValid() || (!nameV.toString().contains( movieStr, Qt::CaseInsensitive) && !nameV.toString().contains("deepin-movie", Qt::CaseInsensitive)))
Expand All @@ -75,20 +75,20 @@ void VolumeMonitoring::timeoutSlot()
if (sinkInputPath.isEmpty())
return;

QDBusInterface ainterface("com.deepin.daemon.Audio", sinkInputPath,
"com.deepin.daemon.Audio.SinkInput",
QDBusInterface ainterface("org.deepin.dde.Audio1", sinkInputPath,
"org.deepin.dde.Audio1.SinkInput",
QDBusConnection::sessionBus());
if (!ainterface.isValid()) {
return ;
}

//获取音量
QVariant volumeV = DBusUtils::redDBusProperty("com.deepin.daemon.Audio", sinkInputPath,
"com.deepin.daemon.Audio.SinkInput", "Volume");
QVariant volumeV = DBusUtils::redDBusProperty("org.deepin.dde.Audio1", sinkInputPath,
"org.deepin.dde.Audio1.SinkInput", "Volume");

//获取音量
QVariant muteV = DBusUtils::redDBusProperty("com.deepin.daemon.Audio", sinkInputPath,
"com.deepin.daemon.Audio.SinkInput", "Mute");
QVariant muteV = DBusUtils::redDBusProperty("org.deepin.dde.Audio1", sinkInputPath,
"org.deepin.dde.Audio1.SinkInput", "Mute");

// int temp = volumeV.toDouble();
int volume = static_cast<int>(volumeV.toDouble() * 100);
Expand Down
21 changes: 9 additions & 12 deletions src/widgets/platform/platform_toolbox_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <QDBusInterface>
#include <DToolButton>
#include <dthememanager.h>
#include <DWindowManagerHelper>
#include <iostream>
#include "../accessibility/ac-deepin-movie-define.h"
static const int LEFT_MARGIN = 10;
Expand Down Expand Up @@ -615,11 +616,9 @@ class Platform_ThumbnailPreview: public QWidget
setAttribute(Qt::WA_TranslucentBackground);
setObjectName("ThumbnailPreview");
resize(0, 0);

m_pWMDBus = new QDBusInterface("com.deepin.WMSwitcher", "/com/deepin/WMSwitcher", "com.deepin.WMSwitcher", QDBusConnection::sessionBus());
QDBusReply<QString> reply = m_pWMDBus->call("CurrentWM");
m_bIsWM = reply.value().contains("deepin wm");
connect(m_pWMDBus, SIGNAL(WMChanged(QString)), this, SLOT(slotWMChanged(QString)));

connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasBlurWindowChanged, this, &Platform_ThumbnailPreview::slotWMChanged);
m_bIsWM = DWindowManagerHelper::instance()->hasBlurWindow();
if (m_bIsWM) {
DStyle::setFrameRadius(this, 8);
} else {
Expand Down Expand Up @@ -670,14 +669,13 @@ class Platform_ThumbnailPreview: public QWidget
}
}
public slots:
void slotWMChanged(QString msg)
void slotWMChanged()
{
if (msg.contains("deepin metacity")) {
m_bIsWM = false;
DStyle::setFrameRadius(this, 0);
} else {
m_bIsWM = true;
m_bIsWM = DWindowManagerHelper::instance()->hasBlurWindow();
if (m_bIsWM) {
DStyle::setFrameRadius(this, 8);
} else {
DStyle::setFrameRadius(this, 0);
}
}

Expand Down Expand Up @@ -735,7 +733,6 @@ public slots:
QImage m_thumbImg;
int m_thumbnailFixed = 106;
QGraphicsDropShadowEffect *m_shadow_effect{nullptr};
QDBusInterface *m_pWMDBus{nullptr};
bool m_bIsWM{false};
};

Expand Down
12 changes: 6 additions & 6 deletions src/widgets/platform/platform_volumeslider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ QString Platform_VolumeSlider::readSinkInputPath()
{
QString strPath = "";

QVariant v = ApplicationAdaptor::redDBusProperty("com.deepin.daemon.Audio", "/com/deepin/daemon/Audio",
"com.deepin.daemon.Audio", "SinkInputs");
QVariant v = ApplicationAdaptor::redDBusProperty("org.deepin.dde.Audio1", "/org/deepin/dde/Audio1",
"org.deepin.dde.Audio1", "SinkInputs");

if (!v.isValid())
return strPath;

QList<QDBusObjectPath> allSinkInputsList = v.value<QList<QDBusObjectPath> >();

for (auto curPath : allSinkInputsList) {
QVariant nameV = ApplicationAdaptor::redDBusProperty("com.deepin.daemon.Audio", curPath.path(),
"com.deepin.daemon.Audio.SinkInput", "Name");
QVariant nameV = ApplicationAdaptor::redDBusProperty("org.deepin.dde.Audio1", curPath.path(),
"org.deepin.dde.Audio1.SinkInput", "Name");
QString strMovie = QObject::tr("Movie");
if (!nameV.isValid() || (!nameV.toString().contains(strMovie, Qt::CaseInsensitive) && !nameV.toString().contains("deepin movie", Qt::CaseInsensitive)))
continue;
Expand All @@ -128,8 +128,8 @@ void Platform_VolumeSlider::setMute(bool muted)
QString sinkInputPath = readSinkInputPath();

if (!sinkInputPath.isEmpty()) {
QDBusInterface ainterface("com.deepin.daemon.Audio", sinkInputPath,
"com.deepin.daemon.Audio.SinkInput",
QDBusInterface ainterface("org.deepin.dde.Audio1", sinkInputPath,
"org.deepin.dde.Audio1.SinkInput",
QDBusConnection::sessionBus());
if (!ainterface.isValid()) {
return;
Expand Down
15 changes: 5 additions & 10 deletions src/widgets/tip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <DUtil>
#include <dthememanager.h>
#include <DLabel>
#include <DWindowManagerHelper>

DWIDGET_USE_NAMESPACE
namespace dmr {
Expand Down Expand Up @@ -92,10 +93,8 @@ Tip::Tip(const QPixmap &icon, const QString &text, QWidget *parent)
bodyShadow->setOffset(0, 2.0);
hide();

m_pWMDBus = new QDBusInterface("com.deepin.WMSwitcher","/com/deepin/WMSwitcher","com.deepin.WMSwitcher",QDBusConnection::sessionBus());
QDBusReply<QString> reply = m_pWMDBus->call("CurrentWM");
bIsWM = reply.value().contains("deepin wm");
connect(m_pWMDBus, SIGNAL(WMChanged(QString)), this, SLOT(slotWMChanged(QString)));
bIsWM = DWindowManagerHelper::instance()->hasBlurWindow();
connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasBlurWindowChanged, this, &Tip::slotWMChanged);
}

Tip::~Tip()
Expand Down Expand Up @@ -154,13 +153,9 @@ void Tip::setBorderColor(QColor borderColor)
d->borderColor = borderColor;
}

void Tip::slotWMChanged(QString msg)
void Tip::slotWMChanged()
{
if (msg.contains("deepin metacity")) {
bIsWM = false;
} else {
bIsWM = true;
}
bIsWM = DWindowManagerHelper::instance()->hasBlurWindow();
}

void Tip::pop(QPoint center)
Expand Down
3 changes: 1 addition & 2 deletions src/widgets/tip.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public slots:
void setBackground(QBrush background);
void setRadius(int radius);
void setBorderColor(QColor borderColor);
void slotWMChanged(QString msg);
void slotWMChanged();

protected:
virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
Expand All @@ -53,7 +53,6 @@ public slots:
QScopedPointer<TipPrivate> d_ptr;
Q_DECLARE_PRIVATE_D(qGetPtrHelper(d_ptr), Tip)
QString m_strText;
QDBusInterface* m_pWMDBus {nullptr};
bool bIsWM {true};
};
}
Expand Down
19 changes: 8 additions & 11 deletions src/widgets/toolbox_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <QDBusInterface>
#include <DToolButton>
#include <dthememanager.h>
#include <DWindowManagerHelper>
#include <iostream>
#include "../accessibility/ac-deepin-movie-define.h"
static const int LEFT_MARGIN = 10;
Expand Down Expand Up @@ -666,10 +667,8 @@ class ThumbnailPreview: public QWidget
setObjectName("ThumbnailPreview");
resize(0, 0);

m_pWMDBus = new QDBusInterface("com.deepin.WMSwitcher", "/com/deepin/WMSwitcher", "com.deepin.WMSwitcher", QDBusConnection::sessionBus());
QDBusReply<QString> reply = m_pWMDBus->call("CurrentWM");
m_bIsWM = reply.value().contains("deepin wm");
connect(m_pWMDBus, SIGNAL(WMChanged(QString)), this, SLOT(slotWMChanged(QString)));
m_bIsWM = DWindowManagerHelper::instance()->hasBlurWindow();
connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasBlurWindowChanged, this, &ThumbnailPreview::slotWMChanged);
if (m_bIsWM) {
DStyle::setFrameRadius(this, 8);
} else {
Expand Down Expand Up @@ -720,14 +719,13 @@ class ThumbnailPreview: public QWidget
}
}
public slots:
void slotWMChanged(QString msg)
void slotWMChanged()
{
if (msg.contains("deepin metacity")) {
m_bIsWM = false;
DStyle::setFrameRadius(this, 0);
} else {
m_bIsWM = true;
m_bIsWM = DWindowManagerHelper::instance()->hasBlurWindow();
if (m_bIsWM) {
DStyle::setFrameRadius(this, 8);
} else {
DStyle::setFrameRadius(this, 0);
}
}

Expand Down Expand Up @@ -785,7 +783,6 @@ public slots:
QImage m_thumbImg;
int m_thumbnailFixed = 106;
QGraphicsDropShadowEffect *m_shadow_effect{nullptr};
QDBusInterface *m_pWMDBus{nullptr};
bool m_bIsWM{false};
};

Expand Down
Loading

0 comments on commit 0f384d4

Please sign in to comment.