aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols2/texteditor
diff options
context:
space:
mode:
authorOliver Eftevaag <oliver.eftevaag@qt.io>2022-08-10 19:57:26 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-08-25 05:44:34 +0000
commitf2905d635f28c9fa5d0609ce375d97ba4c3d26e9 (patch)
tree42e21bbadfa90911f3a020fc8fe10e1758144073 /examples/quickcontrols2/texteditor
parenta103f852036ff3c3c3cfaf9bc2a9ff8f11c118f3 (diff)
TextEditor example: use the ColorDialog from qt quick dialogs
In 6.4 we're introducing the ColorDialog in the qt quick dialogs module. This was the final dialog, that was missing from the module in previous versions of qt. This change will make use of the new dialog, instead of the qt labs platform version, which is using the widgets color dialog as a fallback. The eventual goal for this example should be to eliminate the need for the qt labs platform module entirely. Note that I am also making a small change to how the font dialog is being used, since we deprecated the currentFont property in the 6.3 release, but I forgot to update this example along with it. Change-Id: Ib99ca7cbf110d3084ff96dfadfa1cd8c8af8815e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 314cae87524993a2af8068aa81c90ab2f1006590) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/quickcontrols2/texteditor')
-rw-r--r--examples/quickcontrols2/texteditor/qml/texteditor.qml30
1 files changed, 20 insertions, 10 deletions
diff --git a/examples/quickcontrols2/texteditor/qml/texteditor.qml b/examples/quickcontrols2/texteditor/qml/texteditor.qml
index 0824b6c7b4..decf0801e4 100644
--- a/examples/quickcontrols2/texteditor/qml/texteditor.qml
+++ b/examples/quickcontrols2/texteditor/qml/texteditor.qml
@@ -168,14 +168,13 @@ ApplicationWindow {
FontDialog {
id: fontDialog
-
- onAccepted: document.font = fontDialog.selectedFont
- onVisibleChanged: if (visible) currentFont = document.font
+ onAccepted: document.font = selectedFont
}
- Platform.ColorDialog {
+ ColorDialog {
id: colorDialog
- currentColor: "black"
+ selectedColor: "black"
+ onAccepted: document.textColor = selectedColor
}
MessageDialog {
@@ -290,14 +289,20 @@ ApplicationWindow {
font.underline: document.underline
font.strikeout: document.strikeout
focusPolicy: Qt.TabFocus
- onClicked: fontDialog.open()
+ onClicked: function () {
+ fontDialog.selectedFont = document.font
+ fontDialog.open()
+ }
}
ToolButton {
id: textColorButton
text: "\uF1FC" // icon-brush
font.family: "fontello"
focusPolicy: Qt.TabFocus
- onClicked: colorDialog.open()
+ onClicked: function () {
+ colorDialog.selectedColor = document.textColor
+ colorDialog.open()
+ }
Rectangle {
width: aFontMetrics.width + 3
@@ -368,7 +373,6 @@ ApplicationWindow {
cursorPosition: textArea.cursorPosition
selectionStart: textArea.selectionStart
selectionEnd: textArea.selectionEnd
- textColor: colorDialog.color
property alias family: document.font.family
property alias bold: document.font.bold
@@ -451,12 +455,18 @@ ApplicationWindow {
Platform.MenuItem {
text: qsTr("Font...")
- onTriggered: fontDialog.open()
+ onTriggered: function () {
+ fontDialog.selectedFont = document.font
+ fontDialog.open()
+ }
}
Platform.MenuItem {
text: qsTr("Color...")
- onTriggered: colorDialog.open()
+ onTriggered: function () {
+ colorDialog.selectedColor = document.textColor
+ colorDialog.open()
+ }
}
}