Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/inpututils.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class InputUtils: public QObject

/** InputApp platform */
static QString appPlatform();
static bool isMobilePlatform();
Q_INVOKABLE static bool isMobilePlatform();

static QString appDataDir();

Expand Down
62 changes: 53 additions & 9 deletions app/qml/components/MMListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
4 changes: 3 additions & 1 deletion app/qml/components/MMScrollView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions app/qml/project/components/MMProjectDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading