summaryrefslogtreecommitdiffstats
path: root/src/webenginequick/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/webenginequick/ui')
-rw-r--r--src/webenginequick/ui/AlertDialog.qml64
-rw-r--r--src/webenginequick/ui/AuthenticationDialog.qml101
-rw-r--r--src/webenginequick/ui/AutofillPopup.qml41
-rw-r--r--src/webenginequick/ui/CMakeLists.txt50
-rw-r--r--src/webenginequick/ui/ColorDialog.qml13
-rw-r--r--src/webenginequick/ui/ConfirmDialog.qml77
-rw-r--r--src/webenginequick/ui/DirectoryPicker.qml15
-rw-r--r--src/webenginequick/ui/FilePicker.qml15
-rw-r--r--src/webenginequick/ui/Menu.qml22
-rw-r--r--src/webenginequick/ui/MenuItem.qml7
-rw-r--r--src/webenginequick/ui/MenuSeparator.qml6
-rw-r--r--src/webenginequick/ui/PromptDialog.qml79
-rw-r--r--src/webenginequick/ui/ToolTip.qml10
-rw-r--r--src/webenginequick/ui/TouchHandle.qml6
-rw-r--r--src/webenginequick/ui/TouchSelectionMenu.qml139
-rw-r--r--src/webenginequick/ui/custom/ColorDialog.qml285
-rw-r--r--src/webenginequick/ui/information.pngbin0 -> 254 bytes
-rw-r--r--src/webenginequick/ui/question.pngbin0 -> 257 bytes
18 files changed, 930 insertions, 0 deletions
diff --git a/src/webenginequick/ui/AlertDialog.qml b/src/webenginequick/ui/AlertDialog.qml
new file mode 100644
index 000000000..e4c17b056
--- /dev/null
+++ b/src/webenginequick/ui/AlertDialog.qml
@@ -0,0 +1,64 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+Dialog {
+ property alias text: message.text
+ property bool handled: false
+ signal accepted()
+ signal rejected()
+ title: qsTr("Alert Dialog")
+ modal: false
+ anchors.centerIn: parent
+ objectName: "alertDialog"
+
+ //handle the case where users simply closes the dialog
+ onVisibleChanged: {
+ if (visible == false && handled == false) {
+ handled = true;
+ rejected();
+ } else {
+ handled = false;
+ }
+ }
+
+ function acceptDialog() {
+ accepted();
+ handled = true;
+ close();
+ }
+
+ ColumnLayout {
+ id: rootLayout
+ anchors.fill: parent
+ anchors.margins: 4
+ property int minimumWidth: rootLayout.implicitWidth + rootLayout.doubleMargins
+ property int minimumHeight: rootLayout.implicitHeight + rootLayout.doubleMargins
+ property int doubleMargins: anchors.margins * 2
+ SystemPalette { id: palette; colorGroup: SystemPalette.Active }
+ RowLayout {
+ Layout.alignment: Qt.AlignRight
+ spacing: 8
+ Image {
+ source: "qrc:/qt-project.org/imports/QtWebEngine/ControlsDelegates/information.png"
+ }
+ Label {
+ id: message
+ Layout.fillWidth: true
+ color: palette.windowText
+ textFormat: Text.PlainText
+ }
+ }
+ Item {
+ Layout.fillHeight: true
+ }
+ Button {
+ Layout.alignment: Qt.AlignHCenter
+ text: qsTr("OK")
+ onClicked: acceptDialog()
+ }
+ }
+}
diff --git a/src/webenginequick/ui/AuthenticationDialog.qml b/src/webenginequick/ui/AuthenticationDialog.qml
new file mode 100644
index 000000000..d0611b84f
--- /dev/null
+++ b/src/webenginequick/ui/AuthenticationDialog.qml
@@ -0,0 +1,101 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+Dialog {
+ property alias text: message.text
+ property bool handled: false
+ signal accepted(string user, string password)
+ signal rejected()
+ title: qsTr("Authentication Required")
+ modal: false
+ anchors.centerIn: parent
+ objectName: "authenticationDialog"
+
+ //handle the case where users simply closes the dialog
+ onVisibleChanged: {
+ if (visible == false && handled == false) {
+ handled = true;
+ rejected();
+ } else {
+ handled = false;
+ }
+ }
+
+ function acceptDialog() {
+ accepted(userField.text, passwordField.text);
+ handled = true;
+ close();
+ }
+
+ function rejectDialog() {
+ rejected();
+ handled = true;
+ close();
+ }
+
+ ColumnLayout {
+ id: rootLayout
+ anchors.fill: parent
+ anchors.margins: 4
+ property int minimumWidth: rootLayout.implicitWidth + rootLayout.doubleMargins
+ property int minimumHeight: rootLayout.implicitHeight + rootLayout.doubleMargins
+
+ property int doubleMargins: anchors.margins * 2
+
+ SystemPalette { id: palette; colorGroup: SystemPalette.Active }
+ Label {
+ id: message
+ color: palette.windowText
+ textFormat: Text.PlainText
+ }
+ GridLayout {
+ columns: 2
+ Label {
+ text: qsTr("Username:")
+ color: palette.windowText
+ }
+ TextField {
+ id: userField
+ focus: true
+ Layout.fillWidth: true
+ onAccepted: {
+ if (userField.text && passwordField.text)
+ acceptDialog();
+ }
+ }
+ Label {
+ text: qsTr("Password:")
+ color: palette.windowText
+ }
+ TextField {
+ id: passwordField
+ Layout.fillWidth: true
+ echoMode: TextInput.Password
+ onAccepted: {
+ if (userField.text && passwordField.text)
+ acceptDialog();
+ }
+ }
+ }
+ Item {
+ Layout.fillHeight: true
+ }
+ RowLayout {
+ Layout.alignment: Qt.AlignRight
+ spacing: 8
+ Button {
+ id: cancelButton
+ text: qsTr("Cancel")
+ onClicked: rejectDialog()
+ }
+ Button {
+ text: qsTr("Log In")
+ onClicked: acceptDialog()
+ }
+ }
+ }
+}
diff --git a/src/webenginequick/ui/AutofillPopup.qml b/src/webenginequick/ui/AutofillPopup.qml
new file mode 100644
index 000000000..0a14b6233
--- /dev/null
+++ b/src/webenginequick/ui/AutofillPopup.qml
@@ -0,0 +1,41 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+
+Popup {
+ id: root
+ // Let Chromium close the popup.
+ closePolicy: Popup.NoAutoClose
+
+ property variant controller: null
+ property int itemHeight: 0
+
+ signal selected(int index)
+ signal accepted()
+
+ function setCurrentIndex(index)
+ {
+ listView.currentIndex = index;
+ }
+
+ ListView {
+ id: listView
+ anchors.fill: parent
+ clip: true
+
+ model: controller.model
+ currentIndex: -1
+
+ delegate: ItemDelegate {
+ width: listView.width
+ height: root.itemHeight
+ text: model.display
+ highlighted: ListView.isCurrentItem
+
+ onHoveredChanged: if (hovered) selected(index);
+ onClicked: accepted();
+ }
+ }
+}
diff --git a/src/webenginequick/ui/CMakeLists.txt b/src/webenginequick/ui/CMakeLists.txt
new file mode 100644
index 000000000..ac960535e
--- /dev/null
+++ b/src/webenginequick/ui/CMakeLists.txt
@@ -0,0 +1,50 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+if (Qt6Quick_VERSION VERSION_GREATER_EQUAL "6.4.0")
+set(colorDialog "ColorDialog.qml")
+else()
+set(colorDialog "custom/ColorDialog.qml")
+endif()
+
+set(qml_files
+ "AlertDialog.qml"
+ "AuthenticationDialog.qml"
+ "AutofillPopup.qml"
+ "ConfirmDialog.qml"
+ "DirectoryPicker.qml"
+ "FilePicker.qml"
+ "Menu.qml"
+ "MenuItem.qml"
+ "MenuSeparator.qml"
+ "PromptDialog.qml"
+ "ToolTip.qml"
+ "TouchHandle.qml"
+ "TouchSelectionMenu.qml"
+ ${colorDialog}
+)
+
+set(resource_files
+ "information.png"
+ "question.png"
+)
+
+qt_internal_add_qml_module(WebEngineQuickDelegatesQml
+ URI "QtWebEngine.ControlsDelegates"
+ VERSION "${PROJECT_VERSION}"
+ QML_FILES ${qml_files}
+ PAST_MAJOR_VERSIONS 1
+ NO_SYNC_QT
+ PLUGIN_TARGET qtwebenginequickdelegatesplugin
+ DEPENDENCIES QtQuickControls2
+ NO_GENERATE_CPP_EXPORTS
+)
+
+qt_internal_add_resource(qtwebenginequickdelegatesplugin "qtwebenginequickdelegatesplugin"
+ PREFIX
+ "/qt-project.org/imports/QtWebEngine/ControlsDelegates"
+ FILES
+ ${resource_files}
+)
+
+
diff --git a/src/webenginequick/ui/ColorDialog.qml b/src/webenginequick/ui/ColorDialog.qml
new file mode 100644
index 000000000..f4d5b817b
--- /dev/null
+++ b/src/webenginequick/ui/ColorDialog.qml
@@ -0,0 +1,13 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick.Dialogs
+
+ColorDialog {
+ id: colorDialog
+ objectName: "colorDialog"
+
+ signal selectedColor(var color)
+
+ onAccepted : selectedColor(selectedColor)
+}
diff --git a/src/webenginequick/ui/ConfirmDialog.qml b/src/webenginequick/ui/ConfirmDialog.qml
new file mode 100644
index 000000000..cfffe7c4d
--- /dev/null
+++ b/src/webenginequick/ui/ConfirmDialog.qml
@@ -0,0 +1,77 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+Dialog {
+ property alias text: message.text
+ property bool handled: false
+ signal accepted()
+ signal rejected()
+ title: qsTr("Confirm Dialog")
+ modal: false
+ anchors.centerIn: parent
+ objectName: "confirmDialog"
+
+ //handle the case where users simply closes the dialog
+ onVisibleChanged: {
+ if (visible == false && handled == false) {
+ handled = true;
+ rejected();
+ } else {
+ handled = false;
+ }
+ }
+
+ function acceptDialog() {
+ accepted();
+ handled = true;
+ close();
+ }
+
+ function rejectDialog() {
+ rejected();
+ handled = true;
+ close();
+ }
+
+ ColumnLayout {
+ id: rootLayout
+ anchors.fill: parent
+ anchors.margins: 4
+ property int minimumWidth: rootLayout.implicitWidth + rootLayout.doubleMargins
+ property int minimumHeight: rootLayout.implicitHeight + rootLayout.doubleMargins
+ property int doubleMargins: anchors.margins * 2
+ SystemPalette { id: palette; colorGroup: SystemPalette.Active }
+ RowLayout {
+ Layout.alignment: Qt.AlignRight
+ spacing: 8
+ Image {
+ source: "qrc:/qt-project.org/imports/QtWebEngine/ControlsDelegates/question.png"
+ }
+ Text {
+ id: message
+ Layout.fillWidth: true
+ color: palette.windowText
+ textFormat: Text.PlainText
+ }
+ }
+ Item {
+ Layout.fillHeight: true
+ }
+ RowLayout {
+ Layout.alignment: Qt.AlignRight
+ spacing: 8
+ Button {
+ text: qsTr("OK")
+ onClicked: acceptDialog()
+ }
+ Button {
+ text: qsTr("Cancel")
+ onClicked: rejectDialog()
+ }
+ }
+ }
+}
diff --git a/src/webenginequick/ui/DirectoryPicker.qml b/src/webenginequick/ui/DirectoryPicker.qml
new file mode 100644
index 000000000..a8a6d47c9
--- /dev/null
+++ b/src/webenginequick/ui/DirectoryPicker.qml
@@ -0,0 +1,15 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick.Dialogs
+
+FolderDialog {
+ id: folderDialog
+ objectName: "folderDialog"
+
+ signal folderSelected(var folder)
+
+ onAccepted: {
+ folderSelected([selectedFolder])
+ }
+}
diff --git a/src/webenginequick/ui/FilePicker.qml b/src/webenginequick/ui/FilePicker.qml
new file mode 100644
index 000000000..d82c3bf35
--- /dev/null
+++ b/src/webenginequick/ui/FilePicker.qml
@@ -0,0 +1,15 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick.Dialogs
+
+FileDialog {
+ id: fileDialog
+ objectName: "fileDialog"
+
+ signal filesSelected(var fileList)
+
+ onAccepted: {
+ filesSelected(selectedFiles)
+ }
+}
diff --git a/src/webenginequick/ui/Menu.qml b/src/webenginequick/ui/Menu.qml
new file mode 100644
index 000000000..bfa037d1c
--- /dev/null
+++ b/src/webenginequick/ui/Menu.qml
@@ -0,0 +1,22 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls as C
+
+C.Menu {
+ id: menu
+ signal done()
+ objectName: "menu"
+
+ // Use private API for now
+ onAboutToHide: doneTimer.start()
+
+ // WORKAROUND On Mac the Menu may be destroyed before the MenuItem
+ // is actually triggered (see qtbase commit 08cc9b9991ae9ab51)
+ Timer {
+ id: doneTimer
+ interval: 100
+ onTriggered: menu.done()
+ }
+}
diff --git a/src/webenginequick/ui/MenuItem.qml b/src/webenginequick/ui/MenuItem.qml
new file mode 100644
index 000000000..8fefcdc69
--- /dev/null
+++ b/src/webenginequick/ui/MenuItem.qml
@@ -0,0 +1,7 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls as C
+
+C.MenuItem { }
diff --git a/src/webenginequick/ui/MenuSeparator.qml b/src/webenginequick/ui/MenuSeparator.qml
new file mode 100644
index 000000000..af37f57a9
--- /dev/null
+++ b/src/webenginequick/ui/MenuSeparator.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+
+Item { id: dummy }
diff --git a/src/webenginequick/ui/PromptDialog.qml b/src/webenginequick/ui/PromptDialog.qml
new file mode 100644
index 000000000..275deace8
--- /dev/null
+++ b/src/webenginequick/ui/PromptDialog.qml
@@ -0,0 +1,79 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+Dialog {
+ property alias text: message.text
+ property alias prompt: field.text
+ property bool handled: false
+ signal input(string text)
+ signal accepted()
+ signal rejected()
+ title: qsTr("Prompt Dialog")
+ modal: false
+ anchors.centerIn: parent
+ objectName: "promptDialog"
+
+ //handle the case where users simply closes the dialog
+ onVisibleChanged: {
+ if (visible == false && handled == false) {
+ handled = true;
+ rejected();
+ } else {
+ handled = false;
+ }
+ }
+
+ function acceptDialog() {
+ input(field.text);
+ accepted();
+ handled = true;
+ close();
+ }
+
+ function rejectDialog() {
+ rejected();
+ handled = true;
+ close();
+ }
+
+ ColumnLayout {
+ id: rootLayout
+ anchors.fill: parent
+ anchors.margins: 4
+ property int minimumWidth: rootLayout.implicitWidth + rootLayout.doubleMargins
+ property int minimumHeight: rootLayout.implicitHeight + rootLayout.doubleMargins
+ property int doubleMargins: anchors.margins * 2
+ SystemPalette { id: palette; colorGroup: SystemPalette.Active }
+ Text {
+ id: message
+ Layout.fillWidth: true
+ color: palette.windowText
+ textFormat: Text.PlainText
+ }
+ TextField {
+ id:field
+ focus: true
+ Layout.fillWidth: true
+ onAccepted: acceptDialog()
+ }
+ Item {
+ Layout.fillHeight: true
+ }
+ RowLayout {
+ Layout.alignment: Qt.AlignRight
+ spacing: 8
+ Button {
+ text: qsTr("OK")
+ onClicked: acceptDialog()
+ }
+ Button {
+ text: qsTr("Cancel")
+ onClicked: rejectDialog()
+ }
+ }
+ }
+}
diff --git a/src/webenginequick/ui/ToolTip.qml b/src/webenginequick/ui/ToolTip.qml
new file mode 100644
index 000000000..525258e2f
--- /dev/null
+++ b/src/webenginequick/ui/ToolTip.qml
@@ -0,0 +1,10 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick.Controls as C
+
+C.ToolTip {
+ delay: 1000
+ timeout: 1500
+ objectName: "toolTip"
+}
diff --git a/src/webenginequick/ui/TouchHandle.qml b/src/webenginequick/ui/TouchHandle.qml
new file mode 100644
index 000000000..a879ec71b
--- /dev/null
+++ b/src/webenginequick/ui/TouchHandle.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+
+Image { }
diff --git a/src/webenginequick/ui/TouchSelectionMenu.qml b/src/webenginequick/ui/TouchSelectionMenu.qml
new file mode 100644
index 000000000..f42c256bb
--- /dev/null
+++ b/src/webenginequick/ui/TouchSelectionMenu.qml
@@ -0,0 +1,139 @@
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Layouts
+
+Rectangle {
+ id: menu
+
+ signal cutTriggered
+ signal copyTriggered
+ signal pasteTriggered
+ signal contextMenuTriggered
+
+ property bool isCutEnabled: false
+ property bool isCopyEnabled: false
+ property bool isPasteEnabled: false
+
+ property color borderColor: "darkGray"
+ property color bgColor: "white"
+
+ radius: 4
+ border.color: borderColor
+ color: borderColor
+ antialiasing: true
+
+ RowLayout {
+ anchors.fill: parent
+ spacing: parent.border.width
+ anchors.margins: parent.border.width
+
+ Rectangle {
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ radius: menu.radius
+ color: bgColor
+ visible: isCutEnabled
+
+ Text {
+ id: cutText
+ anchors.centerIn: parent
+ text: "Cut"
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: {
+ parent.color = borderColor;
+ cutText.color = "white";
+ }
+ onReleased: {
+ parent.color = bgColor;
+ cutText.color = "black";
+ cutTriggered();
+ }
+ }
+ }
+
+ Rectangle {
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ radius: menu.radius
+ color: bgColor
+ visible: isCopyEnabled
+
+ Text {
+ id: copyText
+ anchors.centerIn: parent
+ text: "Copy"
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: {
+ parent.color = borderColor;
+ copyText.color = "white";
+ }
+ onReleased: {
+ parent.color = bgColor;
+ copyText.color = "black";
+ copyTriggered();
+ }
+ }
+ }
+
+ Rectangle {
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ radius: menu.radius
+ color: bgColor
+ visible: isPasteEnabled
+
+ Text {
+ id: pasteText
+ anchors.centerIn: parent
+ text: "Paste"
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: {
+ parent.color = borderColor;
+ pasteText.color = "white";
+ }
+ onReleased: {
+ parent.color = bgColor;
+ pasteText.color = "black";
+ pasteTriggered();
+ }
+ }
+ }
+
+ Rectangle {
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ radius: menu.radius
+ color: bgColor
+
+ Text {
+ id: contextMenuText
+ anchors.centerIn: parent
+ text: "..."
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: {
+ parent.color = borderColor;
+ contextMenuText.color = "white";
+ }
+ onReleased: {
+ parent.color = bgColor;
+ contextMenuText.color = "black";
+ contextMenuTriggered();
+ }
+ }
+ }
+ }
+}
diff --git a/src/webenginequick/ui/custom/ColorDialog.qml b/src/webenginequick/ui/custom/ColorDialog.qml
new file mode 100644
index 000000000..895c90198
--- /dev/null
+++ b/src/webenginequick/ui/custom/ColorDialog.qml
@@ -0,0 +1,285 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+Dialog {
+ id: colorDialog
+ title: qsTr("Color Picker Dialog")
+ modal: false
+ anchors.centerIn: parent
+ objectName: "colorDialog"
+
+ property bool handled: false
+ property color color
+
+ signal selectedColor(var color)
+ signal rejected()
+
+ function accept() {
+ handled = true;
+ selectedColor(colorDialog.color)
+ close();
+ }
+
+ function reject() {
+ handled = true;
+ rejected();
+ close();
+ }
+
+ // Handle the case where users simply closes or clicks out of the dialog.
+ onVisibleChanged: {
+ if (!visible && !handled) {
+ handled = true;
+ rejected();
+ } else {
+ handled = false;
+ }
+ }
+
+ function selectColorFromPalette(paletteColor) {
+ colorDialog.color = paletteColor;
+ }
+
+ function zeroPadding(text, length = 2) {
+ var textLength = text.length;
+
+ if (textLength >= length) {
+ return text;
+ }
+
+ for (var i = 0; i < length - textLength; i++) {
+ text = "0" + text;
+ }
+
+ return text;
+ }
+
+ function calculateRGBA() {
+
+ var rgbArray = [colorDialog.color.r, colorDialog.color.g, colorDialog.color.b]
+ if (colorDialog.color.a != 1) {
+ rgbArray.push(colorDialog.color.a);
+ }
+
+ for (var i = 0; i < rgbArray.length; i++) {
+ rgbArray[i] = Number(Math.round(rgbArray[i] * 255)).toString(16);
+ rgbArray[i] = zeroPadding(rgbArray[i]);
+ }
+
+ return "#" + rgbArray.join("");
+ }
+
+
+ function isNaNOrUndefined(value) {
+ return value == null || value == undefined || Number.isNaN(value);
+ }
+
+ function parseColorText(colorText) {
+ if (colorText[0] == '#') {
+ colorText = colorText.substring(1);
+ }
+
+ if (!(colorText.length == 6 || colorText.length == 8)) {
+ return undefined;
+ }
+
+ var rgbaValues = [parseInt("0x" + colorText.substring(0,2)),
+ parseInt("0x" + colorText.substring(2,4)),
+ parseInt("0x" + colorText.substring(4,6)),
+ parseInt("0x" + (colorText.length > 6 ? colorText.substring(6,8) : "FF"))]
+
+ for (var i = 0; i < rgbaValues.length; i++) {
+ if (isNaNOrUndefined(rgbaValues[i])) {
+ return undefined;
+ }
+ rgbaValues[i] = rgbaValues[i] / 255;
+ }
+
+ return Qt.rgba(rgbaValues[0], rgbaValues[1], rgbaValues[2], rgbaValues[3]);
+ }
+
+ ListModel {
+ id: colorList
+ ListElement { rectangleColor: "red" }
+ ListElement { rectangleColor: "orangered" }
+ ListElement { rectangleColor: "orange" }
+ ListElement { rectangleColor: "gold" }
+ ListElement { rectangleColor: "yellow" }
+ ListElement { rectangleColor: "yellowgreen" }
+ ListElement { rectangleColor: "green" }
+ ListElement { rectangleColor: "lightskyblue" }
+ ListElement { rectangleColor: "blue" }
+ ListElement { rectangleColor: "blueviolet" }
+ ListElement { rectangleColor: "violet" }
+ ListElement { rectangleColor: "mediumvioletred" }
+ ListElement { rectangleColor: "black" }
+ ListElement { rectangleColor: "white" }
+ }
+
+ contentItem: GridLayout {
+ id: grid
+ columns: 7
+ rows: 5
+
+ Repeater {
+ model: colorList
+ delegate: Rectangle {
+ width: 50
+ height: 50
+ color: rectangleColor
+ border.color: "black"
+ border.width: 1
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: selectColorFromPalette(parent.color)
+ }
+ }
+ }
+ ColumnLayout {
+ id: colorTools
+ Layout.columnSpan: 4
+ Layout.rowSpan: 2
+ Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
+
+ Rectangle {
+ height: 100
+ width: 200
+ border.color: "black"
+ border.width: 1
+
+ Binding on color {
+ when: colorDialog.color
+ value: colorDialog.color
+ }
+ }
+ TextField {
+ id: colorTextField
+ width: 100
+ selectByMouse: true
+ Layout.alignment: Qt.AlignHCenter
+
+ Binding on text {
+ when: colorDialog.color
+ value: calculateRGBA()
+ delayed: true
+ }
+
+ onTextEdited: {
+ var parsedColor = parseColorText(colorTextField.text);
+ if (parsedColor != undefined) {
+ colorDialog.color = parsedColor;
+ }
+ }
+
+ MouseArea {
+ id: colorTextFieldMouseArea
+ anchors.fill: parent
+ acceptedButtons: Qt.RightButton
+ onClicked: colorTextFieldContextMenu.open()
+ }
+
+ Menu {
+ id: colorTextFieldContextMenu
+ x: colorTextFieldMouseArea.mouseX
+ y: colorTextFieldMouseArea.mouseY
+ MenuItem {
+ text: qsTr("Copy color")
+ onTriggered: {
+ colorTextField.selectAll();
+ colorTextField.copy();
+ colorTextField.deselect();
+ }
+ }
+ MenuSeparator {}
+ MenuItem {
+ text: qsTr("Paste")
+ onTriggered: {
+ colorTextField.selectAll();
+ colorTextField.paste();
+ }
+ enabled: colorTextField.canPaste
+ }
+ }
+ }
+ }
+ ListModel {
+ id: sliderBoxElements
+ ListElement { labelText: "Red value"; colorChannel: 0 }
+ ListElement { labelText: "Green value"; colorChannel: 1 }
+ ListElement { labelText: "Blue value"; colorChannel: 2 }
+ ListElement { labelText: "Alpha value"; colorChannel: 3 }
+ }
+ ColumnLayout {
+ id: sliderBox
+ Layout.columnSpan: 3
+ Layout.rowSpan: 2
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+
+ Repeater {
+ model: sliderBoxElements
+ delegate: ColumnLayout {
+ Label {
+ text: labelText
+ }
+ Slider {
+ id: colorSlider
+ property int channel: colorChannel
+ from: 0
+ to: 255
+ stepSize: 1
+ value: {
+ if (colorSlider.channel == 0)
+ return colorDialog.color.r * 255;
+ else if (colorSlider.channel == 1)
+ return colorDialog.color.g * 255;
+ else if (colorSlider.channel == 2)
+ return colorDialog.color.b * 255;
+ else if (colorSlider.channel == 3)
+ return colorDialog.color.a * 255;
+ }
+
+ Connections {
+ function onMoved() {
+ var redChannelValue = colorDialog.color.r;
+ var greenChannelValue = colorDialog.color.g;
+ var blueChannelValue = colorDialog.color.b;
+ var alphaChannelValue = colorDialog.color.a;
+
+ if (colorSlider.channel == 0)
+ redChannelValue = colorSlider.value / 255;
+ else if (colorSlider.channel == 1)
+ greenChannelValue = colorSlider.value / 255;
+ else if (colorSlider.channel == 2)
+ blueChannelValue = colorSlider.value / 255;
+ else if (colorSlider.channel == 3)
+ alphaChannelValue = colorSlider.value / 255;
+
+ colorDialog.color = Qt.rgba(redChannelValue, greenChannelValue, blueChannelValue, alphaChannelValue);
+ }
+ }
+ }
+ }
+ }
+ }
+ DialogButtonBox {
+ id: dialogButtonBox
+ Layout.columnSpan: 7
+ Layout.alignment: Qt.AlignRight
+
+ Button {
+ text: qsTr("Apply")
+ onClicked: accept()
+ }
+ Button {
+ text: qsTr("Cancel")
+ onClicked: reject()
+ }
+ }
+ }
+}
diff --git a/src/webenginequick/ui/information.png b/src/webenginequick/ui/information.png
new file mode 100644
index 000000000..0a2eb87d1
--- /dev/null
+++ b/src/webenginequick/ui/information.png
Binary files differ
diff --git a/src/webenginequick/ui/question.png b/src/webenginequick/ui/question.png
new file mode 100644
index 000000000..2dd92fd79
--- /dev/null
+++ b/src/webenginequick/ui/question.png
Binary files differ