Skip to content

Commit 888cad5

Browse files
committed
Add custom ListView widget
Disables annoying mobile device behaviors and always clips the content. Also allows the specify whether the vertical scrollbar is always visible or only as needed.
1 parent 6df2521 commit 888cad5

14 files changed

Lines changed: 97 additions & 109 deletions

action_plugins/macro/MacroAction.qml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,10 @@ Item {
151151
ListView {
152152
Layout.fillWidth: true
153153
implicitHeight: contentHeight
154-
155-
// Make it behave like a sensible scrolling container
156-
ScrollBar.vertical: ScrollBar {}
157-
flickableDirection: Flickable.VerticalFlick
158-
boundsBehavior: Flickable.StopAtBounds
154+
spacing: 5
159155

160156
model: _root.action.actions
161157
delegate: _delegateChooser
162-
spacing: 5
163158
}
164159
}
165160

gremlin/ui/device.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,6 @@ def _update_calibration(self, index: int) -> None:
14001400
)
14011401

14021402
def _set_guid(self, guid: str) -> None:
1403-
print(guid)
14041403
if self._device is not None and guid == str(self._device.device_guid):
14051404
return
14061405

qml/BetterComboBox.qml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,13 @@ ComboBox {
5555
Universal.theme: control.Universal.theme
5656
Universal.accent: control.Universal.accent
5757

58-
contentItem: ListView {
59-
clip: true
58+
contentItem: JGListView {
6059
implicitHeight: contentHeight
6160
model: control.delegateModel
62-
currentIndex: control.highlightedIndex
6361
highlightMoveDuration: 0
62+
scrollbarAlwaysVisible: true
6463

65-
ScrollBar.vertical: ScrollBar {
66-
policy: ScrollBar.AlwaysOn
67-
}
64+
currentIndex: control.highlightedIndex
6865

6966
MouseArea {
7067
anchors.fill: parent

qml/ConfigSection.qml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,13 @@ import Gremlin.Config
2424
import "helpers.js" as Helpers
2525

2626

27-
ListView {
27+
JGListView {
2828
property ConfigGroupModel groupModel
2929

30-
spacing: 10
3130
rightMargin: 30
3231
bottomMargin: 10
33-
34-
// Make it behave like a sensible scrolling container
35-
ScrollBar.vertical: ScrollBar {
36-
policy: ScrollBar.AlwaysOn
37-
}
38-
flickableDirection: Flickable.VerticalFlick
39-
boundsBehavior: Flickable.StopAtBounds
32+
spacing: 10
33+
scrollbarAlwaysVisible: true
4034

4135
model: groupModel
4236
delegate: ConfigGroup {

qml/DeviceInputList.qml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ Item {
4848
}
4949

5050
// List of all the inputs available on the device
51-
ListView {
51+
JGListView {
5252
id: _inputList
5353
anchors.fill: parent
54+
scrollbarAlwaysVisible: true
5455

5556
property int minimumWidth: 200
5657

@@ -63,13 +64,6 @@ Item {
6364
currentIndex
6465
)
6566
}
66-
67-
// Make it behave like a sensible scrolling container
68-
ScrollBar.vertical: ScrollBar {
69-
policy: ScrollBar.AlwaysOn
70-
}
71-
flickableDirection: Flickable.VerticalFlick
72-
boundsBehavior: Flickable.StopAtBounds
7367
}
7468

7569
// Renders the information about a single input, including name and

qml/DeviceTabBar.qml

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,54 +29,54 @@ T.TabBar {
2929
contentHeight + topPadding + bottomPadding)
3030

3131
contentItem: ListView {
32-
model: control.contentModel
33-
currentIndex: control.currentIndex
32+
model: control.contentModel
33+
currentIndex: control.currentIndex
3434

35-
spacing: control.spacing
36-
orientation: ListView.Horizontal
37-
boundsBehavior: Flickable.StopAtBounds
38-
flickableDirection: Flickable.AutoFlickIfNeeded
39-
snapMode: ListView.SnapToItem
35+
spacing: control.spacing
36+
orientation: ListView.Horizontal
37+
boundsBehavior: Flickable.StopAtBounds
38+
flickableDirection: Flickable.AutoFlickIfNeeded
39+
snapMode: ListView.SnapToItem
4040

41-
ScrollBar.horizontal: ScrollBar {
42-
policy: ScrollBar.AlwaysOn
43-
}
44-
45-
highlightMoveDuration: 100
46-
highlightRangeMode: ListView.ApplyRange
47-
preferredHighlightBegin: 48
48-
preferredHighlightEnd: width - 48
41+
ScrollBar.horizontal: ScrollBar {
42+
policy: ScrollBar.AlwaysOn
43+
}
4944

45+
highlightMoveDuration: 100
46+
highlightRangeMode: ListView.ApplyRange
47+
preferredHighlightBegin: 48
48+
preferredHighlightEnd: width - 48
5049

51-
MouseArea {
52-
anchors.fill: parent
5350

54-
// Scroll the view without the need for a modifier
55-
onWheel: function(evt) {
56-
if(parent.contentWidth < parent.width) {
57-
return
58-
}
51+
MouseArea {
52+
anchors.fill: parent
5953

60-
if (evt.angleDelta.y > 0) {
61-
parent.contentX = Math.max(0, parent.contentX - 10)
62-
} else {
63-
parent.contentX = Math.min(
64-
parent.contentWidth - parent.width,
65-
parent.contentX + 10
66-
)
67-
}
54+
// Scroll the view without the need for a modifier.
55+
onWheel: function(evt) {
56+
if(parent.contentWidth < parent.width) {
57+
return
6858
}
6959

70-
// Ignore all other events and thus pass then to the
71-
// underlying ListView
72-
onClicked: (mouse) => mouse.accepted = false
73-
onPressed: (mouse) => mouse.accepted = false
74-
onReleased: (mouse) => mouse.accepted = false
75-
onDoubleClicked: (mouse) => mouse.accepted = false
76-
onPositionChanged: (mouse) => mouse.accepted = false
77-
onPressAndHold: (mouse) => mouse.accepted = false
60+
if (evt.angleDelta.y > 0) {
61+
parent.contentX = Math.max(0, parent.contentX - 10)
62+
} else {
63+
parent.contentX = Math.min(
64+
parent.contentWidth - parent.width,
65+
parent.contentX + 10
66+
)
67+
}
7868
}
69+
70+
// Ignore all other events and thus pass then to the
71+
// underlying ListView.
72+
onClicked: (mouse) => mouse.accepted = false
73+
onPressed: (mouse) => mouse.accepted = false
74+
onReleased: (mouse) => mouse.accepted = false
75+
onDoubleClicked: (mouse) => mouse.accepted = false
76+
onPositionChanged: (mouse) => mouse.accepted = false
77+
onPressAndHold: (mouse) => mouse.accepted = false
7978
}
79+
}
8080

8181
background: Rectangle {
8282
implicitWidth: 200

qml/DialogCalibration.qml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,21 @@ Window {
6161
}
6262
}
6363

64-
ListView {
64+
JGListView {
6565
id: _axisView
6666

67+
scrollbarAlwaysVisible: true
68+
spacing: 10
6769
Layout.fillWidth: true
6870
Layout.fillHeight: true
69-
spacing: 10
7071

7172
model: AxisCalibration {
7273
guid: _deviceSelection.currentValue
7374
}
74-
clip: true
7575

7676
delegate: CalibrationItem {
7777
width: ListView.view.width
7878
}
79-
80-
// Make it behave like a sensible scrolling container
81-
ScrollBar.vertical: ScrollBar {
82-
policy: ScrollBar.AlwaysOn
83-
}
84-
flickableDirection: Flickable.VerticalFlick
85-
boundsBehavior: Flickable.StopAtBounds
8679
}
8780
}
8881

qml/DialogManageModes.qml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,14 @@ Window {
5757

5858
anchors.fill: parent
5959

60-
ListView {
60+
JGListView {
6161
Layout.fillWidth: true
6262
Layout.fillHeight: true
6363

64-
flickableDirection: Flickable.VerticalFlick
65-
boundsBehavior: Flickable.StopAtBounds
64+
scrollbarAlwaysVisible: true
6665
spacing: 10
6766

6867
model: mode.modeList
69-
7068
delegate: _delegate
7169
}
7270

qml/DialogOptions.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Window {
4343
anchors.fill: parent
4444

4545
// Shows the list of all option sections
46-
ListView {
46+
JGListView {
4747
id: _sectionSelector
4848

4949
Layout.preferredWidth: 200

qml/InputConfiguration.qml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,12 @@ Item {
5151
anchors.fill: parent
5252

5353
// Show all actions associated with this input
54-
ListView {
54+
JGListView {
5555
id: _listView
5656

5757
Layout.fillHeight: true
5858
Layout.fillWidth: true
59-
60-
// Make it behave like a sensible scrolling container
61-
ScrollBar.vertical: ScrollBar {
62-
policy: ScrollBar.AlwaysOn
63-
}
64-
flickableDirection: Flickable.VerticalFlick
65-
boundsBehavior: Flickable.StopAtBounds
59+
scrollbarAlwaysVisible: true
6660

6761
// Content to visualize
6862
model: _root.inputItemModel

0 commit comments

Comments
 (0)