diff options
Diffstat (limited to 'src/webengine/ui')
-rw-r--r-- | src/webengine/ui/AuthenticationDialog.qml | 16 | ||||
-rw-r--r-- | src/webengine/ui/ColorDialog.qml | 2 | ||||
-rw-r--r-- | src/webengine/ui/FilePicker.qml | 2 | ||||
-rw-r--r-- | src/webengine/ui/Menu.qml | 2 | ||||
-rw-r--r-- | src/webengine/ui/MessageBubble.qml | 52 | ||||
-rw-r--r-- | src/webengine/ui/PromptDialog.qml | 34 | ||||
-rw-r--r-- | src/webengine/ui/ToolTip.qml | 91 | ||||
-rw-r--r-- | src/webengine/ui/qmldir | 2 | ||||
-rw-r--r-- | src/webengine/ui/ui.pro | 5 |
9 files changed, 154 insertions, 52 deletions
diff --git a/src/webengine/ui/AuthenticationDialog.qml b/src/webengine/ui/AuthenticationDialog.qml index 6a703b7df..a7eedd14d 100644 --- a/src/webengine/ui/AuthenticationDialog.qml +++ b/src/webengine/ui/AuthenticationDialog.qml @@ -44,8 +44,8 @@ import QtQuick.Layouts 1.0 import QtQuick.Window 2.2 Window { - signal accepted(string user, string password); - signal rejected; + signal accepted(string user, string password) + signal rejected property alias text: message.text title: qsTr("Authentication Required") @@ -75,7 +75,7 @@ Window { anchors.margins: 4 property int doubleMargins: anchors.margins * 2 Text { - id: message; + id: message color: palette.windowText } GridLayout { @@ -88,7 +88,10 @@ Window { id: userField focus: true Layout.fillWidth: true - onAccepted: acceptDialog() + onAccepted: { + if (userField.text && passwordField.text) + acceptDialog(); + } } Label { text: qsTr("Password:") @@ -98,7 +101,10 @@ Window { id: passwordField Layout.fillWidth: true echoMode: TextInput.Password - onAccepted: acceptDialog() + onAccepted: { + if (userField.text && passwordField.text) + acceptDialog(); + } } } Item { diff --git a/src/webengine/ui/ColorDialog.qml b/src/webengine/ui/ColorDialog.qml index 04af954b9..b74fd2cd7 100644 --- a/src/webengine/ui/ColorDialog.qml +++ b/src/webengine/ui/ColorDialog.qml @@ -45,6 +45,6 @@ ColorDialog { signal selectedColor(var color) onAccepted: { - selectedColor(colorDialog.currentColor) + selectedColor(colorDialog.currentColor); } } diff --git a/src/webengine/ui/FilePicker.qml b/src/webengine/ui/FilePicker.qml index 07c8a3638..e6af977ba 100644 --- a/src/webengine/ui/FilePicker.qml +++ b/src/webengine/ui/FilePicker.qml @@ -41,7 +41,7 @@ import QtQuick.Dialogs 1.1 FileDialog { - signal filesSelected(var fileList); + signal filesSelected(var fileList) onAccepted: { filesSelected(fileUrls); diff --git a/src/webengine/ui/Menu.qml b/src/webengine/ui/Menu.qml index 8e07b771c..36efa7680 100644 --- a/src/webengine/ui/Menu.qml +++ b/src/webengine/ui/Menu.qml @@ -45,7 +45,7 @@ Controls.Menu { signal done() // Use private API for now - onAboutToHide: doneTimer.start(); + onAboutToHide: doneTimer.start() // WORKAROUND On Mac the Menu may be destroyed before the MenuItem // is actually triggered (see qtbase commit 08cc9b9991ae9ab51) diff --git a/src/webengine/ui/MessageBubble.qml b/src/webengine/ui/MessageBubble.qml index c43e46474..056aac1fe 100644 --- a/src/webengine/ui/MessageBubble.qml +++ b/src/webengine/ui/MessageBubble.qml @@ -46,8 +46,8 @@ Item { height: 1 property int maxWidth: 0 - property string mainText: ""; - property string subText: ""; + property string mainText: "" + property string subText: "" property int border: 1 @@ -111,40 +111,40 @@ Item { property int messageBoxBottom: height - border onPaint: { - var ctx = getContext("2d") + var ctx = getContext("2d"); - ctx.lineWidth = bubble.border - ctx.strokeStyle = "#555" - ctx.fillStyle = "#ffffe1" + ctx.lineWidth = bubble.border; + ctx.strokeStyle = "#555"; + ctx.fillStyle = "#ffffe1"; - ctx.beginPath() + ctx.beginPath(); - ctx.moveTo(messageBoxLeft + cornerRadius, messageBoxTop) + ctx.moveTo(messageBoxLeft + cornerRadius, messageBoxTop); // Arrow - ctx.lineTo(messageBoxLeft + bubble.arrowOffset, messageBoxTop) - ctx.lineTo(messageBoxLeft + bubble.arrowOffset, messageBoxTop - bubble.arrowHeight) - ctx.lineTo(messageBoxLeft + bubble.arrowOffset + bubble.arrowWidth, messageBoxTop) + ctx.lineTo(messageBoxLeft + bubble.arrowOffset, messageBoxTop); + ctx.lineTo(messageBoxLeft + bubble.arrowOffset, messageBoxTop - bubble.arrowHeight); + ctx.lineTo(messageBoxLeft + bubble.arrowOffset + bubble.arrowWidth, messageBoxTop); // Message Box - ctx.lineTo(messageBoxRight - cornerRadius, messageBoxTop) - ctx.quadraticCurveTo(messageBoxRight, messageBoxTop, messageBoxRight, messageBoxTop + cornerRadius) - ctx.lineTo(messageBoxRight, messageBoxBottom - cornerRadius) - ctx.quadraticCurveTo(messageBoxRight, messageBoxBottom, messageBoxRight - cornerRadius, messageBoxBottom) - ctx.lineTo(messageBoxLeft + cornerRadius, messageBoxBottom) - ctx.quadraticCurveTo(messageBoxLeft, messageBoxBottom, messageBoxLeft, messageBoxBottom - cornerRadius) - ctx.lineTo(messageBoxLeft, messageBoxTop + cornerRadius) - ctx.quadraticCurveTo(messageBoxLeft, messageBoxTop, messageBoxLeft + cornerRadius, messageBoxTop) - - ctx.closePath() - - ctx.fill() - ctx.stroke() + ctx.lineTo(messageBoxRight - cornerRadius, messageBoxTop); + ctx.quadraticCurveTo(messageBoxRight, messageBoxTop, messageBoxRight, messageBoxTop + cornerRadius); + ctx.lineTo(messageBoxRight, messageBoxBottom - cornerRadius); + ctx.quadraticCurveTo(messageBoxRight, messageBoxBottom, messageBoxRight - cornerRadius, messageBoxBottom); + ctx.lineTo(messageBoxLeft + cornerRadius, messageBoxBottom); + ctx.quadraticCurveTo(messageBoxLeft, messageBoxBottom, messageBoxLeft, messageBoxBottom - cornerRadius); + ctx.lineTo(messageBoxLeft, messageBoxTop + cornerRadius); + ctx.quadraticCurveTo(messageBoxLeft, messageBoxTop, messageBoxLeft + cornerRadius, messageBoxTop); + + ctx.closePath(); + + ctx.fill(); + ctx.stroke(); } onPainted: { - bubble.width = bubbleCanvas.width - bubble.height = bubbleCanvas.height + bubble.width = bubbleCanvas.width; + bubble.height = bubbleCanvas.height; } } } diff --git a/src/webengine/ui/PromptDialog.qml b/src/webengine/ui/PromptDialog.qml index 657bf7631..c4dcd6b98 100644 --- a/src/webengine/ui/PromptDialog.qml +++ b/src/webengine/ui/PromptDialog.qml @@ -43,45 +43,49 @@ import QtQuick.Layouts 1.0 import QtQuick 2.5 ApplicationWindow { - signal input(string text); - signal accepted; - signal rejected; - property alias text: message.text; - property alias prompt: field.text; + signal input(string text) + signal accepted + signal rejected + property alias text: message.text + property alias prompt: field.text width: 350 height: 100 flags: Qt.Dialog + onClosing: { + rejected(); + } + function open() { show(); } ColumnLayout { - anchors.fill: parent; - anchors.margins: 4; + anchors.fill: parent + anchors.margins: 4 Text { - id: message; - Layout.fillWidth: true; + id: message + Layout.fillWidth: true } TextField { - id:field; - Layout.fillWidth: true; + id:field + Layout.fillWidth: true } RowLayout { Layout.alignment: Qt.AlignRight - spacing: 8; + spacing: 8 Button { - text: "OK" + text: qsTr("OK") onClicked: { - input(field.text) + input(field.text); accepted(); close(); destroy(); } } Button { - text: "Cancel" + text: qsTr("Cancel") onClicked: { rejected(); close(); diff --git a/src/webengine/ui/ToolTip.qml b/src/webengine/ui/ToolTip.qml new file mode 100644 index 000000000..96033e8f1 --- /dev/null +++ b/src/webengine/ui/ToolTip.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.5 + +Item { + id: toolTipContainer + z: 9999 + width: content.width + height: content.height + visible: false + + property alias text: toolTip.text + property int delayTimerInterval: 1000 + property int hideTimerInterval: 1500 + + Timer { + id: delayTimer + interval: delayTimerInterval + onTriggered: { + toolTipContainer.visible = true + hideTimer.start() + } + } + + Timer { + id: hideTimer + interval: hideTimerInterval + onTriggered: toolTipContainer.visible = false + } + + Rectangle { + id: content + color: "#f8eabf" + border.color: "black" + anchors.centerIn: parent + width: toolTip.contentWidth + 10 + height: toolTip.contentHeight + 10 + radius: 3 + + Text { + id: toolTip + anchors {fill: parent; margins: 5} + wrapMode: Text.WrapAnywhere + } + } + + function open() { + delayTimer.start(); + } + + function hide() { + hideTimer.start(); + } +} diff --git a/src/webengine/ui/qmldir b/src/webengine/ui/qmldir index 69ebe1bad..e23b972be 100644 --- a/src/webengine/ui/qmldir +++ b/src/webengine/ui/qmldir @@ -1,4 +1,4 @@ -module QtWebEngine.UIDelegates +module QtWebEngine.Controls1Delegates AlertDialog 1.0 AlertDialog.qml ConfirmDialog 1.0 ConfirmDialog.qml FilePicker 1.0 FilePicker.qml diff --git a/src/webengine/ui/ui.pro b/src/webengine/ui/ui.pro index 249d7dcfd..bce03cc0c 100644 --- a/src/webengine/ui/ui.pro +++ b/src/webengine/ui/ui.pro @@ -1,4 +1,4 @@ -TARGETPATH = QtWebEngine/UIDelegates +TARGETPATH = QtWebEngine/Controls1Delegates QML_FILES += \ # Authentication Dialog @@ -14,6 +14,7 @@ QML_FILES += \ MenuItem.qml \ MenuSeparator.qml \ # Message Bubble - MessageBubble.qml + MessageBubble.qml \ + ToolTip.qml load(qml_module) |