aboutsummaryrefslogtreecommitdiff
path: root/ui.qt/source/qml/Document.qml
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-06-27 00:10:58 +0000
committerrtk0c <[email protected]>2022-06-27 00:10:58 +0000
commit9ad9af9f2596b91e1dd65e71543f75b0644e8283 (patch)
treef8190a9314a7602872de3b4910bac1a5201d0466 /ui.qt/source/qml/Document.qml
parent753c26d320e894069157bd401f7779ad07073d7c (diff)
(From git) Initial GUI setup for text document
git-svn-id: file:///home/arch/svn/epistmool/trunk@3 71f44415-077c-4ad7-a976-72ddbf76608f
Diffstat (limited to 'ui.qt/source/qml/Document.qml')
-rw-r--r--ui.qt/source/qml/Document.qml164
1 files changed, 144 insertions, 20 deletions
diff --git a/ui.qt/source/qml/Document.qml b/ui.qt/source/qml/Document.qml
index e62b731..a3d4075 100644
--- a/ui.qt/source/qml/Document.qml
+++ b/ui.qt/source/qml/Document.qml
@@ -1,39 +1,163 @@
import QtCore
import QtQuick
import QtQuick.Controls
+import QtQuick.Dialogs
+import Qt.labs.platform as Platform
import EpistmoolUI
Item {
- DocumentModel {
- id: documentModel
+ Action {
+ id: boldAction
+ shortcut: StandardKey.Bold
+ onTriggered: docHandler.bold = !docHandler.bold
}
- ScrollView {
- id: scrollView
+ Action {
+ id: italicAction
+ shortcut: StandardKey.Italic
+ onTriggered: docHandler.italic = !docHandler.italic
+ }
+
+ Action {
+ id: underlineAction
+ shortcut: StandardKey.Underline
+ onTriggered: docHandler.underline = !docHandler.underline
+ }
+
+ Action {
+ id: strikeoutAction
+ shortcut: "Ctrl+Shift+X"
+ onTriggered: docHandler.strikeout = !docHandler.strikeout
+ }
- ListView {
- id: listView
- model: documentModel
- anchors.fill: parent
+ Platform.ColorDialog {
+ id: colorDialog
+ currentColor: "black"
+ }
+
+ Item {
+ id: toolbar
+ width: parent.width
+ height: childrenRect.height
+
+ Row {
+ id: toolbarLeft
+ layoutDirection: Qt.LeftToRight
+
+ ToolButton {
+ id: boldButton
+ text: "B"
+ font.bold: true
+ focusPolicy: Qt.TabFocus
+ checkable: true
+ checked: docHandler.bold
+ action: boldAction
+ }
+ ToolButton {
+ id: italicButton
+ text: "I"
+ font.italic: true
+ focusPolicy: Qt.TabFocus
+ checkable: true
+ checked: docHandler.italic
+ action: italicAction
+ }
+ ToolButton {
+ id: underlineButton
+ text: "U"
+ font.underline: true
+ focusPolicy: Qt.TabFocus
+ checkable: true
+ checked: docHandler.underline
+ action: underlineAction
+ }
+ ToolButton {
+ id: strikeoutButton
+ text: "S"
+ font.strikeout: true
+ focusPolicy: Qt.TabFocus
+ checkable: true
+ checked: docHandler.strikeout
+ action: strikeoutAction
+ }
+ ToolButton {
+ id: textColorButton
+ text: "\uF1FC" // icon-brush
+ font.family: "fontello"
+ focusPolicy: Qt.TabFocus
+ onClicked: colorDialog.open()
- delegate: Item {
- required property DocumentBlock documentBlock
- required property date modifyTime
+ Rectangle {
+ width: aFontMetrics.width + 3
+ height: 2
+ color: docHandler.activeTextColor
+ parent: textColorButton.contentItem
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.baseline: parent.baseline
+ anchors.baselineOffset: 6
- Component.onCompleted: {
- documentBlock.textDocument = textArea.textDocument
+ TextMetrics {
+ id: aFontMetrics
+ font: textColorButton.font
+ text: textColorButton.text
+ }
}
+ }
+ }
+
+ Row {
+ id: toolbarRight
+ layoutDirection: Qt.RightToLeft
+ height: parent.height
+ anchors.left: toolbarLeft.right
+ anchors.right: parent.right
+
+ Label {
+ text: docHandler.modifyTime.toLocaleTimeString()
- TextArea {
- id: textArea
- textFormat: Qt.RichText
- wrapMode: TextArea.Wrap
- focus: true
- selectByMouse: true
- persistentSelection: true
+ ToolTip.visible: ma.containsMouse
+ ToolTip.text: docHandler.modifyTime.toLocaleString()
+
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+ hoverEnabled: true
}
}
}
}
+
+ DocumentHandler {
+ id: docHandler
+ document: textArea.textDocument
+
+ // Binding for current editing state of the TextArea
+ cursorPos: textArea.cursorPosition
+ selectionBegin: textArea.selectionStart
+ selectionEnd: textArea.selectionEnd
+
+ property alias family: docHandler.activeFont.family
+ property alias bold: docHandler.activeFont.bold
+ property alias italic: docHandler.activeFont.italic
+ property alias underline: docHandler.activeFont.underline
+ property alias strikeout: docHandler.activeFont.strikeout
+ property alias size: docHandler.activeFont.pointSize
+ }
+
+ ScrollView {
+ id: scrollView
+ width: parent.width
+ anchors.top: toolbar.bottom
+ anchors.bottom: parent.bottom
+
+ TextArea {
+ id: textArea
+ textFormat: Qt.RichText
+ wrapMode: TextArea.Wrap
+ focus: true
+ selectByMouse: true
+ persistentSelection: true
+ }
+ }
}