Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Can't pack v23 in obs #289

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ option(DOTEST "option for test" OFF)
# 是否开启单元测试编译
#set(DOTEST ON)

# 判断系统环境
#file(STRINGS "/etc/os-version" MAJOR_STR REGEX "MajorVersion")
execute_process(COMMAND cat /etc/os-version OUTPUT_VARIABLE OS_INFO_STR)
string(REGEX MATCHALL "MajorVersion=[0-9]+" MAJOR_STR "${OS_INFO_STR}")
string(REGEX MATCH "[0-9]+" MAJOR_VERSION "${MAJOR_STR}")
if (MAJOR_VERSION MATCHES "23")
message("--------------------- OS_BUILD_V23 on")
add_definitions(-DOS_BUILD_V23)
endif()

include(GNUInstallDirs)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
Expand Down
6 changes: 3 additions & 3 deletions deepin-system-monitor-main/common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "common.h"
#include "stack_trace.h"
#include "hash.h"
#include "helper.hpp"

#include <QPainter>
#include <QString>
Expand Down Expand Up @@ -208,9 +209,8 @@ void WaylandSearchCentered()

if (XDG_SESSION_TYPE == QLatin1String("wayland") || WAYLAND_DISPLAY.contains(QLatin1String("wayland"), Qt::CaseInsensitive)) {
WaylandCentered = true;
#ifdef OS_BUILD_V23
qputenv("QT_WAYLAND_SHELL_INTEGRATION", "kwayland-shell");
#endif
if (!common::systemInfo().isOldVersion())
qputenv("QT_WAYLAND_SHELL_INTEGRATION", "kwayland-shell");
} else {
WaylandCentered = false;
}
Expand Down
17 changes: 4 additions & 13 deletions deepin-system-monitor-main/dbus/dbusalarmnotify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,14 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "dbusalarmnotify.h"
#include "helper.hpp"

#include <QDBusMessage>
#include <QDBusConnection>
#include <QProcess>
#include <QDebug>
#include <QDateTime>

#ifdef OS_BUILD_V23
const QString NotificationService = "org.deepin.dde.Notification1";
const QString NotificationPath = "/org/deepin/dde/Notification1";
const QString NotificationInterface = "org.deepin.dde.Notification1";
#else
const QString NotificationService = "com.deepin.dde.Notification";
const QString NotificationPath = "/com/deepin/dde/Notification";
const QString NotificationInterface = "com.deepin.dde.Notification";
#endif

#define AlarmMessageTimeOut 10000
QMutex DBusAlarmNotify::mutex;
QAtomicPointer<DBusAlarmNotify> DBusAlarmNotify::instance = nullptr;
Expand Down Expand Up @@ -59,11 +50,11 @@

}

void DBusAlarmNotify::showAlarmNotify(QString topic, QString msg, int timeout)

Check warning on line 53 in deepin-system-monitor-main/dbus/dbusalarmnotify.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'topic' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.

