summaryrefslogtreecommitdiff
path: root/kodereviewer/qml/ProjectListPage.qml
diff options
context:
space:
mode:
Diffstat (limited to 'kodereviewer/qml/ProjectListPage.qml')
-rw-r--r--kodereviewer/qml/ProjectListPage.qml130
1 files changed, 130 insertions, 0 deletions
diff --git a/kodereviewer/qml/ProjectListPage.qml b/kodereviewer/qml/ProjectListPage.qml
new file mode 100644
index 0000000..334799e
--- /dev/null
+++ b/kodereviewer/qml/ProjectListPage.qml
@@ -0,0 +1,130 @@
+pragma ComponentBehavior: Bound
+import QtQuick 2.15 // Removing version break onCurrentItemChanged
+import QtQuick.Layouts
+import QtQuick.Controls as QQC2
+
+import org.kde.kirigamiaddons.delegates as Delegates
+import org.kde.kitemmodels 1 as KItemModels
+import org.kde.kirigami as Kirigami
+
+import org.deprecated.kodereviewer
+
+Kirigami.Page {
+ id: root
+
+ required property NetworkManager connection
+ required property Project project
+
+
+ readonly property int currentWidth: _private.currentWidth + 1
+
+ onCurrentWidthChanged: pageStack.defaultColumnWidth = root.currentWidth
+ Component.onCompleted: {
+ pageStack.defaultColumnWidth = root.currentWidth
+ connection.getPullRequests()
+ }
+
+ Kirigami.Theme.colorSet: Kirigami.Theme.View
+ Kirigami.Theme.inherit: false
+
+ PullRequestModel {
+ id: pullRequestModel
+ project: root.project
+ }
+
+ KItemModels.KSortFilterProxyModel {
+ id: pullRequestFilterModel
+ sourceModel: pullRequestModel
+ filterRoleName: "title"
+ }
+
+ title: "Pull Requests"
+
+ actions: [
+ Kirigami.Action {
+ id: searchAction
+ icon.name: "search"
+ shortcut: Shortcut {
+ sequence: "Ctrl+F"
+ onActivated: {
+ print("Shortcut triggered")
+ searchAction.trigger()
+ }
+ }
+
+ onTriggered: print("search triggered")
+ }
+ ]
+
+ contentItem: QQC2.StackView {
+ id: stackView
+ anchors.fill: parent
+
+ initialItem: pullRequestListView
+
+ Component {
+ id: pullRequestListView
+ QQC2.ScrollView {
+ ListView {
+ id: view
+ model: pullRequestFilterModel
+ clip: true
+ delegate: Delegates.RoundedItemDelegate {
+ required property int number
+ required property string title
+ required property int index
+ highlighted: ListView.isCurrentItem
+
+ text: `${number} - ${title}`
+ icon.name: "vcs-merge-request"
+ }
+ }
+ }
+ }
+ }
+
+ MouseArea {
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ parent: applicationWindow().overlay.parent
+
+ x: root.currentWidth - width / 2
+ width: Kirigami.Units.smallSpacing * 2
+ z: root.z + 1
+ enabled: true
+ visible: enabled
+ cursorShape: Qt.SplitHCursor
+
+ property int _lastX
+
+ onPressed: mouse => {
+ _lastX = mouse.x;
+ }
+ onPositionChanged: mouse => {
+ if (_lastX == -1) {
+ return;
+ }
+ if (mouse.x > _lastX) {
+ // _private.currentWidth = _private.currentWidth + (_lastX + mouse.x);
+ _private.currentWidth = Math.min(_private.defaultWidth, _private.currentWidth + (mouse.x - _lastX))
+ } else if (mouse.x < _lastX) {
+ const tmpWidth = _private.currentWidth - (_lastX - mouse.x);
+ if (tmpWidth > _private.minWidth)
+ _private.currentWidth = tmpWidth;
+
+ }
+ }
+ }
+
+ /*
+ * Hold the modifiable currentWidth in a private object so that only internal
+ * members can modify it.
+ */
+ QtObject {
+ id: _private
+ property int currentWidth: defaultWidth
+ readonly property int defaultWidth: Kirigami.Units.gridUnit * 17
+ readonly property int minWidth: Kirigami.Units.gridUnit * 2
+ }
+
+}