Skip to content

Commit

Permalink
Merge pull request #4723 from nextcloud/bugfix/apps-menu-height
Browse files Browse the repository at this point in the history
Make apps menu scrollable when content taller than available vertical space, preventing borking of layout
  • Loading branch information
claucambra authored Jul 27, 2022
2 parents bedf4a6 + 061f443 commit 16fd9c5
Showing 1 changed file with 44 additions and 29 deletions.
73 changes: 44 additions & 29 deletions src/gui/tray/Window.qml
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ Window {
icon.color: UserModel.currentUser.headerTextColor

onClicked: {
if(appsMenu.count <= 0) {
if(appsMenuListView.count <= 0) {
UserModel.openCurrentAccountServer()
} else if (appsMenu.visible) {
appsMenu.close()
Expand All @@ -593,10 +593,12 @@ Window {
Accessible.name: qsTr("More apps")
Accessible.onPressAction: trayWindowAppsButton.clicked()

AutoSizingMenu {
Menu {
id: appsMenu
x: -2
y: (trayWindowAppsButton.y + trayWindowAppsButton.height + 2)
readonly property Item listContentItem: contentItem.contentItem
width: Style.trayWindowWidth * 0.35
height: implicitHeight + y > Style.trayWindowHeight ? Style.trayWindowHeight - y : implicitHeight
closePolicy: Menu.CloseOnPressOutsideParent | Menu.CloseOnEscape

background: Rectangle {
Expand All @@ -605,34 +607,47 @@ Window {
radius: 2
}

Instantiator {
id: appsMenuInstantiator
model: UserAppsModel
onObjectAdded: appsMenu.insertItem(index, object)
onObjectRemoved: appsMenu.removeItem(object)
delegate: MenuItem {
id: appEntry
text: appName
font.pixelSize: Style.topLinePixelSize
palette.windowText: Style.ncTextColor
icon.source: appIconUrl
icon.color: Style.ncTextColor
onTriggered: UserAppsModel.openAppUrl(appUrl)
hoverEnabled: true

background: Item {
height: parent.height
width: parent.width
Rectangle {
anchors.fill: parent
anchors.margins: 1
color: parent.parent.hovered || parent.parent.visualFocus ? Style.lightHover : "transparent"
contentItem: ScrollView {
id: appsMenuScrollView
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff

data: WheelHandler {
target: appMenuScrollView.contentItem
}
ListView {
id: appsMenuListView
implicitHeight: contentHeight
model: UserAppsModel
interactive: true
clip: true
currentIndex: appsMenu.currentIndex
delegate: MenuItem {
id: appEntry
anchors.left: parent.left
anchors.right: parent.right

text: model.appName
font.pixelSize: Style.topLinePixelSize
palette.windowText: Style.ncTextColor
icon.source: model.appIconUrl
icon.color: Style.ncTextColor
onTriggered: UserAppsModel.openAppUrl(appUrl)
hoverEnabled: true

background: Item {
height: parent.height
width: parent.width
Rectangle {
anchors.fill: parent
anchors.margins: 1
color: parent.parent.hovered || parent.parent.visualFocus ? Style.lightHover : "transparent"
}
}
}

Accessible.role: Accessible.MenuItem
Accessible.name: qsTr("Open %1 in browser").arg(appName)
Accessible.onPressAction: appEntry.triggered()
Accessible.role: Accessible.MenuItem
Accessible.name: qsTr("Open %1 in browser").arg(model.appName)
Accessible.onPressAction: appEntry.triggered()
}
}
}
}
Expand Down

0 comments on commit 16fd9c5

Please sign in to comment.