Skip to content

Commit 061f443

Browse files
claucambramgallien
authored andcommitted
Make apps menu scrollable when content taller than available vertical space, preventing borking of layout
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
1 parent bedf4a6 commit 061f443

1 file changed

Lines changed: 44 additions & 29 deletions

File tree

src/gui/tray/Window.qml

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ Window {
580580
icon.color: UserModel.currentUser.headerTextColor
581581

582582
onClicked: {
583-
if(appsMenu.count <= 0) {
583+
if(appsMenuListView.count <= 0) {
584584
UserModel.openCurrentAccountServer()
585585
} else if (appsMenu.visible) {
586586
appsMenu.close()
@@ -593,10 +593,12 @@ Window {
593593
Accessible.name: qsTr("More apps")
594594
Accessible.onPressAction: trayWindowAppsButton.clicked()
595595

596-
AutoSizingMenu {
596+
Menu {
597597
id: appsMenu
598+
x: -2
598599
y: (trayWindowAppsButton.y + trayWindowAppsButton.height + 2)
599-
readonly property Item listContentItem: contentItem.contentItem
600+
width: Style.trayWindowWidth * 0.35
601+
height: implicitHeight + y > Style.trayWindowHeight ? Style.trayWindowHeight - y : implicitHeight
600602
closePolicy: Menu.CloseOnPressOutsideParent | Menu.CloseOnEscape
601603

602604
background: Rectangle {
@@ -605,34 +607,47 @@ Window {
605607
radius: 2
606608
}
607609

608-
Instantiator {
609-
id: appsMenuInstantiator
610-
model: UserAppsModel
611-
onObjectAdded: appsMenu.insertItem(index, object)
612-
onObjectRemoved: appsMenu.removeItem(object)
613-
delegate: MenuItem {
614-
id: appEntry
615-
text: appName
616-
font.pixelSize: Style.topLinePixelSize
617-
palette.windowText: Style.ncTextColor
618-
icon.source: appIconUrl
619-
icon.color: Style.ncTextColor
620-
onTriggered: UserAppsModel.openAppUrl(appUrl)
621-
hoverEnabled: true
622-
623-
background: Item {
624-
height: parent.height
625-
width: parent.width
626-
Rectangle {
627-
anchors.fill: parent
628-
anchors.margins: 1
629-
color: parent.parent.hovered || parent.parent.visualFocus ? Style.lightHover : "transparent"
610+
contentItem: ScrollView {
611+
id: appsMenuScrollView
612+
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
613+
614+
data: WheelHandler {
615+
target: appMenuScrollView.contentItem
616+
}
617+
ListView {
618+
id: appsMenuListView
619+
implicitHeight: contentHeight
620+
model: UserAppsModel
621+
interactive: true
622+
clip: true
623+
currentIndex: appsMenu.currentIndex
624+
delegate: MenuItem {
625+
id: appEntry
626+
anchors.left: parent.left
627+
anchors.right: parent.right
628+
629+
text: model.appName
630+
font.pixelSize: Style.topLinePixelSize
631+
palette.windowText: Style.ncTextColor
632+
icon.source: model.appIconUrl
633+
icon.color: Style.ncTextColor
634+
onTriggered: UserAppsModel.openAppUrl(appUrl)
635+
hoverEnabled: true
636+
637+
background: Item {
638+
height: parent.height
639+
width: parent.width
640+
Rectangle {
641+
anchors.fill: parent
642+
anchors.margins: 1
643+
color: parent.parent.hovered || parent.parent.visualFocus ? Style.lightHover : "transparent"
644+
}
630645
}
631-
}
632646

633-
Accessible.role: Accessible.MenuItem
634-
Accessible.name: qsTr("Open %1 in browser").arg(appName)
635-
Accessible.onPressAction: appEntry.triggered()
647+
Accessible.role: Accessible.MenuItem
648+
Accessible.name: qsTr("Open %1 in browser").arg(model.appName)
649+
Accessible.onPressAction: appEntry.triggered()
650+
}
636651
}
637652
}
638653
}

0 commit comments

Comments
 (0)