diff --git a/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp b/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp index 4917e8c59ac..a0ff5fb3b16 100644 --- a/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp +++ b/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp @@ -4,6 +4,8 @@ #include "qmljscomponentnamedialog.h" #include "qmljseditortr.h" +#include +#include #include #include #include @@ -19,6 +21,58 @@ using namespace QmlJSEditor::Internal; +namespace { +constexpr auto properitesCheckedByDefault = Utils::to_array({ + u"x", + u"y", + u"anchors.alignWhenCentered", + u"anchors.baseline", + u"anchors.baselineOffset", + u"anchors.bottom", + u"anchors.bottomMargin", + u"anchors.centerIn", + u"anchors.fill", + u"anchors.horizontalCenter", + u"anchors.horizontalCenterOffset", + u"anchors.left", + u"anchors.leftMargin", + u"anchors.margins", + u"anchors.right", + u"anchors.rightMargin", + u"anchors.top", + u"anchors.topMargin", + u"anchors.verticalCenter", + u"anchors.verticalCenterOffset", + u"Layout.alignment", + u"Layout.bottomMargin", + u"Layout.column", + u"Layout.columnSpan", + u"Layout.fillHeight", + u"Layout.fillWidth", + u"Layout.horizontalStretchFactor", + u"Layout.leftMargin", + u"Layout.margins", + u"Layout.maximumHeight", + u"Layout.maximumWidth", + u"Layout.minimumHeight", + u"Layout.minimumWidth", + u"Layout.preferredHeight", + u"Layout.preferredWidth", + u"Layout.rightMargin", + u"Layout.row", + u"Layout.rowSpan", + u"Layout.topMargin", + u"Layout.useDefaultSizePolicy", + u"Layout.verticalStretchFactor", +}); + +bool isCheckedByDefault(const QString &property) +{ + return std::find(properitesCheckedByDefault.begin(), properitesCheckedByDefault.end(), property) + != properitesCheckedByDefault.end(); +} +} // namespace + ComponentNameDialog::ComponentNameDialog(QWidget *parent) : QDialog(parent) { @@ -113,8 +167,7 @@ void ComponentNameDialog::setProperties(const QStringList &properties) for (int i = 0; i < m_listWidget->count(); ++i) { QListWidgetItem *item = m_listWidget->item(i); item->setFlags(Qt::ItemIsUserCheckable | Qt:: ItemIsEnabled); - if (item->text() == QLatin1String("x") - || item->text() == QLatin1String("y")) + if (isCheckedByDefault(item->text())) m_listWidget->item(i)->setCheckState(Qt::Checked); else m_listWidget->item(i)->setCheckState(Qt::Unchecked);