feat: Adapt to V23 dde dbus interface#166
Open
wangrong1069 wants to merge 1 commit intolinuxdeepin:masterfrom
Open
feat: Adapt to V23 dde dbus interface#166wangrong1069 wants to merge 1 commit intolinuxdeepin:masterfrom
wangrong1069 wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
As title. Log: Adapt to V23 dde dbus interface
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wangrong1069 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
deepin pr auto review代码审查意见:
综合以上意见,代码可以改进为: static void setWallpaperWithDBus(const QString &path)
{
//202011/12 bug54279 设置壁纸代码改变,采用DBus
qDebug() << "SettingWallpaper: " << "flatpak" << path;
QDBusInterface *interface = nullptr;
if (QDBusInterface interfaceV23("org.deepin.dde.Appearance1", "/org/deepin/dde/Appearance1", "org.deepin.dde.Appearance1").isValid()) {
interface = &interfaceV23;
} else {
interface = new QDBusInterface("com.deepin.daemon.Appearance", "/com/deepin/daemon/Appearance", "com.deepin.daemon.Appearance");
}
if (interface && interface->isValid()) {
QString screenname;
bool isWayland = QGuiApplication::platformName() == "wayland";
if (isWayland) {
QDBusInterface *interfaceWayland = nullptr;
if (QDBusInterface interfaceWaylandV23("org.deepin.dde.Display1", "/org/deepin/dde/Display1", "org.deepin.dde.Display1").isValid()) {
interfaceWayland = &interfaceWaylandV23;
} else {
interfaceWayland = new QDBusInterface("com.deepin.daemon.Display", "/com/deepin/daemon/Display", "com.deepin.daemon.Display");
}
screenname = qvariant_cast< QString >(interfaceWayland->property("Primary"));
delete interfaceWayland;
} else {
screenname = QGuiApplication::primaryScreen()->name();
}
QDBusMessage reply = interface->call(QStringLiteral("SetMonitorBackground"), screenname, path);
QString error = reply.errorMessage();
if (!error.isEmpty()) {
qWarning() << "SettingWallpaper: replay" << error;
}
reply = interface->call(QStringLiteral("Set"), QStringLiteral("greeterbackground"), path);
error = reply.errorMessage();
if (!error.isEmpty()) {
qWarning() << "Set greeterbackground: replay" << error;
}
PermissionConfig::instance()->triggerAction(PermissionConfig::TidCopy, path);
} else {
qWarning() << "SettingWallpaper failed" << (interface ? interface->lastError().message() : "Unknown error");
}
delete interface;
}这个改进版本解决了上述提到的问题,提高了代码的可读性和可维护性。 |
Contributor
|
TAG Bot New tag: 6.5.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As title.
Log: Adapt to V23 dde dbus interface