diff --git a/CMakeLists.txt b/CMakeLists.txt index 35915fd1..3ccfacc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,16 @@ 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) diff --git a/debian/control b/debian/control index ea735b17..b277e363 100644 --- a/debian/control +++ b/debian/control @@ -2,13 +2,41 @@ Source: deepin-system-monitor Section: utils Priority: optional Maintainer: Deepin Packages Builder -Build-Depends: debhelper (>= 11), cmake, pkg-config, qtbase5-dev, qttools5-dev, libdtkwidget-dev, libxcb1-dev, libqt5x11extras5-dev, libxext-dev, libpcap-dev, qttools5-dev-tools, libicu-dev, deepin-gettext-tools, libxcb-util0-dev, libxcb-icccm4-dev, libnl-3-dev, libnl-route-3-dev, libudev-dev, libgsettings-qt-dev, dde-dock-dev, libgtest-dev, libgmock-dev, libdwayland-dev +Build-Depends: + debhelper (>= 11), + cmake, + pkg-config, + qtbase5-dev, + qttools5-dev, + libdtkwidget-dev, + libxcb1-dev, + libqt5x11extras5-dev, + libxext-dev, + libpcap-dev, + qttools5-dev-tools, + libicu-dev, + deepin-gettext-tools, + libxcb-util0-dev, + libxcb-icccm4-dev, + libnl-3-dev, + libnl-route-3-dev, + libudev-dev, + libgsettings-qt-dev, + dde-dock-dev, + libgtest-dev, + libgmock-dev, + libdwayland-dev | libkf5wayland-dev Standards-Version: 3.9.8 Homepage: https://github.com/linuxdeepin/deepin-system-monitor Package: deepin-system-monitor Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libcap2-bin, libdwaylandclient5, libdwaylandserver5,deepin-service-manager +Depends: ${shlibs:Depends}, + ${misc:Depends}, + libcap2-bin, + libdwaylandclient5 | libkf5waylandclient5, + libdwaylandserver5 | libkf5waylandserver5, + deepin-service-manager Recommends: uos-reporter, deepin-event-log Replaces: deepin-system-monitor-plugin Description: A system monitor tool. diff --git a/deepin-system-monitor-main/CMakeLists.txt b/deepin-system-monitor-main/CMakeLists.txt index 831d2b36..c62b5224 100644 --- a/deepin-system-monitor-main/CMakeLists.txt +++ b/deepin-system-monitor-main/CMakeLists.txt @@ -39,7 +39,16 @@ check_symbol_exists(SYS_getrandom "sys/syscall.h" HAVE_SYS_GETRANDOM) include(FindPkgConfig) if (USE_DEEPIN_WAYLAND) find_package(DWayland) + find_package(KF5Wayland) + if (DWayland_FOUND) + message("DWayland founded.") + add_definitions(-DDWAYLAND) + elseif(KF5Wayland_FOUND) + message("KF5Wayland founded.") + add_definitions(-DKF5WAYLAND) + endif() endif() + find_package(Qt5 COMPONENTS Core REQUIRED) find_package(Qt5 COMPONENTS Widgets REQUIRED) find_package(Qt5 COMPONENTS Gui REQUIRED) @@ -57,7 +66,7 @@ find_library(LIB_XEXT NAMES Xext REQUIRED) find_library(LIB_ICCCM NAMES xcb-icccm REQUIRED) find_package(ICU COMPONENTS i18n uc REQUIRED) -pkg_search_module(DFrameworkDBus REQUIRED dframeworkdbus) # chinalife +#pkg_search_module(DFrameworkDBus REQUIRED dframeworkdbus) # chinalife pkg_search_module(LIB_NL3 REQUIRED libnl-3.0) pkg_search_module(LIB_NL3_ROUTE REQUIRED libnl-route-3.0) pkg_search_module(LIB_UDEV REQUIRED libudev) @@ -72,7 +81,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libsmartcols/src) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../) -include_directories(${DFrameworkDBus_INCLUDE_DIRS}) # chinalife +#include_directories(${DFrameworkDBus_INCLUDE_DIRS}) # chinalife #安全测试加固编译参数 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -z relro -z now -z noexecstack -pie") @@ -590,10 +599,16 @@ set(LIBS ${LIB_NL3_LIBRARIES} ${LIB_NL3_ROUTE_LIBRARIES} ${LIB_UDEV_LIBRARIES} - ${DFrameworkDBus_LIBRARIES} # chinalife +# ${DFrameworkDBus_LIBRARIES} # chinalife ) + if (USE_DEEPIN_WAYLAND) - list(APPEND LIBS DWaylandClient DWaylandServer) + message("................................link wayland: ${OS_BUILD_V23}") + if (OS_BUILD_V23) + list(APPEND LIBS DWaylandClient DWaylandServer) + else() + list(APPEND LIBS KF5::WaylandClient KF5::WaylandServer) + endif() endif() file(GLOB APP_TS_FILES LIST_DIRECTORIES false translations/*.ts) diff --git a/deepin-system-monitor-main/common/common.cpp b/deepin-system-monitor-main/common/common.cpp index 0a65604a..f8b8eae3 100644 --- a/deepin-system-monitor-main/common/common.cpp +++ b/deepin-system-monitor-main/common/common.cpp @@ -208,7 +208,9 @@ 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 } else { WaylandCentered = false; } diff --git a/deepin-system-monitor-main/dbus/dbusalarmnotify.cpp b/deepin-system-monitor-main/dbus/dbusalarmnotify.cpp index 731983da..aba7d5ce 100644 --- a/deepin-system-monitor-main/dbus/dbusalarmnotify.cpp +++ b/deepin-system-monitor-main/dbus/dbusalarmnotify.cpp @@ -11,13 +11,15 @@ #include #include +#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"; - -//const QString NotificationService = "com.deepin.dde.Notification"; -//const QString NotificationPath = "/com/deepin/dde/Notification"; -//const QString NotificationInterface = "com.deepin.dde.Notification"; +#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; diff --git a/deepin-system-monitor-main/gui/dialog/systemprotectionsetting.cpp b/deepin-system-monitor-main/gui/dialog/systemprotectionsetting.cpp index d825dc58..213e70ef 100644 --- a/deepin-system-monitor-main/gui/dialog/systemprotectionsetting.cpp +++ b/deepin-system-monitor-main/gui/dialog/systemprotectionsetting.cpp @@ -41,7 +41,23 @@ 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) @@ -55,9 +71,9 @@ bool changeWidgetFontSizeByDiffWithSystem(QWidget *widget, double diff) // 获取系统字体大小设置 - QDBusInterface interface("org.deepin.dde.Appearance1", - "/org/deepin/dde/Appearance1", - "org.deepin.dde.Appearance1"); + QDBusInterface interface(AppearanceService, + AppearancePath, + AppearanceInterface); // 获取失败,返回 if (interface.isValid() == false) { return false; @@ -476,14 +492,17 @@ void SystemProtectionSetting::onMessgaeSetting(QVariant value) if (genericName.isEmpty() == false) { // 跳转到设置页并指定Item - QDBusMessage showDDEControlCenterPage = QDBusMessage::createMethodCall("org.deepin.dde.ControlCenter1", - "/org/deepin/dde/ControlCenter1", - "org.deepin.dde.ControlCenter1", + QDBusMessage showDDEControlCenterPage = QDBusMessage::createMethodCall(ControlCenterService, + ControlCenterPath, + ControlCenterInterface, "ShowPage"); QList args; +#ifdef OS_BUILD_V23 args << QString("notification/%1").append(genericName); -// args.append("notification"); -// args.append(genericName); +#else + args.append("notification"); + args.append(genericName); +#endif showDDEControlCenterPage.setArguments(args); QDBusMessage replyMsg = QDBusConnection::sessionBus().call(showDDEControlCenterPage); @@ -496,10 +515,18 @@ void SystemProtectionSetting::onMessgaeSetting(QVariant value) } else { // 跳转到设置页 // qdbus org.deepin.dde.ControlCenter1 /org/deepin/dde/ControlCenter1 org.deepin.dde.ControlCenter1.ShowModule notification - QDBusMessage showDDEControlCenter = QDBusMessage::createMethodCall("org.deepin.dde.ControlCenter1", - "/org/deepin/dde/ControlCenter1", - "org.deepin.dde.ControlCenter1", +#ifdef OS_BUILD_V23 + QDBusMessage showDDEControlCenter = QDBusMessage::createMethodCall(ControlCenterService, + ControlCenterPath, + ControlCenterInterface, "ShowPage"); +#else + QDBusMessage showDDEControlCenter = QDBusMessage::createMethodCall("com.deepin.dde.ControlCenter", + "/com/deepin/dde/ControlCenter", + "com.deepin.dde.ControlCenter", + "ShowModule"); +#endif + QList args; args << "notification"; showDDEControlCenter.setArguments(args); @@ -585,9 +612,9 @@ void SystemProtectionSetting::onUpdateNewBackend() { // 创建新的数据后端,应对可能的设置数据变化 QString strConfigPath = QString("%1/%2/%3/protection.conf") - .arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)) - .arg(qApp->organizationName()) - .arg(qApp->applicationName()); + .arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)) + .arg(qApp->organizationName()) + .arg(qApp->applicationName()); Dtk::Core::QSettingBackend *newBackend = new QSettingBackend(strConfigPath); // 为DSetting更新数据后端 diff --git a/deepin-system-monitor-main/gui/process_table_view.cpp b/deepin-system-monitor-main/gui/process_table_view.cpp index cdae220e..4e8b5322 100644 --- a/deepin-system-monitor-main/gui/process_table_view.cpp +++ b/deepin-system-monitor-main/gui/process_table_view.cpp @@ -228,6 +228,7 @@ void ProcessTableView::openExecDirWithFM() whichProcess.waitForFinished(); QString output(whichProcess.readAllStandardOutput()); +#ifdef OS_BUILD_V23 QString path = QString(output.split("\n")[0]).trimmed(); // 读取persistent目录 if (path.isEmpty()) { @@ -272,6 +273,9 @@ void ProcessTableView::openExecDirWithFM() } } } +#else + const QString &path = QString(output.split("\n")[0]).trimmed(); +#endif common::openFilePathItem(path); } // Find flatpak application location. @@ -345,7 +349,6 @@ void ProcessTableView::killProcess() {"process_name", proc.name()} }; EventLogUtils::get().writeLogs(obj); - ProcessDB::instance()->killProcess(qvariant_cast(m_selectedPID)); } else { return; diff --git a/deepin-system-monitor-main/gui/xwin_kill_preview_widget.cpp b/deepin-system-monitor-main/gui/xwin_kill_preview_widget.cpp index d7e734b1..03250b0c 100644 --- a/deepin-system-monitor-main/gui/xwin_kill_preview_widget.cpp +++ b/deepin-system-monitor-main/gui/xwin_kill_preview_widget.cpp @@ -353,7 +353,7 @@ void XWinKillPreviewWidget::initUI() // default forbid style cursor m_defaultCursor = QCursor(Qt::ForbiddenCursor); - QTimer::singleShot(800, this, [ = ] { + QTimer::singleShot(500, this, [ = ] { // show background window in all screens for (auto screen : QApplication::screens()) { diff --git a/deepin-system-monitor-main/gui/xwin_kill_preview_widget.h b/deepin-system-monitor-main/gui/xwin_kill_preview_widget.h index bd1d2222..131bb882 100644 --- a/deepin-system-monitor-main/gui/xwin_kill_preview_widget.h +++ b/deepin-system-monitor-main/gui/xwin_kill_preview_widget.h @@ -19,10 +19,17 @@ // 使用 USE_DEEPIN_WAYLAND 宏决定编译时是否支持 wayland // 如果支持,用全局变量 WaylandCentered 运行时控制 #ifdef USE_DEEPIN_WAYLAND +#ifdef DWAYLAND #include #include #include #include +#else +#include +#include +#include +#include +#endif using namespace KWayland::Client; #endif // USE_DEEPIN_WAYLAND diff --git a/deepin-system-monitor-main/model/process_table_model.cpp b/deepin-system-monitor-main/model/process_table_model.cpp index 8ce1bab2..855f4420 100644 --- a/deepin-system-monitor-main/model/process_table_model.cpp +++ b/deepin-system-monitor-main/model/process_table_model.cpp @@ -490,4 +490,4 @@ qreal ProcessTableModel::getTotalDiskWrite() diskwrite += proc.writeBps(); } return diskwrite; -} \ No newline at end of file +} diff --git a/deepin-system-monitor-main/process/desktop_entry_cache.h b/deepin-system-monitor-main/process/desktop_entry_cache.h index 569cc80e..08dcd8df 100644 --- a/deepin-system-monitor-main/process/desktop_entry_cache.h +++ b/deepin-system-monitor-main/process/desktop_entry_cache.h @@ -53,7 +53,7 @@ inline const DesktopEntry DesktopEntryCache::entry(const QString &name) const inline const DesktopEntry DesktopEntryCache::entryWithSubName(const QString &subName) const { for (auto &key : m_cache.keys()) { - if (key.toLower().compare(subName) == 0) + if (key.toLower().compare(subName) == 0) return m_cache[key]; } for (auto &key : m_cache.keys()) { diff --git a/deepin-system-monitor-main/process/desktop_entry_cache_updater.cpp b/deepin-system-monitor-main/process/desktop_entry_cache_updater.cpp index 342cd385..c15f6f93 100644 --- a/deepin-system-monitor-main/process/desktop_entry_cache_updater.cpp +++ b/deepin-system-monitor-main/process/desktop_entry_cache_updater.cpp @@ -65,7 +65,7 @@ DesktopEntry DesktopEntryCacheUpdater::createEntry(const QFileInfo &fileInfo) } // startup wm class & name - auto wmclass = dde.stringValue("StartupWMClass").toLower();; + auto wmclass = dde.stringValue("StartupWMClass").toLower(); if (!wmclass.isEmpty()) { entry->startup_wm_class = wmclass; entry->name = wmclass; diff --git a/deepin-system-monitor-main/translations/deepin-system-monitor_pl.ts b/deepin-system-monitor-main/translations/deepin-system-monitor_pl.ts index 33a05262..d35347f2 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor_pl.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor_pl.ts @@ -16,14 +16,6 @@ Hide details Ukryj szczegóły - - Overall utilization - - - - Individual utilization - - BlockDevItemWidget @@ -372,7 +364,7 @@ Mapped - Mapowane + Mapowane Total swap @@ -419,7 +411,7 @@ Reads merged/s - Odczytów połączonych/s + Odczytów scalonych/s Sectors written @@ -431,7 +423,7 @@ Writes merged - Zapisów połączonych + Zapisów scalonych Writes/s @@ -443,7 +435,7 @@ Writes merged/s - Zapisów połączonych/s + Zapisów scalonych/s @@ -502,14 +494,7 @@ Czy na pewno chcesz kontynuować? End button - Koniec - - - - MainWindow - - Settings - Ustawienia + Zakończ @@ -574,7 +559,7 @@ Czy na pewno chcesz kontynuować? RX packets - Paczki RX + Pakiety RX RX bytes @@ -590,7 +575,7 @@ Czy na pewno chcesz kontynuować? RX overruns - Nadpisane RX + Przekroczenia RX RX frame @@ -598,7 +583,7 @@ Czy na pewno chcesz kontynuować? TX packets - Paczki TX + Pakiety TX TX bytes @@ -610,7 +595,7 @@ Czy na pewno chcesz kontynuować? TX overruns - Nadpisane TX + Przekroczenia TX TX carrier @@ -936,34 +921,6 @@ Czy na pewno chcesz kontynuować? Not support Brak wsparcia - - Settings - Ustawienia - - - System Protection - Ochrona systemu - - - Show warnings when the usage exceeds the thresholds - Wyświetlaj ostrzeżenia, gdy użycie przekracza progi - - - Notifications - Powiadomienia - - - CPU warning threshold (%) - - - - Memory warning threshold (%) - - - - Warning interval (min) - - Service.Action.Set.Startup.Mode @@ -1059,21 +1016,6 @@ Czy na pewno chcesz kontynuować? Typ uruchomienia - - SystemProtectionSetting - - Settings - Ustawienia - - - (Modifiable) - (Modyfikowalny) - - - Range: %1-%2 - Zakres: %1-%2 - - Title.Bar.Context.Menu @@ -1133,4 +1075,4 @@ Czy na pewno chcesz kontynuować? Edytuj informacje konta - + \ No newline at end of file diff --git a/deepin-system-monitor-main/translations/policy/policy_pl.ts b/deepin-system-monitor-main/translations/policy/policy_pl.ts index 4ad64b36..88b2f9ba 100644 --- a/deepin-system-monitor-main/translations/policy/policy_pl.ts +++ b/deepin-system-monitor-main/translations/policy/policy_pl.ts @@ -4,27 +4,27 @@ Authentication is required to change process priority - Uwierzytelnienie jest wymagane, aby zmienić priorytet procesu + Wymagane jest uwierzytelnienie, aby zmienić priorytet procesu Renice process - Proces renice + Zmień priorytet procesu Authentication is required to control other users' processes - Uwierzytelnianie jest wymagane do kontrolowania procesów innych użytkowników + Wymagane jest uwierzytelnienie do kontrolowania procesów innych użytkowników Kill process - Zamknij proces + Zabij Authentication is required to set service startup type - Uwierzytelnianie jest wymagane, aby ustawić typ uruchamiania usługi + Wymagane jest uwierzytelnienie, aby ustawić typ uruchamiania usługi diff --git a/deepin-system-monitor-main/wm/wm_window_list.cpp b/deepin-system-monitor-main/wm/wm_window_list.cpp index 2c081930..87ff2f0c 100644 --- a/deepin-system-monitor-main/wm/wm_window_list.cpp +++ b/deepin-system-monitor-main/wm/wm_window_list.cpp @@ -36,6 +36,16 @@ 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) { @@ -267,9 +277,9 @@ QString WMWindowList::getWindowTitle(pid_t pid) const QList WMWindowList::getTrayWindows() const { - QDBusInterface busInterface("org.deepin.dde.TrayManager1", "/org/deepin/dde/TrayManager1", - "org.freedesktop.DBus.Properties", QDBusConnection::sessionBus()); - QDBusMessage reply = busInterface.call("Get", "org.deepin.dde.TrayManager1", "TrayIcons"); + QDBusInterface busInterface(TrayManagerService, TrayManagerPath, + TrayManagerInterface, QDBusConnection::sessionBus()); + QDBusMessage reply = busInterface.call("Get", TrayManagerService, "TrayIcons"); QVariant v = reply.arguments().first(); const QDBusArgument &argument = v.value().variant().value(); diff --git a/deepin-system-monitor-plugin-popup/CMakeLists.txt b/deepin-system-monitor-plugin-popup/CMakeLists.txt index 0c6a57d4..3a46cfaa 100644 --- a/deepin-system-monitor-plugin-popup/CMakeLists.txt +++ b/deepin-system-monitor-plugin-popup/CMakeLists.txt @@ -304,6 +304,7 @@ target_link_libraries(${PROJECT_NAME} # gsettings-qt ) + #生成qm file(GLOB APP_TS_FILES LIST_DIRECTORIES false translations/*.ts) qt5_add_translation(APP_QM_FILES ${APP_TS_FILES}) diff --git a/deepin-system-monitor-plugin-popup/dbus/dbusdockinterface.cpp b/deepin-system-monitor-plugin-popup/dbus/dbusdockinterface.cpp index 0c46766f..07c86e57 100644 --- a/deepin-system-monitor-plugin-popup/dbus/dbusdockinterface.cpp +++ b/deepin-system-monitor-plugin-popup/dbus/dbusdockinterface.cpp @@ -10,9 +10,9 @@ */ DBusDockInterface::DBusDockInterface(QObject *parent) - : QDBusAbstractInterface("org.deepin.dde.Dock1", "/org/deepin/dde/Dock1", staticInterfaceName(), QDBusConnection::sessionBus(), parent) + : QDBusAbstractInterface(DockService, DockPath, staticInterfaceName(), QDBusConnection::sessionBus(), parent) { - QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage))); + QDBusConnection::sessionBus().connect(this->service(), this->path(), DockInterface, "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage))); } DBusDockInterface::~DBusDockInterface() diff --git a/deepin-system-monitor-plugin-popup/dbus/dbusdockinterface.h b/deepin-system-monitor-plugin-popup/dbus/dbusdockinterface.h index b29399c8..6be59622 100644 --- a/deepin-system-monitor-plugin-popup/dbus/dbusdockinterface.h +++ b/deepin-system-monitor-plugin-popup/dbus/dbusdockinterface.h @@ -14,6 +14,17 @@ #include #include #include + +#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 */ @@ -27,7 +38,7 @@ class DBusDockInterface: public QDBusAbstractInterface if (3 != arguments.count()) return; QString interfaceName = msg.arguments().at(0).toString(); - if (interfaceName != "org.deepin.dde.Dock1") + if (interfaceName != DockService) return; QVariantMap changedProps = qdbus_cast(arguments.at(1).value()); foreach(const QString &prop, changedProps.keys()) { @@ -42,7 +53,7 @@ class DBusDockInterface: public QDBusAbstractInterface } public: static inline const char *staticInterfaceName() - { return "org.deepin.dde.Dock1"; } + { return DockService.toStdString().c_str(); } public: explicit DBusDockInterface( QObject *parent = nullptr); diff --git a/deepin-system-monitor-plugin-popup/gui/mainwindow.cpp b/deepin-system-monitor-plugin-popup/gui/mainwindow.cpp index 055b1306..0325a4f5 100644 --- a/deepin-system-monitor-plugin-popup/gui/mainwindow.cpp +++ b/deepin-system-monitor-plugin-popup/gui/mainwindow.cpp @@ -33,7 +33,30 @@ #define DOCK_BOTTOM 2 #define DOCK_LEFT 3 +#ifdef OS_BUILD_V23 #define MONITOR_SERVICE "org.deepin.dde.XEventMonitor1" + +#define DISPLAY_SERVICE "org.deepin.dde.Display1" +#define DISPLAY_PATH "/org/deepin/dde/Display1" +#define DISPLAY_INTERFACE "org.deepin.dde.Display1" +#define DISPLAYMONITOR_INTERFACE "org.deepin.dde.Display1.Monitor" + +#define DOCK_SERVICE "org.deepin.dde.daemon.Dock1" +#define DOCK_PATH "/org/deepin/dde/daemon/Dock1" +#define DOCK_INTERFACE "org.deepin.dde.daemon.Dock1" +#else +#define MONITOR_SERVICE "com.deepin.api.XEventMonitor" + +#define DISPLAY_SERVICE "com.deepin.daemon.Display" +#define DISPLAY_PATH "/com/deepin/daemon/Display" +#define DISPLAY_INTERFACE "com.deepin.daemon.Display" +#define DISPLAYMONITOR_INTERFACE "com.deepin.daemon.Display.Monitor" + +#define DOCK_SERVICE "com.deepin.dde.daemon.Dock" +#define DOCK_PATH "/com/deepin/dde/daemon/Dock" +#define DOCK_INTERFACE "com.deepin.dde.daemon.Dock" +#endif + #define SCREEN_HEIGHT_MAX 1080 #define NOT_USE_QUIT_TIME_INTERVAL 5*60*1000 @@ -43,8 +66,14 @@ const QString KILL_DBUS_COMMAND = "killall deepin-system-monitor-plugin-popup"; MainWindow::MainWindow(QWidget *parent) : DBlurEffectWidget(parent) - , m_displayInter(new QDBusInterface("org.deepin.dde.Display1", "/org/deepin/dde/Display1","org.deepin.dde.Display1", QDBusConnection::sessionBus(), this)) - , m_daemonDockInter(new QDBusInterface("org.deepin.dde.daemon.Dock1", "/org/deepin/dde/daemon/Dock1", "org.deepin.dde.daemon.Dock1",QDBusConnection::sessionBus(), this)) + , m_displayInter(new QDBusInterface(DISPLAY_SERVICE, + DISPLAY_PATH, + DISPLAY_INTERFACE, + QDBusConnection::sessionBus(), this)) + , m_daemonDockInter(new QDBusInterface(DOCK_SERVICE, + DOCK_PATH, + DOCK_INTERFACE, + QDBusConnection::sessionBus(), this)) , m_dockInter(new DBusDockInterface) , m_systemMonitorDbusAdaptor(new SystemMonitorDBusAdaptor) , m_regionMonitor(nullptr) @@ -64,9 +93,10 @@ MainWindow::MainWindow(QWidget *parent) if(m_displayInter->isValid()){ auto ss = m_displayInter->property("Monitors"); - QDBusInterface busInterface("org.deepin.dde.Display1", "/org/deepin/dde/Display1", + QDBusInterface busInterface(DISPLAY_SERVICE, + DISPLAY_PATH, "org.freedesktop.DBus.Properties", QDBusConnection::sessionBus()); - QDBusMessage reply = busInterface.call("Get", "org.deepin.dde.Display1", "Monitors"); + QDBusMessage reply = busInterface.call("Get", DISPLAY_INTERFACE, "Monitors"); QVariant v = reply.arguments().first(); const QDBusArgument &argument = v.value().variant().value(); while (!argument.atEnd()) { @@ -388,9 +418,10 @@ void MainWindow::changeTheme(DApplicationHelper::ColorType themeType) void MainWindow::dbusPropertiesChanged(QString interface, QVariantMap maps, QStringList strs) { - if((interface == "org.deepin.dde.Display1" && maps.contains("PrimaryRect")) || (interface == "org.deepin.dde.daemon.Dock1" && (maps.contains("Position") || maps.contains("DisplayMode")))){ + if((interface == DISPLAY_INTERFACE && maps.contains("PrimaryRect")) || + (interface == DOCK_INTERFACE && (maps.contains("Position") || maps.contains("DisplayMode")))){ geometryChanged(); - } else if(m_daemonDockInter->isValid() && interface == "org.deepin.dde.daemon.Dock1" && maps.contains("Opacity")){ + } else if(m_daemonDockInter->isValid() && interface == DOCK_INTERFACE && maps.contains("Opacity")){ this->setMaskAlpha(static_cast(m_daemonDockInter->property("Opacity").toDouble() * 255)); } } @@ -502,7 +533,7 @@ QRect MainWindow::getDisplayScreen() { QRect dockRect = m_dockInter->geometry(); for (const auto &monitorPath : m_dbusPathList) { - QDBusInterface monitor("org.deepin.dde.Display1", monitorPath.path(), "org.deepin.dde.Display1.Monitor",QDBusConnection::sessionBus()); + QDBusInterface monitor(DISPLAY_INTERFACE, monitorPath.path(), DISPLAYMONITOR_INTERFACE,QDBusConnection::sessionBus()); if(monitor.isValid()){ int curX = m_displayInter->property("X").toInt(); int curY = m_displayInter->property("X").toInt(); @@ -514,9 +545,9 @@ QRect MainWindow::getDisplayScreen() } } if(m_displayInter->isValid()){ - QDBusInterface busInterface("org.deepin.dde.Display1", "/org/deepin/dde/Display1", + QDBusInterface busInterface(DISPLAY_SERVICE, DISPLAY_PATH, "org.freedesktop.DBus.Properties", QDBusConnection::sessionBus()); - QDBusMessage reply = busInterface.call("Get", "org.deepin.dde.Display1", "PrimaryRect"); + QDBusMessage reply = busInterface.call("Get", DISPLAY_INTERFACE, "PrimaryRect"); QVariant v = reply.arguments().first(); const QDBusArgument &argument = v.value().variant().value(); diff --git a/deepin-system-monitor-plugin/gui/monitor_plugin.cpp b/deepin-system-monitor-plugin/gui/monitor_plugin.cpp index 4c4d8df1..18420090 100644 --- a/deepin-system-monitor-plugin/gui/monitor_plugin.cpp +++ b/deepin-system-monitor-plugin/gui/monitor_plugin.cpp @@ -67,15 +67,36 @@ void MonitorPlugin::init(PluginProxyInterface *proxyInter) QWidget *MonitorPlugin::itemWidget(const QString &itemKey) { +#ifdef OS_BUILD_V23 // if (itemKey == "system-monitor") // return m_itemWidget; +#else + if (itemKey == "system-monitor") + return m_itemWidget; +#endif return nullptr; } void MonitorPlugin::pluginStateSwitched() { +#ifdef OS_BUILD_V23 +#else + bool pluginState = !m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, false).toBool(); + m_proxyInter->saveValue(this, constantVal::PLUGIN_STATE_KEY, pluginState); + + refreshPluginItemsVisible(); +#endif +} + +#ifdef OS_BUILD_V23 + +#else +bool MonitorPlugin::pluginIsDisable() +{ + return !m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, false).toBool(); } +#endif QWidget *MonitorPlugin::itemTipsWidget(const QString &itemKey) { @@ -150,6 +171,7 @@ void MonitorPlugin::invokedMenuItem(const QString &itemKey, const QString &menuI } } +#ifdef OS_BUILD_V23 QIcon MonitorPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType) { QString iconName = "dsm_pluginicon_light"; @@ -186,6 +208,7 @@ QIcon MonitorPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::Color } return icon; } +#endif void MonitorPlugin::udpateTipsInfo() { @@ -243,7 +266,17 @@ void MonitorPlugin::loadPlugin() m_itemWidget = new MonitorPluginButtonWidget; if (!m_isFirstInstall) { +#ifdef OS_BUILD_V23 m_proxyInter->itemAdded(this, pluginName()); +#else + // 非初始状态 + if (m_proxyInter->getValue(this, constantVal::PLUGIN_STATE_KEY, true).toBool()) { + m_proxyInter->itemAdded(this, pluginName()); + } else { + m_proxyInter->saveValue(this, constantVal::PLUGIN_STATE_KEY, false); + m_proxyInter->itemRemoved(this, pluginName()); + } +#endif } else { m_proxyInter->saveValue(this, constantVal::PLUGIN_STATE_KEY, false); m_proxyInter->itemRemoved(this, pluginName()); @@ -251,6 +284,22 @@ void MonitorPlugin::loadPlugin() displayModeChanged(displayMode()); } +#ifdef OS_BUILD_V23 + +#else +void MonitorPlugin::refreshPluginItemsVisible() +{ + if (pluginIsDisable()) { + m_proxyInter->itemRemoved(this, pluginName()); + } else { + if (!m_pluginLoaded) { + loadPlugin(); + return; + } + m_proxyInter->itemAdded(this, pluginName()); + } +} +#endif void MonitorPlugin::initPluginState() { diff --git a/deepin-system-monitor-plugin/gui/monitor_plugin.h b/deepin-system-monitor-plugin/gui/monitor_plugin.h index 1e10dfc8..ecae67a0 100644 --- a/deepin-system-monitor-plugin/gui/monitor_plugin.h +++ b/deepin-system-monitor-plugin/gui/monitor_plugin.h @@ -81,6 +81,21 @@ class MonitorPlugin : public QObject, PluginsItemInterface //! \brief pluginStateSwitched 当插件的禁用状态被用户改变时此接口被调用 //! void pluginStateSwitched() Q_DECL_OVERRIDE; +#ifdef OS_BUILD_V23 + +#else + //! + //! \brief pluginIsAllowDisable 返回插件是否允许被禁用(默认不允许被禁用) + //! \return + //! + bool pluginIsAllowDisable() Q_DECL_OVERRIDE { return true; } + + //! + //! \brief pluginIsDisable 返回插件当前是否处于被禁用的状态 + //! \return + //! + bool pluginIsDisable() Q_DECL_OVERRIDE; +#endif //! //! \brief itemTipsWidget 返回鼠标悬浮在插件主控件上时显示的提示框控件 @@ -131,11 +146,13 @@ class MonitorPlugin : public QObject, PluginsItemInterface //! void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) Q_DECL_OVERRIDE; +#ifdef OS_BUILD_V23 /// /// the icon for the plugin /// themeType {0:UnknownType 1:LightType 2:DarkType} /// QIcon icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType()) Q_DECL_OVERRIDE; +#endif private slots: @@ -149,7 +166,14 @@ private slots: //! \brief loadPlugin 加载插件 //! void loadPlugin(); +#ifdef OS_BUILD_V23 +#else + //! + //! \brief refreshPluginItemsVisible 刷新插件项显示隐藏 + //! + void refreshPluginItemsVisible(); +#endif //! //! \brief initPluginState 初始化插件状态 //!