From fa23f3bfbf47b3984ed69553c6cc8ffbfbe6ebcd Mon Sep 17 00:00:00 2001 From: houchengqiu Date: Wed, 24 Jul 2024 15:32:37 +0800 Subject: [PATCH] fix: [UI] adjust combobox UI pop style [UI] adjust combobox UI pop style Log: [UI] adjust combobox UI popstyle Bug: https://pms.uniontech.com/bug-view-168279.html --- src/qml/Control/FilterComboBox.qml | 35 ++++++++++++++++++- .../CollecttionView/AllCollection.qml | 3 +- .../CustomAlbum/CustomAlbum.qml | 2 +- .../HaveImportedView/HaveImportedView.qml | 2 +- .../RecentlyDeletedView.qml | 2 +- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/qml/Control/FilterComboBox.qml b/src/qml/Control/FilterComboBox.qml index e07f4ed20..b81052f2d 100644 --- a/src/qml/Control/FilterComboBox.qml +++ b/src/qml/Control/FilterComboBox.qml @@ -8,9 +8,10 @@ import QtQuick.Controls 2.4 import QtQuick.Layouts 1.11 import QtQml 2.11 import org.deepin.dtk 1.0 - +import org.deepin.dtk.style 1.0 as DS ComboBox { + id: comboBox textRole: "text" iconNameRole: "icon" flat: true @@ -20,5 +21,37 @@ ComboBox { ListElement { text: qsTr("Photos"); icon: "images" } ListElement { text: qsTr("Videos"); icon: "videos" } } + + delegate: MenuItem { + useIndicatorPadding: true + width: parent.width + text: comboBox.textRole ? (Array.isArray(comboBox.model) ? modelData[comboBox.textRole] : model[comboBox.textRole]) : modelData + icon.name: (comboBox.iconNameRole && model[comboBox.iconNameRole] !== undefined) ? model[comboBox.iconNameRole] : null + highlighted: comboBox.highlightedIndex === index + hoverEnabled: comboBox.hoverEnabled + autoExclusive: true + checked: comboBox.currentIndex === index + } + + // 为符合UI效果,弹框宽度比下拉框宽度略大 + popup: Popup { + clip: true + x: -15 + implicitWidth: comboBox.width + 15 + contentItem: ArrowListView { + maxVisibleItems: comboBox.maxVisibleItems + view.model: comboBox.delegateModel + view.currentIndex: comboBox.highlightedIndex + view.highlightRangeMode: ListView.ApplyRange + view.highlightMoveDuration: 0 + } + + background: FloatingPanel { + implicitWidth: DS.Style.menu.item.width + implicitHeight: DS.Style.menu.item.height + radius: DS.Style.menu.radius + backgroundColor: DS.Style.menu.background + } + } } diff --git a/src/qml/ThumbnailImageView/CollecttionView/AllCollection.qml b/src/qml/ThumbnailImageView/CollecttionView/AllCollection.qml index e6b403107..25faabfe7 100644 --- a/src/qml/ThumbnailImageView/CollecttionView/AllCollection.qml +++ b/src/qml/ThumbnailImageView/CollecttionView/AllCollection.qml @@ -132,10 +132,9 @@ Item { topMargin: 4 right: parent.right } - width: 130 + width: 115 height: 30 visible: parent.visible && albumControl.getAllCount() !== 0 - //visible: !(numLabelText === "" && filterType === 0) } MouseArea { diff --git a/src/qml/ThumbnailImageView/CustomAlbum/CustomAlbum.qml b/src/qml/ThumbnailImageView/CustomAlbum/CustomAlbum.qml index 555f5637d..41cf6e096 100644 --- a/src/qml/ThumbnailImageView/CustomAlbum/CustomAlbum.qml +++ b/src/qml/ThumbnailImageView/CustomAlbum/CustomAlbum.qml @@ -148,7 +148,7 @@ BaseView { topMargin: 4 right: parent.right } - width: 130 + width: 115 height: 30 } diff --git a/src/qml/ThumbnailImageView/HaveImportedView/HaveImportedView.qml b/src/qml/ThumbnailImageView/HaveImportedView/HaveImportedView.qml index c53b7776f..3d091740f 100644 --- a/src/qml/ThumbnailImageView/HaveImportedView/HaveImportedView.qml +++ b/src/qml/ThumbnailImageView/HaveImportedView/HaveImportedView.qml @@ -126,7 +126,7 @@ BaseView { topMargin: 4 right: parent.right } - width: 130 + width: 115 height: 30 } } diff --git a/src/qml/ThumbnailImageView/RecentlyDeletedView/RecentlyDeletedView.qml b/src/qml/ThumbnailImageView/RecentlyDeletedView/RecentlyDeletedView.qml index bddb28196..4c9d1d172 100644 --- a/src/qml/ThumbnailImageView/RecentlyDeletedView/RecentlyDeletedView.qml +++ b/src/qml/ThumbnailImageView/RecentlyDeletedView/RecentlyDeletedView.qml @@ -167,7 +167,7 @@ BaseView { topMargin: 4 right: parent.right } - width: 130 + width: 115 height: 30 visible: (!theView.haveSelect && totalCount > 0) || totalCount === 0 }