Check warning on line 53 in deepin-system-monitor-main/dbus/dbusalarmnotify.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'msg' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.
{
QDBusMessage ddeNotify = QDBusMessage::createMethodCall(NotificationService,
NotificationPath,
NotificationInterface,
QDBusMessage ddeNotify = QDBusMessage::createMethodCall(common::systemInfo().NotificationService,
common::systemInfo().NotificationPath,
common::systemInfo().NotificationInterface,
"Notify");
QStringList action;
action << "_open1" << tr("View"); //添加按钮
Expand Down
61 changes: 24 additions & 37 deletions deepin-system-monitor-main/gui/dialog/systemprotectionsetting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "systemprotectionsetting.h"
#include "helper.hpp"

#include <DSettingsWidgetFactory>
#include <DCommandLinkButton>
Expand Down Expand Up @@ -41,24 +42,6 @@ int SystemProtectionSetting::m_lastValidCPUValue = 0;
int SystemProtectionSetting::m_lastValidMemoryValue = 0;
int SystemProtectionSetting::m_lastValidInternalValue = 0;

#ifdef OS_BUILD_V23
const QString AppearanceService = "org.deepin.dde.Appearance1";
const QString AppearancePath = "/org/deepin/dde/Appearance1";
const QString AppearanceInterface = "org.deepin.dde.Appearance1";

const QString ControlCenterService = "org.deepin.dde.ControlCenter1";
const QString ControlCenterPath = "/org/deepin/dde/ControlCenter1";
const QString ControlCenterInterface = "org.deepin.dde.ControlCenter1";
#else
const QString AppearanceService = "com.deepin.daemon.Appearance";
const QString AppearancePath = "/com/deepin/daemon/Appearance";
const QString AppearanceInterface = "com.deepin.daemon.Appearance";

const QString ControlCenterService = "com.deepin.dde.ControlCenter";
const QString ControlCenterPath = "/com/deepin/dde/ControlCenter";
const QString ControlCenterInterface = "com.deepin.dde.ControlCenter";
#endif

Q_GLOBAL_STATIC(SystemProtectionSetting, theInstance)

// 修改控件字体大小
Expand All @@ -71,9 +54,9 @@ bool changeWidgetFontSizeByDiffWithSystem(QWidget *widget, double diff)

// 获取系统字体大小设置

QDBusInterface interface(AppearanceService,
AppearancePath,
AppearanceInterface);
QDBusInterface interface(common::systemInfo().AppearanceService,
common::systemInfo().AppearancePath,
common::systemInfo().AppearanceInterface);
// 获取失败,返回
if (interface.isValid() == false) {
return false;
Expand Down Expand Up @@ -492,17 +475,18 @@ void SystemProtectionSetting::onMessgaeSetting(QVariant value)

if (genericName.isEmpty() == false) {
// 跳转到设置页并指定Item
QDBusMessage showDDEControlCenterPage = QDBusMessage::createMethodCall(ControlCenterService,
ControlCenterPath,
ControlCenterInterface,
QDBusMessage showDDEControlCenterPage = QDBusMessage::createMethodCall(common::systemInfo().ControlCenterService,
common::systemInfo().ControlCenterPath,
common::systemInfo().ControlCenterInterface,
"ShowPage");
QList<QVariant> args;
#ifdef OS_BUILD_V23
args << QString("notification/%1").append(genericName);
#else
args.append("notification");
args.append(genericName);
#endif
if (!common::systemInfo().isOldVersion()) {
args << QString("notification/%1").append(genericName);
} else {
args.append("notification");
args.append(genericName);
}

showDDEControlCenterPage.setArguments(args);

QDBusMessage replyMsg = QDBusConnection::sessionBus().call(showDDEControlCenterPage);
Expand All @@ -515,17 +499,20 @@ void SystemProtectionSetting::onMessgaeSetting(QVariant value)
} else {
// 跳转到设置页
// qdbus org.deepin.dde.ControlCenter1 /org/deepin/dde/ControlCenter1 org.deepin.dde.ControlCenter1.ShowModule notification
#ifdef OS_BUILD_V23
QDBusMessage showDDEControlCenter = QDBusMessage::createMethodCall(ControlCenterService,
ControlCenterPath,
ControlCenterInterface,

QDBusMessage showDDEControlCenter;
if (!common::systemInfo().isOldVersion()) {
showDDEControlCenter = QDBusMessage::createMethodCall(common::systemInfo().ControlCenterService,
common::systemInfo().ControlCenterPath,
common::systemInfo().ControlCenterInterface,
"ShowPage");
#else
QDBusMessage showDDEControlCenter = QDBusMessage::createMethodCall("com.deepin.dde.ControlCenter",
} else {
showDDEControlCenter = QDBusMessage::createMethodCall("com.deepin.dde.ControlCenter",
"/com/deepin/dde/ControlCenter",
"com.deepin.dde.ControlCenter",
"ShowModule");
#endif
}


QList<QVariant> args;
args << "notification";
Expand Down
12 changes: 7 additions & 5 deletions deepin-system-monitor-main/gui/process_table_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "model/process_table_model.h"
#include "process/process_db.h"
#include "common/eventlogutils.h"
#include "helper.hpp"

#include <DApplication>
#include <DApplicationHelper>
Expand Down Expand Up @@ -228,8 +229,9 @@ void ProcessTableView::openExecDirWithFM()
whichProcess.waitForFinished();
QString output(whichProcess.readAllStandardOutput());

#ifdef OS_BUILD_V23
QString path = QString(output.split("\n")[0]).trimmed();
QString path;
if (!common::systemInfo().isOldVersion()) {
path = QString(output.split("\n")[0]).trimmed();
// 读取persistent目录
if (path.isEmpty()) {
char nsPath[PATH_MAX] = {0}, nsSelfPath[PATH_MAX] = {0};
Expand Down Expand Up @@ -273,9 +275,9 @@ void ProcessTableView::openExecDirWithFM()
}
}
}
#else
const QString &path = QString(output.split("\n")[0]).trimmed();
#endif
} else {
path = QString(output.split("\n")[0]).trimmed();
}
common::openFilePathItem(path);
}
// Find flatpak application location.
Expand Down
29 changes: 5 additions & 24 deletions deepin-system-monitor-main/model/accounts_info_model.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "accounts_info_model.h"
#include "helper.hpp"
#include <QDBusReply>
#include <QDBusPendingReply>
#include <QDebug>
Expand All @@ -10,34 +11,14 @@
#define PKEXEC_PATH "/usr/bin/pkexec"
#define PKILL_PATH "/usr/bin/pkill"

#ifdef OS_BUILD_V23
const QString AccountsService = "org.deepin.dde.Accounts1";
const QString AccountsPath = "/org/deepin/dde/Accounts1";
const QString AccountsInterface = "org.deepin.dde.Accounts1";
const QString UserInterface = "org.deepin.dde.Accounts1.User";

const QString ControlCenterService = "org.deepin.dde.ControlCenter1";
const QString ControlCenterPath = "/org/deepin/dde/ControlCenter1";
const QString ControlCenterInterface = "org.deepin.dde.ControlCenter1";
#else
const QString AccountsService = "com.deepin.daemon.Accounts";
const QString AccountsPath = "/com/deepin/daemon/Accounts";
const QString AccountsInterface = "com.deepin.daemon.Accounts";
const QString UserInterface = "com.deepin.daemon.Accounts.User";

const QString ControlCenterService = "com.deepin.dde.ControlCenter";
const QString ControlCenterPath = "/com/deepin/dde/ControlCenter";
const QString ControlCenterInterface = "com.deepin.dde.ControlCenter";
#endif

const QString LoginService = "org.freedesktop.login1";
const QString LoginPath = "/org/freedesktop/login1";
const QString LoginInterface = "org.freedesktop.login1.Manager";

AccountsInfoModel::AccountsInfoModel(QObject *parent): QObject(parent)
, m_accountsInter(new QDBusInterface(AccountsService, AccountsPath, AccountsInterface, QDBusConnection::systemBus(), this))
, m_accountsInter(new QDBusInterface(common::systemInfo().AccountsService, common::systemInfo().AccountsPath, common::systemInfo().AccountsInterface, QDBusConnection::systemBus(), this))
, m_LoginInter(new QDBusInterface(LoginService, LoginPath, LoginInterface, QDBusConnection::systemBus(), this))
, m_controlInter(new QDBusInterface(ControlCenterService, ControlCenterPath, ControlCenterInterface, QDBusConnection::sessionBus(), this))
, m_controlInter(new QDBusInterface(common::systemInfo().ControlCenterService, common::systemInfo().ControlCenterPath, common::systemInfo().ControlCenterInterface, QDBusConnection::sessionBus(), this))
, m_currentUserType(-1)
{
qDBusRegisterMetaType<SessionInfo>();
Expand All @@ -54,7 +35,7 @@ AccountsInfoModel::AccountsInfoModel(QObject *parent): QObject(parent)
updateUserList(userList);
qInfo() << "AccountsInfoModel constructor line 31" << "Accounts user list:" << userList;

QDBusConnection::systemBus().connect(AccountsService, AccountsPath, AccountsInterface, "UserListChanged",
QDBusConnection::systemBus().connect(common::systemInfo().AccountsService, common::systemInfo().AccountsPath, common::systemInfo().AccountsInterface, "UserListChanged",
this, SLOT(onUserListChanged(QStringList)));
QDBusConnection::systemBus().connect(LoginService, LoginPath, LoginInterface, "SessionNew",
this, SLOT(onSessionNew(QString, QDBusObjectPath)));
Expand Down Expand Up @@ -87,7 +68,7 @@ void AccountsInfoModel::updateUserList(const QStringList &userPathList)
qInfo() << "AccountsInfoModel updateUserList line 61" << "updateUserList begins!" ;
m_userMap.clear();
for (QString userPath : userPathList) {
QDBusInterface *userDBus = new QDBusInterface(AccountsService, userPath, UserInterface, QDBusConnection::systemBus(), this);
QDBusInterface *userDBus = new QDBusInterface(common::systemInfo().AccountsService, userPath, common::systemInfo().UserInterface, QDBusConnection::systemBus(), this);
User *newUser = new User;

newUser->setName(userDBus->property("UserName").toString());
Expand Down
17 changes: 4 additions & 13 deletions deepin-system-monitor-main/wm/wm_window_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "system/system_monitor_thread.h"
#include "process/process_db.h"
#include "common/common.h"
#include "helper.hpp"

#include <QtDBus>

Expand All @@ -36,16 +37,6 @@ const int maxImageW = 1024;
const int maxImageH = 1024;
const int offsetImagePointerWH = 2;

#ifdef OS_BUILD_V23
const QString TrayManagerService = "org.deepin.dde.TrayManager1";
const QString TrayManagerPath = "/org/deepin/dde/TrayManager1";
const QString TrayManagerInterface = "org.freedesktop.DBus.Properties";
#else
const QString TrayManagerService = "com.deepin.dde.TrayManager";
const QString TrayManagerPath = "/com/deepin/dde/TrayManager";
const QString TrayManagerInterface = "org.freedesktop.DBus.Properties";
#endif

WMWindowList::WMWindowList(QObject *parent)
: QObject(parent)
{
Expand Down Expand Up @@ -277,9 +268,9 @@ QString WMWindowList::getWindowTitle(pid_t pid) const

QList<WMWId> WMWindowList::getTrayWindows() const
{
QDBusInterface busInterface(TrayManagerService, TrayManagerPath,
TrayManagerInterface, QDBusConnection::sessionBus());
QDBusMessage reply = busInterface.call("Get", TrayManagerService, "TrayIcons");
QDBusInterface busInterface(common::systemInfo().TrayManagerService, common::systemInfo().TrayManagerPath,
common::systemInfo().TrayManagerInterface, QDBusConnection::sessionBus());
QDBusMessage reply = busInterface.call("Get", common::systemInfo().TrayManagerService, "TrayIcons");
QVariant v = reply.arguments().first();
const QDBusArgument &argument = v.value<QDBusVariant>().variant().value<QDBusArgument>();

Expand Down
4 changes: 2 additions & 2 deletions deepin-system-monitor-plugin-popup/dbus/dbusdockinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*/

DBusDockInterface::DBusDockInterface(QObject *parent)
: QDBusAbstractInterface(DockService, DockPath, staticInterfaceName(), QDBusConnection::sessionBus(), parent)
: QDBusAbstractInterface(common::systemInfo().DockService, common::systemInfo().DockPath, staticInterfaceName(), QDBusConnection::sessionBus(), parent)
{
QDBusConnection::sessionBus().connect(this->service(), this->path(), DockInterface, "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage)));
QDBusConnection::sessionBus().connect(this->service(), this->path(), common::systemInfo().DockInterface, "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage)));
}

DBusDockInterface::~DBusDockInterface()
Expand Down
16 changes: 4 additions & 12 deletions deepin-system-monitor-plugin-popup/dbus/dbusdockinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef DBUSDOCK_H
#define DBUSDOCK_H

#include "helper.hpp"

#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
Expand All @@ -15,16 +17,6 @@
#include <QtCore/QVariant>
#include <QtDBus/QtDBus>

#ifdef OS_BUILD_V23
const QString DockService = "org.deepin.dde.Dock1";
const QString DockPath = "/org/deepin/dde/Dock1";
const QString DockInterface = "org.freedesktop.DBus.Properties";
#else
const QString DockService = "com.deepin.dde.Dock";
const QString DockPath = "/com/deepin/dde/Dock";
const QString DockInterface = "org.freedesktop.DBus.Properties";
#endif

/*
* Proxy class for interface local.MainWindow
*/
Expand All @@ -38,7 +30,7 @@ class DBusDockInterface: public QDBusAbstractInterface
if (3 != arguments.count())
return;
QString interfaceName = msg.arguments().at(0).toString();
if (interfaceName != DockService)
if (interfaceName != common::systemInfo().DockService)
return;
QVariantMap changedProps = qdbus_cast<QVariantMap>(arguments.at(1).value<QDBusArgument>());
foreach(const QString &prop, changedProps.keys()) {
Expand All @@ -53,7 +45,7 @@ class DBusDockInterface: public QDBusAbstractInterface
}
public:
static inline const char *staticInterfaceName()
{ return DockService.toStdString().c_str(); }
{ return common::systemInfo().DockService.toStdString().c_str(); }

public:
explicit DBusDockInterface( QObject *parent = nullptr);
Expand Down
Loading
Loading