Init
This commit is contained in:
parent
6800bca693
commit
62636ee1b1
1
clip-it-and-ship-it/.gitignore
vendored
Normal file
1
clip-it-and-ship-it/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
env/
|
33
clip-it-and-ship-it/src/main.py
Normal file
33
clip-it-and-ship-it/src/main.py
Normal file
@ -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()
|
71
clip-it-and-ship-it/src/qml/main.qml
Normal file
71
clip-it-and-ship-it/src/qml/main.qml
Normal file
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user