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 /src | |
parent | b1f54536ba882c75251a3f8f5844b4338fbb4fc8 (diff) | |
download | qt-creator-6f774ff10e9f2348824e41ab0ff419d9f1254a40.tar.gz |
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 'src')
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.cpp | 15 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.h | 6 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.cpp b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.cpp index b3207f0006..71d4c1b6d4 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 <coreplugin/icore.h> + +#include <QColorDialog> #include <QHash> #include <QByteArray> #include <QDebug> @@ -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 3ed2cc8a31..f487859d07 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(); |