diff --git a/clip-it-and-ship-it/.gitignore b/clip-it-and-ship-it/.gitignore new file mode 100644 index 00000000..ae412d6a --- /dev/null +++ b/clip-it-and-ship-it/.gitignore @@ -0,0 +1 @@ +env/ \ No newline at end of file diff --git a/clip-it-and-ship-it/src/main.py b/clip-it-and-ship-it/src/main.py new file mode 100644 index 00000000..3043debd --- /dev/null +++ b/clip-it-and-ship-it/src/main.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +import os +import sys +import signal +from PyQt6.QtGui import QGuiApplication +from PyQt6.QtCore import QUrl +from PyQt6.QtQml import QQmlApplicationEngine + +def main(): + """Initializes and manages the application execution""" + app = QGuiApplication(sys.argv) + engine = QQmlApplicationEngine() + + """Needed to close the app with Ctrl+C""" + signal.signal(signal.SIGINT, signal.SIG_DFL) + + """Needed to get proper KDE style outside of Plasma""" + if not os.environ.get("QT_QUICK_CONTROLS_STYLE"): + os.environ["QT_QUICK_CONTROLS_STYLE"] = "org.kde.desktop" + + base_path = os.path.abspath(os.path.dirname(__file__)) + url = QUrl(f"file://{base_path}/qml/main.qml") + engine.load(url) + + if len(engine.rootObjects()) == 0: + quit() + + app.exec() + + +if __name__ == "__main__": + main() diff --git a/clip-it-and-ship-it/src/qml/main.qml b/clip-it-and-ship-it/src/qml/main.qml new file mode 100644 index 00000000..babc5903 --- /dev/null +++ b/clip-it-and-ship-it/src/qml/main.qml @@ -0,0 +1,71 @@ +import QtQuick +import QtQuick.Controls as Controls +import org.kde.kirigami as Kirigami +import QtQuick.Layouts + +Kirigami.ApplicationWindow { + id: root + + title: qsTr("Simple Markdown viewer") + + minimumWidth: Kirigami.Units.gridUnit * 20 + minimumHeight: Kirigami.Units.gridUnit * 20 + width: minimumWidth + height: minimumHeight + + pageStack.initialPage: initPage + + Component { + id: initPage + + Kirigami.Page { + title: qsTr("Markdown Viewer") + + ColumnLayout { + anchors { + top: parent.top + left: parent.left + right: parent.right + } + Controls.TextArea { + id: sourceArea + + placeholderText: qsTr("Write some Markdown code here") + wrapMode: Text.WrapAnywhere + Layout.fillWidth: true + Layout.minimumHeight: Kirigami.Units.gridUnit * 5 + } + + RowLayout { + Layout.fillWidth: true + + Controls.Button { + text: qsTr("Format") + + onClicked: formattedText.text = sourceArea.text + } + + Controls.Button { + text: qsTr("Clear") + + onClicked: { + sourceArea.text = "" + formattedText.text = "" + } + } + } + + Text { + id: formattedText + + textFormat: Text.RichText + wrapMode: Text.WordWrap + text: sourceArea.text + + Layout.fillWidth: true + Layout.minimumHeight: Kirigami.Units.gridUnit * 5 + } + } + } + } +}