Skip to content

Commit 2da7b5e

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 2da7b5e

File tree

4 files changed

+29
-22
lines changed

4 files changed

+29
-22
lines changed

panels/dock/taskmanager/dockglobalelementmodel.cpp

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,10 @@ void DockGlobalElementModel::requestActivate(const QModelIndex &index) const
340340
auto sourceIndex = sourceModel->index(sourceRow, 0);
341341
m_activeAppModel->requestActivate(sourceIndex);
342342
} else {
343-
this->requestNewInstance(index, "");
343+
if (auto interface = dynamic_cast<AbstractTaskManagerInterface*>(sourceModel)) {
344+
auto sourceIndex = sourceModel->index(sourceRow, 0);
345+
interface->requestNewInstance(sourceIndex, "");
346+
}
344347
}
345348
}
346349

@@ -363,26 +366,6 @@ void DockGlobalElementModel::requestOpenUrls(const QModelIndex &index, const QLi
363366
}
364367
}
365368

366-
void DockGlobalElementModel::requestNewInstance(const QModelIndex &index, const QString &action) const
367-
{
368-
if (action == DOCK_ACTION_DOCK) {
369-
auto data = m_data.value(index.row());
370-
auto id = std::get<0>(data);
371-
TaskManagerSettings::instance()->toggleDockedElement(QStringLiteral("desktop/%1").arg(id));
372-
} else if (action == DOCK_ACTION_FORCEQUIT) {
373-
requestClose(index, true);
374-
} else if (action == DOCK_ACTION_CLOSEALL) {
375-
requestClose(index);
376-
} else {
377-
auto data = m_data.value(index.row());
378-
auto id = std::get<0>(data);
379-
QProcess process;
380-
process.setProcessChannelMode(QProcess::MergedChannels);
381-
process.start("dde-am", {"--by-user", id, action});
382-
process.waitForFinished();
383-
return;
384-
}
385-
}
386369
void DockGlobalElementModel::requestClose(const QModelIndex &index, bool force) const
387370
{
388371
auto data = m_data.value(index.row());
@@ -398,6 +381,7 @@ void DockGlobalElementModel::requestClose(const QModelIndex &index, bool force)
398381

399382
qWarning() << "unable to close app not running";
400383
}
384+
401385
void DockGlobalElementModel::requestUpdateWindowGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate) const
402386
{
403387
Q_UNUSED(index)

panels/dock/taskmanager/dockglobalelementmodel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class DockGlobalElementModel : public QAbstractListModel, public AbstractTaskMan
2828
inline int mapToSourceModelRole(QAbstractItemModel *model, int role) const;
2929

3030
void requestActivate(const QModelIndex &index) const override;
31-
void requestNewInstance(const QModelIndex &index, const QString &action) const override;
3231

3332
void requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) const override;
3433
void requestClose(const QModelIndex &index, bool force = false) const override;

panels/dock/taskmanager/dockgroupmodel.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#include "abstracttaskmanagerinterface.h"
77
#include "rolegroupmodel.h"
88
#include "taskmanager.h"
9+
#include "taskmanagersettings.h"
10+
#include "globals.h"
11+
12+
#include <QProcess>
913

1014
namespace dock
1115
{
@@ -150,4 +154,23 @@ void DockGroupModel::requestWindowsView(const QModelIndexList &indexes) const
150154

151155
callInterfaceMethod(sourceIndexes, &AbstractTaskManagerInterface::requestWindowsView);
152156
}
157+
158+
void DockGroupModel::requestNewInstance(const QModelIndex &index, const QString &action) const
159+
{
160+
if (action == DOCK_ACTION_DOCK) {
161+
auto desktopId = index.data(TaskManager::DesktopIdRole).toString();
162+
TaskManagerSettings::instance()->toggleDockedElement(QStringLiteral("desktop/%1").arg(desktopId));
163+
} else if (action == DOCK_ACTION_FORCEQUIT) {
164+
requestClose(index, true);
165+
} else if (action == DOCK_ACTION_CLOSEALL) {
166+
requestClose(index);
167+
} else {
168+
auto desktopId = index.data(TaskManager::DesktopIdRole).toString();
169+
QProcess process;
170+
process.setProcessChannelMode(QProcess::MergedChannels);
171+
process.start("dde-am", {"--by-user", desktopId, action});
172+
process.waitForFinished();
173+
return;
174+
}
175+
}
153176
}

panels/dock/taskmanager/dockgroupmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class DockGroupModel : public RoleGroupModel, public AbstractTaskManagerInterfac
2020
Q_INVOKABLE virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
2121

2222
void requestActivate(const QModelIndex &index) const override;
23+
void requestNewInstance(const QModelIndex &index, const QString &action) const override;
2324
void requestClose(const QModelIndex &index, bool force = false) const override;
2425
void requestUpdateWindowGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate = nullptr) const override;
2526
void requestWindowsView(const QModelIndexList &indexes) const override;

0 commit comments

Comments
 (0)