diff options
author | Thomas Hartmann <thomas.hartmann@qt.io> | 2019-08-30 16:03:53 +0200 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2019-08-30 15:01:20 +0000 |
commit | 6f774ff10e9f2348824e41ab0ff419d9f1254a40 (patch) | |
tree | 32985fea00e47544fa160e571d2bb7a5c8fac843 /share/qtcreator | |
parent | b1f54536ba882c75251a3f8f5844b4338fbb4fc8 (diff) |
QmlDesigner: Open color dialog from property editor
Task-number: QDS-601
Change-Id: I8ab2b286213174c19b330b1db4c27efd7af8792c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'share/qtcreator')
4 files changed, 77 insertions, 11 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorButton.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorButton.qml index f960e5ea23..cb896024e9 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorButton.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorButton.qml @@ -43,6 +43,7 @@ Item { property bool block: false signal clicked + signal rightMouseButtonClicked onAlphaChanged: invalidateColor(); onSaturationChanged: invalidateColor(); @@ -202,7 +203,7 @@ Item { id: mapMouseArea anchors.fill: parent onPositionChanged: { - if (pressed) { + if (pressed && mouse.button === Qt.LeftButton) { var xx = Math.max(0, Math.min(mouse.x, parent.width)) var yy = Math.max(0, Math.min(mouse.y, parent.height)) @@ -210,8 +211,21 @@ Item { colorButton.saturation = xx / parent.width; } } - onPressed: positionChanged(mouse) - onReleased: colorButton.clicked() + onPressed: { + if (mouse.button === Qt.LeftButton) + positionChanged(mouse) + } + onReleased: { + if (mouse.button === Qt.LeftButton) + colorButton.clicked() + } + + acceptedButtons: Qt.LeftButton | Qt.RightButton + + onClicked: { + if (mouse.button === Qt.RightButton) + colorButton.rightMouseButtonClicked() + } } Rectangle { anchors.fill: parent diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorCheckButton.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorCheckButton.qml index 5f094dc00d..9751c7c777 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorCheckButton.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorCheckButton.qml @@ -26,12 +26,13 @@ import QtQuick 2.1 Item { - id: colorCheckButtonRoot + id: root property bool checked: false property alias buttonColor: checkBox.color width: 30 height: 24 + signal rightMouseButtonClicked Rectangle { id: backgroundBox @@ -63,13 +64,20 @@ Item { anchors.right: backgroundBox.left anchors.rightMargin: 2 opacity: colorToolTip.containsMouse ? 1 : 0.8 - rotation: colorCheckButtonRoot.checked ? 0.0 : 270.0 + rotation: root.checked ? 0.0 : 270.0 } ToolTipArea { id: colorToolTip - onClicked: checked = !checked + acceptedButtons: Qt.LeftButton | Qt.RightButton + + onClicked: { + if (mouse.button === Qt.RightButton) + root.rightMouseButtonClicked() + else + root.checked = !root.checked + } hoverEnabled: true anchors.fill: parent anchors.leftMargin: -arrowImage.width diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml index 15246a4405..ade6b3e526 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml @@ -26,6 +26,8 @@ import QtQuick 2.1 import QtQuick.Layouts 1.0 import QtQuickDesignerTheme 1.0 +import QtQuick.Dialogs 1.3 +import StudioControls 1.0 as StudioControls Column { id: colorEditor @@ -198,6 +200,12 @@ Column { ColorCheckButton { id: checkButton buttonColor: colorEditor.color + + onCheckedChanged: { + if (contextMenu.opened) + contextMenu.close() + } + onRightMouseButtonClicked: contextMenu.popup(checkButton) } LineEdit { @@ -615,7 +623,13 @@ Column { sliderMargins: 4 - onClicked: colorEditor.color = colorButton.color + onClicked: { + colorEditor.color = colorButton.color + if (contextMenu.opened) + contextMenu.close() + } + + onRightMouseButtonClicked: contextMenu.popup(colorButton) } Item { @@ -702,13 +716,23 @@ Column { clickable: !colorEditor.transparent - onSelectedColorChanged: { - colorEditor.color = colorPalette.selectedColor; - } + onSelectedColorChanged: colorEditor.color = colorPalette.selectedColor + + + onDialogColorChanged: colorEditor.color = colorPalette.selectedColor } } } } } + + StudioControls.Menu { + id: contextMenu + + StudioControls.MenuItem { + text: qsTr("Open Color Dialog") + onTriggered: colorPalette.showColorDialog(colorEditor.color) + } + } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/SimpleColorPalette.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/SimpleColorPalette.qml index 9cc787bd23..d69fc08e4b 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/SimpleColorPalette.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/SimpleColorPalette.qml @@ -32,7 +32,12 @@ import QtQuick.Controls.Private 1.0 // showing a ToolTip Item { property color selectedColor property bool clickable : true + property color oldColor + function showColorDialog(color) { + oldColor = color + paletteModel.showDialog(color) + } width: 200 height: 40 @@ -43,6 +48,8 @@ Item { paletteModel.addItem(colorCode) } + signal dialogColorChanged + Component { id: colorItemDelegate @@ -94,7 +101,20 @@ Item { } } - SimpleColorPaletteModel { id: paletteModel } + SimpleColorPaletteModel { + + id: paletteModel + + onCurrentColorChanged: { + selectedColor = color + dialogColorChanged() + + } + onColorDialogRejected: { + selectedColor = oldColor + dialogColorChanged() + } + } ListView { id: colorPaletteView model: paletteModel |