diff --git a/.gitignore b/.gitignore index 83359cd3..a6b55000 100755 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build/ *.user.* .vscode/* .directory +config.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fb608b1..1c2022c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,16 @@ if (${XDGTYPE} MATCHES "wayland") else() SET(WAYLAND_SESSION_TYPE 0) endif() + +#判断龙芯架构 +if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips64") + SET(IS_LOONGARCH_TYPE 1) +elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "__longarch64") + SET(NOT_LOONGARCH_TYPE ) +else() + SET(IS_LOONGARCH_TYPE 0) +endif() + #系统监视器主应用 ADD_SUBDIRECTORY(deepin-system-monitor-main) #系统监视器插件 @@ -44,3 +54,4 @@ ADD_SUBDIRECTORY(deepin-system-monitor-daemon) #单元测试 ADD_SUBDIRECTORY(tests) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h) diff --git a/deepin-system-monitor-main/config.h.in b/config.h.in similarity index 96% rename from deepin-system-monitor-main/config.h.in rename to config.h.in index aeaf210a..8a562569 100644 --- a/deepin-system-monitor-main/config.h.in +++ b/config.h.in @@ -20,3 +20,4 @@ #cmakedefine HAVE_SYS_CALL 1 #cmakedefine HAVE_SYS_GETRANDOM 1 #cmakedefine WAYLAND_SESSION_TYPE +#cmakedefine IS_LOONGARCH_TYPE \ No newline at end of file diff --git a/deepin-system-monitor-main/CMakeLists.txt b/deepin-system-monitor-main/CMakeLists.txt index f2d85ef0..ab3b73ae 100644 --- a/deepin-system-monitor-main/CMakeLists.txt +++ b/deepin-system-monitor-main/CMakeLists.txt @@ -31,7 +31,6 @@ check_include_files ("sys/random.h" HAVE_SYS_RANDOM_H) include(CheckSymbolExists) check_symbol_exists(syscall "unistd.h" HAVE_SYS_CALL) check_symbol_exists(SYS_getrandom "sys/syscall.h" HAVE_SYS_GETRANDOM) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) include(FindPkgConfig) find_package(KF5Wayland) @@ -62,10 +61,9 @@ include_directories(${LIB_UDEV_INCLUDE_DIRS}) 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}/../) set(HPP_GLOBAL - config.h environments.h accessible.h accessibledefine.h @@ -128,6 +126,7 @@ set(HPP_DBUS dbus/unit_file_info.h dbus/unit_info.h dbus/dbusforsystemomonitorpluginservce.h + dbus/dbus_object.h ) set(CPP_DBUS dbus/environment_file.cpp @@ -138,6 +137,7 @@ set(CPP_DBUS dbus/systemd1_unit_interface.cpp dbus/dbus_properties_interface.cpp dbus/dbusforsystemomonitorpluginservce.cpp + dbus/dbus_object.cpp ) set(HPP_MODEL @@ -492,6 +492,7 @@ set(LSCPU_INCLUDE ) set(APP_HPP + ${CMAKE_HOME_DIRECTORY}/config.h ${HPP_GLOBAL} ${HPP_COMMON} ${HPP_DBUS} diff --git a/deepin-system-monitor-main/common/common.cpp b/deepin-system-monitor-main/common/common.cpp index 06d882e0..9d175893 100644 --- a/deepin-system-monitor-main/common/common.cpp +++ b/deepin-system-monitor-main/common/common.cpp @@ -345,11 +345,9 @@ QString format::formatUnit(QVariant size, format::SizeUnit base, int prec, bool if (isSpeed) { return QString("%1 %2%3").arg(v, 0, 'f', prec).arg(UnitSuffixExt[u]).arg("/s"); - } else { - //return QString("%1 %2").arg(v, 0, 'f', prec).arg(UnitSuffix[u]); - //统一单位 - return QString("%1 %2").arg(v, 0, 'f', prec).arg(UnitSuffixExt[u]); } + //统一单位 + return QString("%1 %2").arg(v, 0, 'f', prec).arg(UnitSuffixExt[u]); } // ::format::formatUnit diff --git a/deepin-system-monitor-main/dbus/dbus_object.cpp b/deepin-system-monitor-main/dbus/dbus_object.cpp new file mode 100644 index 00000000..a67d15e0 --- /dev/null +++ b/deepin-system-monitor-main/dbus/dbus_object.cpp @@ -0,0 +1,85 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: yukuan +* Maintainer: yukuan +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ +#include "dbus_object.h" +#include "gui/main_window.h" +#include "application.h" + +#include +#include + +#define DBUS_SERVER "com.deepin.systemMonitor" +#define DBUS_SERVER_PATH "/com/deepin/systemMonitor" + +QMutex DBusObject::mutex; +QAtomicPointer DBusObject::instance; + +DBusObject &DBusObject::getInstance() +{ + if (instance.testAndSetOrdered(nullptr, nullptr)) + { + QMutexLocker locker(&mutex); + + instance.testAndSetOrdered(nullptr, new DBusObject); + } + return *instance; +} + +bool DBusObject::registerOrNotify() +{ + QDBusConnection dbus = QDBusConnection::sessionBus(); + if (!dbus.registerService(DBUS_SERVER)) { + QDBusInterface notification(DBUS_SERVER, DBUS_SERVER_PATH, DBUS_SERVER, QDBusConnection::sessionBus()); + QList args; + QString error = notification.callWithArgumentList(QDBus::Block, "handleWindow", args).errorMessage(); + if (!error.isEmpty()) + qInfo() << error; + return false; + } + + dbus.registerObject(DBUS_SERVER_PATH, this, QDBusConnection::ExportScriptableSlots); + + return true; +} + +void DBusObject::unRegister() +{ + internalMutex.lockForRead(); + QDBusConnection dbus = QDBusConnection::sessionBus(); + dbus.unregisterService(DBUS_SERVER); + internalMutex.unlock(); +} + +void DBusObject::handleWindow() +{ + internalMutex.lockForRead(); + MainWindow *mw = gApp->mainWindow(); + mw->setWindowState((mw->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); + internalMutex.unlock(); +} + +DBusObject::DBusObject(QObject *parent) : QObject(parent) +{ + +} + +DBusObject::~DBusObject() +{ + +} diff --git a/deepin-system-monitor-main/dbus/dbus_object.h b/deepin-system-monitor-main/dbus/dbus_object.h new file mode 100644 index 00000000..57472411 --- /dev/null +++ b/deepin-system-monitor-main/dbus/dbus_object.h @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: yukuan +* Maintainer: yukuan +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ +#ifndef DBUS_OBJECT_H +#define DBUS_OBJECT_H + + +#include +#include +#include +#include +#include +#include + +class DBusObject : public QObject +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.deepin.systemMonitor") +public: + static DBusObject &getInstance(); + + /** + * @brief registerOrNotify + * 注册服务,成功返回true,如果失败则通知已经存在的服务并返回false + * @return + */ + bool registerOrNotify(); + + /** + * @brief unRegister + * 反注册,当应用准备销毁时调用 + */ + void unRegister(); + + +public slots: + /** + * @brief handleWindow + * 接收DBus激活窗口响应接口 + */ + Q_SCRIPTABLE void handleWindow(); + +private: + DBusObject(QObject *parent = nullptr); + ~DBusObject(); + DBusObject(const DBusObject &) = delete; + DBusObject &operator=(const DBusObject &) = delete; + +private: + QReadWriteLock internalMutex; + static QMutex mutex; + static QAtomicPointer instance; +}; + +#endif // DBUS_OBJECT_H diff --git a/deepin-system-monitor-main/gui/base/base_detail_view_widget.h b/deepin-system-monitor-main/gui/base/base_detail_view_widget.h index b6cc98b6..7743d667 100644 --- a/deepin-system-monitor-main/gui/base/base_detail_view_widget.h +++ b/deepin-system-monitor-main/gui/base/base_detail_view_widget.h @@ -82,8 +82,8 @@ public slots: // 切换多核显示或单CPU显示 按钮 Dtk::Widget::DIconButton *m_switchButton; // 切换按钮图片 - QIcon *m_switchIconLight; - QIcon *m_switchIconDark; + QIcon *m_switchIconLight {}; + QIcon *m_switchIconDark {}; // 当前是否为多核模式 bool m_isMultiCoreMode = false; 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 0e9989f9..d0dc3d8e 100644 --- a/deepin-system-monitor-main/gui/xwin_kill_preview_widget.cpp +++ b/deepin-system-monitor-main/gui/xwin_kill_preview_widget.cpp @@ -101,9 +101,7 @@ void XWinKillPreviewWidget::mousePressEvent(QMouseEvent *event) it!=m_windowStates.end();++it) { // if the window is created by ourself, then ignore it qDebug()<pid; - if (getpid() == it->pid || QString::fromStdString(it->resourceName)=="dde-desktop" || - QString::fromStdString(it->resourceName) == "deepin-system-monitor"|| - QString::fromStdString(it->resourceName)=="qtcreator") + if (getpid() == it->pid || QString::fromStdString(it->resourceName)=="dde-desktop") continue; // if such window exists, we emit window clicked signal to notify kill application performed action @@ -173,9 +171,7 @@ void XWinKillPreviewWidget::mouseMoveEvent(QMouseEvent *) for (QVector::iterator it=m_windowStates.begin(); it!=m_windowStates.end();++it) { // if the window is created by ourself, then ignore it - if (getpid() == it->pid|| QString::fromStdString(it->resourceName)=="dde-desktop" || - QString::fromStdString(it->resourceName) == "deepin-system-monitor"|| - QString::fromStdString(it->resourceName)=="qtcreator") + if (getpid() == it->pid|| QString::fromStdString(it->resourceName)=="dde-desktop") continue; auto selRect = QRect(static_cast(it->geometry.x / x), static_cast(it ->geometry.y / x), static_cast(it->geometry.width / x), static_cast(it->geometry.height/ x)); 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 9f29c69e..9c8799da 100644 --- a/deepin-system-monitor-main/gui/xwin_kill_preview_widget.h +++ b/deepin-system-monitor-main/gui/xwin_kill_preview_widget.h @@ -20,7 +20,7 @@ #ifndef XWIN_KILL_PREVIEW_WIDGET_H #define XWIN_KILL_PREVIEW_WIDGET_H -#include "config.h" +#include "../config.h" #include #ifdef WAYLAND_SESSION_TYPE #include diff --git a/deepin-system-monitor-main/main.cpp b/deepin-system-monitor-main/main.cpp index e027d09b..de45ee7e 100644 --- a/deepin-system-monitor-main/main.cpp +++ b/deepin-system-monitor-main/main.cpp @@ -23,6 +23,7 @@ #include "settings.h" #include "gui/main_window.h" #include "common/perf.h" +#include "dbus/dbus_object.h" #include #include @@ -42,6 +43,9 @@ using namespace common::init; int main(int argc, char *argv[]) { + //=======通知已经打开的进程 + if (!DBusObject::getInstance().registerOrNotify()) + return 0; //Judge if Wayland WaylandSearchCentered(); // diff --git a/deepin-system-monitor-plugin-popup/CMakeLists.txt b/deepin-system-monitor-plugin-popup/CMakeLists.txt index 77485bab..cd840743 100644 --- a/deepin-system-monitor-plugin-popup/CMakeLists.txt +++ b/deepin-system-monitor-plugin-popup/CMakeLists.txt @@ -29,7 +29,6 @@ check_include_files("sys/random.h" HAVE_SYS_RANDOM_H) include(CheckSymbolExists) check_symbol_exists(syscall "unistd.h" HAVE_SYS_CALL) check_symbol_exists(SYS_getrandom "sys/syscall.h" HAVE_SYS_CALL) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) include(FindPkgConfig) find_package(Qt5 COMPONENTS Core REQUIRED) @@ -67,6 +66,7 @@ include_directories(${LIB_UDEV_INCLUDE_DIRS}) #include_directories(${QGSettings_INCLUDE_DIRS}) include_directories(${MAIN_APP_DIR}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../) FILE(GLOB_RECURSE SRCS "*.h" "*.cpp") @@ -238,6 +238,7 @@ SET(CPP_PROCESS ${MAIN_APP_DIR}/process/process_controller.cpp ) set(APP_HPP + ${CMAKE_HOME_DIRECTORY}/config.h application.h ${HPP_MODEL} ${HPP_SYSTEM} diff --git a/deepin-system-monitor-plugin-popup/config.h.in b/deepin-system-monitor-plugin-popup/config.h.in deleted file mode 100644 index 9dd1e432..00000000 --- a/deepin-system-monitor-plugin-popup/config.h.in +++ /dev/null @@ -1,21 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd -* -* Author: maojj -* Maintainer: maojj -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* any later version. -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#cmakedefine HAVE_SYS_RANDOM_H 1 -#cmakedefine HAVE_SYS_CALL 1 -#cmakedefine HAVE_SYS_GETRANDOM 1 diff --git a/deepin-system-monitor-plugin-popup/gui/cpu_widget.cpp b/deepin-system-monitor-plugin-popup/gui/cpu_widget.cpp index 6adc81c4..675adeae 100644 --- a/deepin-system-monitor-plugin-popup/gui/cpu_widget.cpp +++ b/deepin-system-monitor-plugin-popup/gui/cpu_widget.cpp @@ -267,14 +267,13 @@ bool CpuWidget::eventFilter(QObject *target, QEvent *event) return QWidget::eventFilter(target, event); } -void CpuWidget::mousePressEvent(QMouseEvent *event) +void CpuWidget::mouseDoubleClickEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - if (event->type() == QMouseEvent::MouseButtonDblClick) { - DataDealSingleton::getInstance().sendJumpWidgetMessage("MSG_CPU"); - } + DataDealSingleton::getInstance().sendJumpWidgetMessage("MSG_CPU"); + return; } - return QWidget::mousePressEvent(event); + return QWidget::mouseDoubleClickEvent(event); } void CpuWidget::changeFont(const QFont &font) diff --git a/deepin-system-monitor-plugin-popup/gui/cpu_widget.h b/deepin-system-monitor-plugin-popup/gui/cpu_widget.h index 763d92e2..1b2f382f 100644 --- a/deepin-system-monitor-plugin-popup/gui/cpu_widget.h +++ b/deepin-system-monitor-plugin-popup/gui/cpu_widget.h @@ -45,10 +45,10 @@ public slots: bool eventFilter(QObject *target, QEvent *event) override; //! - //! \brief mousePressEvent 鼠标压下事件,唤醒系统监视器主进程,并跳转到CPU详情界面 + //! \brief mouseDoubleClickEvent 鼠标压下事件,唤醒系统监视器主进程,并跳转到CPU详情界面 //! \param event //! - void mousePressEvent(QMouseEvent *event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; private: void initConnection(); diff --git a/deepin-system-monitor-plugin-popup/gui/datadealsingleton.cpp b/deepin-system-monitor-plugin-popup/gui/datadealsingleton.cpp index 8192b0ef..ce2f724b 100644 --- a/deepin-system-monitor-plugin-popup/gui/datadealsingleton.cpp +++ b/deepin-system-monitor-plugin-popup/gui/datadealsingleton.cpp @@ -29,10 +29,17 @@ #include "system/block_device_info_db.h" #include "common/datacommon.h" #include "dbus/dbuscallmaininterface.h" +#include "config.h" //Qt #include +#ifdef IS_LOONGARCH_TYPE +#define POPUP_WAITING_TIME 1000 +#else +#define POPUP_WAITING_TIME 500 +#endif + QMutex DataDealSingleton::mutex; QAtomicPointer DataDealSingleton::instance; @@ -110,11 +117,16 @@ bool DataDealSingleton::readDiskInfo(QString &diskRead, QString &diskTotalSize, bool DataDealSingleton::sendJumpWidgetMessage(const QString &dbusMessage) { + //1000ms内重复点击,不响应 + if (m_popupTrickTimer->isActive()) { + return false; + } + m_popupTrickTimer->start(); //1.先唤醒主进程 bool rt = QProcess::startDetached(Globals::DEEPIN_SYSTEM_MONITOR_PATH); if (true == rt) { //2.跳转DBUS - QTimer::singleShot(500, this, [=]() { + QTimer::singleShot(POPUP_WAITING_TIME, this, [=]() { DbusCallMainInterface::getInstance()->jumpWidget(dbusMessage); }); } @@ -123,7 +135,11 @@ bool DataDealSingleton::sendJumpWidgetMessage(const QString &dbusMessage) DataDealSingleton::DataDealSingleton(QObject *parent) :QObject (parent) -{ + , m_popupTrickTimer(new QTimer(this)) + { + m_popupTrickTimer->setInterval(1000); + m_popupTrickTimer->setSingleShot(true); + connect(SystemMonitor::instance(), &SystemMonitor::statInfoUpdated, this, &DataDealSingleton::sigDataUpdate); } diff --git a/deepin-system-monitor-plugin-popup/gui/datadealsingleton.h b/deepin-system-monitor-plugin-popup/gui/datadealsingleton.h index 9f46b913..808722ec 100644 --- a/deepin-system-monitor-plugin-popup/gui/datadealsingleton.h +++ b/deepin-system-monitor-plugin-popup/gui/datadealsingleton.h @@ -23,6 +23,7 @@ #include #include #include +#include class CPUInfoModel; @@ -92,6 +93,9 @@ class DataDealSingleton : public QObject static QMutex mutex; static QAtomicPointer instance; + + //防止300ms内重复按键 + QTimer* m_popupTrickTimer; }; #endif // DATADEALSINGLETON_H diff --git a/deepin-system-monitor-plugin-popup/gui/disk_widget.cpp b/deepin-system-monitor-plugin-popup/gui/disk_widget.cpp index 456dbed3..724e242a 100644 --- a/deepin-system-monitor-plugin-popup/gui/disk_widget.cpp +++ b/deepin-system-monitor-plugin-popup/gui/disk_widget.cpp @@ -377,14 +377,13 @@ bool DiskWidget::eventFilter(QObject *target, QEvent *event) return QWidget::eventFilter(target, event); } -void DiskWidget::mousePressEvent(QMouseEvent *event) +void DiskWidget::mouseDoubleClickEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - if (event->type() == QMouseEvent::MouseButtonDblClick) { - DataDealSingleton::getInstance().sendJumpWidgetMessage("MSG_DISK"); - } + DataDealSingleton::getInstance().sendJumpWidgetMessage("MSG_DISK"); + return; } - return QWidget::mousePressEvent(event); + return QWidget::mouseDoubleClickEvent(event); } void DiskWidget::changeFont(const QFont &font) diff --git a/deepin-system-monitor-plugin-popup/gui/disk_widget.h b/deepin-system-monitor-plugin-popup/gui/disk_widget.h index 8571a8c3..7b5cb880 100644 --- a/deepin-system-monitor-plugin-popup/gui/disk_widget.h +++ b/deepin-system-monitor-plugin-popup/gui/disk_widget.h @@ -42,9 +42,11 @@ public slots: void paintEvent(QPaintEvent *event) override; bool eventFilter(QObject *target, QEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; - - + //! + //! \brief mouseDoubleClickEvent 鼠标压下事件,唤醒系统监视器主进程,并跳转到CPU详情界面 + //! \param event + //! + void mouseDoubleClickEvent(QMouseEvent *event) override; private: void changeTheme(DApplicationHelper::ColorType themeType); diff --git a/deepin-system-monitor-plugin-popup/gui/mainwindow.h b/deepin-system-monitor-plugin-popup/gui/mainwindow.h index 0b78ae48..c69c6704 100644 --- a/deepin-system-monitor-plugin-popup/gui/mainwindow.h +++ b/deepin-system-monitor-plugin-popup/gui/mainwindow.h @@ -193,9 +193,9 @@ private slots: DiskWidget *m_diskWidget {}; MemoryWidget *m_memoryWidget {}; ProcessWidget *m_processWidget{}; - DScrollArea *m_scrollArea; + DScrollArea *m_scrollArea {}; // 滚动区域 - // 防止300ms内重复按键 + // 防止1000ms内重复按键 QTimer* m_trickTimer; //最近一次拖动的距离 int m_last_time_move = 0; diff --git a/deepin-system-monitor-plugin-popup/gui/memory_widget.cpp b/deepin-system-monitor-plugin-popup/gui/memory_widget.cpp index c8b4167a..9aaccbc7 100644 --- a/deepin-system-monitor-plugin-popup/gui/memory_widget.cpp +++ b/deepin-system-monitor-plugin-popup/gui/memory_widget.cpp @@ -311,14 +311,13 @@ bool MemoryWidget::eventFilter(QObject *target, QEvent *event) return QWidget::eventFilter(target, event); } -void MemoryWidget::mousePressEvent(QMouseEvent *event) +void MemoryWidget::mouseDoubleClickEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - if (event->type() == QMouseEvent::MouseButtonDblClick) { - DataDealSingleton::getInstance().sendJumpWidgetMessage("MSG_MEM"); - } + DataDealSingleton::getInstance().sendJumpWidgetMessage("MSG_MEM"); + return; } - return QWidget::mousePressEvent(event); + return QWidget::mouseDoubleClickEvent(event); } void MemoryWidget::changeFont(const QFont &font) diff --git a/deepin-system-monitor-plugin-popup/gui/memory_widget.h b/deepin-system-monitor-plugin-popup/gui/memory_widget.h index 57300bdb..7996a280 100644 --- a/deepin-system-monitor-plugin-popup/gui/memory_widget.h +++ b/deepin-system-monitor-plugin-popup/gui/memory_widget.h @@ -43,7 +43,11 @@ public slots: void paintEvent(QPaintEvent *event) override; bool eventFilter(QObject *target, QEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; + //! + //! \brief mouseDoubleClickEvent 鼠标压下事件,唤醒系统监视器主进程,并跳转到CPU详情界面 + //! \param event + //! + void mouseDoubleClickEvent(QMouseEvent *event) override; private: void changeTheme(DApplicationHelper::ColorType themeType); diff --git a/deepin-system-monitor-plugin-popup/gui/net_widget.cpp b/deepin-system-monitor-plugin-popup/gui/net_widget.cpp index 44bf5e94..4c5e1538 100644 --- a/deepin-system-monitor-plugin-popup/gui/net_widget.cpp +++ b/deepin-system-monitor-plugin-popup/gui/net_widget.cpp @@ -404,14 +404,13 @@ bool NetWidget::eventFilter(QObject *target, QEvent *event) return QWidget::eventFilter(target, event); } -void NetWidget::mousePressEvent(QMouseEvent *event) +void NetWidget::mouseDoubleClickEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - if (event->type() == QMouseEvent::MouseButtonDblClick) { - DataDealSingleton::getInstance().sendJumpWidgetMessage("MSG_NET"); - } + DataDealSingleton::getInstance().sendJumpWidgetMessage("MSG_NET"); + return; } - return QWidget::mousePressEvent(event); + return QWidget::mouseDoubleClickEvent(event); } void NetWidget::changeFont(const QFont &font) diff --git a/deepin-system-monitor-plugin-popup/gui/net_widget.h b/deepin-system-monitor-plugin-popup/gui/net_widget.h index 3dad28a9..282dc8d9 100644 --- a/deepin-system-monitor-plugin-popup/gui/net_widget.h +++ b/deepin-system-monitor-plugin-popup/gui/net_widget.h @@ -43,7 +43,11 @@ public slots: void paintEvent(QPaintEvent *event) override; bool eventFilter(QObject *target, QEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; + //! + //! \brief mouseDoubleClickEvent 鼠标压下事件,唤醒系统监视器主进程,并跳转到CPU详情界面 + //! \param event + //! + void mouseDoubleClickEvent(QMouseEvent *event) override; private: void initConnection(); diff --git a/deepin-system-monitor-plugin-popup/gui/process_widget.cpp b/deepin-system-monitor-plugin-popup/gui/process_widget.cpp index bd25fe4f..1f73589a 100644 --- a/deepin-system-monitor-plugin-popup/gui/process_widget.cpp +++ b/deepin-system-monitor-plugin-popup/gui/process_widget.cpp @@ -225,14 +225,13 @@ bool ProcessWidget::eventFilter(QObject *target, QEvent *event) return QWidget::eventFilter(target, event); } -void ProcessWidget::mousePressEvent(QMouseEvent *event) +void ProcessWidget::mouseDoubleClickEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - if (event->type() == QEvent::MouseButtonDblClick) { - DataDealSingleton::getInstance().sendJumpWidgetMessage("MSG_PROCESS"); - } + DataDealSingleton::getInstance().sendJumpWidgetMessage("MSG_PROCESS"); + return; } - return QWidget::mousePressEvent(event); + return QWidget::mouseDoubleClickEvent(event); } void ProcessWidget::changeFont(const QFont &font) diff --git a/deepin-system-monitor-plugin-popup/gui/process_widget.h b/deepin-system-monitor-plugin-popup/gui/process_widget.h index 366528b6..09a47e13 100644 --- a/deepin-system-monitor-plugin-popup/gui/process_widget.h +++ b/deepin-system-monitor-plugin-popup/gui/process_widget.h @@ -34,7 +34,7 @@ class ProcessWidget : public QWidget public: explicit ProcessWidget(QWidget *parent = nullptr); - ~ProcessWidget(); + virtual ~ProcessWidget() override; public slots: void updateStatus(qreal totalCpuPercent, const QList cPercents); @@ -44,7 +44,11 @@ public slots: void paintEvent(QPaintEvent *event) override; bool eventFilter(QObject *target, QEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; + //! + //! \brief mouseDoubleClickEvent 鼠标压下事件,唤醒系统监视器主进程,并跳转到CPU详情界面 + //! \param event + //! + void mouseDoubleClickEvent(QMouseEvent *event) override; private: void changeTheme(DApplicationHelper::ColorType themeType); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a14603af..5dbdafef 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -35,7 +35,7 @@ check_include_files ("sys/random.h" HAVE_SYS_RANDOM_H) include(CheckSymbolExists) check_symbol_exists(syscall "unistd.h" HAVE_SYS_CALL) check_symbol_exists(SYS_getrandom "sys/syscall.h" HAVE_SYS_GETRANDOM) -configure_file(${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) +configure_file(${CMAKE_HOME_DIRECTORY}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) include(FindPkgConfig) find_package(KF5Wayland) @@ -75,7 +75,7 @@ include_directories(${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/3rdparty/includ include_directories(${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/3rdparty/libsmartcols/src) set(HPP_GLOBAL - ${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/config.h + ${CMAKE_HOME_DIRECTORY}/config.h ${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/environments.h ${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/accessible.h ${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/accessibledefine.h @@ -139,6 +139,7 @@ set(HPP_DBUS ${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/dbus/unit_file_info.h ${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/dbus/unit_info.h ${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/dbus/dbusforsystemomonitorpluginservce.h + ${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/dbus/dbus_object.h ) set(CPP_DBUS ${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/dbus/environment_file.cpp @@ -149,6 +150,7 @@ set(CPP_DBUS ${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/dbus/systemd1_unit_interface.cpp ${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/dbus/dbus_properties_interface.cpp ${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/dbus/dbusforsystemomonitorpluginservce.cpp + ${CMAKE_HOME_DIRECTORY}/${PROJECT_NAME}-main/dbus/dbus_object.cpp ) set(HPP_MODEL