diff --git a/app/inpututils.h b/app/inpututils.h index 122661a0f..e4d9c128f 100644 --- a/app/inpututils.h +++ b/app/inpututils.h @@ -222,7 +222,7 @@ class InputUtils: public QObject /** InputApp platform */ static QString appPlatform(); - static bool isMobilePlatform(); + Q_INVOKABLE static bool isMobilePlatform(); static QString appDataDir(); diff --git a/app/qml/components/MMListView.qml b/app/qml/components/MMListView.qml index d1d26e95b..56e9c3883 100644 --- a/app/qml/components/MMListView.qml +++ b/app/qml/components/MMListView.qml @@ -2,22 +2,66 @@ * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ import QtQuick +import QtQuick.Controls -ListView { +// Drop-in replacement for ListView that also shows a scrollbar on desktop. +// Wraps a real ListView in a ScrollView internally so callers can keep using +// it exactly like a plain ListView, without knowing about the wrapping. +ScrollView { id: root - // when flicking up really fast, we should go back to the first item - onVerticalOvershootChanged: { - if (verticalOvershoot < -200) { - root.contentY= -root.topMargin - root.returnToBounds(); + + property alias model: listView.model + property alias delegate: listView.delegate + property alias header: listView.header + property alias footer: listView.footer + property alias section: listView.section + property alias add: listView.add + property alias addDisplaced: listView.addDisplaced + + property alias orientation: listView.orientation + property alias interactive: listView.interactive + property alias maximumFlickVelocity: listView.maximumFlickVelocity + property alias topMargin: listView.topMargin + property alias bottomMargin: listView.bottomMargin + + property alias currentIndex: listView.currentIndex + property alias count: listView.count + + property alias contentY: listView.contentY + property alias atYEnd: listView.atYEnd + + function positionViewAtIndex( index, mode ) { + listView.positionViewAtIndex( index, mode ) + } + + function positionViewAtEnd() { + listView.positionViewAtEnd() + } + + rightPadding: ScrollBar.vertical.visible ? ScrollBar.vertical.width * 2 : 0 + bottomPadding: ScrollBar.horizontal.visible ? ScrollBar.horizontal.height * 2 : 0 + + ScrollBar.vertical.policy: !__inputUtils.isMobilePlatform() && listView.orientation === ListView.Vertical && listView.contentHeight > listView.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff + ScrollBar.horizontal.policy: !__inputUtils.isMobilePlatform() && listView.orientation === ListView.Horizontal && listView.contentWidth > listView.width ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff + + ListView { + id: listView + + spacing: root.spacing + + // when flicking up really fast, we should go back to the first item + onVerticalOvershootChanged: { + if (verticalOvershoot < -200) { + listView.contentY = -listView.topMargin + listView.returnToBounds(); + } } + delegateModelAccess: DelegateModel.ReadWrite } - delegateModelAccess: DelegateModel.ReadWrite -} \ No newline at end of file +} diff --git a/app/qml/components/MMScrollView.qml b/app/qml/components/MMScrollView.qml index 5ea4c2dea..01b60682e 100644 --- a/app/qml/components/MMScrollView.qml +++ b/app/qml/components/MMScrollView.qml @@ -16,8 +16,10 @@ import QtQuick.Controls ScrollView { id: root + rightPadding: ScrollBar.vertical.visible ? ScrollBar.vertical.width * 2 : 0 + contentWidth: availableWidth // to only scroll vertically - ScrollBar.vertical.policy: ScrollBar.AlwaysOff + ScrollBar.vertical.policy: !__inputUtils.isMobilePlatform() && root.contentHeight > root.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff ScrollBar.horizontal.policy: ScrollBar.AlwaysOff } diff --git a/app/qml/project/components/MMProjectDelegate.qml b/app/qml/project/components/MMProjectDelegate.qml index b858b0666..54d3bcbab 100644 --- a/app/qml/project/components/MMProjectDelegate.qml +++ b/app/qml/project/components/MMProjectDelegate.qml @@ -38,6 +38,9 @@ Control { height: implicitHeight + // shrink to leave room for the list's vertical scrollbar, so content isn't drawn underneath it + implicitWidth: ListView.view.width + topPadding: __style.margin20 rightPadding: __style.margin20 leftPadding: __style.margin20