From e51dc6fa86947e74a51ec18c4dfaaad2adaef8d9 Mon Sep 17 00:00:00 2001 From: hewenfei Date: Fri, 8 Mar 2024 17:51:44 +0800 Subject: [PATCH] =?UTF-8?q?ui:=20=E4=BC=98=E5=8C=96=E5=85=A8=E5=B1=8F?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=BA=94=E7=94=A8=E5=88=97=E8=A1=A8=E5=B8=83?= =?UTF-8?q?=E5=B1=80=EF=BC=8C=E9=99=90=E5=88=B6=E5=BC=80=E5=A7=8B=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E5=B0=BA=E5=AF=B8=E5=9C=A8=E5=B1=8F=E5=B9=95=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E5=86=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml/AppUI/FullScreenAppList.qml | 21 +++++++++++--------- qml/AppUI/FullScreenUI.qml | 6 ++++-- src/windows/menu-main-window.cpp | 34 +++++++++----------------------- 3 files changed, 25 insertions(+), 36 deletions(-) diff --git a/qml/AppUI/FullScreenAppList.qml b/qml/AppUI/FullScreenAppList.qml index ab367e7..144763e 100644 --- a/qml/AppUI/FullScreenAppList.qml +++ b/qml/AppUI/FullScreenAppList.qml @@ -38,8 +38,9 @@ ListView { property int itemHeight: 40 property alias sourceModel: appGroupModel.sourceModel - // TODO: 动态计算尺寸 - property int column: 10 + property int cellWidth: 180 + property int cellHeight: 180 + property int column: Math.floor(width / cellWidth) spacing: 5 clip: true @@ -66,10 +67,11 @@ ListView { } GridView { - width: parent.width - height: childrenRect.height - cellWidth: width / root.column - cellHeight: cellWidth + anchors.horizontalCenter: parent.horizontalCenter + width: root.cellWidth * root.column + height: contentHeight + cellWidth: root.cellWidth + cellHeight: root.cellHeight interactive: false model: DelegateModel { @@ -237,7 +239,8 @@ ListView { GridView { id: favoriteView - width: parent.width + anchors.horizontalCenter: parent.horizontalCenter + width: root.cellWidth * root.column height: contentHeight property string mergeToAppId: "" property bool isMergeToFolder: false @@ -245,8 +248,8 @@ ListView { property int exchangedStartIndex: 0 property alias viewModel: visualModel - cellWidth: width / root.column - cellHeight: cellWidth + cellWidth: root.cellWidth + cellHeight: root.cellHeight interactive: false function indexAtNullItem() { diff --git a/qml/AppUI/FullScreenUI.qml b/qml/AppUI/FullScreenUI.qml index c57732c..3428954 100644 --- a/qml/AppUI/FullScreenUI.qml +++ b/qml/AppUI/FullScreenUI.qml @@ -164,11 +164,13 @@ FocusScope { anchors.centerIn: parent width: 120 height: parent.height + clip: true AppLabelPage { id: appLabelPage anchors.centerIn: parent + height: (contentHeight > parent.height) ? parent.height : contentHeight width: parent.width labelBottle: AppPageBackend.appModel.labelBottle labelColum: 1 @@ -196,7 +198,8 @@ FocusScope { return []; } - interactive: height > parent.height + boundsBehavior: Flickable.StopAtBounds + interactive: height >= parent.height highlightMoveDuration: 300 highlight: UkuiItems.StyleBackground { width: appLabelPage.cellWidth @@ -262,4 +265,3 @@ FocusScope { } } - diff --git a/src/windows/menu-main-window.cpp b/src/windows/menu-main-window.cpp index 21ae086..414ed11 100644 --- a/src/windows/menu-main-window.cpp +++ b/src/windows/menu-main-window.cpp @@ -100,21 +100,16 @@ void WindowGeometryHelper::updateGeometry() int height = MenuSetting::instance()->get(MENU_HEIGHT).toInt(); int margin = MenuSetting::instance()->get(MENU_MARGIN).toInt(); - if (width > screenRect.width()) { - width = screenRect.width(); - } - if (height > screenRect.height()) { - height = screenRect.height(); - } - //上: 1, 下: 0, 左: 2, 右: 3 switch (m_panelPos) { + default: case 0: { fullRect.setTopLeft(screenRect.topLeft()); fullRect.setSize({screenRect.width(), screenRect.height() - m_panelSize}); - normalMaskRect.setTopLeft({margin, screenRect.height() - height - margin - m_panelSize}); - normalMaskRect.setSize({width, height}); + QSize normalSize(qMin(fullRect.width() - margin*2, width), qMin(fullRect.height() - margin*2, height)); + normalMaskRect.setTopLeft({margin, fullRect.height() - normalSize.height() - margin}); + normalMaskRect.setSize(normalSize); break; } case 1: { @@ -122,8 +117,7 @@ void WindowGeometryHelper::updateGeometry() fullRect.setSize({screenRect.width(), screenRect.height() - m_panelSize}); normalMaskRect.setTopLeft({margin, margin}); - normalMaskRect.setSize({width, height}); - + normalMaskRect.setSize({qMin(fullRect.width() - margin*2, width), qMin(fullRect.height() - margin*2, height)}); break; } case 2: { @@ -131,26 +125,16 @@ void WindowGeometryHelper::updateGeometry() fullRect.setSize({screenRect.width() - m_panelSize, screenRect.height()}); normalMaskRect.setTopLeft({margin, margin}); - normalMaskRect.setSize({width, height}); - + normalMaskRect.setSize({qMin(fullRect.width() - margin*2, width), qMin(fullRect.height() - margin*2, height)}); break; } case 3: { fullRect.setTopLeft(screenRect.topLeft()); fullRect.setSize({screenRect.width() - m_panelSize, screenRect.height()}); - normalMaskRect.setTopLeft({screenRect.width() - width - margin - m_panelSize, margin}); - normalMaskRect.setSize({width, height}); - - break; - } - default: { - fullRect.setTopLeft({screenRect.x(), screenRect.y()}); - fullRect.setSize({screenRect.width(), screenRect.height()}); - - normalMaskRect.setTopLeft({margin, screenRect.height() - height - margin - m_panelSize}); - normalMaskRect.setSize({width, height}); - + QSize normalSize(qMin(fullRect.width() - margin*2, width), qMin(fullRect.height() - margin*2, height)); + normalMaskRect.setTopLeft({fullRect.width() - normalSize.width() - margin, margin}); + normalMaskRect.setSize(normalSize); break; } }