Skip to content

Commit 6430c48

Browse files
wjyrichdeepin-bot[bot]
authored andcommitted
feat: implement window split mode with dynamic title display
1. Add window split mode to display individual windows separately in taskbar 2. Implement dynamic title calculation with adaptive character limits based on available space 3. Add new AppItemWithTitle component that displays window titles alongside icons 4. Enhance drag and drop functionality to support individual window dragging 5. Update context menu to show "Close" instead of "Close All" in split mode 6. Add WinTitleRole support in model for window title data 7. Implement intelligent window grouping logic to keep windows of same app together Log: Added window split mode showing individual window titles in taskbar Influence: 1. Test window split mode activation and deactivation 2. Verify window titles display correctly with dynamic character limits 3. Test drag and drop of individual windows in split mode 4. Check context menu shows appropriate close options 5. Verify window grouping maintains proper order 6. Test window activation and new instance creation 7. Validate title truncation and ellipsis behavior 8. Test with multiple windows of same application feat: 实现窗口分离模式并支持动态标题显示 1. 添加窗口分离模式,在任务栏中分别显示各个窗口 2. 实现基于可用空间的动态字符限制计算 3. 新增 AppItemWithTitle 组件,在图标旁显示窗口标题 4. 增强拖放功能以支持单独窗口拖动 5. 更新上下文菜单,在分离模式下显示"关闭"而非"全部关闭" 6. 在模型中添加 WinTitleRole 支持窗口标题数据 7. 实现智能窗口分组逻辑,保持同一应用的窗口在一起 Log: 新增窗口分离模式,在任务栏显示单独窗口标题 整体计算方式为: 获取任务栏的剩余范围remainingSpacesForSplitWindow,默认给所有应用窗口标题为最大宽度--7个汉字的宽度, 然后判断所有应用窗口的图标+标题总和宽度是否大于remainingSpacesForSplitWindow, 如果大于就开始缩减此时窗口的标签中最长标题的长度,(charLimits具体就是存着相对应的index存着字符的数量。)
1 parent 66f3128 commit 6430c48

File tree

5 files changed

+912
-27
lines changed

5 files changed

+912
-27
lines changed

panels/dock/taskmanager/dockglobalelementmodel.cpp

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ DockGlobalElementModel::DockGlobalElementModel(QAbstractItemModel *appsModel, Do
123123
*it = std::make_tuple(id, m_appsModel, row);
124124
Q_EMIT dataChanged(pIndex,
125125
pIndex,
126-
{TaskManager::ActiveRole, TaskManager::AttentionRole, TaskManager::WindowsRole, TaskManager::MenusRole});
126+
{TaskManager::ActiveRole, TaskManager::AttentionRole, TaskManager::WindowsRole, TaskManager::MenusRole, TaskManager::WinTitleRole});
127127
}
128128
} else {
129129
beginRemoveRows(QModelIndex(), pos, pos);
@@ -303,7 +303,11 @@ QString DockGlobalElementModel::getMenus(const QModelIndex &index) const
303303
if (TaskManagerSettings::instance()->isAllowedForceQuit()) {
304304
menusArray.append(QJsonObject{{"id", DOCK_ACTION_FORCEQUIT}, {"name", tr("Force Quit")}});
305305
}
306-
menusArray.append(QJsonObject{{"id", DOCK_ACTION_CLOSEALL}, {"name", tr("Close All")}});
306+
if (TaskManagerSettings::instance()->isWindowSplit()) {
307+
menusArray.append(QJsonObject{{"id", DOCK_ACTION_CLOSEWINDOW}, {"name", tr("Close")}});
308+
} else {
309+
menusArray.append(QJsonObject{{"id", DOCK_ACTION_CLOSEALL}, {"name", tr("Close All")}});
310+
}
307311
}
308312

309313
return QJsonDocument(menusArray).toJson();
@@ -366,6 +370,49 @@ void DockGlobalElementModel::requestActivate(const QModelIndex &index) const
366370
}
367371
}
368372

373+
void DockGlobalElementModel::requestNewInstance(const QModelIndex &index, const QString &action) const
374+
{
375+
auto data = m_data.value(index.row());
376+
auto id = std::get<0>(data);
377+
auto sourceModel = std::get<1>(data);
378+
auto sourceRow = std::get<2>(data);
379+
380+
// Handle special actions first (for both active and docked apps)
381+
if (action == DOCK_ACTION_DOCK) {
382+
TaskManagerSettings::instance()->toggleDockedElement(QStringLiteral("desktop/%1").arg(id));
383+
return;
384+
} else if (action == DOCK_ACTION_FORCEQUIT) {
385+
requestClose(index, true);
386+
return;
387+
} else if (action == DOCK_ACTION_CLOSEWINDOW || action == DOCK_ACTION_CLOSEALL) {
388+
requestClose(index, false);
389+
return;
390+
}
391+
392+
//应用自身处理的action
393+
if (!action.isEmpty()) {
394+
QProcess process;
395+
process.setProcessChannelMode(QProcess::MergedChannels);
396+
process.start("dde-am", {"--by-user", id, action});
397+
process.waitForFinished();
398+
return;
399+
}
400+
401+
// Handle launch/activate (empty action)
402+
if (sourceModel == m_activeAppModel) {
403+
auto sourceIndex = sourceModel->index(sourceRow, 0);
404+
m_activeAppModel->requestNewInstance(sourceIndex, action);
405+
} else {
406+
QString dbusPath = QStringLiteral("/org/desktopspec/ApplicationManager1/") + escapeToObjectPath(id);
407+
using Application = org::desktopspec::ApplicationManager1::Application;
408+
Application appInterface(QStringLiteral("org.desktopspec.ApplicationManager1"), dbusPath, QDBusConnection::sessionBus());
409+
410+
if (appInterface.isValid()) {
411+
appInterface.Launch(QString(), QStringList(), QVariantMap());
412+
}
413+
}
414+
}
415+
369416
void DockGlobalElementModel::requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) const
370417
{
371418
auto data = m_data.value(index.row());

panels/dock/taskmanager/dockglobalelementmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ 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;
3132

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

panels/dock/taskmanager/globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace dock {
1313
static inline const QString DOCK_ACTION_ALLWINDOW = "dock-action-allWindow";
1414
static inline const QString DOCK_ACTION_FORCEQUIT = "dock-action-forceQuit";
1515
static inline const QString DOCK_ACTION_CLOSEALL = "dock-action-closeAll";
16+
static inline const QString DOCK_ACTION_CLOSEWINDOW = "dock-action-closeWindow";
1617
static inline const QString DOCK_ACTIN_LAUNCH = "dock-action-launch";
1718
static inline const QString DOCK_ACTION_DOCK = "dock-action-dock";
1819

0 commit comments

Comments
 (0)