From a98abb965dff8dfcbdc2b47454ecfbd370b93a50 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Sun, 22 Sep 2024 17:11:16 -0300 Subject: Now it's building --- .qmlls.ini | 3 + justfile | 9 +++ kodereviewer/qml/CommentDelegate.qml | 4 +- kodereviewer/qml/MarkdownLabel.qml | 17 ++++++ kodereviewer/qml/PullRequestPage.qml | 106 +++++++++++++++++++---------------- pyproject.toml | 9 ++- 6 files changed, 95 insertions(+), 53 deletions(-) create mode 100644 .qmlls.ini create mode 100644 justfile create mode 100644 kodereviewer/qml/MarkdownLabel.qml diff --git a/.qmlls.ini b/.qmlls.ini new file mode 100644 index 0000000..026d017 --- /dev/null +++ b/.qmlls.ini @@ -0,0 +1,3 @@ +[General] +buildDir=/home/matias/code/kodereviewer-py/qmltypes/ +no-cmake-calls=false diff --git a/justfile b/justfile new file mode 100644 index 0000000..c368629 --- /dev/null +++ b/justfile @@ -0,0 +1,9 @@ +run: + python -mkodereviewer + +build: + python -mbuild + +qmltypes: + # If this fails, comment __main__.py code + pyside6-qml-stubgen kodereviewer/ --out-dir ./qmltypes/ diff --git a/kodereviewer/qml/CommentDelegate.qml b/kodereviewer/qml/CommentDelegate.qml index bac75d0..3b2681b 100644 --- a/kodereviewer/qml/CommentDelegate.qml +++ b/kodereviewer/qml/CommentDelegate.qml @@ -66,11 +66,9 @@ Kirigami.AbstractCard { Kirigami.Separator { Layout.fillWidth: true } - QQC2.Label { + MarkdownLabel { Layout.fillWidth: true text: root.body - textFormat: Text.MarkdownText - wrapMode: Text.WordWrap } } } diff --git a/kodereviewer/qml/MarkdownLabel.qml b/kodereviewer/qml/MarkdownLabel.qml new file mode 100644 index 0000000..1bf6b20 --- /dev/null +++ b/kodereviewer/qml/MarkdownLabel.qml @@ -0,0 +1,17 @@ +/* A for markdown rendering + * This Control accepts clicks for urls! + */ +import QtQml +import QtQuick 6.7 +import QtQuick.Controls 6.7 as QQC2 + +QQC2.Label { + textFormat: Text.MarkdownText + wrapMode: Text.WordWrap + onLinkActivated: link => Qt.openUrlExternally(link) + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Text + cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor + } +} diff --git a/kodereviewer/qml/PullRequestPage.qml b/kodereviewer/qml/PullRequestPage.qml index 19defdc..5a687e9 100644 --- a/kodereviewer/qml/PullRequestPage.qml +++ b/kodereviewer/qml/PullRequestPage.qml @@ -18,67 +18,79 @@ Kirigami.ScrollablePage { Kirigami.Theme.colorSet: Kirigami.Theme.View Kirigami.Theme.inherit: false + property string currentView: "info" + CommentModel { id: commentModel pullRequest: root.pullRequest - onPullRequestChanged: root.connection.getPullRequestComments(pullRequest.number) + onPullRequestChanged: root.connection.getPullRequestComments(root.pullRequest.number) } - ListView { - id: listView - model: commentModel - spacing: Kirigami.Units.largeSpacing * 2 - topMargin: Kirigami.Units.largeSpacing * 2 - rightMargin: Kirigami.Units.largeSpacing * 2 - leftMargin: Kirigami.Units.largeSpacing * 2 - bottomMargin: Kirigami.Units.largeSpacing * 2 // + commentToolbar.heigh - - header: ColumnLayout { - id: headerLayout - visible: !!root.pullRequest - width: ListView.view ? ListView.view.width - ListView.view.leftMargin - ListView.view.rightMargin : 0 - - Kirigami.Heading { - Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter - leftPadding: Kirigami.Units.largeSpacing - rightPadding: Kirigami.Units.largeSpacing - level: 1 - text: root.pullRequest ? root.pullRequest.title : "" - wrapMode: Text.WordWrap - } + Kirigami.PlaceholderMessage { + visible: !root.pullRequest + anchors.centerIn: parent + icon.name: "org.deprecated.kodereviewer" + text: "Select a pull request" + } - Kirigami.ListSectionHeader { - Layout.fillWidth: true - text: "description" - } + ColumnLayout { + id: mainLayout + visible: !!root.pullRequest && root.currentView == "info" - QQC2.Label { - Layout.fillWidth: true - Layout.fillHeight: false - leftPadding: Kirigami.Units.largeSpacing - rightPadding: Kirigami.Units.largeSpacing - text: root.pullRequest ? root.pullRequest.body : "" - textFormat: Text.MarkdownText - wrapMode: Text.WordWrap - } + spacing: Kirigami.Units.largeSpacing * 2 - Kirigami.ListSectionHeader { - Layout.fillWidth: true - text: "Comments" - } + Kirigami.Heading { + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + leftPadding: Kirigami.Units.largeSpacing + rightPadding: Kirigami.Units.largeSpacing + level: 1 + text: root.pullRequest ? root.pullRequest.title : "" + wrapMode: Text.WordWrap } - delegate: CommentDelegate {} + Kirigami.ListSectionHeader { + Layout.fillWidth: true + text: "description" + } - Kirigami.PlaceholderMessage { - visible: !root.pullRequest - anchors.centerIn: parent - icon.name: "org.deprecated.kodereviewer" - text: "Select a pull request" + MarkdownLabel { + Layout.fillWidth: true + Layout.fillHeight: false + leftPadding: Kirigami.Units.largeSpacing + rightPadding: Kirigami.Units.largeSpacing + text: root.pullRequest ? root.pullRequest.body : "" + } + } + ColumnLayout { + visible: !!root.pullRequest && root.currentView == "comments" + Repeater { + model: commentModel + delegate: CommentDelegate {} } } + + footer: Kirigami.NavigationTabBar { + actions: [ + Kirigami.Action { + icon.name: "info" + text: i18n("Info") + onTriggered: root.currentView = "info" + }, + Kirigami.Action { + icon.name: "comment-symbolic" + text: i18n("Comments") + onTriggered: root.currentView = "comments" + + }, + Kirigami.Action { + icon.name: "file-catalog-symbolic" + text: i18n("Files") + onTriggered: root.currentView = "files" + } + ] + } } diff --git a/pyproject.toml b/pyproject.toml index 4bed84a..11941f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "org.deprecated.kodereviewer" +name = "kodereviewer" version = "0.1" authors = [ {name = "Matias Linares", email = "matias@deprecated.org" } @@ -17,8 +17,11 @@ packages = "kodereviewer" include_package_data = true [build-system] -requires = ["setuptools", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.build.targets.wheel] +packages = ["kodereviewer/"] [options.data_files] "share/applications" = "org.deprecated.kodereviewer.desktop" -- cgit v1.2.3-70-g09d2