Skip to content

Commit bdb4e84

Browse files
committed
feat: implement close all windows functionality
1. Add requestCloseAll method to handle close all action for grouped applications 2. When close all is triggered, find all windows with the same desktop ID and close them 3. Use X11Utils to send close commands to individual windows 4. Add necessary includes for DockGroupModel and X11Utils 5. Update action handler to call requestCloseAll instead of requestClose for close all action feat: 实现关闭所有窗口功能 1. 添加 requestCloseAll 方法来处理分组应用的关闭所有操作 2. 当触发关闭所有时,查找具有相同桌面 ID 的所有窗口并关闭它们 3. 使用 X11Utils 向各个窗口发送关闭命令 4. 添加 DockGroupModel 和 X11Utils 的必要包含 5. 更新操作处理器,为关闭所有操作调用 requestCloseAll 而不是 requestClose Pms: BUG-334659
1 parent 3bcaa09 commit bdb4e84

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

panels/dock/taskmanager/dockglobalelementmodel.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
#include "dockglobalelementmodel.h"
66
#include "applicationinterface.h"
7+
#include "dockgroupmodel.h"
78
#include "globals.h"
89
#include "taskmanager.h"
910
#include "taskmanagersettings.h"
11+
#include "x11utils.h"
1012

1113
#include <QAbstractListModel>
1214
#include <QDBusConnection>
@@ -372,7 +374,7 @@ void DockGlobalElementModel::requestNewInstance(const QModelIndex &index, const
372374
} else if (action == DOCK_ACTION_FORCEQUIT) {
373375
requestClose(index, true);
374376
} else if (action == DOCK_ACTION_CLOSEALL) {
375-
requestClose(index);
377+
requestCloseAll(index);
376378
} else {
377379
auto data = m_data.value(index.row());
378380
auto id = std::get<0>(data);
@@ -398,6 +400,37 @@ void DockGlobalElementModel::requestClose(const QModelIndex &index, bool force)
398400

399401
qWarning() << "unable to close app not running";
400402
}
403+
404+
void DockGlobalElementModel::requestCloseAll(const QModelIndex &index) const
405+
{
406+
auto data = m_data.value(index.row());
407+
auto sourceModel = std::get<1>(data);
408+
auto sourceRow = std::get<2>(data);
409+
410+
if (sourceModel == m_activeAppModel) {
411+
auto sourceIndex = sourceModel->index(sourceRow, 0);
412+
if (auto combineModel = qobject_cast<DockCombineModel*>(sourceModel)) {
413+
QString targetDesktopId = sourceIndex.data(TaskManager::DesktopIdRole).toString();
414+
QList<uint32_t> windowIds;
415+
for (int i = 0; i < combineModel->rowCount(); i++) {
416+
QModelIndex idx = combineModel->index(i, 0);
417+
QString desktopId = idx.data(TaskManager::DesktopIdRole).toString();
418+
if (desktopId == targetDesktopId) {
419+
uint32_t winId = idx.data(TaskManager::WinIdRole).toUInt();
420+
if (winId != 0) {
421+
windowIds.append(winId);
422+
}
423+
}
424+
}
425+
426+
for (uint32_t winId : windowIds) {
427+
X11Utils::instance()->closeWindow(winId);
428+
}
429+
}
430+
return;
431+
}
432+
}
433+
401434
void DockGlobalElementModel::requestUpdateWindowGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate) const
402435
{
403436
Q_UNUSED(index)

panels/dock/taskmanager/dockglobalelementmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class DockGlobalElementModel : public QAbstractListModel, public AbstractTaskMan
3232

3333
void requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) const override;
3434
void requestClose(const QModelIndex &index, bool force = false) const override;
35+
void requestCloseAll(const QModelIndex &index) const;
3536
void requestUpdateWindowGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate = nullptr) const override;
3637

3738
void requestWindowsView(const QModelIndexList &indexes) const override;

0 commit comments

Comments
 (0)