diff --git a/deepin-system-monitor-main/CMakeLists.txt b/deepin-system-monitor-main/CMakeLists.txt index 0b0e84d9..831d2b36 100644 --- a/deepin-system-monitor-main/CMakeLists.txt +++ b/deepin-system-monitor-main/CMakeLists.txt @@ -57,6 +57,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(LIB_NL3 REQUIRED libnl-3.0) pkg_search_module(LIB_NL3_ROUTE REQUIRED libnl-route-3.0) pkg_search_module(LIB_UDEV REQUIRED libudev) @@ -71,6 +72,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 #安全测试加固编译参数 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -z relro -z now -z noexecstack -pie") @@ -178,6 +180,9 @@ set(HPP_MODEL model/block_dev_info_model.h model/block_dev_info_sort_filter_proxy_model.h model/model_manager.h + model/accounts_info_model.h + model/user.h + ) set(CPP_MODEL model/system_service_table_model.cpp @@ -196,6 +201,8 @@ set(CPP_MODEL model/block_dev_stat_model.cpp model/block_dev_info_sort_filter_proxy_model.cpp model/model_manager.cpp + model/accounts_info_model.cpp + model/user.cpp ) set(HPP_GUI @@ -239,6 +246,10 @@ set(HPP_GUI gui/block_dev_item_widget.h gui/dialog/systemprotectionsetting.h gui/dialog/custombuttonbox.h + gui/user_page_widget.h + gui/accounts_widget.h + gui/onlineicon.h + gui/user_list_view.h ) set(CPP_GUI gui/base/base_detail_item_delegate.cpp @@ -282,6 +293,10 @@ set(CPP_GUI gui/dialog/systemprotectionsetting.cpp gui/dialog/settingsdialog.cpp gui/dialog/custombuttonbox.cpp + gui/user_page_widget.cpp + gui/accounts_widget.cpp + gui/onlineicon.cpp + gui/user_list_view.cpp ) set(HPP_PROCESS @@ -575,6 +590,7 @@ set(LIBS ${LIB_NL3_LIBRARIES} ${LIB_NL3_ROUTE_LIBRARIES} ${LIB_UDEV_LIBRARIES} + ${DFrameworkDBus_LIBRARIES} # chinalife ) if (USE_DEEPIN_WAYLAND) list(APPEND LIBS DWaylandClient DWaylandServer) diff --git a/deepin-system-monitor-main/accessible.h b/deepin-system-monitor-main/accessible.h index 6d20088a..cd452c7a 100644 --- a/deepin-system-monitor-main/accessible.h +++ b/deepin-system-monitor-main/accessible.h @@ -97,6 +97,7 @@ SET_FORM_ACCESSIBLE(CompactNetworkMonitor, "CompactNetworkMonitor") SET_FORM_ACCESSIBLE(CpuMonitor, "CpuMonitor") SET_FORM_ACCESSIBLE(MemoryMonitor, "MemoryMonitor") SET_FORM_ACCESSIBLE(NetworkMonitor, "NetworkMonitor") +SET_FORM_ACCESSIBLE(UserPageWidget, "UserPageWidget") // Qt控件 SET_FORM_ACCESSIBLE(QFrame, m_w->objectName().isEmpty() ? "frame" : m_w->objectName()) @@ -156,6 +157,7 @@ QAccessibleInterface *accessibleFactory(const QString &classname, QObject *objec USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), CpuMonitor); USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), MemoryMonitor); USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), NetworkMonitor); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), UserPageWidget); // Qt 控件 USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), QFrame); diff --git a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/d_system-monitor.md b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/d_system-monitor.md index 99869e7e..ee2ab0da 100644 --- a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/d_system-monitor.md +++ b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/d_system-monitor.md @@ -132,6 +132,17 @@ In the list of system services, force-ending of application is prohibited. You can also right-click a system process and select **Restart**. + + + +### User Management + +On the "Users" tab, you can view the names and types of logged-in user accounts. After selecting an account, you can: +- Right-click and select **Edit account information** to modify the account info in the Accounts window of Control Center. +- View all processes under the account on the right, and right-click a process to end or suspend it, change its priority, etc. + +![user](fig/user.png) + ## Main Menu In the main menu, you can force ending applications, switch monitoring modes and themes, view help manual, and learn more information of System Monitor. diff --git a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/fig/detail1.png b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/fig/detail1.png new file mode 100644 index 00000000..bcb8bd96 Binary files /dev/null and b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/fig/detail1.png differ diff --git a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/fig/pause.png b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/fig/pause.png new file mode 100644 index 00000000..4e92bf7c Binary files /dev/null and b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/fig/pause.png differ diff --git a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/fig/user.png b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/fig/user.png new file mode 100644 index 00000000..c7757318 Binary files /dev/null and b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/fig/user.png differ diff --git a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/system-monitor.md b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/system-monitor.md index 37a6dac6..290c123e 100644 --- a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/system-monitor.md +++ b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/en_US/system-monitor.md @@ -132,6 +132,16 @@ In the list of system services, force-ending of application is prohibited. You can also right-click a system process and select **Restart**. + + +### User Management + +On the "Users" tab, you can view the names and types of logged-in user accounts. After selecting an account, you can: +- Right-click and select **Edit account information** to modify the account info in the Accounts window of Control Center. +- View all processes under the account on the right, and right-click a process to end or suspend it, change its priority, etc. + +![user](fig/user.png) + ## Main Menu In the main menu, you can force ending applications, switch monitoring modes and themes, view help manual, and learn more information of System Monitor. diff --git a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_CN/fig/app_process.psd b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_CN/fig/app_process.psd new file mode 100755 index 00000000..c9a4ae69 Binary files /dev/null and b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_CN/fig/app_process.psd differ diff --git a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_CN/fig/modify.png b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_CN/fig/modify.png new file mode 100644 index 00000000..9a45a23b Binary files /dev/null and b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_CN/fig/modify.png differ diff --git a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_CN/fig/user.png b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_CN/fig/user.png new file mode 100644 index 00000000..e5a42e53 Binary files /dev/null and b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_CN/fig/user.png differ diff --git a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_HK/fig/info.png b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_HK/fig/info.png new file mode 100755 index 00000000..26f09ef6 Binary files /dev/null and b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_HK/fig/info.png differ diff --git a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_HK/fig/search.png b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_HK/fig/search.png new file mode 100755 index 00000000..ed19b54a Binary files /dev/null and b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_HK/fig/search.png differ diff --git a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_HK/fig/user.png b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_HK/fig/user.png new file mode 100644 index 00000000..3f6057bf Binary files /dev/null and b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_HK/fig/user.png differ diff --git a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_TW/fig/detail1.png b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_TW/fig/detail1.png new file mode 100644 index 00000000..07e1cf32 Binary files /dev/null and b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_TW/fig/detail1.png differ diff --git a/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_TW/fig/user.png b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_TW/fig/user.png new file mode 100644 index 00000000..b13142f1 Binary files /dev/null and b/deepin-system-monitor-main/assets/deepin-system-monitor/system-monitor/zh_TW/fig/user.png differ diff --git a/deepin-system-monitor-main/gui/accounts_widget.cpp b/deepin-system-monitor-main/gui/accounts_widget.cpp new file mode 100644 index 00000000..fd017dcb --- /dev/null +++ b/deepin-system-monitor-main/gui/accounts_widget.cpp @@ -0,0 +1,345 @@ +#include "accounts_widget.h" + +#include +#include +#include + +#include +#include +#include +#include +const QMargins ScrollAreaMargins(0, 0, 0, 0); +const QString LogoutDescription = "Log out the user may cause data loss, log out or not?"; + +AccountsWidget::AccountsWidget(QWidget *parent) + : QWidget(parent) + , m_userModel(new AccountsInfoModel(this)) + , m_userItemModel(new QStandardItemModel(this)) + , m_userlistView(new UserListView(this)) +{ + m_currentUserType = m_userModel->getCurrentUserType(); + qInfo() << "AccountsWidget Constructor line 20:" << "current user type:" << m_currentUserType; + initUI(); + initConnection(); + addInfo(m_userModel); + m_userlistView->resetStatus(m_userItemModel->index(0, 0)); + + +} + +AccountsWidget::~AccountsWidget() +{ + if (m_userItemModel) { + m_userItemModel->clear(); + m_userItemModel->deleteLater(); + m_userItemModel = nullptr; + } + if (m_onlineIconList.size() > 0) { + m_onlineIconList.clear(); + } + +} + + +void AccountsWidget::initUI() +{ + // disable auto fill frame background + setAutoFillBackground(false); + // set frame background role +// setBackgroundRole(DPalette::Window); + // 禁用横向滚动条,防止内容被截断 + QVBoxLayout *mainContentLayout = new QVBoxLayout(this); + mainContentLayout->setMargin(0); + mainContentLayout->setSpacing(0); + + mainContentLayout->addWidget(m_userlistView); + + m_userlistView->setFrameShape(QFrame::NoFrame); + m_userlistView->setViewportMargins(ScrollAreaMargins); + m_userlistView->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + m_userlistView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_userlistView->setEditTriggers(QListView::NoEditTriggers); + m_userlistView->setDragEnabled(false); + m_userlistView->setIconSize(QSize(32, 32)); + setLayoutDirection(Qt::LeftToRight); + m_userlistView->setModel(m_userItemModel); + + QScroller::grabGesture(m_userlistView->viewport(), QScroller::LeftMouseButtonGesture); + QScroller *scroller = QScroller::scroller(m_userlistView); + QScrollerProperties sp; + sp.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, QScrollerProperties::OvershootAlwaysOff); + scroller->setScrollerProperties(sp); + setLayout(mainContentLayout); + + setFixedWidth(250); + m_contextMenu = new DMenu(this); + + +} + +void AccountsWidget::initConnection() +{ + connect(m_userModel, &AccountsInfoModel::signalUserOnlineStatusUpdated, this, &AccountsWidget::onUpdateUserList); + connect(m_userlistView, &QListView::clicked, this, &AccountsWidget::onItemClicked); + connect(m_userlistView, &UserListView::signalRightButtonClicked, this, &AccountsWidget::onRightButtonClicked); + connect(m_userlistView, &DListView::activated, m_userlistView, &QListView::clicked); + + + + /******************************* User Operation Menu on right Button Clicked******************************/ + +// auto *connectAction = m_contextMenu->addAction("Connect"); +// connect(connectAction, &QAction::triggered, this, &AccountsWidget::onConnectTriggered); + +// auto *disconnectAction = m_contextMenu->addAction("Disconnect"); +// connect(disconnectAction, &QAction::triggered, this, &AccountsWidget::onDisconnectTriggered); + +// auto *logoutAction = m_contextMenu->addAction("log out"); +// connect(logoutAction, &QAction::triggered, this, &AccountsWidget::onLogoutTriggered); + +// m_contextMenu->addSeparator(); + + auto *EditAction = m_contextMenu->addAction(DApplication::translate("User.Account.Operation", "Edit account information")); + connect(EditAction, &QAction::triggered, this, &AccountsWidget::onEditAccountTriggered); + + +// //判断当前用户是否为管理员用户,非管理员用户不展示连接和注销功能 +// if (!(m_currentUserType == User::UserType::Administrator)) { +// connectAction->setVisible(false); +// logoutAction->setVisible(false); +// } + + /******************************* User Operation Menu on right Button Clicked******************************/ +} + +void AccountsWidget::onUpdateUserList() +{ + + //原来已连接现在注销的用户 + for (auto user : m_userList) { + if (!m_userModel->userList().contains(user)) { + removeUser(user); + } + } + //新增连接的用户 + qInfo() << m_userList.size() << m_userModel->userList().size(); + for (auto user : m_userModel->userList()) { + if (!m_userList.contains(user)) { + addUser(user); + } + } + +} + +void AccountsWidget::addInfo(AccountsInfoModel *model) +{ + qInfo() << "AccountsWidget addInfo line 130:" << "add info from list:" << model->userList(); + //给账户列表添加用户 + for (auto user : model->userList()) { + qInfo() << "AccountsWidget addInfo line 132:" << "add user to listview:" << user->name(); + addUser(user); + } + +} + +void AccountsWidget::addUser(User *user) +{ + //active + qInfo() << "AccountsWidget addUser line 141:" << "addUser begins:" << user->name(); + m_userList << user; + DStandardItem *item = new DStandardItem; + item->setData(0, AccountsWidget::ItemDataRole); + + + auto setTitelFunc = [ = ](int userType, DViewItemAction * subTitleAction) { + + subTitleAction->setText(userType == User::UserType::Administrator ? DApplication::translate("User.Account.Type", "Administrator") : DApplication::translate("User.Account.Type", "Standard User")); + }; + + /* 用户列表显示用户类型 */ + auto *subTitleAction = new DViewItemAction; + setTitelFunc(user->userType(), subTitleAction); + + qInfo() << "AccountsWidget addUser line 156:" << "subTitleAction text:" << subTitleAction->text(); + + + + subTitleAction->setFontSize(DFontSizeManager::T8); + subTitleAction->setTextColorRole(DPalette::TextTips); + item->setTextActionList({subTitleAction}); + +// DViewItemAction *onlineFlag = new DViewItemAction(Qt::AlignCenter | Qt::AlignRight, QSize(), QSize(), true); + +// OnlineIcon *onlineIcon = new OnlineIcon(m_userlistView->viewport()); +// onlineIcon->setFixedSize(8, 8); +// onlineFlag->setWidget(onlineIcon); +// item->setActionList(Qt::Edge::RightEdge, {onlineFlag}); +// if (!user->online()) { +// onlineIcon->setColor(QColor(Qt::gray)); +// } + +// onlineFlag->setVisible(true); +// if (onlineFlag->widget()) { +// onlineFlag->widget()->setVisible(true); +// } + +// m_onlineIconList << onlineIcon; + + + m_userItemModel->appendRow(item); + + auto path = user->iconFile(); + path = path.startsWith("file://") ? QUrl(path).toLocalFile() : path; + QPixmap pixmap = pixmapToRound(path); + + item->setIcon(QIcon(pixmap)); + + item->setText(user->displayName()); + + item->setToolTip(user->displayName()); + + if (user->isCurrentUser()) { + //如果是当前用户 + auto tttitem = m_userItemModel->takeRow(m_userItemModel->rowCount() - 1); + Q_ASSERT(tttitem[0] == item); + m_userItemModel->insertRow(0, item); + + m_userList.push_front(user); + m_userList.pop_back(); + + } +} + +void AccountsWidget::removeUser(User *user) +{ + m_userItemModel->removeRow(m_userList.indexOf(user)); + + m_userList.removeOne(user); + +// //对于删除的用户Item,不显示小圆点 +// for (int i = m_userItemModel->rowCount(); i < m_onlineIconList.size(); i++) { +// m_onlineIconList.at(i)->setVisible(false); +// } + + m_userlistView->update(); +} + + + +QPixmap AccountsWidget::pixmapToRound(const QPixmap &src) +{ + if (src.isNull()) { + return QPixmap(); + } + + auto pixmap = QPixmap(src); + QSize size = pixmap.size(); + QPixmap mask(size); + mask.fill(Qt::transparent); + + QPainter painter(&mask); + painter.setRenderHint(QPainter::Antialiasing); + + QPainterPath path; + path.addEllipse(0, 0, size.width(), size.height()); + painter.setClipPath(path); + painter.drawPixmap(0, 0, pixmap); + + return mask; +} + + +QString AccountsWidget::getCurrentItemUserName() +{ + //判断是否是全名 + for (auto *user : m_userList) { + if (user->displayName() == m_userlistView->currentIndex().data().toString()) { + return user->name(); + } + } + return m_userlistView->currentIndex().data().toString(); +} + + +void AccountsWidget::onItemClicked(const QModelIndex &index) +{ + m_userlistView->resetStatus(index); + Q_EMIT signalCurrentChanged(); +} + + + +// show process table view context menu on specified positon +void AccountsWidget::onRightButtonClicked(const QPoint &p) +{ + + QPoint point = mapToGlobal(p); + + + +// QString name = m_userlistView->indexAt(p).data().toString(); +// //获取当前操作的用户对象 +// getUserToBeOperated(name); + +// //判断是否为当前用户,当前用户展示断开连接, +// if (m_userToBeOperated->isCurrentUser()) { +// m_contextMenu->actions().at(0)->setVisible(false); +// m_contextMenu->actions().at(1)->setVisible(true); +// } else { +// if (m_currentUserType == User::UserType::Administrator) { +// m_contextMenu->actions().at(0)->setVisible(true); +// } + +// m_contextMenu->actions().at(1)->setVisible(false); +// } + + m_contextMenu->popup(point); + + + + + + +} +void AccountsWidget::getUserToBeOperated(const QString &userName) +{ + for (auto *user : m_userList) { + if (user->displayName() == userName) { + m_userToBeOperated = user; + } + } +} + +void AccountsWidget::onConnectTriggered() +{ + m_userModel->activateSessionByUserName(m_userToBeOperated->name()); +} + +void AccountsWidget::onDisconnectTriggered() +{ + m_userModel->lockSessionByUserName(m_userToBeOperated->name()); +} + +void AccountsWidget::onLogoutTriggered() +{ + // show confirm dialog + KillProcessConfirmDialog dialog(this); + dialog.setMessage(LogoutDescription); + dialog.addButton(DApplication::translate("Cancel", "Cancel"), false); + dialog.addButton(DApplication::translate("Logout", "Logout"), true, + DDialog::ButtonRecommend); + dialog.exec(); + if (dialog.result() == QMessageBox::Ok) { + m_userModel->LogoutByUserName(m_userToBeOperated->name()); + //若为当前选中用户,进程列表切换到当前用户 + //todo + } else { + return; + } + +} + +void AccountsWidget::onEditAccountTriggered() +{ + m_userModel->EditAccount(); +} diff --git a/deepin-system-monitor-main/gui/accounts_widget.h b/deepin-system-monitor-main/gui/accounts_widget.h new file mode 100644 index 00000000..92b3471b --- /dev/null +++ b/deepin-system-monitor-main/gui/accounts_widget.h @@ -0,0 +1,73 @@ +#ifndef ACCOUNTSWIDGET_H +#define ACCOUNTSWIDGET_H + +#include "model/accounts_info_model.h" +#include "onlineicon.h" +#include "user_list_view.h" +#include "kill_process_confirm_dialog.h" + +#include +#include +#include +#include +#include +#include +#include +DWIDGET_USE_NAMESPACE +using LogoutConfirmDialog = KillProcessConfirmDialog; + +class AccountsWidget : public QWidget +{ + Q_OBJECT + +public: + + enum AccountRole { + ItemDataRole = Dtk::UserRole + 1 + }; + + + explicit AccountsWidget(QWidget *parent = nullptr); + virtual ~AccountsWidget() override; + void addInfo(AccountsInfoModel *model) ; + QPixmap pixmapToRound(const QPixmap &src); + void addUser(User *user); + void removeUser(User *user); + void showDefaultAccountInfo(); + void initUI(); + void initConnection(); + + + QString getCurrentItemUserName(); + void onRightButtonClicked(const QPoint &p); + +protected: +// void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override; +// QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override; +// void keyPressEvent(QKeyEvent *event) override; + + void getUserToBeOperated(const QString &userName); +Q_SIGNALS: + void signalCurrentChanged(); +public Q_SLOTS: + void onUpdateUserList(); + void onItemClicked(const QModelIndex &); + void onDisconnectTriggered(); + void onConnectTriggered(); + void onLogoutTriggered(); + void onEditAccountTriggered(); +private: + AccountsInfoModel *m_userModel; + QStandardItemModel *m_userItemModel; + QList m_userList; + UserListView *m_userlistView; + QList m_onlineIconList; + // User Login Control menu + DMenu *m_contextMenu {}; + //User to be operated + User *m_userToBeOperated {}; + User::UserType m_currentUserType; + + +}; +#endif // ACCOUNTSWIDGET_H diff --git a/deepin-system-monitor-main/gui/main_window.cpp b/deepin-system-monitor-main/gui/main_window.cpp index 4c3b72e4..3958bf7b 100644 --- a/deepin-system-monitor-main/gui/main_window.cpp +++ b/deepin-system-monitor-main/gui/main_window.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "main_window.h" - +#include "user_page_widget.h" #include "application.h" #include "process_page_widget.h" #include "system_service_page_widget.h" @@ -179,11 +179,12 @@ void MainWindow::initUI() m_procPage = new ProcessPageWidget(m_pages); m_svcPage = new SystemServicePageWidget(m_pages); + m_accountProcPage = new UserPageWidget(m_pages); m_pages->setContentsMargins(0, 0, 0, 0); m_pages->addWidget(m_procPage); m_pages->addWidget(m_svcPage); - + m_pages->addWidget(m_accountProcPage); m_tbShadow->raise(); installEventFilter(this); @@ -211,7 +212,15 @@ void MainWindow::initConnections() m_tbShadow->show(); PERF_PRINT_END("POINT-05"); }); - + connect(m_toolbar, &Toolbar::accountProcTabButtonClicked, this, [ = ]() { + PERF_PRINT_BEGIN("POINT-05", QString("switch(%1->%2)").arg(DApplication::translate("Title.Bar.Switch", "Users")).arg(DApplication::translate("Title.Bar.Switch", "Services"))); + m_toolbar->clearSearchText(); + m_pages->setCurrentWidget(m_accountProcPage); + m_accountProcPage->onUserChanged(); + m_tbShadow->raise(); + m_tbShadow->show(); + PERF_PRINT_END("POINT-05"); + }); connect(gApp, &Application::backgroundTaskStateChanged, this, [ = ](Application::TaskState state) { if (state == Application::kTaskStarted) { // save last focused widget inside main window diff --git a/deepin-system-monitor-main/gui/main_window.h b/deepin-system-monitor-main/gui/main_window.h index fb97979e..0f499076 100644 --- a/deepin-system-monitor-main/gui/main_window.h +++ b/deepin-system-monitor-main/gui/main_window.h @@ -5,7 +5,7 @@ #ifndef MAIN_WINDOW_H #define MAIN_WINDOW_H - +#include "user_page_widget.h" #include #include #include @@ -17,7 +17,7 @@ class Toolbar; class SystemServicePageWidget; class ProcessPageWidget; class Settings; - +class UserPageWidget; class MainWindow : public DMainWindow { Q_OBJECT @@ -126,7 +126,7 @@ public Q_SLOTS: DStackedWidget *m_pages = nullptr; ProcessPageWidget *m_procPage = nullptr; SystemServicePageWidget *m_svcPage = nullptr; - + UserPageWidget *m_accountProcPage = nullptr; bool m_initLoad = false; DShadowLine *m_tbShadow = nullptr; QWidget *m_focusedWidget = nullptr; diff --git a/deepin-system-monitor-main/gui/onlineicon.cpp b/deepin-system-monitor-main/gui/onlineicon.cpp new file mode 100644 index 00000000..ed1067d6 --- /dev/null +++ b/deepin-system-monitor-main/gui/onlineicon.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2011 ~ 2019 Uniontech Technology Co., Ltd. + * + * Author: wangwei + * + * Maintainer: wangwei + * + * 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 . + */ + +// Copyright (c) 2016 Deepin Ltd. All rights reserved. +// Use of this source is governed by General Public License that can be found +// in the LICENSE file. + +#include "onlineicon.h" + +#include +#include +#include +#include +#include +#include +#include + +OnlineIcon::OnlineIcon(QWidget *parent) + : QWidget(parent) + , m_shadowEffect(new QGraphicsDropShadowEffect(this)) +{ + m_shadowEffect->setColor(QColor(0, 0, 0, 16)); // 阴影的颜色 + m_shadowEffect->setOffset(0, 2); + setGraphicsEffect(m_shadowEffect); +} + +void OnlineIcon::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + painter.save(); + painter.setRenderHints(QPainter::Antialiasing); + + painter.setBrush(QBrush(m_color)); + painter.setPen(Qt::NoPen); + painter.drawEllipse(rect().adjusted(1, 1, -1, -1)); + + QPen pen; + pen.setColor(Qt::white); + pen.setWidth(1); + painter.setPen(pen); + painter.setBrush(Qt::NoBrush); + painter.drawEllipse(rect().adjusted(1, 1, -1, -1)); + setGraphicsEffect(m_shadowEffect); + painter.restore(); +} + +void OnlineIcon::setColor(QColor color) +{ + m_color = color; +} diff --git a/deepin-system-monitor-main/gui/onlineicon.h b/deepin-system-monitor-main/gui/onlineicon.h new file mode 100644 index 00000000..e899b31a --- /dev/null +++ b/deepin-system-monitor-main/gui/onlineicon.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2011 ~ 2019 Uniontech Technology Co., Ltd. + * + * Author: wangwei + * + * Maintainer: wangwei + * + * 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 . + */ + +// Copyright (c) 2016 Deepin Ltd. All rights reserved. +// Use of this source is governed by General Public License that can be found +// in the LICENSE file. + +#ifndef ACCOUNTS_ONLINE_DELEGATE_H +#define ACCOUNTS_ONLINE_DELEGATE_H + +#include +#include + +class OnlineIcon : public QWidget +{ + Q_OBJECT +public: + explicit OnlineIcon(QWidget *parent = nullptr); + void setColor(QColor color); +protected: + void paintEvent(QPaintEvent *event) override; +private: + QGraphicsDropShadowEffect *m_shadowEffect; + QColor m_color = QColor(Qt::green); +}; + + +#endif // ACCOUNTS_ONLINE_DELEGATE_H diff --git a/deepin-system-monitor-main/gui/process_page_widget.cpp b/deepin-system-monitor-main/gui/process_page_widget.cpp index 5b713555..e0d47858 100644 --- a/deepin-system-monitor-main/gui/process_page_widget.cpp +++ b/deepin-system-monitor-main/gui/process_page_widget.cpp @@ -97,7 +97,6 @@ void ProcessPageWidget::initUI() m_views = new DStackedWidget(this); m_views->setAutoFillBackground(false); m_views->setContentsMargins(0, 0, 0, 0); - m_views->setAutoFillBackground(false); m_views->setFixedWidth(common::getStatusBarMaxWidth()); // right ====> tab button + process table diff --git a/deepin-system-monitor-main/gui/process_table_view.cpp b/deepin-system-monitor-main/gui/process_table_view.cpp index 9dc89b03..cdae220e 100644 --- a/deepin-system-monitor-main/gui/process_table_view.cpp +++ b/deepin-system-monitor-main/gui/process_table_view.cpp @@ -52,22 +52,24 @@ using namespace common::init; // process table view backup setting key const QByteArray header_version = "_1.0.0"; static const char *kSettingsOption_ProcessTableHeaderState = "process_table_header_state"; -ProcessTableView::ProcessTableView(DWidget *parent) +static const char *kSettingsOption_ProcessTableHeaderStateOfUserMode = "process_table_header_state_user"; +ProcessTableView::ProcessTableView(DWidget *parent, QString userName) : BaseTableView(parent) + , m_useModeName(userName) { // install event filter for table view to handle key events installEventFilter(this); // model & sort filter proxy model instance - m_model = new ProcessTableModel(this); + m_model = new ProcessTableModel(this, userName); m_proxyModel = new ProcessSortFilterProxyModel(this); m_proxyModel->setSourceModel(m_model); // setModel must be called before calling loadSettings(); setModel(m_proxyModel); // load process table view backup settings - bool settingsLoaded = loadSettings(); - + bool settingsLoaded = userName.isNull() ? loadSettings(kSettingsOption_ProcessTableHeaderState) : + loadSettings(kSettingsOption_ProcessTableHeaderStateOfUserMode); // initialize ui components & connections initUI(settingsLoaded); initConnections(settingsLoaded); @@ -75,6 +77,17 @@ ProcessTableView::ProcessTableView(DWidget *parent) // adjust search result tip label text color dynamically on theme type change onThemeTypeChanged(); connect(DApplicationHelper::instance(), &DApplicationHelper::themeTypeChanged, this, &ProcessTableView::onThemeTypeChanged); + if (!userName.isNull()) { + m_cpuUsage = m_model->getTotalCPUUsage(); + m_memUsage = m_model->getTotalMemoryUsage(); + m_download = m_model->getTotalDownload(); + m_upload = m_model->getTotalUpload(); + m_smemUsage = m_model->getTotalSharedMemoryUsage(); + m_vmemUsage = m_model->getTotalVirtualMemoryUsage(); + m_diskread = m_model->getTotalDiskRead(); + m_diskwrite = m_model->getTotalDiskWrite(); + } + } // destructor @@ -373,11 +386,12 @@ void ProcessTableView::changeProcessPriority(int priority) } // load & restore table view settings from backup storage -bool ProcessTableView::loadSettings() +bool ProcessTableView::loadSettings(const QString &flag) { Settings *s = Settings::instance(); if (s) { - const QVariant &opt = s->getOption(kSettingsOption_ProcessTableHeaderState); + const QVariant &opt = s->getOption(flag); + if (opt.isValid()) { const QByteArray &buf = QByteArray::fromBase64(opt.toByteArray()); if (buf.endsWith(header_version)) { @@ -399,7 +413,12 @@ void ProcessTableView::saveSettings() QByteArray buf = header()->saveState(); buf += header_version; - s->setOption(kSettingsOption_ProcessTableHeaderState, buf.toBase64()); + if (m_useModeName.isNull()) { + s->setOption(kSettingsOption_ProcessTableHeaderState, buf.toBase64()); + } else { + s->setOption(kSettingsOption_ProcessTableHeaderStateOfUserMode, buf.toBase64()); + } + s->flush(); } } @@ -672,6 +691,7 @@ void ProcessTableView::initConnections(bool settingsLoaded) connect(cpuHeaderAction, &QAction::triggered, this, [this](bool b) { header()->setSectionHidden(ProcessTableModel::kProcessCPUColumn, !b); saveSettings(); + Q_EMIT signalHeadchanged(); }); // process user action auto *userHeaderAction = m_headerContextMenu->addAction( @@ -688,6 +708,7 @@ void ProcessTableView::initConnections(bool settingsLoaded) connect(memHeaderAction, &QAction::triggered, this, [this](bool b) { header()->setSectionHidden(ProcessTableModel::kProcessMemoryColumn, !b); saveSettings(); + Q_EMIT signalHeadchanged(); }); // share memory action auto *sharememHeaderAction = m_headerContextMenu->addAction( @@ -696,6 +717,7 @@ void ProcessTableView::initConnections(bool settingsLoaded) connect(sharememHeaderAction, &QAction::triggered, this, [this](bool b) { header()->setSectionHidden(ProcessTableModel::kProcessShareMemoryColumn, !b); saveSettings(); + Q_EMIT signalHeadchanged(); }); //vtr memory action auto *vtrmemHeaderAction = m_headerContextMenu->addAction( @@ -704,6 +726,7 @@ void ProcessTableView::initConnections(bool settingsLoaded) connect(vtrmemHeaderAction, &QAction::triggered, this, [this](bool b) { header()->setSectionHidden(ProcessTableModel::kProcessVTRMemoryColumn, !b); saveSettings(); + Q_EMIT signalHeadchanged(); }); // upload rate action auto *uploadHeaderAction = m_headerContextMenu->addAction( @@ -712,6 +735,7 @@ void ProcessTableView::initConnections(bool settingsLoaded) connect(uploadHeaderAction, &QAction::triggered, this, [this](bool b) { header()->setSectionHidden(ProcessTableModel::kProcessUploadColumn, !b); saveSettings(); + Q_EMIT signalHeadchanged(); }); // download rate action auto *downloadHeaderAction = m_headerContextMenu->addAction( @@ -720,6 +744,7 @@ void ProcessTableView::initConnections(bool settingsLoaded) connect(downloadHeaderAction, &QAction::triggered, this, [this](bool b) { header()->setSectionHidden(ProcessTableModel::kProcessDownloadColumn, !b); saveSettings(); + Q_EMIT signalHeadchanged(); }); // disk read rate action auto *dreadHeaderAction = m_headerContextMenu->addAction( @@ -728,6 +753,7 @@ void ProcessTableView::initConnections(bool settingsLoaded) connect(dreadHeaderAction, &QAction::triggered, this, [this](bool b) { header()->setSectionHidden(ProcessTableModel::kProcessDiskReadColumn, !b); saveSettings(); + Q_EMIT signalHeadchanged(); }); // disk write rate action auto *dwriteHeaderAction = m_headerContextMenu->addAction( @@ -736,6 +762,7 @@ void ProcessTableView::initConnections(bool settingsLoaded) connect(dwriteHeaderAction, &QAction::triggered, this, [this](bool b) { header()->setSectionHidden(ProcessTableModel::kProcessDiskWriteColumn, !b); saveSettings(); + Q_EMIT signalHeadchanged(); }); // pid action auto *pidHeaderAction = m_headerContextMenu->addAction( @@ -815,6 +842,17 @@ void ProcessTableView::initConnections(bool settingsLoaded) this->setCurrentIndex(m_proxyModel->index(i, 0)); } } + if (!m_useModeName.isNull()) { + m_cpuUsage = m_model->getTotalCPUUsage(); + m_memUsage = m_model->getTotalMemoryUsage(); + m_download = m_model->getTotalDownload(); + m_upload = m_model->getTotalUpload(); + m_smemUsage = m_model->getTotalSharedMemoryUsage(); + m_vmemUsage = m_model->getTotalVirtualMemoryUsage(); + m_diskread = m_model->getTotalDiskRead(); + m_diskwrite = m_model->getTotalDiskWrite(); + } + Q_EMIT signalModelUpdated(); }); // end process shortcut @@ -975,3 +1013,12 @@ void ProcessTableView::customizeProcessPriority() }); prioDialog->exec(); } + +void ProcessTableView::setUserModeName(const QString &userName) +{ + if (userName != m_useModeName) { + m_useModeName = userName; + m_model->setUserModeName(m_useModeName); + } + +} diff --git a/deepin-system-monitor-main/gui/process_table_view.h b/deepin-system-monitor-main/gui/process_table_view.h index c4c8f268..8e1bca60 100644 --- a/deepin-system-monitor-main/gui/process_table_view.h +++ b/deepin-system-monitor-main/gui/process_table_view.h @@ -36,7 +36,7 @@ class ProcessTableView : public BaseTableView * @brief Process table view constructor * @param parent Parent object */ - explicit ProcessTableView(DWidget *parent = nullptr); + explicit ProcessTableView(DWidget *parent = nullptr, QString userName = nullptr); /** * @brief Destructor */ @@ -56,6 +56,15 @@ class ProcessTableView : public BaseTableView * @return To filter this event out, return true; otherwise return false */ bool eventFilter(QObject *obj, QEvent *event) override; + void setUserModeName(const QString &userName); + inline qreal getUserCPUUsage() {return m_cpuUsage;} + inline qreal getUserMemUsage() {return m_memUsage;} + inline qreal getUserDownload() {return m_download;} + inline qreal getUserUpload() {return m_upload;} + inline qreal getUserSMemUsage() {return m_smemUsage;} + inline qreal getUserVMemUsage() {return m_vmemUsage;} + inline qreal getUserDiskRead() {return m_diskread;} + inline qreal getUserDiskWrite() {return m_diskwrite;} public Q_SLOTS: /** @@ -102,13 +111,16 @@ public Q_SLOTS: * @brief onThemeTypeChanged */ void onThemeTypeChanged(); +Q_SIGNALS: + void signalModelUpdated(); + void signalHeadchanged(); protected: /** * @brief Load process table view backup settings * @return Settings load success or not */ - bool loadSettings(); + bool loadSettings(const QString &flag); /** * @brief Backup process table view settings */ @@ -201,9 +213,16 @@ public Q_SLOTS: // Kill process shortcut QShortcut *m_killProcKP {}; - - - + //User mode User Name + QString m_useModeName {}; + qreal m_cpuUsage {}; + qreal m_memUsage {}; + qreal m_download {}; + qreal m_upload {}; + qreal m_smemUsage {}; + qreal m_vmemUsage {}; + qreal m_diskread {}; + qreal m_diskwrite {}; }; #endif // PROCESS_TABLE_VIEW_H diff --git a/deepin-system-monitor-main/gui/toolbar.cpp b/deepin-system-monitor-main/gui/toolbar.cpp index 8093aac3..d21e4d2c 100644 --- a/deepin-system-monitor-main/gui/toolbar.cpp +++ b/deepin-system-monitor-main/gui/toolbar.cpp @@ -44,13 +44,24 @@ Toolbar::Toolbar(QWidget *parent) m_procBtn->setCheckable(true); m_procBtn->setChecked(true); m_procBtn->setFocusPolicy(Qt::TabFocus); + + DFontSizeManager::instance()->bind(m_procBtn, DFontSizeManager::T7, QFont::Medium); // service tab button instance m_svcBtn = new DButtonBoxButton( DApplication::translate("Title.Bar.Switch", "Services"), m_switchFuncTabBtnGrp); m_svcBtn->setCheckable(true); m_svcBtn->setFocusPolicy(Qt::TabFocus); + + DFontSizeManager::instance()->bind(m_svcBtn, DFontSizeManager::T7, QFont::Medium); + // user process tab button instance + m_accountProcBtn = new DButtonBoxButton( + DApplication::translate("Title.Bar.Switch", "Users"), m_switchFuncTabBtnGrp); + m_accountProcBtn->setCheckable(true); + m_accountProcBtn->setFocusPolicy(Qt::TabFocus); + + DFontSizeManager::instance()->bind(m_accountProcBtn, DFontSizeManager::T7, QFont::Medium); QList list; - list << m_procBtn << m_svcBtn; + list << m_procBtn << m_svcBtn << m_accountProcBtn; m_switchFuncTabBtnGrp->setButtonList(list, true); // move focus to process tab button when toolbar got focus @@ -59,11 +70,12 @@ Toolbar::Toolbar(QWidget *parent) // install event filer for both tab button to handle key press event m_procBtn->installEventFilter(this); m_svcBtn->installEventFilter(this); + m_accountProcBtn->installEventFilter(this); // emit button clicked signal when process or service tab button toggled connect(m_procBtn, &DButtonBoxButton::toggled, this, [ = ](bool) { Q_EMIT procTabButtonClicked(); }); connect(m_svcBtn, &DButtonBoxButton::toggled, this, [ = ](bool) { Q_EMIT serviceTabButtonClicked(); }); - + connect(m_accountProcBtn, &DButtonBoxButton::toggled, this, [ = ](bool) { Q_EMIT accountProcTabButtonClicked(); }); // search text editor instance searchEdit = new DSearchEdit(this); // set the search edit text max length @@ -91,12 +103,12 @@ Toolbar::Toolbar(QWidget *parent) if (loading) { m_procBtn->setEnabled(false); m_svcBtn->setEnabled(false); - + m_accountProcBtn->setEnabled(false); searchEdit->setEnabled(false); } else { m_procBtn->setEnabled(true); m_svcBtn->setEnabled(true); - + m_accountProcBtn->setEnabled(true); searchEdit->setEnabled(true); } }); @@ -138,6 +150,13 @@ bool Toolbar::eventFilter(QObject *obj, QEvent *event) m_procBtn->setFocus(); return true; } + } else if (obj == m_accountProcBtn) { + // set focus to process tab button when left key pressed + auto *kev = dynamic_cast(event); + if (kev->key() == Qt::Key_Left) { + m_accountProcBtn->setFocus(); + return true; + } } } diff --git a/deepin-system-monitor-main/gui/toolbar.h b/deepin-system-monitor-main/gui/toolbar.h index e8d115e1..85e3cd32 100644 --- a/deepin-system-monitor-main/gui/toolbar.h +++ b/deepin-system-monitor-main/gui/toolbar.h @@ -105,16 +105,22 @@ public Q_SLOTS: * @brief Sevice tab button triggered signal */ void serviceTabButtonClicked(); + /** + * @brief User Procss tab button triggered signal + */ + void accountProcTabButtonClicked(); private: // Button group - CustomButtonBox *m_switchFuncTabBtnGrp {}; + CustomButtonBox *m_switchFuncTabBtnGrp {nullptr}; // Process tab button - DButtonBoxButton *m_procBtn {}; + DButtonBoxButton *m_procBtn {nullptr}; // Service tab button - DButtonBoxButton *m_svcBtn {}; + DButtonBoxButton *m_svcBtn {nullptr}; + // User Process tab button + DButtonBoxButton *m_accountProcBtn {nullptr}; // Search text input - DSearchEdit *searchEdit {}; + DSearchEdit *searchEdit {nullptr}; // Start timer when search content changed, do the actual search only when timer timed out QTimer *searchTimer; @@ -122,7 +128,7 @@ public Q_SLOTS: // Searched content cache QString searchTextCache; - QWidget *m_spaceItem {}; + QWidget *m_spaceItem {nullptr}; }; #endif diff --git a/deepin-system-monitor-main/gui/user_list_view.cpp b/deepin-system-monitor-main/gui/user_list_view.cpp new file mode 100644 index 00000000..4c41be46 --- /dev/null +++ b/deepin-system-monitor-main/gui/user_list_view.cpp @@ -0,0 +1,80 @@ +#include "user_list_view.h" + +#include +#include +#include + +UserListView::UserListView(QWidget *parent): DListView(parent) + , m_currentIndex(0) +{ + // 禁用横向滚动条,防止内容被截断 + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +} + +void UserListView::resetStatus(const QModelIndex &index) +{ + m_currentIndex = index.row(); + + DListView::clearSelection(); + DListView::setSelectionMode(DListView::SingleSelection); + DListView::setCurrentIndex(index); +} + +void UserListView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) +{ + DListView::setSelectionMode(DListView::SingleSelection); + DListView::currentChanged(current, previous); +} + +QModelIndex UserListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) +{ + DListView::setSelectionMode(DListView::MultiSelection); + return DListView::moveCursor(cursorAction, modifiers); +} + +void UserListView::keyPressEvent(QKeyEvent *event) +{ + + if (event->key() == Qt::Key_Up) { + QModelIndex nextIndex = model()->index(m_currentIndex - 1, 0); + if (nextIndex.isValid()) { + if (isRowHidden(m_currentIndex - 1)) { + if (m_currentIndex - 1 <= 0) { + return; + } + m_currentIndex--; + keyPressEvent(event); + return; + } + setCurrentIndex(nextIndex); + Q_EMIT clicked(nextIndex); + } + return; + } else if (event->key() == Qt::Key_Down) { + QModelIndex nextIndex = model()->index(m_currentIndex + 1, 0); + if (nextIndex.isValid()) { + if (isRowHidden(m_currentIndex + 1)) { + if (model()->rowCount() - 1 <= m_currentIndex + 1) { + return; + } + m_currentIndex++; + keyPressEvent(event); + return; + } + setCurrentIndex(nextIndex); + Q_EMIT clicked(nextIndex); + } + return; + } + return DListView::keyPressEvent(event); +} +void UserListView::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::RightButton) { + + Q_EMIT signalRightButtonClicked(QPoint(event->x(), event->y())); + + return; + } + return DListView::mousePressEvent(event); +} diff --git a/deepin-system-monitor-main/gui/user_list_view.h b/deepin-system-monitor-main/gui/user_list_view.h new file mode 100644 index 00000000..cc850fb2 --- /dev/null +++ b/deepin-system-monitor-main/gui/user_list_view.h @@ -0,0 +1,29 @@ +#ifndef USER_LIST_VIEW_H +#define USER_LIST_VIEW_H + +#include +#include +DWIDGET_USE_NAMESPACE +class UserListView : public DListView +{ + Q_OBJECT +public: + explicit UserListView(QWidget *parent = nullptr); + void resetStatus(const QModelIndex &index); + + +Q_SIGNALS: + void signalRightButtonClicked(const QPoint &p); + +protected: + void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override; + QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override; + void keyPressEvent(QKeyEvent *event) override; + + void mousePressEvent(QMouseEvent *event) override; + +private: + int m_currentIndex; +}; + +#endif // USER_LIST_VIEW_H diff --git a/deepin-system-monitor-main/gui/user_page_widget.cpp b/deepin-system-monitor-main/gui/user_page_widget.cpp new file mode 100644 index 00000000..e80477a0 --- /dev/null +++ b/deepin-system-monitor-main/gui/user_page_widget.cpp @@ -0,0 +1,377 @@ +/* +* Copyright (C) 2021 ~ 2022 Uniontech Software Technology Co.,Ltd +* +* Author: lishiqi +* Maintainer: lishiqi +* +* 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 "user_page_widget.h" +#include "process_table_view.h" +#include "model/process_table_model.h" +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE +using namespace common::format; + +UserPageWidget::UserPageWidget(DWidget *parent) + : DFrame(parent) +{ + struct passwd *pws; + pws = getpwuid(getuid()); + m_currentUser = QString(pws->pw_name); + qInfo() << "UserPageWidget Construction:" << "currentuser:" << m_currentUser; + initUI(); + initConnections(); + +} + +// destructor +UserPageWidget::~UserPageWidget() {} + +// initialize ui components +void UserPageWidget::initUI() +{ + m_dAppHelper = DApplicationHelper::instance(); + // process table view instance + m_procTable = new ProcessTableView(this, m_currentUser); + m_procTable->switchDisplayMode(kNoFilter); + + // content margin + int margin = 10; + + //left user info instance + m_accountListWidget = new AccountsWidget(this); + m_accountListWidget->setAutoFillBackground(false); + m_accountListWidget->setContentsMargins(0, 0, 0, 0); + m_accountListWidget->setFixedWidth(250); + + /***********************************************usage Labels**************************************************/ + + QWidget *usageSummaryWidget = new QWidget(this); + QHBoxLayout *usageLayout = new QHBoxLayout(usageSummaryWidget); + + usageLayout->addWidget(m_CPUUsageSummary, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->setContentsMargins(0, 0, 0, 0); + + // top user resource usage summary label instance + + m_CPULabel = new DLabel(usageSummaryWidget); + m_MemeryLabel = new DLabel(usageSummaryWidget); + m_SMemLabel = new DLabel(usageSummaryWidget); + m_VMemLabel = new DLabel(usageSummaryWidget); + m_UploadLabel = new DLabel(usageSummaryWidget); + m_DownLoadLabel = new DLabel(usageSummaryWidget); + m_DiskReadLabel = new DLabel(usageSummaryWidget); + m_DiskWriteLabel = new DLabel(usageSummaryWidget); + + m_CPULabel->setText(QApplication::translate("Process.Table.Header", kProcessCPU)); + m_MemeryLabel->setText(QApplication::translate("Process.Table.Header", kProcessMemory)); + m_SMemLabel->setText(QApplication::translate("Process.Table.Header", kProcessShareMemory)); + m_VMemLabel->setText(QApplication::translate("Process.Table.Header", kProcessVtrMemory)); + m_UploadLabel->setText(QApplication::translate("Process.Table.Header", kProcessUpload)); + m_DownLoadLabel->setText(QApplication::translate("Process.Table.Header", kProcessDownload)); + m_DiskReadLabel->setText(QApplication::translate("Process.Table.Header", kProcessDiskRead)); + m_DiskWriteLabel->setText(QApplication::translate("Process.Table.Header", kProcessDiskWrite)); + + m_CPULabel->setToolTip(QApplication::translate("Process.Table.Header", kProcessCPU)); + m_MemeryLabel->setToolTip(QApplication::translate("Process.Table.Header", kProcessMemory)); + m_SMemLabel->setToolTip(QApplication::translate("Process.Table.Header", kProcessShareMemory)); + m_VMemLabel->setToolTip(QApplication::translate("Process.Table.Header", kProcessVtrMemory)); + m_UploadLabel->setToolTip(QApplication::translate("Process.Table.Header", kProcessUpload)); + m_DownLoadLabel->setToolTip(QApplication::translate("Process.Table.Header", kProcessDownload)); + m_DiskReadLabel->setToolTip(QApplication::translate("Process.Table.Header", kProcessDiskRead)); + m_DiskWriteLabel->setToolTip(QApplication::translate("Process.Table.Header", kProcessDiskWrite)); + + + m_CPUUsageSummary = new DLabel(usageSummaryWidget); + m_MemeryUsageSummary = new DLabel(usageSummaryWidget); + m_SMemUsageSummary = new DLabel(usageSummaryWidget); + m_VMemUsageSummary = new DLabel(usageSummaryWidget); + m_UploadSummary = new DLabel(usageSummaryWidget); + m_DownLoadSummary = new DLabel(usageSummaryWidget); + m_DiskReadSummary = new DLabel(usageSummaryWidget); + m_DiskWriteSummary = new DLabel(usageSummaryWidget); + + setLabelFormat(m_CPULabel, DPalette::TextTitle); + setLabelFormat(m_MemeryLabel, DPalette::TextTitle); + setLabelFormat(m_SMemLabel, DPalette::TextTitle); + setLabelFormat(m_VMemLabel, DPalette::TextTitle); + setLabelFormat(m_UploadLabel, DPalette::TextTitle); + setLabelFormat(m_DownLoadLabel, DPalette::TextTitle); + setLabelFormat(m_DiskReadLabel, DPalette::TextTitle); + setLabelFormat(m_DiskWriteLabel, DPalette::TextTitle); + setLabelFormat(m_CPUUsageSummary, DPalette::TextTips); + setLabelFormat(m_MemeryUsageSummary, DPalette::TextTips); + setLabelFormat(m_SMemUsageSummary, DPalette::TextTips); + setLabelFormat(m_VMemUsageSummary, DPalette::TextTips); + setLabelFormat(m_UploadSummary, DPalette::TextTips); + setLabelFormat(m_DownLoadSummary, DPalette::TextTips); + setLabelFormat(m_DiskReadSummary, DPalette::TextTips); + setLabelFormat(m_DiskWriteSummary, DPalette::TextTips); + + usageLayout->addWidget(m_CPULabel, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addWidget(m_CPUUsageSummary, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addSpacing(5); + usageLayout->addWidget(m_MemeryLabel, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addWidget(m_MemeryUsageSummary, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addSpacing(5); + usageLayout->addWidget(m_SMemLabel, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addWidget(m_SMemUsageSummary, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addSpacing(5); + usageLayout->addWidget(m_VMemLabel, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addWidget(m_VMemUsageSummary, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addSpacing(5); + usageLayout->addWidget(m_UploadLabel, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addWidget(m_UploadSummary, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addSpacing(5); + usageLayout->addWidget(m_DownLoadLabel, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addWidget(m_DownLoadSummary, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addSpacing(5); + usageLayout->addWidget(m_DiskReadLabel, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addWidget(m_DiskReadSummary, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addSpacing(5); + usageLayout->addWidget(m_DiskWriteLabel, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addWidget(m_DiskWriteSummary, 0, Qt::AlignLeft | Qt::AlignVCenter); + usageLayout->addStretch(); + usageSummaryWidget->setLayout(usageLayout); + /***********************************************usage Labels**************************************************/ + + + QWidget *userInfoWideget = new QWidget(this); + + auto *contentlayout = new QVBoxLayout(userInfoWideget); + contentlayout->setSpacing(margin); + contentlayout->addWidget(usageSummaryWidget); + contentlayout->addWidget(m_procTable, 1); + userInfoWideget->setLayout(contentlayout); + + QHBoxLayout *layout = new QHBoxLayout(this); + layout->setMargin(10); + layout->setSpacing(0); + layout->addWidget(m_accountListWidget); + layout->addWidget(userInfoWideget); + setLayout(layout); + setAutoFillBackground(false); + //初始化汇总数据显示状态 + onHeaderChanged(); +} +void UserPageWidget::initConnections() +{ + connect(m_accountListWidget, &AccountsWidget::signalCurrentChanged, this, &UserPageWidget::onUserChanged); + connect(m_procTable, &ProcessTableView::signalModelUpdated, this, &UserPageWidget::onTextContentChanged); + connect(m_dAppHelper, &DApplicationHelper::themeTypeChanged, this, &UserPageWidget::onThemeChanged); + connect(m_procTable, &ProcessTableView::signalHeadchanged, this, &UserPageWidget::onHeaderChanged); +} + +// paint event handler +void UserPageWidget::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + + QPainterPath path; + path.addRect(QRectF(rect())); + painter.setOpacity(1); + + DApplicationHelper *dAppHelper = DApplicationHelper::instance(); + DPalette palette = dAppHelper->applicationPalette(); + QColor bgColor = palette.color(DPalette::Background); + + + +} +void UserPageWidget::onUserChanged() +{ + QString userName = m_accountListWidget->getCurrentItemUserName(); + qInfo() << userName << "user changed"; + m_procTable->setUserModeName(userName); + onTextContentChanged(); + update(); +} + + +void UserPageWidget::onTextContentChanged() +{ + + m_CPUUsageSummary->setText(QString("%1%").arg(m_procTable->getUserCPUUsage(), 0, 'f', 1)); + + m_MemeryUsageSummary->setText(formatUnit_memory_disk(m_procTable->getUserMemUsage(), KB)); + + m_SMemUsageSummary->setText(formatUnit_memory_disk(m_procTable->getUserSMemUsage(), KB)); + + m_VMemUsageSummary->setText(formatUnit_memory_disk(m_procTable->getUserVMemUsage(), KB)); + + m_UploadSummary->setText(formatUnit_net(8 * m_procTable->getUserUpload(), B, 1, true)); + + m_DownLoadSummary->setText(formatUnit_net(8 * m_procTable->getUserDownload(), B, 1, true)); + + m_DiskReadSummary->setText(formatUnit_memory_disk(m_procTable->getUserDiskRead(), B, 1, true)); + + m_DiskWriteSummary->setText(formatUnit_memory_disk(m_procTable->getUserDiskWrite(), B, 1, true)); + + m_CPUUsageSummary->setToolTip(QString("%1%").arg(m_procTable->getUserCPUUsage(), 0, 'f', 1)); + + m_MemeryUsageSummary->setToolTip(formatUnit_memory_disk(m_procTable->getUserMemUsage(), KB)); + + m_SMemUsageSummary->setToolTip(formatUnit_memory_disk(m_procTable->getUserSMemUsage(), KB)); + + m_VMemUsageSummary->setToolTip(formatUnit_memory_disk(m_procTable->getUserVMemUsage(), KB)); + + m_UploadSummary->setToolTip(formatUnit_net(8 * m_procTable->getUserUpload(), B, 1, true)); + + m_DownLoadSummary->setToolTip(formatUnit_net(8 * m_procTable->getUserDownload(), B, 1, true)); + + m_DiskReadSummary->setToolTip(formatUnit_memory_disk(m_procTable->getUserDiskRead(), B, 1, true)); + + m_DiskWriteSummary->setToolTip(formatUnit_memory_disk(m_procTable->getUserDiskWrite(), B, 1, true)); + + update(); +} + +void UserPageWidget::onHeaderChanged() +{ + m_CPULabel->setVisible(!m_procTable->isColumnHidden(1)); + m_CPUUsageSummary->setVisible(!m_procTable->isColumnHidden(1)); + + m_MemeryLabel->setVisible(!m_procTable->isColumnHidden(3)); + m_MemeryUsageSummary->setVisible(!m_procTable->isColumnHidden(3)); + + m_SMemLabel->setVisible(!m_procTable->isColumnHidden(4)); + m_SMemUsageSummary->setVisible(!m_procTable->isColumnHidden(4)); + + m_VMemLabel->setVisible(!m_procTable->isColumnHidden(5)); + m_VMemUsageSummary->setVisible(!m_procTable->isColumnHidden(5)); + + m_UploadLabel->setVisible(!m_procTable->isColumnHidden(6)); + m_UploadSummary->setVisible(!m_procTable->isColumnHidden(6)); + + m_DownLoadLabel->setVisible(!m_procTable->isColumnHidden(7)); + m_DownLoadSummary->setVisible(!m_procTable->isColumnHidden(7)); + + m_DiskReadLabel->setVisible(!m_procTable->isColumnHidden(8)); + m_DiskReadSummary->setVisible(!m_procTable->isColumnHidden(8)); + + m_DiskWriteLabel->setVisible(!m_procTable->isColumnHidden(9)); + m_DiskWriteSummary->setVisible(!m_procTable->isColumnHidden(9)); + + update(); +} + +void UserPageWidget::setLabelFormat(DLabel *label, DPalette::ColorType corlorType) +{ + + auto palette = m_dAppHelper->applicationPalette(); + + DFontSizeManager::instance()->bind(label, DFontSizeManager::T7, QFont::Medium); + // text aligment & elide mode + label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + label->setElideMode(Qt::ElideRight); + // change text color to text tips style + auto pa = DApplicationHelper::instance()->palette(label); + palette.setColor(DPalette::Text, palette.color(corlorType)); + label->setPalette(palette); + label->adjustSize(); +} + +void UserPageWidget::onThemeChanged() +{ + if (m_CPULabel) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTitle)); + m_CPULabel->setPalette(palette); + } + if (m_MemeryLabel) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTitle)); + m_MemeryLabel->setPalette(palette); + } + if (m_SMemLabel) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTitle)); + m_SMemLabel->setPalette(palette); + } + if (m_VMemLabel) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTitle)); + m_VMemLabel->setPalette(palette); + } + if (m_UploadLabel) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTitle)); + m_UploadLabel->setPalette(palette); + } + if (m_DownLoadLabel) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTitle)); + m_DownLoadLabel->setPalette(palette); + } + if (m_DiskReadLabel) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTitle)); + m_DiskReadLabel->setPalette(palette); + } + if (m_DiskWriteLabel) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTitle)); + m_DiskWriteLabel->setPalette(palette); + } + + + if (m_CPUUsageSummary) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTips)); + m_CPUUsageSummary->setPalette(palette); + } + if (m_MemeryUsageSummary) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTips)); + m_MemeryUsageSummary->setPalette(palette); + } + if (m_SMemUsageSummary) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTips)); + m_SMemUsageSummary->setPalette(palette); + } + if (m_VMemUsageSummary) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTips)); + m_VMemUsageSummary->setPalette(palette); + } + if (m_UploadSummary) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTips)); + m_UploadSummary->setPalette(palette); + } + if (m_DownLoadSummary) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTips)); + m_DownLoadSummary->setPalette(palette); + } + if (m_DiskReadSummary) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTips)); + m_DiskReadSummary->setPalette(palette); + } + if (m_DiskWriteSummary) { + auto palette = DApplicationHelper::instance()->applicationPalette(); + palette.setColor(DPalette::Text, palette.color(DPalette::TextTips)); + m_DiskWriteSummary->setPalette(palette); + } + + +} diff --git a/deepin-system-monitor-main/gui/user_page_widget.h b/deepin-system-monitor-main/gui/user_page_widget.h new file mode 100644 index 00000000..ca769492 --- /dev/null +++ b/deepin-system-monitor-main/gui/user_page_widget.h @@ -0,0 +1,110 @@ +#ifndef USER_PAGE_WIDGET_H +#define USER_PAGE_WIDGET_H + +/* +* Copyright (C) 2021 ~ 2022 Uniontech Software Technology Co.,Ltd +* +* Author: lishiqi +* Maintainer: lishiqi +* +* 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 "accounts_widget.h" +#include +#include +#include +#include + +class ProcessTableView; + + +DWIDGET_USE_NAMESPACE + + +/** + * @brief Process & performance monitor view frame + */ +class UserPageWidget : public DFrame +{ + Q_OBJECT + +public: + /** + * @brief Default constructor + * @param parent Parent object + */ + explicit UserPageWidget(DWidget *parent = nullptr); + /** + * @brief Destructor + */ + ~UserPageWidget(); + + /** + * @brief Initialize ui components + */ + void initUI(); + /** + * @brief Initialize connections + */ + void initConnections(); + + +protected: + /** + * @brief Paint event handler + */ + void paintEvent(QPaintEvent *); + +public Q_SLOTS: + void onUserChanged(); + + void onTextContentChanged(); + + void onThemeChanged(); + + void onHeaderChanged(); +private: + void setLabelFormat(DLabel *label, DPalette::ColorType corlorType); + +private: + ProcessTableView *m_procTable = nullptr; + AccountsWidget *m_accountListWidget = nullptr; + + + DLabel *m_CPULabel = nullptr; + DLabel *m_MemeryLabel = nullptr; + DLabel *m_SMemLabel = nullptr; + DLabel *m_VMemLabel = nullptr; + DLabel *m_UploadLabel = nullptr; + DLabel *m_DownLoadLabel = nullptr; + DLabel *m_DiskReadLabel = nullptr; + DLabel *m_DiskWriteLabel = nullptr; + + DLabel *m_CPUUsageSummary = nullptr; + DLabel *m_MemeryUsageSummary = nullptr; + DLabel *m_SMemUsageSummary = nullptr; + DLabel *m_VMemUsageSummary = nullptr; + DLabel *m_UploadSummary = nullptr; + DLabel *m_DownLoadSummary = nullptr; + DLabel *m_DiskReadSummary = nullptr; + DLabel *m_DiskWriteSummary = nullptr; + + DApplicationHelper *m_dAppHelper = nullptr; + + QString m_currentUser {}; +}; + + + +#endif // USER_PAGE_WIDGET_H diff --git a/deepin-system-monitor-main/model/accounts_info_model.cpp b/deepin-system-monitor-main/model/accounts_info_model.cpp new file mode 100644 index 00000000..c36caab1 --- /dev/null +++ b/deepin-system-monitor-main/model/accounts_info_model.cpp @@ -0,0 +1,227 @@ +#include "accounts_info_model.h" +#include +#include +#include +#include + +#define PKEXEC_PATH "/usr/bin/pkexec" +#define PKILL_PATH "/usr/bin/pkill" + +const QString AccountsService("com.deepin.daemon.Accounts"); +const QString LoginService("org.freedesktop.login1"); +const QString ControlCenterService("com.deepin.dde.ControlCenter"); + +AccountsInfoModel::AccountsInfoModel(QObject *parent): QObject(parent) + , m_accountsInter(new Accounts(AccountsService, "/com/deepin/daemon/Accounts", QDBusConnection::systemBus(), this)) + , m_LoginInter(new LoginManager(LoginService, "/org/freedesktop/login1", QDBusConnection::systemBus(), this)) + , m_controlInter(new ControlCenter(ControlCenterService, "/com/deepin/dde/ControlCenter", QDBusConnection::sessionBus(), this)) + , m_currentUserType(-1) +{ + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + struct passwd *pws; + pws = getpwuid(getuid()); + m_currentUserName = QString(pws->pw_name); + qInfo() << "AccountsInfoModel constructor line 26" << "m_currentUserName:" << m_currentUserName; + //获取online userList + updateUserOnlineStatus(); + qInfo() << "AccountsInfoModel constructor line 29" << "online user list:" << m_onlineUsers; + updateUserList(m_accountsInter->userList()); + qInfo() << "AccountsInfoModel constructor line 31" << "Accounts user list:" << m_accountsInter->userList(); + + connect(m_accountsInter, &Accounts::UserListChanged, this, &AccountsInfoModel::onUserListChanged, Qt::QueuedConnection); + connect(m_LoginInter, &LoginManager::SessionNew, this, &AccountsInfoModel::onSessionNew, Qt::QueuedConnection); + connect(m_LoginInter, &LoginManager::SessionRemoved, this, &AccountsInfoModel::onSessionNew, Qt::QueuedConnection); + +} + +void AccountsInfoModel::onUserListChanged(const QStringList &userPathList) +{ + updateUserList(userPathList); + qInfo() << "get update:" << userPathList; +} + + + + + +void AccountsInfoModel::onSessionNew(const QString &in0, const QDBusObjectPath &in1) +{ + Q_UNUSED(in0); + Q_UNUSED(in1); + updateUserOnlineStatus(); +} +void AccountsInfoModel::onSessionRemoved(const QString &in0, const QDBusObjectPath &in1) +{ + Q_UNUSED(in0); + Q_UNUSED(in1); + updateUserOnlineStatus(); +} + + +void AccountsInfoModel::updateUserList(const QStringList &userPathList) +{ + qInfo() << "AccountsInfoModel updateUserList line 61" << "updateUserList begins!" ; + m_userMap.clear(); + for (QString userPath : userPathList) { + AccountsUser *userDBus = new AccountsUser("com.deepin.daemon.Accounts", userPath, QDBusConnection::systemBus(), this); + User *newUser = new User; + newUser->setName(userDBus->userName()); + newUser->setFullname(userDBus->fullName()); + newUser->setIconFile(userDBus->iconFile()); + newUser->setUserType(userDBus->accountType()); + newUser->setUserUid(userDBus->uid()); + //当前用户 + if (newUser->name() == m_currentUserName) { + newUser->setIsCurrentUser(true); + m_currentUserType = newUser->userType(); + } + qInfo() << "AccountsInfoModel updateUserList line 78" << "get user info of :" << newUser->name(); + m_userMap.insert(newUser->name(), newUser); + + } + + +} + + +void AccountsInfoModel::updateUserOnlineStatus() +{ + qInfo() << "AccountsInfoModel updateUserOnlineStatus line 88" << "updateUserOnlineStatus begins!" ; + m_onlineUsers.clear(); + + //异步获取SessionList + QDBusMessage message = m_LoginInter->call("ListSessions"); + QDBusPendingReply reply = m_LoginInter->asyncCall(QStringLiteral("ListSessions")); + reply.waitForFinished(); + if (reply.isValid()) { + m_sessionList = reply.value(); + } + for (auto session : m_sessionList) { + + m_onlineUsers << session.userName; + } + + Q_EMIT signalUserOnlineStatusUpdated(); +} + + +QList AccountsInfoModel::userList() const +{ + QList onlineUsers; + //筛选已登录用户 + for (auto user : m_userMap.values()) { + if (m_onlineUsers.contains(user->name())) { + user->setOnline(true); + onlineUsers << user; + } + } + qInfo() << "AccountsInfoModel userList" << "get online users:" << m_onlineUsers; + + return onlineUsers; +} + +User::UserType AccountsInfoModel::getCurrentUserType() const +{ + if (m_currentUserType == -1) { + return User::UserType::Customized; + } else if (m_currentUserType == 0) { + return User::UserType::StandardUser; + } else if (m_currentUserType == 1) { + return User::UserType::Administrator; + } +} + +bool AccountsInfoModel::lockSessionByUserName(const QString &userName) +{ + if (m_sessionList.size() > 0) { + for (SessionInfo si : m_sessionList) { + if (si.userName == userName) { + m_LoginInter->LockSession(si.sessionId); + return true; + } + } + qDebug() << "cannot find session with this username!"; + return false; + } else { + qDebug() << "no session found!"; + return false; + } + +} + + +bool AccountsInfoModel::activateSessionByUserName(const QString &userName) +{ + + if (m_sessionList.size() > 0) { + + for (SessionInfo si : m_sessionList) { + if (si.userName == userName) { + + m_LoginInter->ActivateSession(si.sessionId); + return true; + } + + } + qDebug() << "cannot find session with this username!"; + return false; + } else { + qDebug() << "no session found!"; + return false; + } + +} +bool AccountsInfoModel::LogoutByUserName(const QString &userName) +{ + if (userName == m_currentUserName) { + if (m_sessionList.size() > 0) { + qInfo() << "m_sessionList is OK"; + for (SessionInfo si : m_sessionList) { + if (si.userName == userName) { + qInfo() << "found" << userName << si.sessionId; + qInfo() << m_LoginInter->TerminateSession(si.sessionId).error(); + return true; + } + + } + qDebug() << "cannot find session with current username!"; + + } else { + qDebug() << "no session found!"; + + } + } else { + QStringList params; + + // check pkexec existance + if (!QFile::exists({PKEXEC_PATH})) { + return false; + } + + // check kill existance + if (!QFile::exists({PKILL_PATH})) { + return false; + } + + params << QString(PKILL_PATH) << QString("-u") << userName; + + QProcess proc; + + proc.start({PKEXEC_PATH}, params); + proc.waitForFinished(); + return true; + } + return false; + +} + +void AccountsInfoModel::EditAccount() +{ + if (m_controlInter) + m_controlInter->ShowPage("accounts", "Accounts Detail"); + +} + + + diff --git a/deepin-system-monitor-main/model/accounts_info_model.h b/deepin-system-monitor-main/model/accounts_info_model.h new file mode 100644 index 00000000..19331d11 --- /dev/null +++ b/deepin-system-monitor-main/model/accounts_info_model.h @@ -0,0 +1,94 @@ +#ifndef ACCOUNTS_INFO_MODEL_H +#define ACCOUNTS_INFO_MODEL_H +#include "user.h" +#include +#include +#include +#include +#include + + +using Accounts = com::deepin::daemon::Accounts; +using AccountsUser = com::deepin::daemon::accounts::User; +using LoginManager = org::freedesktop::login1::Manager; +using ControlCenter = com::deepin::dde::ControlCenter; + +typedef struct _SessionInfo { + QString sessionId; + uint userId; + QString userName; + QString seatId; + QDBusObjectPath sessionPath; +} SessionInfo; +typedef QList SessionInfoList; +Q_DECLARE_METATYPE(SessionInfoList); +Q_DECLARE_METATYPE(SessionInfo); + + +inline QDBusArgument &operator<<(QDBusArgument &argument, const SessionInfo &sessionInfo) +{ + argument.beginStructure(); + argument << sessionInfo.sessionId; + argument << sessionInfo.userId; + argument << sessionInfo.userName; + argument << sessionInfo.seatId; + argument << sessionInfo.sessionPath; + argument.endStructure(); + + return argument; +} + +inline const QDBusArgument &operator>>(const QDBusArgument &argument, SessionInfo &sessionInfo) +{ + argument.beginStructure(); + argument >> sessionInfo.sessionId; + argument >> sessionInfo.userId; + argument >> sessionInfo.userName; + argument >> sessionInfo.seatId; + argument >> sessionInfo.sessionPath; + argument.endStructure(); + + return argument; +} + + + + +class AccountsInfoModel : public QObject +{ + Q_OBJECT + +public: + explicit AccountsInfoModel(QObject *parent = nullptr); + void updateUserList(const QStringList &userPathList); + QList userList() const; + User::UserType getCurrentUserType() const; + bool lockSessionByUserName(const QString &userName); + bool activateSessionByUserName(const QString &userName); + bool LogoutByUserName(const QString &userName); + void EditAccount(); +Q_SIGNALS: + void signalUserOnlineStatusUpdated(); + + +public Q_SLOTS: + void onUserListChanged(const QStringList &userPathList); + void updateUserOnlineStatus(); + + void onSessionNew(const QString &in0, const QDBusObjectPath &in1); + void onSessionRemoved(const QString &in0, const QDBusObjectPath &in1); + + +private: + Accounts *m_accountsInter; + QMap m_userMap ; + QStringList m_onlineUsers; + LoginManager *m_LoginInter; + ControlCenter *m_controlInter; + QString m_currentUserName; + int m_currentUserType; + SessionInfoList m_sessionList {}; +}; + + +#endif // ACCOUNTS_INFO_MODEL_H diff --git a/deepin-system-monitor-main/model/process_table_model.cpp b/deepin-system-monitor-main/model/process_table_model.cpp index 771ad6c3..8ce1bab2 100644 --- a/deepin-system-monitor-main/model/process_table_model.cpp +++ b/deepin-system-monitor-main/model/process_table_model.cpp @@ -18,9 +18,11 @@ using namespace common::format; DGUI_USE_NAMESPACE // using namespace Dtk::Gui; // model constructor -ProcessTableModel::ProcessTableModel(QObject *parent) +ProcessTableModel::ProcessTableModel(QObject *parent, const QString &username) : QAbstractTableModel(parent) { + setUserModeName(username); + qInfo() << "ProcessTableModel Constructor line 41:" << "new model with name" << username; //update model's process list cache on process list updated signal auto *monitor = ThreadManager::instance()->thread(BaseThread::kSystemMonitorThread)->systemMonitorInstance(); connect(monitor, &SystemMonitor::statInfoUpdated, this, &ProcessTableModel::updateProcessList); @@ -72,7 +74,36 @@ Process ProcessTableModel::getProcess(pid_t pid) const // update process model with the data provided by list void ProcessTableModel::updateProcessList() { - QTimer::singleShot(0, this, SLOT(updateProcessListDelay())); + if (m_userModeName.isNull()) { + QTimer::singleShot(0, this, SLOT(updateProcessListDelay())); + } else { + QTimer::singleShot(0, this, SLOT(updateProcessListWithUserSpecified())); + } +} + +void ProcessTableModel::updateProcessListWithUserSpecified() +{ + + ProcessSet *processSet = ProcessDB::instance()->processSet(); + const QList &newpidlst = processSet->getPIDList(); + + beginRemoveRows({}, 0, m_procIdList.size()); + endRemoveRows(); + m_procIdList.clear(); + m_processList.clear(); + int raw; + for (const auto &pid : newpidlst) { + Process changedProc = processSet->getProcessById(pid); + if (changedProc.userName() == m_userModeName) { + raw = m_procIdList.size(); + beginInsertRows({}, raw, raw); + m_procIdList << pid; + m_processList << changedProc; + endInsertRows(); + } + } + + Q_EMIT modelUpdated(); } void ProcessTableModel::updateProcessListDelay() @@ -383,3 +414,80 @@ void ProcessTableModel::updateProcessPriority(pid_t pid, int priority) Q_EMIT dataChanged(index(row, 0), index(row, columnCount() - 1)); } } + + +void ProcessTableModel::setUserModeName(const QString &userName) +{ + if (userName != m_userModeName) { + m_userModeName = userName; + updateProcessListWithUserSpecified(); + } +} + +qreal ProcessTableModel::getTotalCPUUsage() +{ + qreal cpuUsage = 0; + for (const auto &proc : m_processList) { + cpuUsage += proc.cpu(); + } + return cpuUsage; +} +qreal ProcessTableModel::getTotalMemoryUsage() +{ + qreal memUsage = 0; + for (const auto &proc : m_processList) { + memUsage += proc.memory(); + } + return memUsage; +} +qreal ProcessTableModel::getTotalDownload() +{ + qreal download = 0; + for (const auto &proc : m_processList) { + download += proc.recvBps(); + } + return download; +} +qreal ProcessTableModel::getTotalUpload() +{ + qlonglong upload = 0; + for (const auto &proc : m_processList) { + upload += proc.sentBps(); + } + return upload; +} + + + +qreal ProcessTableModel::getTotalVirtualMemoryUsage() +{ + qlonglong vtmem = 0; + for (const auto &proc : m_processList) { + vtmem += proc.vtrmemory(); + } + return vtmem; +} +qreal ProcessTableModel::getTotalSharedMemoryUsage() +{ + qlonglong smem = 0; + for (const auto &proc : m_processList) { + smem += proc.sharememory(); + } + return smem; +} +qreal ProcessTableModel::getTotalDiskRead() +{ + qlonglong diskread = 0; + for (const auto &proc : m_processList) { + diskread += proc.readBps(); + } + return diskread; +} +qreal ProcessTableModel::getTotalDiskWrite() +{ + qlonglong diskwrite = 0; + for (const auto &proc : m_processList) { + diskwrite += proc.writeBps(); + } + return diskwrite; +} \ No newline at end of file diff --git a/deepin-system-monitor-main/model/process_table_model.h b/deepin-system-monitor-main/model/process_table_model.h index 9deebf71..2a8d43e7 100644 --- a/deepin-system-monitor-main/model/process_table_model.h +++ b/deepin-system-monitor-main/model/process_table_model.h @@ -72,7 +72,7 @@ class ProcessTableModel : public QAbstractTableModel * @brief Model constructor * @param parent Parent object */ - explicit ProcessTableModel(QObject *parent = nullptr); + explicit ProcessTableModel(QObject *parent = nullptr, const QString &username = nullptr); /** * @brief Update process model with the data provided by list @@ -141,6 +141,15 @@ class ProcessTableModel : public QAbstractTableModel * @return Process entry item */ Process getProcess(pid_t pid) const; + void setUserModeName(const QString &userName); + qreal getTotalCPUUsage(); + qreal getTotalMemoryUsage(); + qreal getTotalDownload(); + qreal getTotalUpload(); + qreal getTotalVirtualMemoryUsage(); + qreal getTotalSharedMemoryUsage(); + qreal getTotalDiskRead(); + qreal getTotalDiskWrite(); Q_SIGNALS: /** @@ -169,9 +178,12 @@ private Q_SLOTS: void updateProcessListDelay(); + void updateProcessListWithUserSpecified(); private: QList m_procIdList; // pid list QList m_processList; // pid list + + QString m_userModeName {}; }; #endif // PROCESS_TABLE_MODEL_H diff --git a/deepin-system-monitor-main/model/user.cpp b/deepin-system-monitor-main/model/user.cpp new file mode 100644 index 00000000..c46b0a9f --- /dev/null +++ b/deepin-system-monitor-main/model/user.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: sbw + * kirigaya + * Hualet + * + * Maintainer: sbw + * kirigaya + * Hualet + * + * 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 "user.h" + +User::User(QObject *parent) + : QObject(parent) + , m_isCurrentUser(false) + , m_online(false) + , m_userType(0) + , m_name("") + , m_fullname("") + , m_iconFile("") +{ + +} + +User::~User() +{ + +} + +void User::setName(const QString &name) +{ + if (name != m_name) { + m_name = name; + } +} + +void User::setFullname(const QString &fullname) +{ + if (fullname != m_fullname) { + m_fullname = fullname; + } +} + +const QString User::displayName() const +{ + return m_fullname.isEmpty() ? m_name : m_fullname; +} + +void User::setIsCurrentUser(bool isCurrentUser) +{ + if (isCurrentUser == m_isCurrentUser) + return; + + m_isCurrentUser = isCurrentUser; +} + +void User::setUserType(const int userType) +{ + if (m_userType == userType) { + return; + } + m_userType = userType; +} + + +void User::setIconFile(const QString &iconFile) +{ + if (m_iconFile == iconFile) { + return; + } + m_iconFile = iconFile; +} + +void User::setUserUid(const QString &uid) +{ + if (m_uid == uid) { + return; + } + m_uid = uid; +} + +void User::setOnline(bool online) +{ + if (m_online != online) { + m_online = online; + } +} diff --git a/deepin-system-monitor-main/model/user.h b/deepin-system-monitor-main/model/user.h new file mode 100644 index 00000000..ff228a26 --- /dev/null +++ b/deepin-system-monitor-main/model/user.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: sbw + * kirigaya + * Hualet + * + * Maintainer: sbw + * kirigaya + * Hualet + * + * 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 USER_H +#define USER_H + +#include +#include + + +class User : public QObject +{ + Q_OBJECT +public: + + enum UserType { + StandardUser = 0, + Administrator, + Customized + }; + + explicit User(QObject *parent = nullptr); + + ~User(); + + const QString name() const { return m_name; } + void setName(const QString &name); + + const QString fullname() const { return m_fullname; } + void setFullname(const QString &fullname); + + const QString iconFile() const { return m_iconFile; } + void setIconFile(const QString &iconFile); + + inline bool isCurrentUser() const { return m_isCurrentUser; } + void setIsCurrentUser(bool isCurrentUser); + + inline int userType() const { return m_userType; } + void setUserType(const int userType); + + inline QString userUid() const { return m_uid; } + void setUserUid(const QString &uid); + const QString displayName() const; + + inline bool online() const { return m_online; } + void setOnline(bool online); + +private: + bool m_isCurrentUser; + bool m_online; + int m_userType; + QString m_uid; + + QString m_name; + QString m_fullname; + QString m_iconFile; + +}; + + + +#endif // USER_H diff --git a/deepin-system-monitor-main/process/process_set.cpp b/deepin-system-monitor-main/process/process_set.cpp index 78cefadb..65d98c6a 100644 --- a/deepin-system-monitor-main/process/process_set.cpp +++ b/deepin-system-monitor-main/process/process_set.cpp @@ -7,7 +7,6 @@ #include "process/process_db.h" #include "common/common.h" #include "wm/wm_window_list.h" -#include "settings.h" #include @@ -26,11 +25,6 @@ ProcessSet::ProcessSet() , m_pidCtoPMapping {} , m_pidPtoCMapping {} { - m_prePid.clear(); - m_curPid.clear(); - m_pidMyApps.clear(); - m_simpleSet.clear(); - m_settings = Settings::instance(); } ProcessSet::ProcessSet(const ProcessSet &other) @@ -82,7 +76,7 @@ void ProcessSet::scanProcess() procstage->uptime = iter->procuptime(); m_recentProcStage[iter->pid()] = procstage; } - m_curPid.clear(); + m_set.clear(); m_pidPtoCMapping.clear(); m_pidCtoPMapping.clear(); @@ -92,53 +86,15 @@ void ProcessSet::scanProcess() QList appLst; while (iter.hasNext()) { Process proc = iter.next(); + if (!proc.isValid()) + continue; - if(!m_curPid.contains(proc.pid())) - m_curPid.append(proc.pid()); - - } - - if(m_prePid != m_curPid) { - for (const pid_t &pid : m_prePid) { - if(!m_curPid.contains(pid)){ - m_prePid.removeAt(pid); //remove disappear process pid - if(m_simpleSet.contains(pid)) - m_simpleSet.remove(pid); - if(m_pidMyApps.contains(pid)) - m_pidMyApps.removeAt(pid); - } - } - - for (const pid_t &pid : m_curPid) { - if(!m_prePid.contains(pid)){ //add new process pid - Process *proc = new Process(pid); - proc->readProcessSimpleInfo(); - if(!m_simpleSet.contains(pid)) - m_simpleSet.insert(proc->pid(), *proc); + m_set.insert(proc.pid(), proc); + m_pidPtoCMapping.insert(proc.ppid(), proc.pid()); + m_pidCtoPMapping.insert(proc.pid(), proc.ppid()); - if (proc->appType() == kFilterApps && !wmwindowList->isTrayApp(proc->pid())) { - m_pidMyApps << proc->pid(); - } - } - } - m_prePid = m_curPid; - } - - const QVariant &vindex = m_settings->getOption(kSettingKeyProcessTabIndex, kFilterApps); - int index = vindex.toInt(); - - for (const pid_t &pid : m_prePid) { - Process proc = m_simpleSet[pid]; - if( ((kFilterApps == index) && (proc.appType()<= kFilterApps)) || - ((kFilterCurrentUser == index) && (proc.appType() <= kFilterCurrentUser)) || - (kNoFilter == index)) { - proc.readProcessVariableInfo(); // - if (!proc.isValid()) - continue; - - m_set.insert(proc.pid(), proc); - m_pidPtoCMapping.insert(proc.ppid(), proc.pid()); - m_pidCtoPMapping.insert(proc.pid(), proc.ppid()); + if (proc.appType() == kFilterApps && !wmwindowList->isTrayApp(proc.pid())) { + appLst << proc.pid(); } } @@ -154,7 +110,7 @@ void ProcessSet::scanProcess() return b; }; - for (const pid_t &pid : m_pidMyApps) { + for (const pid_t &pid : appLst) { qreal recvBps = 0; qreal sendBps = 0; mergeSubProcNetIO(pid, recvBps, sendBps); @@ -164,8 +120,7 @@ void ProcessSet::scanProcess() mergeSubProcCpu(pid, ptotalCpu); m_set[pid].setCpu(ptotalCpu); - if (!wmwindowList->isGuiApp(pid)) - { + if (!wmwindowList->isGuiApp(pid)) { // only if no ancestor process is gui app we keep this process if (m_pidCtoPMapping.contains(pid) && anyRootIsGuiProc(m_pidCtoPMapping[pid])) { @@ -209,9 +164,11 @@ Process ProcessSet::Iterator::next() if (m_dirent && isdigit(m_dirent->d_name[0])) { auto pid = pid_t(atoi(m_dirent->d_name)); Process proc(pid); + proc.readProcessInfo(); advance(); + if (proc.isValid()) return proc; } @@ -224,8 +181,8 @@ void ProcessSet::Iterator::advance() if (isdigit(m_dirent->d_name[0])) if(pid_t(atoi(m_dirent->d_name)) < 10) continue; - else - break; + else + break; } if (!m_dirent && errno) { print_errno(errno, "read /proc failed"); @@ -244,8 +201,6 @@ const Process ProcessSet::getProcessById(pid_t pid) const QList ProcessSet::getPIDList() const { - const QVariant &vindex = m_settings->getOption(kSettingKeyProcessTabIndex, kFilterApps); - int index = vindex.toInt(); // 当系统读取到的m_set为空时,通过keys()函数返回会造成段错误 原因是keys函数效率低下,会造成大量的内存拷贝 // 替换方案是 QList pidList {}; @@ -254,11 +209,7 @@ QList ProcessSet::getPIDList() const QMap::key_iterator iterBegin = m_set.keyBegin(); for (;iterBegin != m_set.keyEnd(); ++iterBegin) { pid_t tmpKey = *iterBegin; - Process proc = m_set[tmpKey]; - if( ((kFilterApps == index) && (proc.appType()<= kFilterApps)) || - ((kFilterCurrentUser == index) && (proc.appType() <= kFilterCurrentUser)) || - (kNoFilter == index)) - pidList.append(tmpKey); + pidList.append(tmpKey); if (size != m_set.size()) break; } diff --git a/deepin-system-monitor-main/process/process_set.h b/deepin-system-monitor-main/process/process_set.h index 3b9cf5b3..b17160c4 100644 --- a/deepin-system-monitor-main/process/process_set.h +++ b/deepin-system-monitor-main/process/process_set.h @@ -15,7 +15,6 @@ using namespace common::alloc; -class Settings; namespace core { namespace process { @@ -69,16 +68,11 @@ class ProcessSet }; private: - Settings *m_settings = nullptr; - QMap m_simpleSet; QMap m_set; QMap> m_recentProcStage {}; QMap m_pidCtoPMapping {}; // child to parent pid mapping QMultiMap m_pidPtoCMapping {}; // parent to child pid mapping - QList m_prePid; - QList m_curPid; - QList m_pidMyApps; friend class Iterator; }; diff --git a/deepin-system-monitor-main/translations/deepin-system-monitor.ts b/deepin-system-monitor-main/translations/deepin-system-monitor.ts index db24d46e..6125ad4c 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor.ts @@ -1143,5 +1143,27 @@ Are you sure you want to continue? Services Services + + Users + Users + + + + User.Account.Type + + Administrator + Administrator + + + Standard User + Standard User + + + + User.Account.Operation + + Edit account information + Edit account information + diff --git a/deepin-system-monitor-main/translations/deepin-system-monitor_ca.ts b/deepin-system-monitor-main/translations/deepin-system-monitor_ca.ts index 31932a03..2d0a1995 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor_ca.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor_ca.ts @@ -1110,5 +1110,27 @@ Segur que voleu continuar? Services Serveis + + Users + Usuaris + + + + User.Account.Type + + Administrator + Administrador + + + Standard User + Usuari estàndard + + + + User.Account.Operation + + Edit account information + Edita la informació del compte + diff --git a/deepin-system-monitor-main/translations/deepin-system-monitor_en.ts b/deepin-system-monitor-main/translations/deepin-system-monitor_en.ts index 53d4c377..feb3e2aa 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor_en.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor_en.ts @@ -1110,5 +1110,27 @@ Are you sure you want to continue? Services Services + + Users + Users + + + + User.Account.Type + + Administrator + Administrator + + + Standard User + Standard User + + + + User.Account.Operation + + Edit account information + Edit account information + diff --git a/deepin-system-monitor-main/translations/deepin-system-monitor_fi.ts b/deepin-system-monitor-main/translations/deepin-system-monitor_fi.ts index 9624c8a2..603f6fe1 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor_fi.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor_fi.ts @@ -1110,5 +1110,27 @@ Haluatko varmasti jatkaa? Services Palvelut + + Users + Käyttäjät + + + + User.Account.Type + + Administrator + Järjestelmänvalvoja + + + Standard User + Tavallinen käyttäjä + + + + User.Account.Operation + + Edit account information + Muokkaa tilitietoja + diff --git a/deepin-system-monitor-main/translations/deepin-system-monitor_fr.ts b/deepin-system-monitor-main/translations/deepin-system-monitor_fr.ts index f6243802..8f4537fb 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor_fr.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor_fr.ts @@ -1110,5 +1110,27 @@ Es-tu sûr de vouloir continuer ? Services Services + + Users + Utilisateurs + + + + User.Account.Type + + Administrator + Administrateur  + + + Standard User + Utilisateur standard + + + + User.Account.Operation + + Edit account information + Éditer les informations du compte + diff --git a/deepin-system-monitor-main/translations/deepin-system-monitor_hu.ts b/deepin-system-monitor-main/translations/deepin-system-monitor_hu.ts index e742fb24..1af65fb3 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor_hu.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor_hu.ts @@ -1109,5 +1109,27 @@ Are you sure you want to continue? Services Szolgáltatások + + Users + Felhasználók + + + + User.Account.Type + + Administrator + Rendszergazda + + + Standard User + Alap Felhasználó + + + + User.Account.Operation + + Edit account information + Felhasználói fiók adatainak szerkesztése + diff --git a/deepin-system-monitor-main/translations/deepin-system-monitor_it.ts b/deepin-system-monitor-main/translations/deepin-system-monitor_it.ts index 3cd3ad50..3ad3a559 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor_it.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor_it.ts @@ -1104,5 +1104,27 @@ Sicuro di voler terminarla? Services Servizi + + Users + Utenti + + + + User.Account.Type + + Administrator + Amministratore + + + Standard User + Utente standard + + + + User.Account.Operation + + Edit account information + Modifica info account + diff --git a/deepin-system-monitor-main/translations/deepin-system-monitor_nl.ts b/deepin-system-monitor-main/translations/deepin-system-monitor_nl.ts index 5355fb15..56ee3ee9 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor_nl.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor_nl.ts @@ -1103,5 +1103,27 @@ Weet je zeker dat je door wilt gaan? Services Diensten + + Users + Gebruikers + + + + User.Account.Type + + Administrator + Beheerder + + + Standard User + Standaardgebruiker + + + + User.Account.Operation + + Edit account information + Accountinformatie bewerken + 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 2e46dd5d..33a05262 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor_pl.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor_pl.ts @@ -1110,5 +1110,27 @@ Czy na pewno chcesz kontynuować? Services Usługi + + Users + Użytkownicy + + + + User.Account.Type + + Administrator + Administrator + + + Standard User + Standardowy użytkownik + + + + User.Account.Operation + + Edit account information + Edytuj informacje konta + diff --git a/deepin-system-monitor-main/translations/deepin-system-monitor_uk.ts b/deepin-system-monitor-main/translations/deepin-system-monitor_uk.ts index 7c80ccd6..51229f2b 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor_uk.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor_uk.ts @@ -1108,5 +1108,27 @@ Are you sure you want to continue? Services Служби + + Users + Користувачі + + + + User.Account.Type + + Administrator + Адміністратор + + + Standard User + Стандартний користувач + + + + User.Account.Operation + + Edit account information + Редагувати дані облікового запису + diff --git a/deepin-system-monitor-main/translations/deepin-system-monitor_zh_CN.ts b/deepin-system-monitor-main/translations/deepin-system-monitor_zh_CN.ts index 66ed037c..4b2e2097 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor_zh_CN.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor_zh_CN.ts @@ -1125,5 +1125,27 @@ Are you sure you want to continue? Services 系统服务 + + Users + 用户 + + + + User.Account.Type + + Administrator + 管理员 + + + Standard User + 标准用户 + + + + User.Account.Operation + + Edit account information + 修改帐户信息 + diff --git a/deepin-system-monitor-main/translations/deepin-system-monitor_zh_HK.ts b/deepin-system-monitor-main/translations/deepin-system-monitor_zh_HK.ts index 8a6741bd..e4a66172 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor_zh_HK.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor_zh_HK.ts @@ -1110,5 +1110,27 @@ Are you sure you want to continue? Services 系統服務 + + Users + 用戶 + + + + User.Account.Type + + Administrator + 管理員 + + + Standard User + 標準用戶 + + + + User.Account.Operation + + Edit account information + 修改帳戶訊息 + diff --git a/deepin-system-monitor-main/translations/deepin-system-monitor_zh_TW.ts b/deepin-system-monitor-main/translations/deepin-system-monitor_zh_TW.ts index 0a80973b..56527bf0 100644 --- a/deepin-system-monitor-main/translations/deepin-system-monitor_zh_TW.ts +++ b/deepin-system-monitor-main/translations/deepin-system-monitor_zh_TW.ts @@ -1110,5 +1110,27 @@ Are you sure you want to continue? Services 系統服務 + + Users + 使用者 + + + + User.Account.Type + + Administrator + 管理員 + + + Standard User + 標準使用者 + + + + User.Account.Operation + + Edit account information + 修改帳戶訊息 + diff --git a/deepin-system-monitor-main/translations/policy/com.deepin.pkexec.deepin-system-monitor.policy b/deepin-system-monitor-main/translations/policy/com.deepin.pkexec.deepin-system-monitor.policy index a804f293..c2488c09 100644 --- a/deepin-system-monitor-main/translations/policy/com.deepin.pkexec.deepin-system-monitor.policy +++ b/deepin-system-monitor-main/translations/policy/com.deepin.pkexec.deepin-system-monitor.policy @@ -43,4 +43,17 @@ true 设置进程启动方式需要授权 + + Logout other users + Logging out other users is required to change process priority + + + no + no + auth_admin_keep + + /usr/bin/pkill + true + 注销其它用户需要授权 +