19import QtQuick.Controls.Suru 2.2
20import Lomiri.Components 1.3
21import Lomiri.Components.Popups 1.3
22import Dekko.Lomiri.Constants 1.0
27 property var editor: null
28 property string currentFontSize: "11pt"
29 property color currentTextColor:
"#202124"
30 property color currentHighlightColor:
"transparent"
32 signal fontSizeClicked()
33 signal textColorClicked()
34 signal highlightColorClicked()
38 color: theme.palette.normal.background
42 contentWidth: toolbarRow.width + units.gu(2)
44 flickableDirection: Flickable.HorizontalFlick
50 anchors.verticalCenter: parent.verticalCenter
51 spacing: units.gu(0.6)
59 color: editor && editor.font.bold ? Suru.highlightColor : theme.palette.normal.foreground
62 editor.font.bold = !editor.font.bold
73 color: editor && editor.font.italic ? Suru.highlightColor : theme.palette.normal.foreground
76 editor.font.italic = !editor.font.italic
87 color: editor && editor.font.underline ? Suru.highlightColor : theme.palette.normal.foreground
90 editor.font.underline = !editor.font.underline
100 height: units.gu(3.8)
101 text: currentFontSize
102 color: theme.palette.normal.foreground
103 onClicked: toolbar.fontSizeClicked()
109 height: units.gu(3.8)
112 color: theme.palette.normal.foreground
115 bottom: parent.bottom
116 bottomMargin: units.dp(4)
117 horizontalCenter: parent.horizontalCenter
122 color: toolbar.currentTextColor
124 onClicked: toolbar.textColorClicked()
130 height: units.gu(3.8)
131 color: theme.palette.normal.foreground
133 anchors.centerIn: parent
135 height: units.gu(1.6)
137 color: toolbar.currentHighlightColor ===
"transparent" ?
"#fff9c4" : toolbar.currentHighlightColor
138 border.width: units.dp(1)
139 border.color: theme.palette.normal.baseText
141 onClicked: toolbar.highlightColorClicked()
149 height: units.gu(3.8)
150 property bool isActive: editor && editor.textAlignment === Text.AlignLeft
151 color: isActive ? Suru.highlightColor : theme.palette.normal.foreground
152 property color iconColor: isActive ?
"white" : theme.palette.normal.baseText
154 anchors.centerIn: parent
156 Rectangle { width: units.gu(2.4); height: units.dp(2); color: parent.parent.iconColor; anchors.left: parent.left }
157 Rectangle { width: units.gu(1.6); height: units.dp(2); color: parent.parent.iconColor; anchors.left: parent.left }
158 Rectangle { width: units.gu(2.0); height: units.dp(2); color: parent.parent.iconColor; anchors.left: parent.left }
159 Rectangle { width: units.gu(1.2); height: units.dp(2); color: parent.parent.iconColor; anchors.left: parent.left }
161 onClicked:
if (editor) editor.setTextAlignment(Text.AlignLeft)
167 height: units.gu(3.8)
168 property bool isActive: editor && editor.textAlignment === Text.AlignHCenter
169 color: isActive ? Suru.highlightColor : theme.palette.normal.foreground
170 property color iconColor: isActive ?
"white" : theme.palette.normal.baseText
172 anchors.centerIn: parent
174 Rectangle { width: units.gu(2.4); height: units.dp(2); color: parent.parent.iconColor; anchors.horizontalCenter: parent.horizontalCenter }
175 Rectangle { width: units.gu(1.6); height: units.dp(2); color: parent.parent.iconColor; anchors.horizontalCenter: parent.horizontalCenter }
176 Rectangle { width: units.gu(2.0); height: units.dp(2); color: parent.parent.iconColor; anchors.horizontalCenter: parent.horizontalCenter }
177 Rectangle { width: units.gu(1.2); height: units.dp(2); color: parent.parent.iconColor; anchors.horizontalCenter: parent.horizontalCenter }
179 onClicked:
if (editor) editor.setTextAlignment(Text.AlignHCenter)
185 height: units.gu(3.8)
186 property bool isActive: editor && editor.textAlignment === Text.AlignRight
187 color: isActive ? Suru.highlightColor : theme.palette.normal.foreground
188 property color iconColor: isActive ?
"white" : theme.palette.normal.baseText
190 anchors.centerIn: parent
192 Rectangle { width: units.gu(2.4); height: units.dp(2); color: parent.parent.iconColor; anchors.right: parent.right }
193 Rectangle { width: units.gu(1.6); height: units.dp(2); color: parent.parent.iconColor; anchors.right: parent.right }
194 Rectangle { width: units.gu(2.0); height: units.dp(2); color: parent.parent.iconColor; anchors.right: parent.right }
195 Rectangle { width: units.gu(1.2); height: units.dp(2); color: parent.parent.iconColor; anchors.right: parent.right }
197 onClicked:
if (editor) editor.setTextAlignment(Text.AlignRight)
203 height: units.gu(3.8)
204 property bool isActive: editor && editor.textAlignment === Text.AlignJustify
205 color: isActive ? Suru.highlightColor : theme.palette.normal.foreground
206 property color iconColor: isActive ?
"white" : theme.palette.normal.baseText
208 anchors.centerIn: parent
210 Rectangle { width: units.gu(2.4); height: units.dp(2); color: parent.parent.iconColor }
211 Rectangle { width: units.gu(2.4); height: units.dp(2); color: parent.parent.iconColor }
212 Rectangle { width: units.gu(2.4); height: units.dp(2); color: parent.parent.iconColor }
213 Rectangle { width: units.gu(2.4); height: units.dp(2); color: parent.parent.iconColor }
215 onClicked:
if (editor) editor.setTextAlignment(Text.AlignJustify)
223 height: units.gu(3.8)
224 color: theme.palette.normal.foreground
226 onClicked:
if (editor) editor.makeUnorderedList()
232 height: units.gu(3.8)
233 color: theme.palette.normal.foreground
235 onClicked:
if (editor) editor.makeOrderedList()
243 height: units.gu(3.8)
244 color: theme.palette.normal.foreground
245 iconName:
"insert-link"
246 onClicked: toolbar.linkClicked()
254 height: units.gu(3.8)
255 color: theme.palette.normal.foreground
256 iconName:
"edit-undo"
257 onClicked:
if (editor) editor.undo()
263 height: units.gu(3.8)
264 color: theme.palette.normal.foreground
265 iconName:
"edit-redo"
266 onClicked:
if (editor) editor.redo()
274 height: units.gu(3.8)
275 color: theme.palette.normal.foreground
276 iconName:
"edit-clear"
277 onClicked:
if (editor) editor.removeAllFormatting()