diff --git a/app/inpututils.h b/app/inpututils.h index 545b358d0..efca2b6b6 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/MMListDelegate.qml b/app/qml/components/MMListDelegate.qml index b7869968c..ee15ca841 100644 --- a/app/qml/components/MMListDelegate.qml +++ b/app/qml/components/MMListDelegate.qml @@ -40,7 +40,7 @@ Item { property real verticalSpacing: root.secondaryText ? __style.margin8 : __style.margin20 - implicitWidth: ListView?.view?.width ?? 0 // in case ListView is injected as attached property (usually it is) + implicitWidth: ListView?.view?.width - ListView?.view?.scrollBarWidth ?? 0 // in case ListView is injected as attached property (usually it is) implicitHeight: contentLayout.implicitHeight height: visible ? implicitHeight : 0.1 // hide invisible items, for some reason setting 0 does not work ¯\_(ツ)_/¯ diff --git a/app/qml/components/MMListView.qml b/app/qml/components/MMListView.qml index e28f8459a..ec0bb440e 100644 --- a/app/qml/components/MMListView.qml +++ b/app/qml/components/MMListView.qml @@ -8,6 +8,8 @@ ***************************************************************************/ import QtQuick +import QtQuick.Controls +import QtQml // // Hot-fix for hotfix https://github.com/MerginMaps/mobile/issues/3417 @@ -15,6 +17,22 @@ import QtQuick // ListView { + id: root cacheBuffer: 0 + readonly property int scrollBarWidth: __inputUtils.isMobilePlatform() ? 0 : __style.margin10 + property alias scrollBarPolicy: verticalScrollBar.policy + + ScrollBar.vertical: ScrollBar{ + id: verticalScrollBar + + // To make sure the scroll bar stays visible on desktop, even when not focused: + // - both 'policy' and 'visible' properties need to be set, with 'policy' set to AlwaysOn. + // - the use the 'AsNeeded' policy will make the scroll bar hide when not focused or in use, + // and only appear after the user starts scrolling. + policy: __inputUtils.isMobilePlatform() ? ScrollBar.AlwaysOff : ScrollBar.AlwaysOn + visible: contentHeight > availableHeight ? true : false + opacity: active ? 0.7 : 0.4 + width: scrollBarWidth + } } diff --git a/app/qml/components/MMScrollView.qml b/app/qml/components/MMScrollView.qml index 5ea4c2dea..77565dbd3 100644 --- a/app/qml/components/MMScrollView.qml +++ b/app/qml/components/MMScrollView.qml @@ -6,18 +6,30 @@ * (at your option) any later version. * * * ***************************************************************************/ - import QtQuick import QtQuick.Controls - -// Convenient class to use as a pageContent or drawerContent -// base element to make the content scroll +import QtQml ScrollView { - id: root + id: root + + readonly property int scrollBarWidth: __inputUtils.isMobilePlatform() ? 0 : __style.margin10 + property bool scrollBarPolicy: verticalScrollBar.policy + + + contentWidth: availableWidth - scrollBarWidth - contentWidth: availableWidth // to only scroll vertically + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - ScrollBar.vertical.policy: ScrollBar.AlwaysOff - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + // To make sure the scroll bar stays visible on desktop, even when not focused: + // - both 'policy' and 'visible' properties need to be set, with 'policy' set to AlwaysOn. + // - the use the 'AsNeeded' policy will make the scroll bar hide when not focused or in use, + // and only appear after the user starts scrolling. + ScrollBar.vertical { + id : verticalScrollBar + policy: __inputUtils.isMobilePlatform() ? ScrollBar.AlwaysOff : ScrollBar.AlwaysOn + visible: contentHeight > availableHeight ? true : false + opacity: active ? 0.7 : 0.4 + width: scrollBarWidth + } } diff --git a/app/qml/components/MMToolbar.qml b/app/qml/components/MMToolbar.qml index 3e1568fca..b9ff24f7e 100644 --- a/app/qml/components/MMToolbar.qml +++ b/app/qml/components/MMToolbar.qml @@ -8,6 +8,7 @@ ***************************************************************************/ import QtQuick +import QtQuick.Controls import "./private" @@ -43,6 +44,7 @@ Rectangle { MMListView { id: toolbar + scrollBarPolicy : ScrollBar.AlwaysOff onWidthChanged: root.recalculate() model: toolbarModel diff --git a/app/qml/form/MMFormPage.qml b/app/qml/form/MMFormPage.qml index 0d804e61b..ad4bc4ef1 100644 --- a/app/qml/form/MMFormPage.qml +++ b/app/qml/form/MMFormPage.qml @@ -276,7 +276,7 @@ Page { Item { - width: ListView.view.width + width: ListView.view.width - ListView.view.scrollBarWidth implicitHeight: childrenRect.height // In future, better to filter such fields in the field proxy model instead diff --git a/app/qml/form/MMPreviewDrawer.qml b/app/qml/form/MMPreviewDrawer.qml index 5c0891313..1ab4e163d 100644 --- a/app/qml/form/MMPreviewDrawer.qml +++ b/app/qml/form/MMPreviewDrawer.qml @@ -193,7 +193,7 @@ Item { height: contentHeight spacing: __style.margin8 - interactive: false + scrollBarPolicy: ScrollBar.AsNeeded model: root.controller.fieldModel diff --git a/app/qml/layers/MMLayerDetailPage.qml b/app/qml/layers/MMLayerDetailPage.qml index cc9ff8380..b065a85eb 100644 --- a/app/qml/layers/MMLayerDetailPage.qml +++ b/app/qml/layers/MMLayerDetailPage.qml @@ -193,8 +193,6 @@ Page { wrapMode: Text.WordWrap text: __inputUtils.layerAttribution(layerDetailData.mapLayer) } - - ScrollBar.vertical: ScrollBar {} } } } diff --git a/app/qml/project/MMProjectList.qml b/app/qml/project/MMProjectList.qml index 7636434b9..af8b3e77a 100644 --- a/app/qml/project/MMProjectList.qml +++ b/app/qml/project/MMProjectList.qml @@ -94,7 +94,7 @@ Item { delegate: MMProjectComponents.MMProjectDelegate { id: projectDelegate - width: ListView.view.width + width: ListView.view.width - ListView.view.scrollBarWidth height: visible ? implicitHeight : 0 projectDisplayName: root.projectModelType === MM.ProjectsModel.WorkspaceProjectsModel ? model.ProjectName : model.ProjectFullName @@ -202,7 +202,7 @@ Item { topPadding: noLocalProjectsMessageContainer.visible ? noLocalProjectsMessageContainer.height + __style.margin40 : 0 - width: ListView.view.width + width: ListView.view.width - ListView.view.scrollBarWidth Item { width: parent.width diff --git a/app/qml/project/MMProjectWizardPage.qml b/app/qml/project/MMProjectWizardPage.qml index b154c2141..0b0557f5b 100644 --- a/app/qml/project/MMProjectWizardPage.qml +++ b/app/qml/project/MMProjectWizardPage.qml @@ -70,7 +70,7 @@ MMComponents.MMPage { delegate: MMProjectComponents.MMProjectWizardDelegate { id: fieldDelegate - width: ListView.view.width + width: ListView.view.width - ListView.view.scrollBarWidth // find current index in the model comboboxField.comboboxModel: typesmodel diff --git a/app/qml/project/components/MMProjectDelegate.qml b/app/qml/project/components/MMProjectDelegate.qml index b858b0666..c51500805 100644 --- a/app/qml/project/components/MMProjectDelegate.qml +++ b/app/qml/project/components/MMProjectDelegate.qml @@ -37,6 +37,7 @@ Control { signal showChangesRequested() height: implicitHeight + width: ListView.view.width - ListView.view.scrollBarWidth topPadding: __style.margin20 rightPadding: __style.margin20 diff --git a/app/qml/settings/MMLogPage.qml b/app/qml/settings/MMLogPage.qml index 1751985e7..d76e91799 100644 --- a/app/qml/settings/MMLogPage.qml +++ b/app/qml/settings/MMLogPage.qml @@ -53,7 +53,15 @@ MMPage { width: parent.width } - ScrollBar.vertical: ScrollBar { } + ScrollBar.vertical: ScrollBar { + opacity: active ? 0.7 : 0.4 + + contentItem: Rectangle { + implicitWidth: 5 + radius: width / 2 + color: __style.darkGreenColor + } + } } MMButton {