summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcon <qtc-committer@nokia.com>2010-07-01 11:41:36 +0200
committercon <qtc-committer@nokia.com>2010-07-01 11:41:36 +0200
commit926549428966432ffbfcaa98964430bb70b36365 (patch)
tree6e12786e5bdc9dd50a5add38de7124372d016cd6
parent6dc4a039f2cb50a02a0e15265548547b94a6dc9d (diff)
parent9ab9f9d35ffa0362643e615dd01c54d4e9ff5ca7 (diff)
downloadqt-creator-926549428966432ffbfcaa98964430bb70b36365.tar.gz
Merge remote branch 'origin/2.0'
Conflicts: src/libs/qmljs/qmljs-lib.pri src/plugins/debugger/gdb/gdbengine.cpp src/plugins/debugger/gdb/gdbengine.h src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp
-rw-r--r--src/libs/qmljs/qmljs-lib.pri2
-rw-r--r--src/libs/qmljs/qmljspropertyreader.cpp218
-rw-r--r--src/libs/qmljs/qmljspropertyreader.h71
-rw-r--r--src/libs/utils/reloadpromptutils.cpp20
-rw-r--r--src/libs/utils/reloadpromptutils.h2
-rw-r--r--src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp6
-rw-r--r--src/plugins/qmldesigner/components/itemlibrary/itemlibrary.h1
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/colorwidget.cpp110
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/colorwidget.h66
9 files changed, 478 insertions, 18 deletions
diff --git a/src/libs/qmljs/qmljs-lib.pri b/src/libs/qmljs/qmljs-lib.pri
index 5a030a0d6f..f04185efe4 100644
--- a/src/libs/qmljs/qmljs-lib.pri
+++ b/src/libs/qmljs/qmljs-lib.pri
@@ -24,6 +24,7 @@ HEADERS += \
$$PWD/qmljscompletioncontextfinder.h \
$$PWD/qmljscomponentversion.h \
$$PWD/qmljsmodelmanagerinterface.h \
+ $$PWD/qmljspropertyreader.h \
$$PWD/qmljsrewriter.h
SOURCES += \
@@ -39,6 +40,7 @@ SOURCES += \
$$PWD/qmljscompletioncontextfinder.cpp \
$$PWD/qmljscomponentversion.cpp \
$$PWD/qmljsmodelmanagerinterface.cpp \
+ $$PWD/qmljspropertyreader.cpp \
$$PWD/qmljsrewriter.cpp
OTHER_FILES += \
diff --git a/src/libs/qmljs/qmljspropertyreader.cpp b/src/libs/qmljs/qmljspropertyreader.cpp
new file mode 100644
index 0000000000..181508d666
--- /dev/null
+++ b/src/libs/qmljs/qmljspropertyreader.cpp
@@ -0,0 +1,218 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#include "qmljspropertyreader.h"
+#include "qmljsdocument.h"
+#include <qmljs/parser/qmljsast_p.h>
+
+namespace QmlJS {
+
+using namespace AST;
+
+namespace {
+
+static inline QString deEscape(const QString &value)
+{
+ QString result = value;
+
+ result.replace(QLatin1String("\\\\"), QLatin1String("\\"));
+ result.replace(QLatin1String("\\\""), QLatin1String("\""));
+ result.replace(QLatin1String("\\\t"), QLatin1String("\t"));
+ result.replace(QLatin1String("\\\r"), QLatin1String("\r"));
+ result.replace(QLatin1String("\\\n"), QLatin1String("\n"));
+
+ return result;
+}
+
+static inline QString stripQuotes(const QString &str)
+{
+ if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"')))
+ || (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\''))))
+ return str.mid(1, str.length() - 2);
+
+ return str;
+}
+
+static bool isLiteralValue(ExpressionNode *expr)
+{
+ if (cast<NumericLiteral*>(expr))
+ return true;
+ else if (cast<StringLiteral*>(expr))
+ return true;
+ else if (UnaryPlusExpression *plusExpr = cast<UnaryPlusExpression*>(expr))
+ return isLiteralValue(plusExpr->expression);
+ else if (UnaryMinusExpression *minusExpr = cast<UnaryMinusExpression*>(expr))
+ return isLiteralValue(minusExpr->expression);
+ else if (cast<TrueLiteral*>(expr))
+ return true;
+ else if (cast<FalseLiteral*>(expr))
+ return true;
+ else
+ return false;
+}
+
+static inline bool isLiteralValue(UiScriptBinding *script)
+{
+ if (!script || !script->statement)
+ return false;
+
+ ExpressionStatement *exprStmt = cast<ExpressionStatement *>(script->statement);
+ if (exprStmt)
+ return isLiteralValue(exprStmt->expression);
+ else
+ return false;
+}
+
+static inline QString textAt(const Document* doc,
+ const SourceLocation &from,
+ const SourceLocation &to)
+{
+ return doc->source().mid(from.offset, to.end() - from.begin());
+}
+
+static inline int propertyType(const QString &typeName)
+{
+ if (typeName == QLatin1String("bool"))
+ return QMetaType::type("bool");
+ else if (typeName == QLatin1String("color"))
+ return QMetaType::type("QColor");
+ else if (typeName == QLatin1String("date"))
+ return QMetaType::type("QDate");
+ else if (typeName == QLatin1String("int"))
+ return QMetaType::type("int");
+ else if (typeName == QLatin1String("real"))
+ return QMetaType::type("double");
+ else if (typeName == QLatin1String("double"))
+ return QMetaType::type("double");
+ else if (typeName == QLatin1String("string"))
+ return QMetaType::type("QString");
+ else if (typeName == QLatin1String("url"))
+ return QMetaType::type("QUrl");
+ else if (typeName == QLatin1String("variant"))
+ return QMetaType::type("QVariant");
+ else
+ return -1;
+}
+
+static inline QString flatten(UiQualifiedId *qualifiedId)
+{
+ QString result;
+
+ for (UiQualifiedId *iter = qualifiedId; iter; iter = iter->next) {
+ if (!iter->name)
+ continue;
+
+ if (!result.isEmpty())
+ result.append(QLatin1Char('.'));
+
+ result.append(iter->name->asString());
+ }
+ return result;
+}
+
+static bool isEnum(AST::Statement *ast);
+
+bool isEnum(AST::ExpressionNode *ast)
+{
+ if (!ast)
+ return false;
+
+ if (FieldMemberExpression *memberExpr = cast<AST::FieldMemberExpression*>(ast))
+ return isEnum(memberExpr->base);
+ else if (cast<IdentifierExpression*>(ast))
+ return true;
+ else
+ return false;
+}
+
+bool isEnum(AST::ExpressionStatement *ast)
+{
+ if (!ast)
+ return false;
+
+ if (FieldMemberExpression *memberExpr = cast<AST::FieldMemberExpression*>(ast->expression))
+ return isEnum(memberExpr->base);
+ else if (cast<IdentifierExpression*>(ast->expression))
+ return true;
+ else
+ return false;
+}
+
+static bool isEnum(AST::Statement *ast)
+{
+ if (!ast)
+ return false;
+
+ if (ExpressionStatement *exprStmt = cast<ExpressionStatement*>(ast)) {
+ return isEnum(exprStmt->expression);
+ }
+ return false;
+}
+
+} // anonymous namespace
+
+PropertyReader::PropertyReader(Document *doc, AST::UiObjectInitializer *ast)
+{
+ for (UiObjectMemberList *members = ast->members; members; members = members->next) {
+ UiObjectMember *member = members->member;
+
+ if (UiScriptBinding *property = AST::cast<UiScriptBinding *>(member)) {
+ if (!property->qualifiedId)
+ continue; // better safe than sorry.
+ const QString propertyName = flatten(property->qualifiedId);
+ const QString astValue = textAt(doc,
+ property->statement->firstSourceLocation(),
+ property->statement->lastSourceLocation());
+ if (isLiteralValue(property)) {
+ m_properties.insert(propertyName, QVariant(deEscape(stripQuotes(astValue))));
+ } else if (isEnum(property->statement)) { //enum
+ m_properties.insert(propertyName, QVariant(astValue));
+ }
+ } else if (UiObjectDefinition *objectDefinition = cast<UiObjectDefinition *>(member)) { //font { bold: true }
+ const QString propertyName = objectDefinition->qualifiedTypeNameId->name->asString();
+ if (!propertyName.isEmpty() && !propertyName.at(0).isUpper()) {
+ for (UiObjectMemberList *iter = objectDefinition->initializer->members; iter; iter = iter->next) {
+ UiObjectMember *objectMember = iter->member;
+ if (UiScriptBinding *property = cast<UiScriptBinding *>(objectMember)) {
+ const QString propertyNamePart2 = flatten(property->qualifiedId);
+ const QString astValue = textAt(doc,
+ property->statement->firstSourceLocation(),
+ property->statement->lastSourceLocation());
+ if (isLiteralValue(property)) {
+ m_properties.insert(propertyName + '.' + propertyNamePart2, QVariant(deEscape(stripQuotes(astValue))));
+ } else if (isEnum(property->statement)) { //enum
+ m_properties.insert(propertyName + '.' + propertyNamePart2, QVariant(astValue));
+ }
+ }
+ }
+ }
+ }
+ }
+}
+} //QmlJS
diff --git a/src/libs/qmljs/qmljspropertyreader.h b/src/libs/qmljs/qmljspropertyreader.h
new file mode 100644
index 0000000000..76d446a0c4
--- /dev/null
+++ b/src/libs/qmljs/qmljspropertyreader.h
@@ -0,0 +1,71 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#ifndef QMLJSPROPERTYREADER_H
+#define QMLJSPROPERTYREADER_H
+
+#include <qmljs/qmljs_global.h>
+#include <qmljs/parser/qmljsastfwd_p.h>
+
+#include <QHash>
+#include <QVariant>
+#include <QString>
+#include <QStringList>
+
+namespace QmlJS {
+
+class Document;
+
+class QMLJS_EXPORT PropertyReader
+{
+public:
+
+ PropertyReader(Document *doc, AST::UiObjectInitializer *ast);
+
+ bool hasProperty(const QString &propertyName) const
+ { return m_properties.contains(propertyName); }
+
+ QVariant readProperty(const QString &propertyName) const
+ {
+ if (hasProperty(propertyName))
+ return m_properties.value(propertyName);
+ else
+ return QVariant();
+ }
+
+ QStringList properties() const
+ { return m_properties.keys(); }
+
+private:
+ QHash<QString, QVariant> m_properties;
+};
+
+} //QmlJS
+
+#endif // QMLJSPROPERTYREADER_H
diff --git a/src/libs/utils/reloadpromptutils.cpp b/src/libs/utils/reloadpromptutils.cpp
index 23678a9a41..c4463b7e07 100644
--- a/src/libs/utils/reloadpromptutils.cpp
+++ b/src/libs/utils/reloadpromptutils.cpp
@@ -46,19 +46,25 @@ QTCREATOR_UTILS_EXPORT Utils::ReloadPromptAnswer
if (modified)
msg = QCoreApplication::translate("Utils::reloadPrompt",
- "The unsaved file %1 has been changed outside Qt Creator. Do you want to reload it and discard your changes?").arg(QDir::toNativeSeparators(fileName));
+ "The unsaved file <i>%1</i> has been changed outside Qt Creator. Do you want to reload it and discard your changes?");
else
msg = QCoreApplication::translate("Utils::reloadPrompt",
- "The file %1 has changed outside Qt Creator. Do you want to reload it?").arg(QDir::toNativeSeparators(fileName));
- return reloadPrompt(title, msg, parent);
+ "The file <i>%1</i> has changed outside Qt Creator. Do you want to reload it?");
+ msg = msg.arg(QFileInfo(fileName).fileName());
+ return reloadPrompt(title, msg, QDir::toNativeSeparators(fileName), parent);
}
QTCREATOR_UTILS_EXPORT Utils::ReloadPromptAnswer
- Utils::reloadPrompt(const QString &title, const QString &prompt, QWidget *parent)
+ Utils::reloadPrompt(const QString &title, const QString &prompt, const QString &details, QWidget *parent)
{
- switch (QMessageBox::question(parent, title, prompt,
- QMessageBox::Yes|QMessageBox::YesToAll|QMessageBox::No|QMessageBox::NoToAll,
- QMessageBox::YesToAll)) {
+ QMessageBox msg(parent);
+ msg.setStandardButtons(QMessageBox::Yes|QMessageBox::YesToAll|QMessageBox::No|QMessageBox::NoToAll);
+ msg.setDefaultButton(QMessageBox::YesToAll);
+ msg.setWindowTitle(title);
+ msg.setText(prompt);
+ msg.setDetailedText(details);
+
+ switch (msg.exec()) {
case QMessageBox::Yes:
return ReloadCurrent;
case QMessageBox::YesToAll:
diff --git a/src/libs/utils/reloadpromptutils.h b/src/libs/utils/reloadpromptutils.h
index 8f0d3ad258..5b379cb57f 100644
--- a/src/libs/utils/reloadpromptutils.h
+++ b/src/libs/utils/reloadpromptutils.h
@@ -42,7 +42,7 @@ namespace Utils {
enum ReloadPromptAnswer { ReloadCurrent, ReloadAll, ReloadSkipCurrent, ReloadNone };
QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const QString &fileName, bool modified, QWidget *parent);
-QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const QString &title, const QString &prompt, QWidget *parent);
+QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const QString &title, const QString &prompt, const QString &details, QWidget *parent);
enum FileDeletedPromptAnswer { FileDeletedClose, FileDeletedSaveAs, FileDeletedSave };
diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp
index 7e438b1108..7eca9aafd4 100644
--- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp
+++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp
@@ -185,7 +185,6 @@ ItemLibrary::ItemLibrary(QWidget *parent) :
lineEditLayout->addWidget(m_d->m_lineEdit, 1, 1, 1, 1);
lineEditLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 2);
connect(m_d->m_lineEdit, SIGNAL(filterChanged(QString)), this, SLOT(setSearchFilter(QString)));
- connect(m_d->m_lineEdit, SIGNAL(buttonClicked(Utils::FancyLineEdit::Side)), this, SLOT(clearLineEditFocus()));
m_d->m_stackedWidget = new QStackedWidget(this);
m_d->m_stackedWidget->addWidget(m_d->m_itemsView);
@@ -286,11 +285,6 @@ void ItemLibrary::updateSearch()
setSearchFilter(m_d->m_lineEdit->text());
}
-void ItemLibrary::clearLineEditFocus()
-{
- m_d->m_lineEdit->clearFocus();
-}
-
void ItemLibrary::setResourcePath(const QString &resourcePath)
{
if (m_d->m_resourcesView->model() == m_d->m_resourcesDirModel)
diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.h b/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.h
index 0eff37dee9..749ac74f17 100644
--- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.h
+++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.h
@@ -54,7 +54,6 @@ public Q_SLOTS:
void setSearchFilter(const QString &searchFilter);
void updateModel();
void updateSearch();
- void clearLineEditFocus();
void setResourcePath(const QString &resourcePath);
diff --git a/src/plugins/qmldesigner/components/propertyeditor/colorwidget.cpp b/src/plugins/qmldesigner/components/propertyeditor/colorwidget.cpp
index 035930e006..a5797d11ae 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/colorwidget.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/colorwidget.cpp
@@ -43,6 +43,11 @@
#include <QToolButton>
#include <QGradient>
#include <QPainter>
+#include <QDoubleSpinBox>
+#include <QGridLayout>
+#include <QPushButton>
+#include <QDialogButtonBox>
+#include <QGraphicsEffect>
static inline int clamp(int x, int lower, int upper)
{
@@ -151,7 +156,7 @@ void HueControl::setCurrent(int y)
m_color.setHsv((y * 359)/120, m_color.hsvSaturation(), m_color.value());
m_color.setAlpha(oldAlpha);
update(); // redraw pointer
- emit hueChanged();
+ emit hueChanged(m_color.hsvHue());
}
void HueControl::setHue(int newHue)
@@ -160,7 +165,7 @@ void HueControl::setHue(int newHue)
return;
m_color.setHsv(newHue, m_color.hsvSaturation(), m_color.value());
update();
- emit hueChanged();
+ emit hueChanged(m_color.hsvHue());
}
void HueControl::paintEvent(QPaintEvent *event)
@@ -754,4 +759,105 @@ void GradientLine::setCurrentIndex(int i)
update();
}
+BauhausColorDialog::BauhausColorDialog(QWidget *parent) : QFrame(parent )
+{
+
+ setFrameStyle(QFrame::NoFrame);
+ setFrameShape(QFrame::StyledPanel);
+ setFrameShadow(QFrame::Sunken);
+
+ QGraphicsDropShadowEffect *dropShadowEffect = new QGraphicsDropShadowEffect;
+ dropShadowEffect->setBlurRadius(6);
+ dropShadowEffect->setOffset(2, 2);
+ setGraphicsEffect(dropShadowEffect);
+ setAutoFillBackground(true);
+
+ m_hueControl = new HueControl(this);
+ m_colorBox = new ColorBox(this);
+
+ m_rSpinBox = new QDoubleSpinBox(this);
+ m_gSpinBox = new QDoubleSpinBox(this);
+ m_bSpinBox = new QDoubleSpinBox(this);
+ m_alphaSpinBox = new QDoubleSpinBox(this);
+
+ QGridLayout *gridLayout = new QGridLayout(this);
+ setLayout(gridLayout);
+
+ gridLayout->addWidget(m_colorBox, 0, 0, 4, 1);
+ gridLayout->addWidget(m_hueControl, 0, 1, 4, 1);
+
+ gridLayout->addWidget(new QLabel("R", this), 0, 2, 1, 1);
+ gridLayout->addWidget(new QLabel("G", this), 1, 2, 1, 1);
+ gridLayout->addWidget(new QLabel("B", this), 2, 2, 1, 1);
+ gridLayout->addWidget(new QLabel("A", this), 3, 2, 1, 1);
+
+ gridLayout->addWidget(m_rSpinBox, 0, 3, 1, 1);
+ gridLayout->addWidget(m_gSpinBox, 1, 3, 1, 1);
+ gridLayout->addWidget(m_bSpinBox, 2, 3, 1, 1);
+ gridLayout->addWidget(m_alphaSpinBox, 3, 3, 1, 1);
+
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
+
+ QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
+ QPushButton *applyButton = buttonBox->addButton(QDialogButtonBox::Apply);
+
+ gridLayout->addWidget(buttonBox, 4, 0, 2, 1);
+
+ resize(sizeHint());
+
+ connect(m_colorBox, SIGNAL(colorChanged()), this, SLOT(onColorBoxChanged()));
+ connect(m_alphaSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged()));
+ connect(m_rSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged()));
+ connect(m_gSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged()));
+ connect(m_bSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged()));
+ connect(m_hueControl, SIGNAL(hueChanged(int)), this, SLOT(onHueChanged(int)));
+
+ connect(applyButton, SIGNAL(pressed()), this, SLOT(onAccept()));
+ connect(cancelButton, SIGNAL(pressed()), this, SIGNAL(rejected()));
+
+ m_alphaSpinBox->setMaximum(1);
+ m_rSpinBox->setMaximum(1);
+ m_gSpinBox->setMaximum(1);
+ m_bSpinBox->setMaximum(1);
+ m_alphaSpinBox->setSingleStep(0.1);
+ m_rSpinBox->setSingleStep(0.1);
+ m_gSpinBox->setSingleStep(0.1);
+ m_bSpinBox->setSingleStep(0.1);
+
+ m_blockUpdate = false;
+
+}
+
+void BauhausColorDialog::spinBoxChanged()
+{
+ if (m_blockUpdate)
+ return;
+ QColor newColor;
+ newColor.setAlphaF(m_alphaSpinBox->value());
+ newColor.setRedF(m_rSpinBox->value());
+ newColor.setGreenF(m_gSpinBox->value());
+ newColor.setBlueF(m_bSpinBox->value());
+ setColor(newColor);
+}
+
+void BauhausColorDialog::onColorBoxChanged()
+{
+ if (m_blockUpdate)
+ return;
+
+ setColor(m_colorBox->color());
+}
+
+void BauhausColorDialog::setupWidgets()
+{
+ m_blockUpdate = true;
+ m_hueControl->setHue(m_color.hsvHue());
+ m_alphaSpinBox->setValue(m_color.alphaF());
+ m_rSpinBox->setValue(m_color.redF());
+ m_gSpinBox->setValue(m_color.greenF());
+ m_bSpinBox->setValue(m_color.blueF());
+ m_colorBox->setColor(m_color);
+ m_blockUpdate = false;
+}
+
}
diff --git a/src/plugins/qmldesigner/components/propertyeditor/colorwidget.h b/src/plugins/qmldesigner/components/propertyeditor/colorwidget.h
index 8e984f4c34..52b29fd746 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/colorwidget.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/colorwidget.h
@@ -39,10 +39,12 @@
#include <qdeclarative.h>
#include <propertyeditorvalue.h>
#include <qmlitemnode.h>
+#include <QDialog>
QT_BEGIN_NAMESPACE
class QtColorButton;
class QToolButton;
+class QDoubleSpinBox;
QT_END_NAMESPACE
namespace QmlDesigner {
@@ -144,7 +146,7 @@ public:
int hue() const { return m_color.hsvHue(); }
signals:
- void hueChanged();
+ void hueChanged(int hue);
protected:
void paintEvent(QPaintEvent *);
@@ -215,6 +217,68 @@ private:
bool m_dragOff;
};
+class BauhausColorDialog : public QFrame {
+
+ Q_OBJECT
+
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+
+public:
+ BauhausColorDialog(QWidget *parent = 0);
+
+ QColor color() const { return m_color; }
+ void setColor(const QColor &color)
+ {
+ if (color == m_color)
+ return;
+
+ m_color = color;
+ setupWidgets();
+ emit colorChanged();
+ }
+
+public slots:
+ void changeColor(const QColor &color) { setColor(color); }
+ void spinBoxChanged();
+ void onColorBoxChanged();
+ void onHueChanged(int newHue)
+ {
+ if (m_blockUpdate)
+ return;
+
+ if (m_color.hsvHue() == newHue)
+ return;
+ m_color.setHsv(newHue, m_color.hsvSaturation(), m_color.value());
+ setupWidgets();
+ emit colorChanged();
+ }
+ void onAccept()
+ {
+ emit accepted(m_color);
+ }
+
+signals:
+ void colorChanged();
+ void accepted(const QColor &color);
+ void rejected();
+
+protected:
+ void setupWidgets();
+
+private:
+ ColorBox *m_colorBox;
+ HueControl *m_hueControl;
+
+ QDoubleSpinBox *m_rSpinBox;
+ QDoubleSpinBox *m_gSpinBox;
+ QDoubleSpinBox *m_bSpinBox;
+ QDoubleSpinBox *m_alphaSpinBox;
+
+ QColor m_color;
+ bool m_blockUpdate;
+
+};
+
class ColorWidget {