From 6f774ff10e9f2348824e41ab0ff419d9f1254a40 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 30 Aug 2019 16:03:53 +0200 Subject: QmlDesigner: Open color dialog from property editor Task-number: QDS-601 Change-Id: I8ab2b286213174c19b330b1db4c27efd7af8792c Reviewed-by: Tim Jenssen --- .../components/propertyeditor/simplecolorpalettemodel.cpp | 15 +++++++++++++++ .../components/propertyeditor/simplecolorpalettemodel.h | 6 ++++++ 2 files changed, 21 insertions(+) (limited to 'src') diff --git a/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.cpp b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.cpp index b3207f0006d..71d4c1b6d45 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.cpp @@ -29,6 +29,9 @@ #include "designersettings.h" +#include + +#include #include #include #include @@ -143,4 +146,16 @@ void SimpleColorPaletteModel::write() SimpleColorPaletteSingleton::getInstance().writePalette(); } +void SimpleColorPaletteModel::showDialog(QColor color) +{ + auto colorDialog = new QColorDialog(Core::ICore::dialogParent()); + colorDialog->setCurrentColor(color); + colorDialog->setAttribute(Qt::WA_DeleteOnClose); + + connect(colorDialog, &QDialog::rejected, this, &SimpleColorPaletteModel::colorDialogRejected); + connect(colorDialog, &QColorDialog::currentColorChanged, this, &SimpleColorPaletteModel::currentColorChanged); + + QTimer::singleShot(0, [colorDialog](){ colorDialog->exec(); }); +} + } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.h b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.h index 3ed2cc8a31d..f487859d073 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.h +++ b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.h @@ -59,6 +59,12 @@ public: bool read(); void write(); + Q_INVOKABLE void showDialog(QColor color); + +signals: + void colorDialogRejected(); + void currentColorChanged(const QColor &color); + private slots: void setPalette(); -- cgit v1.2.3