ui: 优化全屏界面应用列表布局,限制开始菜单尺寸在屏幕区域内

This commit is contained in:
hewenfei 2024-03-08 17:51:44 +08:00 committed by He Sir
parent d8a63029d7
commit e51dc6fa86
3 changed files with 25 additions and 36 deletions

View File

@ -38,8 +38,9 @@ ListView {
property int itemHeight: 40 property int itemHeight: 40
property alias sourceModel: appGroupModel.sourceModel property alias sourceModel: appGroupModel.sourceModel
// TODO: property int cellWidth: 180
property int column: 10 property int cellHeight: 180
property int column: Math.floor(width / cellWidth)
spacing: 5 spacing: 5
clip: true clip: true
@ -66,10 +67,11 @@ ListView {
} }
GridView { GridView {
width: parent.width anchors.horizontalCenter: parent.horizontalCenter
height: childrenRect.height width: root.cellWidth * root.column
cellWidth: width / root.column height: contentHeight
cellHeight: cellWidth cellWidth: root.cellWidth
cellHeight: root.cellHeight
interactive: false interactive: false
model: DelegateModel { model: DelegateModel {
@ -237,7 +239,8 @@ ListView {
GridView { GridView {
id: favoriteView id: favoriteView
width: parent.width anchors.horizontalCenter: parent.horizontalCenter
width: root.cellWidth * root.column
height: contentHeight height: contentHeight
property string mergeToAppId: "" property string mergeToAppId: ""
property bool isMergeToFolder: false property bool isMergeToFolder: false
@ -245,8 +248,8 @@ ListView {
property int exchangedStartIndex: 0 property int exchangedStartIndex: 0
property alias viewModel: visualModel property alias viewModel: visualModel
cellWidth: width / root.column cellWidth: root.cellWidth
cellHeight: cellWidth cellHeight: root.cellHeight
interactive: false interactive: false
function indexAtNullItem() { function indexAtNullItem() {

View File

@ -164,11 +164,13 @@ FocusScope {
anchors.centerIn: parent anchors.centerIn: parent
width: 120 width: 120
height: parent.height height: parent.height
clip: true
AppLabelPage { AppLabelPage {
id: appLabelPage id: appLabelPage
anchors.centerIn: parent anchors.centerIn: parent
height: (contentHeight > parent.height) ? parent.height : contentHeight
width: parent.width width: parent.width
labelBottle: AppPageBackend.appModel.labelBottle labelBottle: AppPageBackend.appModel.labelBottle
labelColum: 1 labelColum: 1
@ -196,7 +198,8 @@ FocusScope {
return []; return [];
} }
interactive: height > parent.height boundsBehavior: Flickable.StopAtBounds
interactive: height >= parent.height
highlightMoveDuration: 300 highlightMoveDuration: 300
highlight: UkuiItems.StyleBackground { highlight: UkuiItems.StyleBackground {
width: appLabelPage.cellWidth width: appLabelPage.cellWidth
@ -262,4 +265,3 @@ FocusScope {
} }
} }

View File

@ -100,21 +100,16 @@ void WindowGeometryHelper::updateGeometry()
int height = MenuSetting::instance()->get(MENU_HEIGHT).toInt(); int height = MenuSetting::instance()->get(MENU_HEIGHT).toInt();
int margin = MenuSetting::instance()->get(MENU_MARGIN).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 //上: 1, 下: 0, 左: 2, 右: 3
switch (m_panelPos) { switch (m_panelPos) {
default:
case 0: { case 0: {
fullRect.setTopLeft(screenRect.topLeft()); fullRect.setTopLeft(screenRect.topLeft());
fullRect.setSize({screenRect.width(), screenRect.height() - m_panelSize}); fullRect.setSize({screenRect.width(), screenRect.height() - m_panelSize});
normalMaskRect.setTopLeft({margin, screenRect.height() - height - margin - m_panelSize}); QSize normalSize(qMin<int>(fullRect.width() - margin*2, width), qMin<int>(fullRect.height() - margin*2, height));
normalMaskRect.setSize({width, height}); normalMaskRect.setTopLeft({margin, fullRect.height() - normalSize.height() - margin});
normalMaskRect.setSize(normalSize);
break; break;
} }
case 1: { case 1: {
@ -122,8 +117,7 @@ void WindowGeometryHelper::updateGeometry()
fullRect.setSize({screenRect.width(), screenRect.height() - m_panelSize}); fullRect.setSize({screenRect.width(), screenRect.height() - m_panelSize});
normalMaskRect.setTopLeft({margin, margin}); normalMaskRect.setTopLeft({margin, margin});
normalMaskRect.setSize({width, height}); normalMaskRect.setSize({qMin<int>(fullRect.width() - margin*2, width), qMin<int>(fullRect.height() - margin*2, height)});
break; break;
} }
case 2: { case 2: {
@ -131,26 +125,16 @@ void WindowGeometryHelper::updateGeometry()
fullRect.setSize({screenRect.width() - m_panelSize, screenRect.height()}); fullRect.setSize({screenRect.width() - m_panelSize, screenRect.height()});
normalMaskRect.setTopLeft({margin, margin}); normalMaskRect.setTopLeft({margin, margin});
normalMaskRect.setSize({width, height}); normalMaskRect.setSize({qMin<int>(fullRect.width() - margin*2, width), qMin<int>(fullRect.height() - margin*2, height)});
break; break;
} }
case 3: { case 3: {
fullRect.setTopLeft(screenRect.topLeft()); fullRect.setTopLeft(screenRect.topLeft());
fullRect.setSize({screenRect.width() - m_panelSize, screenRect.height()}); fullRect.setSize({screenRect.width() - m_panelSize, screenRect.height()});
normalMaskRect.setTopLeft({screenRect.width() - width - margin - m_panelSize, margin}); QSize normalSize(qMin<int>(fullRect.width() - margin*2, width), qMin<int>(fullRect.height() - margin*2, height));
normalMaskRect.setSize({width, height}); normalMaskRect.setTopLeft({fullRect.width() - normalSize.width() - margin, margin});
normalMaskRect.setSize(normalSize);
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});
break; break;
} }
} }