-
Notifications
You must be signed in to change notification settings - Fork 55
feat: add category-based skip list for cgroups grouping #1384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,10 +63,44 @@ static QString getDesktopIdByPid(const QStringList &identifies) | |
| qCDebug(taskManagerLog) << "appId is empty, AM failed to identify window with pid:" << windowPid; | ||
| return {}; | ||
| } | ||
|
|
||
| return QString::fromUtf8(appId); | ||
| } | ||
|
|
||
| // 检查应用的 Categories 是否在跳过列表中 | ||
| static bool shouldSkipCgroupsByCategories(const QString &desktopId, QAbstractItemModel *activeAppModel, const QHash<int, QByteArray> &roleNames) | ||
| { | ||
| auto skipCategories = Settings->cgroupsBasedGroupingSkipCategories(); | ||
| if (skipCategories.isEmpty() || desktopId.isEmpty()) { | ||
| return false; | ||
| } | ||
|
|
||
| QStringList categories; | ||
|
|
||
| // 从 dde-apps 的 AppItem 读取 categories | ||
| if (activeAppModel) { | ||
| auto existingItem = activeAppModel->match(activeAppModel->index(0, 0), roleNames.key("desktopId"), desktopId, 1, Qt::MatchFixedString | Qt::MatchWrap).value(0); | ||
| if (existingItem.isValid()) { | ||
| categories = activeAppModel->data(existingItem, roleNames.key("categories")).toStringList(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不用再从 |
||
| } | ||
| } | ||
|
|
||
| if (categories.isEmpty()) { | ||
| return false; | ||
| } | ||
|
|
||
| // 检查是否有任何 category 在跳过列表中 | ||
| for (const QString &category : categories) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 是不是反了,不应该是迭代 skipCategories 然后判断 categories 是否包含 skipCategoriy 吗? skipCategories 配置里预期不会有太多值,默认只有终端,也不期望用户自己随便加。 |
||
| if (skipCategories.contains(category)) { | ||
| qCDebug(taskManagerLog) << "Skipping cgroups grouping for" << desktopId | ||
| << "due to category:" << category; | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| class BoolFilterModel : public QSortFilterProxyModel, public AbstractTaskManagerInterface | ||
| { | ||
| Q_OBJECT | ||
|
|
@@ -159,7 +193,9 @@ bool TaskManager::init() | |
| // 尝试通过AM(Application Manager)匹配应用程序 | ||
| if (Settings->cgroupsBasedGrouping()) { | ||
| auto desktopId = getDesktopIdByPid(identifies); | ||
| if (!desktopId.isEmpty() && !Settings->cgroupsBasedGroupingSkipIds().contains(desktopId)) { | ||
| if (!desktopId.isEmpty() && | ||
| !Settings->cgroupsBasedGroupingSkipIds().contains(desktopId) && | ||
| !shouldSkipCgroupsByCategories(desktopId, model, roleNames)) { | ||
| auto res = model->match(model->index(0, 0), roleNames.key(MODEL_DESKTOPID), desktopId, 1, Qt::MatchFixedString | Qt::MatchWrap).value(0); | ||
| if (res.isValid()) { | ||
| qCDebug(taskManagerLog) << "matched by AM desktop ID:" << desktopId << res; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
倒不如直接把 “尝试通过AM(Application Manager)匹配应用程序” 那块提出来。只提目前这一部分有点怪怪的。