summaryrefslogtreecommitdiff
path: root/kodereviewer/qml
diff options
context:
space:
mode:
Diffstat (limited to 'kodereviewer/qml')
-rw-r--r--kodereviewer/qml/AddRepositoryPage.qml97
-rw-r--r--kodereviewer/qml/Main.qml85
-rw-r--r--kodereviewer/qml/ProjectListPage.qml130
-rw-r--r--kodereviewer/qml/SettingsPage.qml39
-rw-r--r--kodereviewer/qml/WelcomePage.qml117
5 files changed, 468 insertions, 0 deletions
diff --git a/kodereviewer/qml/AddRepositoryPage.qml b/kodereviewer/qml/AddRepositoryPage.qml
new file mode 100644
index 0000000..2bd26fe
--- /dev/null
+++ b/kodereviewer/qml/AddRepositoryPage.qml
@@ -0,0 +1,97 @@
+import QtCore
+import QtQuick 6.7
+import QtQuick.Controls 6 as QQC2
+import QtQuick.Layouts 6.7
+
+import org.kde.kirigami as Kirigami
+import org.kde.kirigamiaddons.formcard as FormCard
+
+FormCard.FormCardPage {
+ id: root
+ title: "Add a new repository"
+
+ signal accepted(string url, string name, string owner, string displayName)
+
+ FormCard.FormHeader {
+ title: "Github information"
+ }
+
+ FormCard.FormCard {
+ FormCard.FormTextFieldDelegate {
+ id: urlField
+ label: "URL"
+ onTextChanged: root.fillDataFromUrl(text)
+ }
+
+ FormCard.FormDelegateSeparator {}
+
+ FormCard.FormTextFieldDelegate {
+ id: nameField
+ label: "Name"
+ }
+
+ FormCard.FormDelegateSeparator {}
+
+ FormCard.FormTextFieldDelegate {
+ id: ownerField
+ label: "Owner"
+ }
+
+ FormCard.FormDelegateSeparator {}
+ }
+
+ FormCard.FormHeader {
+ title: "General information"
+ }
+
+ FormCard.FormCard {
+ FormCard.FormTextFieldDelegate {
+ id: displayNameField
+ label: "Display name"
+ }
+ }
+
+
+ FormCard.FormHeader {
+ title: "Git"
+ }
+
+ FormCard.FormCard {
+ FormCard.FormCheckDelegate {
+ id: cloneCheck
+ text: "Clone repository"
+ checked: false
+ }
+
+ FormCard.FormDelegateSeparator {}
+
+ FormCard.FormTextFieldDelegate {
+ id: cloneDirectory
+ label: "Clone directory"
+ enabled: cloneCheck.checked
+ }
+ }
+
+
+ footer: QQC2.ToolBar {
+ contentItem: QQC2.DialogButtonBox {
+ standardButtons: QQC2.Dialog.Ok | QQC2.Dialog.Cancel
+ onAccepted: root.accepted(
+ urlField.text,
+ nameField.text,
+ ownerField.text,
+ displayNameField.text
+ )
+ onRejected: applicationWindow().pageStack.pop()
+ }
+ }
+
+ function fillDataFromUrl(text) {
+ const s = text.split("/")
+ if (s.length > 2) {
+ nameField.text = s[s.length -1]
+ ownerField.text = s[s.length - 2]
+ displayNameField.text = s[s.length -1]
+ }
+ }
+}
diff --git a/kodereviewer/qml/Main.qml b/kodereviewer/qml/Main.qml
new file mode 100644
index 0000000..0b41a05
--- /dev/null
+++ b/kodereviewer/qml/Main.qml
@@ -0,0 +1,85 @@
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtCore
+import QtQuick.Controls as Controls
+import QtQuick.Layouts
+
+import org.kde.kirigami as Kirigami
+import org.kde.kirigamiaddons.formcard as FormCard
+
+import org.deprecated.kodereviewer 1.0
+
+Kirigami.ApplicationWindow {
+ id: root
+
+ title: qsTr("Kode Reviewer")
+
+ minimumWidth: Kirigami.Units.gridUnit * 20
+ minimumHeight: Kirigami.Units.gridUnit * 20
+ width: minimumWidth
+ height: minimumHeight
+
+ signal projectSelected()
+
+ property Project project
+
+ property NetworkManager connection: NetworkManager {
+ project: root.project
+ }
+
+ Settings {
+ id: settings
+ property alias width: root.width
+ property alias height: root.height
+ property string githubToken: ""
+ }
+
+ pageStack.initialPage: initPage
+
+ Component {
+ id: initPage
+ WelcomePage {
+ onProjectSelected: project => {
+ root.project = project
+ root.projectSelected()
+ }
+ }
+ }
+
+ Loader {
+ id: projectListPageLoader
+ active: false
+ sourceComponent: Component {
+ ProjectListPage {
+ connection: root.connection
+ project: root.project
+ }
+ }
+ }
+
+ Loader {
+ id: placeHolderPageLoader
+ active: false
+ sourceComponent: Component {
+ Kirigami.Page {
+
+ Kirigami.Theme.colorSet: Kirigami.Theme.View
+ Kirigami.Theme.inherit: false
+ title: "Select a pull request"
+ spacing: Kirigami.Units.largeSpacing * 2
+ Kirigami.PlaceholderMessage {
+ anchors.centerIn: parent
+ icon.name: "org.deprecated.kodereviewer"
+ text: "Select a pull request"
+ }
+ }
+ }
+ }
+
+ onProjectSelected: {
+ projectListPageLoader.active = true
+ placeHolderPageLoader.active = true
+ pageStack.replace(projectListPageLoader.item)
+ pageStack.push(placeHolderPageLoader.item)
+ }
+}
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
+ }
+
+}
diff --git a/kodereviewer/qml/SettingsPage.qml b/kodereviewer/qml/SettingsPage.qml
new file mode 100644
index 0000000..83e5c90
--- /dev/null
+++ b/kodereviewer/qml/SettingsPage.qml
@@ -0,0 +1,39 @@
+import QtCore
+import QtQuick 6.7
+import QtQuick.Controls 6 as QQC2
+import QtQuick.Layouts 6.7
+
+import org.kde.kirigami as Kirigami
+import org.kde.kirigamiaddons.formcard as FormCard
+
+
+FormCard.FormCardPage {
+ id: root
+
+ actions: [
+ Kirigami.Action {
+ id: saveAction
+ text: "Save"
+ onTriggered: {
+ settings.sync()
+ }
+ }
+ ]
+
+ Settings {
+ id: settings
+ property string githubToken: githubTokenField.text
+ }
+
+ FormCard.FormHeader {
+ title: "Authorization"
+ }
+
+ FormCard.FormCard {
+ FormCard.FormTextFieldDelegate {
+ id: githubTokenField
+ text: settings.githubToken
+ label: "Github Token"
+ }
+ }
+}
diff --git a/kodereviewer/qml/WelcomePage.qml b/kodereviewer/qml/WelcomePage.qml
new file mode 100644
index 0000000..af74d01
--- /dev/null
+++ b/kodereviewer/qml/WelcomePage.qml
@@ -0,0 +1,117 @@
+import QtCore
+import QtQuick 6.7
+import QtQuick.Controls 6 as QQC2
+import QtQuick.Layouts 6.7
+
+import org.kde.kirigami as Kirigami
+import org.kde.kirigamiaddons.formcard as FormCard
+import org.kde.kirigamiaddons.settings as KirigamiSettings
+
+import org.deprecated.kodereviewer
+
+FormCard.FormCardPage {
+ id: root
+
+ title: "Welcome"
+
+ property int projectCount: projectModel.rowCount()
+
+ signal projectSelected(Project project)
+
+ ProjectModel {
+ id: projectModel
+
+ onModelReset: {
+ projectCount = projectModel.rowCount()
+ }
+ }
+
+ Component {
+ id: addRepositoryPage
+ AddRepositoryPage {
+ onAccepted: (url, name, owner, displayName) => {
+ projectModel.add(displayName, owner, url)
+ applicationWindow().pageStack.pop()
+ }
+ }
+ }
+ KirigamiSettings.ConfigurationView {
+ id: configuration
+
+ window: applicationWindow() as Kirigami.ApplicationWindow
+
+ modules: [
+ KirigamiSettings.ConfigurationModule {
+ moduleId: "appearance"
+ text: i18nc("@action:button", "General")
+ icon.name: "preferences-system-symbolic"
+ page: () => Qt.createComponent("SettingsPage.qml")
+ },
+ KirigamiSettings.ConfigurationModule {
+ moduleId: "about"
+ text: i18nc("@action:button", "About Kode Reviewer")
+ icon.name: "help-about"
+ page: () => Qt.createComponent("org.kde.kirigamiaddons.formcard", "AboutPage")
+ category: i18nc("@title:group", "About")
+ },
+ KirigamiSettings.ConfigurationModule {
+ moduleId: "aboutkde"
+ text: i18nc("@action:button", "About KDE")
+ icon.name: "kde"
+ page: () => Qt.createComponent("org.kde.kirigamiaddons.formcard", "AboutKDE")
+ category: i18nc("@title:group", "About")
+ }
+ ]
+ }
+
+ Kirigami.Heading {
+ id: welcomeMessage
+
+ text: "Welcome to Kode Reviewer"
+
+ Layout.alignment: Qt.AlignHCenter
+ Layout.topMargin: Kirigami.Units.largeSpacing
+ }
+
+ FormCard.FormHeader {
+ id: existingProjectsHeader
+ title: "Existing projects"
+ visible: root.projectCount > 0
+ }
+
+ FormCard.FormCard {
+ visible: existingProjectsHeader.visible
+
+ Repeater {
+ id: loadedProjects
+ model: projectModel
+ delegate: FormCard.FormButtonDelegate {
+ required property string name
+ required property string url
+ required property int index
+ text: name
+ description: url
+ onClicked: root.projectSelected(projectModel.get(index))
+ }
+ }
+ }
+
+ FormCard.FormHeader {
+ title: "Add new project"
+ }
+
+ FormCard.FormCard {
+ FormCard.FormButtonDelegate {
+ text: "Add new project"
+ onClicked: applicationWindow().pageStack.push(addRepositoryPage)
+ }
+ }
+
+ FormCard.FormCard {
+ FormCard.FormButtonDelegate {
+ text: "Settings"
+ icon.name: 'settings-configure-symbolic'
+ onClicked: configuration.open()
+ }
+ }
+}