blob: a418f5866cf4a532463de140a19298306881a2e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Dialogs 1.3
import Qt.labs.platform 1.1 as Platform
import EpistmoolUI 1.0
Item {
Action {
id: boldAction
shortcut: StandardKey.Bold
onTriggered: docHandler.bold = !docHandler.bold
}
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
}
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()
Rectangle {
width: aFontMetrics.width + 3
height: 2
color: docHandler.activeTextColor
parent: textColorButton.contentItem
anchors.horizontalCenter: parent.horizontalCenter
anchors.baseline: parent.baseline
anchors.baselineOffset: 6
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()
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
}
}
}
|