From de77b9fb59367770a6be4995551a94380dbf4ede Mon Sep 17 00:00:00 2001 From: liyigang Date: Tue, 12 Sep 2023 15:19:04 +0800 Subject: [PATCH] feat: [workspace]Icon view optimization for dde-file-manager Modify drawing in icon mode, add 3 slots for iconsize Log: Icon view optimization for dde-file-manager Task: https://pms.uniontech.com/task-view-292347.html --- .../core/dfmplugin-workspace/dfmplugin_workspace_global.h | 6 +++--- .../core/dfmplugin-workspace/utils/itemdelegatehelper.h | 5 +++-- .../core/dfmplugin-workspace/views/fileview.cpp | 2 +- .../core/dfmplugin-workspace/views/iconitemdelegate.cpp | 7 ++----- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/plugins/filemanager/core/dfmplugin-workspace/dfmplugin_workspace_global.h b/src/plugins/filemanager/core/dfmplugin-workspace/dfmplugin_workspace_global.h index 9076f6cf0c..17e42c5f30 100644 --- a/src/plugins/filemanager/core/dfmplugin-workspace/dfmplugin_workspace_global.h +++ b/src/plugins/filemanager/core/dfmplugin-workspace/dfmplugin_workspace_global.h @@ -37,7 +37,7 @@ inline QList iconSizeList() inline QList iconWidth() { - return { 44, 36, 28, 28, 28, 28, 28, 28 }; + return { 44, 36, 28, 28, 28, 28, 28, 32 }; } // model defines @@ -50,7 +50,7 @@ inline constexpr int kCompactIconViewSpacing { 0 }; inline constexpr int kCompactIconModeColumnPadding { 5 }; #endif -inline constexpr int kIconViewSpacing { 5 }; // icon模式下的间距的一半 +inline constexpr int kIconViewSpacing { 5 }; // icon模式下的间距的一半 inline constexpr int kListViewSpacing { 0 }; inline constexpr int kIconModeColumnPadding { 10 }; inline constexpr int kDefualtHeaderSectionWidth { 140 }; @@ -64,7 +64,7 @@ inline constexpr int kListModeLeftMargin { 10 }; inline constexpr int kListModeRightMargin { 10 }; inline constexpr int kColumnPadding { 10 }; inline constexpr int kMinMoveLenght { 3 }; -inline constexpr int kIconHorizontalMargin { 15 }; // 水平Margin的宽度 +inline constexpr int kIconHorizontalMargin { 15 }; // 水平Margin的宽度 inline constexpr int kCompactIconHorizontalMargin { 10 }; // tab defines diff --git a/src/plugins/filemanager/core/dfmplugin-workspace/utils/itemdelegatehelper.h b/src/plugins/filemanager/core/dfmplugin-workspace/utils/itemdelegatehelper.h index 1729e01778..4108aed792 100644 --- a/src/plugins/filemanager/core/dfmplugin-workspace/utils/itemdelegatehelper.h +++ b/src/plugins/filemanager/core/dfmplugin-workspace/utils/itemdelegatehelper.h @@ -15,8 +15,9 @@ namespace dfmplugin_workspace { // begin file view item icon delegate global define -inline constexpr int kIconModeTextPadding = { 4 }; // 选中背景和文字之间的距离 -inline constexpr int kIconModeIconSpacing = { 6 }; // icon与背景的边距 +inline constexpr int kIconModeTextPadding = { 4 }; // 选中背景和文字之间的距离 +inline constexpr int kIconModeIconSpacing = { 6 }; // icon与背景的边距 + inline constexpr int kIconModeRectRadius = kIconModeTextPadding; inline constexpr int kIconModeBackRadius = { 6 }; inline constexpr int kIconModeColumuPadding { 10 }; diff --git a/src/plugins/filemanager/core/dfmplugin-workspace/views/fileview.cpp b/src/plugins/filemanager/core/dfmplugin-workspace/views/fileview.cpp index e2fb5567c9..b60f9e5323 100644 --- a/src/plugins/filemanager/core/dfmplugin-workspace/views/fileview.cpp +++ b/src/plugins/filemanager/core/dfmplugin-workspace/views/fileview.cpp @@ -1140,7 +1140,7 @@ QRect FileView::visualRect(const QModelIndex &index) const } rect.moveLeft(rect.left() - horizontalOffset()); - rect.moveTop(rect.top() - verticalOffset()); + rect.moveTop(rect.top() - verticalOffset() + DSizeModeHelper::element(kCompactIconModeColumnPadding, kIconModeColumnPadding)); return rect; } diff --git a/src/plugins/filemanager/core/dfmplugin-workspace/views/iconitemdelegate.cpp b/src/plugins/filemanager/core/dfmplugin-workspace/views/iconitemdelegate.cpp index c172c97f08..3186455d1c 100644 --- a/src/plugins/filemanager/core/dfmplugin-workspace/views/iconitemdelegate.cpp +++ b/src/plugins/filemanager/core/dfmplugin-workspace/views/iconitemdelegate.cpp @@ -224,19 +224,16 @@ void IconItemDelegate::updateItemSizeHint() width += iconWidth().at(iconSizeList().indexOf(width)); #ifdef DTKWIDGET_CLASS_DSizeMode int height = parent()->parent()->iconSize().height() - + 2 * kIconModeIconSpacing // icon与背景的上下两个间距 + 2 * d->textLineHeight // 2行文字的高度 + kIconModeTextPadding // 文字与icon之间的空隙 - + kIconModeTextPadding / 2; // 文字item底部的距离 + + 2 * kIconModeIconSpacing; // icon与背景的上下两个间距 #else int height = parent()->parent()->iconSize().height() - + 2 * kIconModeIconSpacing; // icon与背景的间距 + 2 * d->textLineHeight // 2行文字的高度 + kIconModeTextPadding // 文字与icon之间的空隙 - + kIconModeTextPadding / 2; // 文字item底部的距离 + + 2 * kIconModeIconSpacing; // icon与背景的间距 #endif d->itemSizeHint = QSize(width, height); - parent()->parent()->updateViewportContentsMargins(d->itemIconSize); } int IconItemDelegate::iconSizeLevel() const