Commit 2368252f authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QuickToolBar: proper check of types

We are checking the whole prototype chain now
parent f414179b
......@@ -114,12 +114,12 @@ EasingContextPane::~EasingContextPane()
}
bool EasingContextPane::acceptsType(const QString &typeName)
bool EasingContextPane::acceptsType(const QStringList &types)
{
return typeName.contains("NumberAnimation") ||
typeName.contains("PropertyAnimation") ||
typeName.contains("ColorAnimation") ||
typeName.contains("RotationAnimation");
return types.contains("NumberAnimation") ||
types.contains("PropertyAnimation") ||
types.contains("ColorAnimation") ||
types.contains("RotationAnimation");
}
void EasingContextPane::setProperties(QmlJS::PropertyReader *propertyReader)
......
......@@ -33,7 +33,7 @@ public:
void setGraphDisplayMode(GraphDisplayMode newMode);
void startAnimation();
bool acceptsType(const QString &);
bool acceptsType(const QStringList &);
signals:
void propertyChanged(const QString &, const QVariant &);
......
......@@ -266,7 +266,7 @@ void ContextPaneWidget::setPath(const QString &path)
}
bool ContextPaneWidget::setType(const QString &typeName)
bool ContextPaneWidget::setType(const QStringList &types)
{
m_imageWidget->hide();
m_borderImageWidget->hide();
......@@ -274,42 +274,42 @@ bool ContextPaneWidget::setType(const QString &typeName)
m_rectangleWidget->hide();
m_easingWidget->hide();
if (typeName.contains("Text")) {
if (types.contains("Text")) {
m_currentWidget = m_textWidget;
m_textWidget->show();
m_textWidget->setStyleVisible(true);
m_textWidget->setVerticalAlignmentVisible(true);
if (typeName.contains("TextInput")) {
if (types.contains("TextInput")) {
m_textWidget->setVerticalAlignmentVisible(false);
m_textWidget->setStyleVisible(false);
} else if (typeName.contains("TextEdit")) {
} else if (types.contains("TextEdit")) {
m_textWidget->setStyleVisible(false);
}
resize(sizeHint());
return true;
}
if (m_easingWidget->acceptsType(typeName)) {
if (m_easingWidget->acceptsType(types)) {
m_currentWidget = m_easingWidget;
m_easingWidget->show();
resize(sizeHint());
return true;
}
if (typeName.contains("Rectangle")) {
if (types.contains("Rectangle")) {
m_currentWidget = m_rectangleWidget;
m_rectangleWidget->show();
resize(sizeHint());
return true;
}
if (typeName.contains("BorderImage")) {
if (types.contains("BorderImage")) {
m_currentWidget = m_borderImageWidget;
m_borderImageWidget->show();
resize(sizeHint());
return true;
}
if (typeName.contains("Image")) {
if (types.contains("Image")) {
m_currentWidget = m_imageWidget;
m_imageWidget->show();
resize(sizeHint());
......@@ -318,10 +318,10 @@ bool ContextPaneWidget::setType(const QString &typeName)
return false;
}
bool ContextPaneWidget::acceptsType(const QString &typeName)
bool ContextPaneWidget::acceptsType(const QStringList &types)
{
return typeName.contains("Text") || m_easingWidget->acceptsType(typeName) ||
typeName.contains("Rectangle") || typeName.contains("Image");
return types.contains("Text") || m_easingWidget->acceptsType(types) ||
types.contains("Rectangle") || types.contains("Image");
}
void ContextPaneWidget::onTogglePane()
......
......@@ -55,8 +55,8 @@ public:
BauhausColorDialog *colorDialog();
void setProperties(QmlJS::PropertyReader *propertyReader);
void setPath(const QString &path);
bool setType(const QString &typeName);
bool acceptsType(const QString &typeName);
bool setType(const QStringList &types);
bool acceptsType(const QStringList &types);
QWidget* currentWidget() const { return m_currentWidget; }
public slots:
......
......@@ -90,8 +90,6 @@ void QmlContextPane::apply(TextEditor::BaseTextEditorEditable *editor, Document:
scopeObject = scopeObject->prototype(lookupContext->context());
}
//qDebug() << prototypes;
setEnabled(doc->isParsedCorrectly());
m_editor = editor;
contextWidget()->setParent(editor->widget()->parentWidget());
......@@ -134,7 +132,7 @@ void QmlContextPane::apply(TextEditor::BaseTextEditorEditable *editor, Document:
rect.moveTo(reg.boundingRect().topLeft());
reg = reg.intersect(rect);
if (contextWidget()->acceptsType(name)) {
if (contextWidget()->acceptsType(prototypes)) {
m_node = 0;
PropertyReader propertyReader(doc, initializer);
QTextCursor tc(editor->editor()->document());
......@@ -147,7 +145,7 @@ void QmlContextPane::apply(TextEditor::BaseTextEditorEditable *editor, Document:
offset = QPoint(400 - reg.boundingRect().width() + 10 ,0);
QPoint p3 = editor->editor()->mapToParent(editor->editor()->viewport()->mapToParent(reg.boundingRect().topRight()) + offset);
p2.setX(p1.x());
contextWidget()->setType(name);
contextWidget()->setType(prototypes);
if (!update)
contextWidget()->activate(p3 , p1, p2);
else
......@@ -224,7 +222,6 @@ void QmlContextPane::setProperty(const QString &propertyName, const QVariant &va
int line = -1;
int endLine;
Rewriter::BindingType bindingType = Rewriter::ScriptBinding;
if (stringValue.contains("{") && stringValue.contains("}"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment