Skip to content

Commit 41d44f2

Browse files
Johnson-zsdeepin-bot[bot]
authored andcommitted
refactor: optimize task widget UI layout and behavior
The changes include several UI improvements and functional enhancements to the task widget: 1. Increased kMsgLabelWidth from 390 to 468 for better text display 2. Added createDestLabels flag to control destination labels creation in conflict UI 3. Hid lbDstPath, lbRmTime and chkboxNotAskAgain widgets during permanent delete 4. Added hover state handling for speed/time labels and buttons visibility 5. Restructured UI creation into separate createBaseWidget method 6. Simplified enterEvent handling with QT6 compatibility 7. Adjusted button widths and spacing in conflict dialogs 8. Added preHoverSpeedStr/preHoverRmTimeStr to preserve text during hover 9. Improved layout margins and spacings throughout the widget Log: Improved task widget UI layout and interaction behavior Influence: 1. Test all file operation states (copy, move, delete) 2. Verify conflict resolution dialog layouts 3. Check hover behavior on task items 4. Validate permanent delete confirmation dialog 5. Test progress display update during operations 6. Verify button visibility in different states refactor: 优化任务小部件UI布局和行为 更改包含对任务小部件的多项UI改进和功能增强: 1. 将kMsgLabelWidth从390增加到468以改善文本显示 2. 添加createDestLabels标志控制冲突UI中目标标签的创建 3. 永久删除时隐藏lbDstPath、lbRmTime和chkboxNotAskAgain部件 4. 添加对速度/时间标签悬停状态处理和按钮可见性控制 5. 将UI创建重构为单独的createBaseWidget方法 6. 简化enterEvent处理并保持QT6兼容性 7. 调整冲突对话框中的按钮宽度和间距 8. 添加preHoverSpeedStr/preHoverRmTimeStr保存悬停期间的文本 9. 改进整个小部件的布局边距和间距 Log: 改进任务小部件UI布局和交互行为 Influence: 1. 测试所有文件操作状态(复制、移动、删除) 2. 验证冲突解决对话框布局 3. 检查任务项上的悬停行为 4. 测试永久删除确认对话框 5. 测试操作期间的进度显示更新 6. 验证不同状态下的按钮可见性
1 parent f0daca8 commit 41d44f2

File tree

3 files changed

+176
-111
lines changed

3 files changed

+176
-111
lines changed

src/dfm-base/dialogs/taskdialog/taskdialog.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ void TaskDialog::adjustSize(int hight)
166166
listHeight += h;
167167
}
168168

169+
int oldHeight = height();
169170
if (listHeight < qApp->primaryScreen()->availableGeometry().height() - 60) {
170171
taskListWidget->setFixedHeight(listHeight);
171172
setFixedHeight(listHeight + 60);
@@ -175,6 +176,11 @@ void TaskDialog::adjustSize(int hight)
175176
}
176177

177178
layout()->setSizeConstraint(QLayout::SetNoConstraint);
179+
180+
// 如果高度发生了变化,重新居中对话框以避免位置偏移
181+
if (oldHeight != height()) {
182+
moveYCenter();
183+
}
178184
}
179185
/*!
180186
* \brief TaskDialog::moveYCenter 任务进度框自动调整到屏幕的中央
@@ -215,7 +221,7 @@ void TaskDialog::removeTask()
215221
QListWidgetItem *item = taskItems.value(jobHandler);
216222
taskListWidget->removeItemWidget(item);
217223
taskListWidget->takeItem(taskListWidget->row(item));
218-
delete item; // 显式删除动态分配的对象
224+
delete item; // 显式删除动态分配的对象
219225
taskItems.remove(jobHandler);
220226
setTitle(taskListWidget->count());
221227
if (taskListWidget->count() == 0) {
@@ -235,7 +241,7 @@ void TaskDialog::closeEvent(QCloseEvent *event)
235241
it.key()->operateTaskJob(AbstractJobHandler::SupportAction::kStopAction);
236242
taskListWidget->removeItemWidget(it.value());
237243
QListWidgetItem *item = taskListWidget->takeItem(taskListWidget->row(it.value()));
238-
delete item; // 显式删除动态分配的对象
244+
delete item; // 显式删除动态分配的对象
239245
it = taskItems.erase(it);
240246
}
241247
emit closed();
@@ -245,7 +251,7 @@ void TaskDialog::closeEvent(QCloseEvent *event)
245251

246252
void TaskDialog::keyPressEvent(QKeyEvent *event)
247253
{
248-
//handle escape key press event for emitting close event
254+
// handle escape key press event for emitting close event
249255
if (event->key() == Qt::Key_Escape) {
250256
emit close();
251257
}

0 commit comments

Comments
 (0)