Skip to content
Snippets Groups Projects
Commit b46a0e69 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.propertyEditor: tweak to the text pane

parent 7620746e
No related branches found
No related tags found
No related merge requests found
...@@ -59,7 +59,10 @@ ContextPaneTextWidget::ContextPaneTextWidget(QWidget *parent) : ...@@ -59,7 +59,10 @@ ContextPaneTextWidget::ContextPaneTextWidget(QWidget *parent) :
void ContextPaneTextWidget::setProperties(QmlJS::PropertyReader *propertyReader) void ContextPaneTextWidget::setProperties(QmlJS::PropertyReader *propertyReader)
{ {
if (propertyReader->hasProperty(QLatin1String("font.pointSize"))) { if (propertyReader->hasProperty(QLatin1String("font.pointSize"))) {
ui->fontSizeSpinBox->setValue(propertyReader->readProperty(QLatin1String("font.pointSize")).toInt()); QVariant variant = propertyReader->readProperty(QLatin1String("font.pointSize"));
bool b;
ui->fontSizeSpinBox->setValue(variant.toInt(&b));
ui->fontSizeSpinBox->setEnabled(b);
ui->fontSizeSpinBox->setIsPointSize(true); ui->fontSizeSpinBox->setIsPointSize(true);
} else if (!propertyReader->hasProperty(QLatin1String("font.pixelSize"))) { } else if (!propertyReader->hasProperty(QLatin1String("font.pixelSize"))) {
ui->fontSizeSpinBox->setValue(8); ui->fontSizeSpinBox->setValue(8);
...@@ -72,7 +75,11 @@ void ContextPaneTextWidget::setProperties(QmlJS::PropertyReader *propertyReader) ...@@ -72,7 +75,11 @@ void ContextPaneTextWidget::setProperties(QmlJS::PropertyReader *propertyReader)
} }
if (propertyReader->hasProperty(QLatin1String("font.pixelSize"))) { if (propertyReader->hasProperty(QLatin1String("font.pixelSize"))) {
ui->fontSizeSpinBox->setValue(propertyReader->readProperty(QLatin1String("font.pixelSize")).toInt()); QVariant variant = propertyReader->readProperty(QLatin1String("font.pixelSize"));
bool b;
ui->fontSizeSpinBox->setValue(variant.toInt(&b));
ui->fontSizeSpinBox->setEnabled(b);
ui->fontSizeSpinBox->setIsPixelSize(true); ui->fontSizeSpinBox->setIsPixelSize(true);
} }
...@@ -116,16 +123,26 @@ void ContextPaneTextWidget::setProperties(QmlJS::PropertyReader *propertyReader) ...@@ -116,16 +123,26 @@ void ContextPaneTextWidget::setProperties(QmlJS::PropertyReader *propertyReader)
QString familyName = propertyReader->readProperty(QLatin1String("font.family")).toString(); QString familyName = propertyReader->readProperty(QLatin1String("font.family")).toString();
QFont font; QFont font;
font.setFamily(familyName); font.setFamily(familyName);
ui->fontComboBox->setCurrentFont(font); ui->fontComboBox->setCurrentFont(font);
if (propertyReader->isBindingOrEnum(QLatin1String("font.family")))
ui->fontComboBox->setEnabled(false);
else
ui->fontComboBox->setEnabled(true);
} }
if (propertyReader->hasProperty(QLatin1String("horizontalAlignment"))) { if (propertyReader->hasProperty(QLatin1String("horizontalAlignment"))) {
QString alignment = propertyReader->readProperty(QLatin1String("horizontalAlignment")).toString(); QString alignment = propertyReader->readProperty(QLatin1String("horizontalAlignment")).toString();
ui->leftAlignmentButton->setChecked(true); ui->leftAlignmentButton->setChecked(true);
ui->leftAlignmentButton->setEnabled(true);
if (alignment == QLatin1String("Text.AlignHCenter") || alignment == "AlignHCenter") if (alignment == QLatin1String("Text.AlignHCenter") || alignment == "AlignHCenter")
ui->centerHAlignmentButton->setChecked(true); ui->centerHAlignmentButton->setChecked(true);
else if (alignment == QLatin1String("Text.AlignRight") || alignment == QLatin1String("AlignRight")) else if (alignment == QLatin1String("Text.AlignRight") || alignment == QLatin1String("AlignRight"))
ui->rightAlignmentButton->setChecked(true); ui->rightAlignmentButton->setChecked(true);
else if (alignment == QLatin1String("Text.AlignLeft") || alignment == QLatin1String("AlignLeft"))
ui->leftAlignmentButton->setChecked(true);
else
ui->leftAlignmentButton->setEnabled(false);
} else { } else {
ui->leftAlignmentButton->setChecked(true); ui->leftAlignmentButton->setChecked(true);
} }
...@@ -133,10 +150,15 @@ void ContextPaneTextWidget::setProperties(QmlJS::PropertyReader *propertyReader) ...@@ -133,10 +150,15 @@ void ContextPaneTextWidget::setProperties(QmlJS::PropertyReader *propertyReader)
if (propertyReader->hasProperty(QLatin1String("verticalAlignment"))) { if (propertyReader->hasProperty(QLatin1String("verticalAlignment"))) {
QString alignment = propertyReader->readProperty(QLatin1String("verticalAlignment")).toString(); QString alignment = propertyReader->readProperty(QLatin1String("verticalAlignment")).toString();
ui->topAlignmentButton->setChecked(true); ui->topAlignmentButton->setChecked(true);
ui->bottomAlignmentButton->setEnabled(true);
if (alignment == QLatin1String("Text.AlignVCenter") || alignment == QLatin1String("AlignVCenter")) if (alignment == QLatin1String("Text.AlignVCenter") || alignment == QLatin1String("AlignVCenter"))
ui->centerVAlignmentButton->setChecked(true); ui->centerVAlignmentButton->setChecked(true);
else if (alignment == QLatin1String("Text.AlignBottom") || alignment == QLatin1String("AlignBottom")) else if (alignment == QLatin1String("Text.AlignBottom") || alignment == QLatin1String("AlignBottom"))
ui->bottomAlignmentButton->setChecked(true); ui->bottomAlignmentButton->setChecked(true);
else if (alignment == QLatin1String("Text.Top") || alignment == QLatin1String("AlignTop"))
ui->topAlignmentButton->setChecked(true);
else
ui->bottomAlignmentButton->setEnabled(false);
} else { } else {
ui->topAlignmentButton->setChecked(true); ui->topAlignmentButton->setChecked(true);
} }
...@@ -144,12 +166,17 @@ void ContextPaneTextWidget::setProperties(QmlJS::PropertyReader *propertyReader) ...@@ -144,12 +166,17 @@ void ContextPaneTextWidget::setProperties(QmlJS::PropertyReader *propertyReader)
if (propertyReader->hasProperty(QLatin1String("style"))) { if (propertyReader->hasProperty(QLatin1String("style"))) {
QString style = propertyReader->readProperty(QLatin1String("style")).toString(); QString style = propertyReader->readProperty(QLatin1String("style")).toString();
ui->styleComboBox->setCurrentIndex(0); ui->styleComboBox->setCurrentIndex(0);
ui->styleComboBox->setEnabled(true);
if (style == QLatin1String("Text.Outline") || style == QLatin1String("Outline")) if (style == QLatin1String("Text.Outline") || style == QLatin1String("Outline"))
ui->styleComboBox->setCurrentIndex(1); ui->styleComboBox->setCurrentIndex(1);
if (style == QLatin1String("Text.Raised") || style == QLatin1String("Raised")) if (style == QLatin1String("Text.Raised") || style == QLatin1String("Raised"))
ui->styleComboBox->setCurrentIndex(2); ui->styleComboBox->setCurrentIndex(2);
else if (style == QLatin1String("Text.Sunken") || style == QLatin1String("Sunken")) else if (style == QLatin1String("Text.Sunken") || style == QLatin1String("Sunken"))
ui->styleComboBox->setCurrentIndex(3); ui->styleComboBox->setCurrentIndex(3);
else if (style == QLatin1String("Text.Normal") || style == QLatin1String("Normal"))
ui->styleComboBox->setCurrentIndex(0);
else
ui->styleComboBox->setEnabled(false);
} else { } else {
ui->styleComboBox->setCurrentIndex(0); ui->styleComboBox->setCurrentIndex(0);
} }
...@@ -222,9 +249,9 @@ void ContextPaneTextWidget::onFontFormatChanged() ...@@ -222,9 +249,9 @@ void ContextPaneTextWidget::onFontFormatChanged()
{ {
int size = ui->fontSizeSpinBox->value(); int size = ui->fontSizeSpinBox->value();
if (ui->fontSizeSpinBox->isPointSize()) { if (ui->fontSizeSpinBox->isPointSize()) {
emit removeAndChangeProperty(QLatin1String("font.pixelSize"), QLatin1String("font.pointSize"), size); emit removeAndChangeProperty(QLatin1String("font.pixelSize"), QLatin1String("font.pointSize"), size, true);
} else { } else {
emit removeAndChangeProperty(QLatin1String("font.pointSize"), QLatin1String("font.pixelSize"), size); emit removeAndChangeProperty(QLatin1String("font.pointSize"), QLatin1String("font.pixelSize"), size, true);
} }
} }
......
...@@ -49,7 +49,7 @@ public slots: ...@@ -49,7 +49,7 @@ public slots:
signals: signals:
void propertyChanged(const QString &, const QVariant &); void propertyChanged(const QString &, const QVariant &);
void removeProperty(const QString &); void removeProperty(const QString &);
void removeAndChangeProperty(const QString &, const QString &, const QVariant &); void removeAndChangeProperty(const QString &, const QString &, const QVariant &, bool removeFirst);
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment