Skip to content

Commit 15c2b20

Browse files
committed
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 85f5bbd commit 15c2b20

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
@@ -600,7 +600,7 @@ Window {
600600
icon.color: UserModel.currentUser.headerTextColor
601601

602602
onClicked: {
603-
if(appsMenu.count <= 0) {
603+
if(appsMenuListView.count <= 0) {
604604
UserModel.openCurrentAccountServer()
605605
} else if (appsMenu.visible) {
606606
appsMenu.close()
@@ -613,10 +613,12 @@ Window {
613613
Accessible.name: qsTr("More apps")
614614
Accessible.onPressAction: trayWindowAppsButton.clicked()
615615

616-
AutoSizingMenu {
616+
Menu {
617617
id: appsMenu
618+
x: -2
618619
y: (trayWindowAppsButton.y + trayWindowAppsButton.height + 2)
619-
readonly property Item listContentItem: contentItem.contentItem
620+
width: Style.trayWindowWidth * 0.35
621+
height: implicitHeight + y > Style.trayWindowHeight ? Style.trayWindowHeight - y : implicitHeight
620622
closePolicy: Menu.CloseOnPressOutsideParent | Menu.CloseOnEscape
621623

622624
background: Rectangle {
@@ -625,34 +627,47 @@ Window {
625627
radius: 2
626628
}
627629

628-
Instantiator {
629-
id: appsMenuInstantiator
630-
model: UserAppsModel
631-
onObjectAdded: appsMenu.insertItem(index, object)
632-
onObjectRemoved: appsMenu.removeItem(object)
633-
delegate: MenuItem {
634-
id: appEntry
635-
text: appName
636-
font.pixelSize: Style.topLinePixelSize
637-
palette.windowText: Style.ncTextColor
638-
icon.source: appIconUrl
639-
icon.color: Style.ncTextColor
640-
onTriggered: UserAppsModel.openAppUrl(appUrl)
641-
hoverEnabled: true
642-
643-
background: Item {
644-
height: parent.height
645-
width: parent.width
646-
Rectangle {
647-
anchors.fill: parent
648-
anchors.margins: 1
649-
color: parent.parent.hovered || parent.parent.visualFocus ? Style.lightHover : "transparent"
630+
contentItem: ScrollView {
631+
id: appsMenuScrollView
632+
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
633+
634+
data: WheelHandler {
635+
target: appMenuScrollView.contentItem
636+
}
637+
ListView {
638+
id: appsMenuListView
639+
implicitHeight: contentHeight
640+
model: UserAppsModel
641+
interactive: true
642+
clip: true
643+
currentIndex: appsMenu.currentIndex
644+
delegate: MenuItem {
645+
id: appEntry
646+
anchors.left: parent.left
647+
anchors.right: parent.right
648+
649+
text: model.appName
650+
font.pixelSize: Style.topLinePixelSize
651+
palette.windowText: Style.ncTextColor
652+
icon.source: model.appIconUrl
653+
icon.color: Style.ncTextColor
654+
onTriggered: UserAppsModel.openAppUrl(appUrl)
655+
hoverEnabled: true
656+
657+
background: Item {
658+
height: parent.height
659+
width: parent.width
660+
Rectangle {
661+
anchors.fill: parent
662+
anchors.margins: 1
663+
color: parent.parent.hovered || parent.parent.visualFocus ? Style.lightHover : "transparent"
664+
}
650665
}
651-
}
652666

653-
Accessible.role: Accessible.MenuItem
654-
Accessible.name: qsTr("Open %1 in browser").arg(appName)
655-
Accessible.onPressAction: appEntry.triggered()
667+
Accessible.role: Accessible.MenuItem
668+
Accessible.name: qsTr("Open %1 in browser").arg(model.appName)
669+
Accessible.onPressAction: appEntry.triggered()
670+
}
656671
}
657672
}
658673
}

0 commit comments

Comments
 (0)