summarylogtreecommitdiffstats
path: root/nheko-kirigami-scrollfix.patch
blob: ff1a76d3a679f907950c92a7c9dd1892478593e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8122313..886fda4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -286,6 +286,18 @@ else()
     find_package(KDSingleApplication-qt6 REQUIRED)
 endif()
 
+if(UNIX)
+    set(KF_MIN_VERSION "6.0.0")
+    find_package(ECM ${KF_MIN_VERSION})
+    if(ECM_FOUND)
+        list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
+        find_package(KF6 COMPONENTS Kirigami)
+        if(KF6_FOUND)
+            add_compile_definitions(NHEKO_USE_KIRIGAMI)
+        endif()
+    endif()
+endif()
+
 if(Qt6Widgets_FOUND)
     if(Qt6Widgets_VERSION VERSION_LESS 6.5.0)
         message(STATUS "Qt version ${Qt6Widgets_VERSION}")
@@ -838,12 +850,20 @@ set(QML_SOURCES
     resources/qml/delegates/EncryptionEnabled.qml
     resources/qml/ui/TimelineEffects.qml
 )
+set(QML_DEPENDENCIES
+    QtQuick
+    QtQml.Models
+)
+if(KF6_FOUND)
+    list(APPEND QML_SOURCES resources/qml/components/KirigamiWheelHandler.qml)
+    list(APPEND QML_DEPENDENCIES org.kde.kirigami)
+endif()
 qt_add_qml_module(nheko
     URI im.nheko
     NO_RESOURCE_TARGET_PATH
     RESOURCE_PREFIX "/"
     VERSION 1.1
-    DEPENDENCIES QtQuick QtQml.Models
+    DEPENDENCIES ${QML_DEPENDENCIES}
     QML_FILES
     ${QML_SOURCES}
     SOURCES
diff --git a/resources/qml/CommunitiesList.qml b/resources/qml/CommunitiesList.qml
index a134474..96d89a6 100644
--- a/resources/qml/CommunitiesList.qml
+++ b/resources/qml/CommunitiesList.qml
@@ -38,6 +38,10 @@ Page {
         model: Communities.filtered()
         boundsBehavior: Flickable.StopAtBounds
 
+        Loader {
+            source: NHEKO_USE_KIRIGAMI ? "components/KirigamiWheelHandler.qml" : ""
+        }
+
         ScrollBar.vertical: ScrollBar {
             id: scrollbar
 
diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml
index bdeb7db..536a3dc 100644
--- a/resources/qml/Completer.qml
+++ b/resources/qml/Completer.qml
@@ -93,6 +93,10 @@ Control {
     contentItem: ListView {
         id: listView
 
+        Loader {
+            source: NHEKO_USE_KIRIGAMI ? "components/KirigamiWheelHandler.qml" : ""
+        }
+
         clip: true
         displayMarginBeginning: height / 2
         displayMarginEnd: height / 2
diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml
index 84b34a7..e233540 100644
--- a/resources/qml/MessageView.qml
+++ b/resources/qml/MessageView.qml
@@ -66,6 +66,10 @@ Item {
         spacing: 2
         verticalLayoutDirection: ListView.BottomToTop
 
+        Loader {
+            source: NHEKO_USE_KIRIGAMI ? "components/KirigamiWheelHandler.qml" : ""
+        }
+
         property int lastScrollPos: 0
 
         // Fixup the scroll position when the height changes. Without this, the view is kept around the center of the currently visible content, while we usually want to stick to the bottom.
diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml
index db4f2cb..ff7f272 100644
--- a/resources/qml/RoomList.qml
+++ b/resources/qml/RoomList.qml
@@ -442,6 +442,10 @@ Page {
         model: Rooms
         boundsBehavior: Flickable.StopAtBounds
 
+        Loader {
+            source: NHEKO_USE_KIRIGAMI ? "components/KirigamiWheelHandler.qml" : ""
+        }
+
         //reuseItems: true
         ScrollBar.vertical: ScrollBar {
             id: scrollbar
diff --git a/resources/qml/UploadBox.qml b/resources/qml/UploadBox.qml
index 1d9415e..dd3d218 100644
--- a/resources/qml/UploadBox.qml
+++ b/resources/qml/UploadBox.qml
@@ -22,6 +22,10 @@ Page {
     contentItem: ListView {
         id: uploadsList
 
+        Loader {
+            source: NHEKO_USE_KIRIGAMI ? "components/KirigamiWheelHandler.qml" : ""
+        }
+
         anchors.horizontalCenter: parent.horizontalCenter
         boundsBehavior: Flickable.StopAtBounds
         model: room ? room.input.uploads : undefined
diff --git a/resources/qml/components/AdaptiveLayout.qml b/resources/qml/components/AdaptiveLayout.qml
index eb8ec34..3fda3fb 100644
--- a/resources/qml/components/AdaptiveLayout.qml
+++ b/resources/qml/components/AdaptiveLayout.qml
@@ -122,6 +122,10 @@ Container {
     contentItem: ListView {
         id: view
 
+        Loader {
+            source: NHEKO_USE_KIRIGAMI ? "KirigamiWheelHandler.qml" : ""
+        }
+
         model: container.contentModel
         snapMode: ListView.SnapOneItem
         orientation: ListView.Horizontal
diff --git a/resources/qml/components/ReorderableListview.qml b/resources/qml/components/ReorderableListview.qml
index b5d5f5e..a902b09 100644
--- a/resources/qml/components/ReorderableListview.qml
+++ b/resources/qml/components/ReorderableListview.qml
@@ -100,6 +100,10 @@ Item {
         ListView {
             id: view
 
+            Loader {
+                source: NHEKO_USE_KIRIGAMI ? "KirigamiWheelHandler.qml" : ""
+            }
+
             clip: true
 
             anchors { fill: parent; margins: 2 }
@@ -117,4 +121,3 @@ Item {
 
     }
 
-
diff --git a/resources/qml/dialogs/AliasEditor.qml b/resources/qml/dialogs/AliasEditor.qml
index 82f1275..67fb1ec 100644
--- a/resources/qml/dialogs/AliasEditor.qml
+++ b/resources/qml/dialogs/AliasEditor.qml
@@ -52,6 +52,10 @@ ApplicationWindow {
 
             clip: true
 
+            Loader {
+                source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+            }
+
 
             model: editingModel
             spacing: 4
diff --git a/resources/qml/dialogs/AllowedRoomsSettingsDialog.qml b/resources/qml/dialogs/AllowedRoomsSettingsDialog.qml
index 2278fae..20cc384 100644
--- a/resources/qml/dialogs/AllowedRoomsSettingsDialog.qml
+++ b/resources/qml/dialogs/AllowedRoomsSettingsDialog.qml
@@ -55,6 +55,10 @@ ApplicationWindow {
 
             clip: true
 
+            Loader {
+                source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+            }
+
 
             model: roomSettings.allowedRoomsModel
             spacing: 4
diff --git a/resources/qml/dialogs/IgnoredUsers.qml b/resources/qml/dialogs/IgnoredUsers.qml
index 6d6585f..ac45de3 100644
--- a/resources/qml/dialogs/IgnoredUsers.qml
+++ b/resources/qml/dialogs/IgnoredUsers.qml
@@ -26,6 +26,10 @@ Window {
         spacing: Nheko.paddingMedium
         footerPositioning: ListView.OverlayFooter
 
+        Loader {
+            source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+        }
+
         model: TimelineManager.ignoredUsers
         header: ColumnLayout {
             Text {
diff --git a/resources/qml/dialogs/ImagePackEditorDialog.qml b/resources/qml/dialogs/ImagePackEditorDialog.qml
index 9416ec9..5750e73 100644
--- a/resources/qml/dialogs/ImagePackEditorDialog.qml
+++ b/resources/qml/dialogs/ImagePackEditorDialog.qml
@@ -49,6 +49,10 @@ ApplicationWindow {
 
                 model: imagePack
 
+                Loader {
+                    source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+                }
+
 
                 header: AvatarListTile {
                     title: imagePack.packname
diff --git a/resources/qml/dialogs/ImagePackSettingsDialog.qml b/resources/qml/dialogs/ImagePackSettingsDialog.qml
index 6906840..0d0550f 100644
--- a/resources/qml/dialogs/ImagePackSettingsDialog.qml
+++ b/resources/qml/dialogs/ImagePackSettingsDialog.qml
@@ -59,7 +59,9 @@ ApplicationWindow {
                 model: packlist
                 clip: true
 
-                
+                Loader {
+                    source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+                }
 
                 footer: ColumnLayout {
                     Button {
@@ -231,6 +233,10 @@ ApplicationWindow {
                         currentIndex: -1 // prevent sorting from stealing focus
                         cacheBuffer: 500
 
+                        Loader {
+                            source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+                        }
+
 
                         // Individual emoji
                         delegate: AbstractButton {
diff --git a/resources/qml/dialogs/InviteDialog.qml b/resources/qml/dialogs/InviteDialog.qml
index 4ba4acd..f16f2bc 100644
--- a/resources/qml/dialogs/InviteDialog.qml
+++ b/resources/qml/dialogs/InviteDialog.qml
@@ -170,6 +170,11 @@ ApplicationWindow {
                 Layout.fillWidth: true
                 Layout.fillHeight: true
                 clip: true
+
+                Loader {
+                    source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+                }
+
                 delegate: UserListRow {
                     id: del2
                     width: ListView.view.width
@@ -196,6 +201,10 @@ ApplicationWindow {
                 clip: true
                 visible: inviteDialogRoot.width >= 500
 
+                Loader {
+                    source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+                }
+
                 delegate: UserListRow {
                     id: del
                     hoverEnabled: true
diff --git a/resources/qml/dialogs/PowerLevelSpacesApplyDialog.qml b/resources/qml/dialogs/PowerLevelSpacesApplyDialog.qml
index c86a35c..0e9832c 100644
--- a/resources/qml/dialogs/PowerLevelSpacesApplyDialog.qml
+++ b/resources/qml/dialogs/PowerLevelSpacesApplyDialog.qml
@@ -86,6 +86,10 @@ ApplicationWindow {
 
             clip: true
 
+            Loader {
+                source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+            }
+
             model: editingModel.spaces
             spacing: 4
             cacheBuffer: 50
diff --git a/resources/qml/dialogs/ReadReceipts.qml b/resources/qml/dialogs/ReadReceipts.qml
index e5dfb73..fb69bd7 100644
--- a/resources/qml/dialogs/ReadReceipts.qml
+++ b/resources/qml/dialogs/ReadReceipts.qml
@@ -58,6 +58,10 @@ ApplicationWindow {
                 boundsBehavior: Flickable.StopAtBounds
                 model: readReceipts
 
+                Loader {
+                    source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+                }
+
                 delegate: ItemDelegate {
                     id: del
 
diff --git a/resources/qml/dialogs/RoomDirectory.qml b/resources/qml/dialogs/RoomDirectory.qml
index 6d11c1c..254691b 100644
--- a/resources/qml/dialogs/RoomDirectory.qml
+++ b/resources/qml/dialogs/RoomDirectory.qml
@@ -38,6 +38,10 @@ ApplicationWindow {
         anchors.fill: parent
         model: publicRooms
 
+        Loader {
+            source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+        }
+
         delegate: Rectangle {
             id: roomDirDelegate
 
diff --git a/resources/qml/dialogs/RoomMembers.qml b/resources/qml/dialogs/RoomMembers.qml
index f9f72e5..9f2ecbd 100644
--- a/resources/qml/dialogs/RoomMembers.qml
+++ b/resources/qml/dialogs/RoomMembers.qml
@@ -112,6 +112,10 @@ ApplicationWindow {
                 boundsBehavior: Flickable.StopAtBounds
                 model: members
 
+                Loader {
+                    source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+                }
+
 
                 delegate: ItemDelegate {
                     id: del
diff --git a/resources/qml/dialogs/UserProfile.qml b/resources/qml/dialogs/UserProfile.qml
index d2566d4..beac255 100644
--- a/resources/qml/dialogs/UserProfile.qml
+++ b/resources/qml/dialogs/UserProfile.qml
@@ -49,6 +49,10 @@ ApplicationWindow {
         anchors.margins: 10
         footerPositioning: ListView.OverlayFooter
 
+        Loader {
+            source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+        }
+
         header: ColumnLayout {
             id: contentL
 
diff --git a/resources/qml/emoji/StickerPicker.qml b/resources/qml/emoji/StickerPicker.qml
index 86eca4f..fffae50 100644
--- a/resources/qml/emoji/StickerPicker.qml
+++ b/resources/qml/emoji/StickerPicker.qml
@@ -116,6 +116,10 @@ Menu {
                 clip: true
                 currentIndex: -1 // prevent sorting from stealing focus
 
+                Loader {
+                    source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
+                }
+
                 section.property: "packname"
                 section.criteria: ViewSection.FullString
                 section.delegate: Rectangle {
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index ffa7bd2..07e1506 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -4,6 +4,7 @@
 
 #include <QApplication>
 #include <QMessageBox>
+#include <QQmlContext>
 
 #include <mtx/events/collections.hpp>
 #include <mtx/requests.hpp>
@@ -112,6 +113,12 @@ MainWindow::registerQmlTypes()
 
     QObject::connect(engine(), &QQmlEngine::quit, &QGuiApplication::quit);
 
+#ifdef NHEKO_USE_KIRIGAMI
+    engine()->rootContext()->setContextProperty("NHEKO_USE_KIRIGAMI", QVariant(true));
+#else
+    engine()->rootContext()->setContextProperty("NHEKO_USE_KIRIGAMI", QVariant(false));
+#endif
+
 #ifdef NHEKO_DBUS_SYS
     if (UserSettings::instance()->exposeDBusApi()) {
         if (QDBusConnection::sessionBus().isConnected() &&