diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-06-27 12:42:48 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-07-01 23:09:54 +0200 |
commit | 199329c9df889d371dc5f717248fcc519e8952e3 (patch) | |
tree | 7cf4d9ccff1253aef4f6e05bf5c997c14edecdc5 | |
parent | b5bf195dc9c7576f627f37428c5ff2ff6e958411 (diff) | |
download | qttools-199329c9df889d371dc5f717248fcc519e8952e3.tar.gz |
Qt Designer: Add a setting for calling connectSlotsByName()
Add a boolean attribute to DomUI and a form setting, allowing for
per-form migration to the Qt 5 connection syntax.
[ChangeLog][Designer] A per-form setting for disabling generating
calls to QObject::connectSlotsByName() has been added to support
migrating forms to Qt 5 connection syntax.
Task-number: QTBUG-76375
Change-Id: Id59d4689287fdec025c199e4efc87a919e37ae9e
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
-rw-r--r-- | src/designer/data/ui4.xsd | 1 | ||||
-rw-r--r-- | src/designer/src/components/formeditor/formwindowsettings.cpp | 9 | ||||
-rw-r--r-- | src/designer/src/components/formeditor/formwindowsettings.ui | 341 | ||||
-rw-r--r-- | src/designer/src/components/formeditor/qdesigner_resource.cpp | 8 | ||||
-rw-r--r-- | src/designer/src/lib/shared/formwindowbase.cpp | 14 | ||||
-rw-r--r-- | src/designer/src/lib/shared/formwindowbase_p.h | 3 | ||||
-rw-r--r-- | src/designer/src/lib/uilib/ui4.cpp | 7 | ||||
-rw-r--r-- | src/designer/src/lib/uilib/ui4_p.h | 8 |
8 files changed, 257 insertions, 134 deletions
diff --git a/src/designer/data/ui4.xsd b/src/designer/data/ui4.xsd index 8448a62b4..e1dc35d49 100644 --- a/src/designer/data/ui4.xsd +++ b/src/designer/data/ui4.xsd @@ -27,6 +27,7 @@ <xs:attribute name="language" type="xs:string" /> <xs:attribute name="displayname" type="xs:string" /> <xs:attribute name="idbasedtr" type="xs:boolean" /> + <xs:attribute name="connectslotsbyname" type="xs:boolean" /> <!-- Legacy attribute generated by uic3 --> <xs:attribute name="stdsetdef" type="xs:integer" /> <!-- Legacy attribute generated by the VS integration --> diff --git a/src/designer/src/components/formeditor/formwindowsettings.cpp b/src/designer/src/components/formeditor/formwindowsettings.cpp index 2ed718d88..4ccd7210b 100644 --- a/src/designer/src/components/formeditor/formwindowsettings.cpp +++ b/src/designer/src/components/formeditor/formwindowsettings.cpp @@ -67,6 +67,7 @@ struct FormWindowData { bool hasFormGrid{false}; Grid grid; bool idBasedTranslations{false}; + bool connectSlotsByName{true}; }; inline bool operator==(const FormWindowData &fd1, const FormWindowData &fd2) { return fd1.equals(fd2); } @@ -80,6 +81,7 @@ QDebug operator<<(QDebug str, const FormWindowData &d) << d.pixFunction << " Author=" << d.author << " Hints=" << d.includeHints << " Grid=" << d.hasFormGrid << d.grid.deltaX() << d.grid.deltaY() << " ID-based translations" << d.idBasedTranslations + << " Connect slots by name" << d.connectSlotsByName << '\n'; return str; } @@ -97,7 +99,8 @@ bool FormWindowData::equals(const FormWindowData &rhs) const includeHints == rhs.includeHints && hasFormGrid == rhs.hasFormGrid && grid == rhs.grid && - idBasedTranslations == rhs.idBasedTranslations; + idBasedTranslations == rhs.idBasedTranslations && + connectSlotsByName == rhs.connectSlotsByName; } void FormWindowData::fromFormWindow(FormWindowBase* fw) @@ -128,6 +131,7 @@ void FormWindowData::fromFormWindow(FormWindowBase* fw) hasFormGrid = fw->hasFormGrid(); grid = hasFormGrid ? fw->designerGrid() : FormWindowBase::defaultDesignerGrid(); idBasedTranslations = fw->useIdBasedTranslations(); + connectSlotsByName = fw->connectSlotsByName(); } void FormWindowData::applyToFormWindow(FormWindowBase* fw) const @@ -154,6 +158,7 @@ void FormWindowData::applyToFormWindow(FormWindowBase* fw) const if (hasFormGrid || hadFormGrid != hasFormGrid) fw->setDesignerGrid(hasFormGrid ? grid : FormWindowBase::defaultDesignerGrid()); fw->setUseIdBasedTranslations(idBasedTranslations); + fw->setConnectSlotsByName(connectSlotsByName); } // -------------------------- FormWindowSettings @@ -220,6 +225,7 @@ FormWindowData FormWindowSettings::data() const rc.hasFormGrid = m_ui->gridPanel->isChecked(); rc.grid = m_ui->gridPanel->grid(); rc.idBasedTranslations = m_ui->idBasedTranslationsCheckBox->isChecked(); + rc.connectSlotsByName = m_ui->connectSlotsByNameCheckBox->isChecked(); return rc; } @@ -247,6 +253,7 @@ void FormWindowSettings::setData(const FormWindowData &data) m_ui->gridPanel->setChecked(data.hasFormGrid); m_ui->gridPanel->setGrid(data.grid); m_ui->idBasedTranslationsCheckBox->setChecked(data.idBasedTranslations); + m_ui->connectSlotsByNameCheckBox->setChecked(data.connectSlotsByName); } void FormWindowSettings::accept() diff --git a/src/designer/src/components/formeditor/formwindowsettings.ui b/src/designer/src/components/formeditor/formwindowsettings.ui index 6bb092078..a71ae3542 100644 --- a/src/designer/src/components/formeditor/formwindowsettings.ui +++ b/src/designer/src/components/formeditor/formwindowsettings.ui @@ -33,20 +33,201 @@ <rect> <x>0</x> <y>0</y> - <width>470</width> - <height>466</height> + <width>463</width> + <height>654</height> </rect> </property> <property name="windowTitle"> <string>Form Settings</string> </property> <layout class="QGridLayout"> + <item row="9" column="0" colspan="2"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + <item row="2" column="0" colspan="2"> + <widget class="qdesigner_internal::GridPanel" name="gridPanel"> + <property name="title"> + <string>Grid</string> + </property> + </widget> + </item> + <item row="5" column="0" rowspan="3"> + <widget class="QGroupBox" name="includeHintsGroupBox"> + <property name="title"> + <string>&Include Hints</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="QTextEdit" name="includeHintsTextEdit"/> + </item> + </layout> + </widget> + </item> + <item row="6" column="1"> + <widget class="QGroupBox" name="translationsGroupBox"> + <property name="title"> + <string>Translations</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QCheckBox" name="idBasedTranslationsCheckBox"> + <property name="text"> + <string>ID-based</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="5" column="1"> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QGroupBox" name="pixmapFunctionGroupBox"> + <property name="title"> + <string>&Pixmap Function</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="QLineEdit" name="pixmapFunctionLineEdit"/> + </item> + </layout> + </widget> + </item> + </layout> + </item> + <item row="8" column="0" colspan="2"> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QGroupBox" name="pixmapFunctionGroupBox_2"> + <property name="title"> + <string>&Author</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="QLineEdit" name="authorLineEdit"/> + </item> + </layout> + </widget> + </item> + <item row="7" column="1"> + <spacer> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>111</width> + <height>115</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="0" colspan="2"> + <widget class="QGroupBox" name="embeddedGroupBox"> + <property name="title"> + <string>Embedded Design</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="deviceProfileLabel"> + <property name="text"> + <string notr="true">TextLabel</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> <item row="3" column="0" colspan="2"> <layout class="QHBoxLayout"> <property name="spacing"> <number>6</number> </property> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> <item> @@ -58,7 +239,16 @@ <bool>true</bool> </property> <layout class="QGridLayout"> - <property name="margin"> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> <number>8</number> </property> <property name="spacing"> @@ -102,7 +292,16 @@ <bool>true</bool> </property> <layout class="QGridLayout"> - <property name="margin"> + <property name="leftMargin"> + <number>8</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>8</number> + </property> + <property name="bottomMargin"> <number>8</number> </property> <property name="spacing"> @@ -139,142 +338,22 @@ </item> </layout> </item> - <item row="4" column="1"> - <layout class="QHBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>0</number> - </property> - <item> - <widget class="QGroupBox" name="pixmapFunctionGroupBox"> - <property name="title"> - <string>&Pixmap Function</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>8</number> - </property> - <item> - <widget class="QLineEdit" name="pixmapFunctionLineEdit"/> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item row="8" column="0" colspan="2"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - <item row="7" column="0" colspan="2"> - <widget class="Line" name="line"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="4" column="0" rowspan="3"> - <widget class="QGroupBox" name="includeHintsGroupBox"> + <item row="4" column="0" colspan="2"> + <widget class="QGroupBox" name="connectionsGroupBox"> <property name="title"> - <string>&Include Hints</string> + <string>Connections</string> </property> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>8</number> - </property> - <item> - <widget class="QTextEdit" name="includeHintsTextEdit"/> - </item> - </layout> - </widget> - </item> - <item row="2" column="0" colspan="2"> - <widget class="qdesigner_internal::GridPanel" name="gridPanel"> - <property name="title"> - <string>Grid</string> - </property> - </widget> - </item> - <item row="0" column="0" colspan="2"> - <widget class="QGroupBox" name="embeddedGroupBox"> - <property name="title"> - <string>Embedded Design</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="deviceProfileLabel"> - <property name="text"> - <string notr="true">TextLabel</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QGroupBox" name="pixmapFunctionGroupBox_2"> - <property name="title"> - <string>&Author</string> - </property> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>8</number> - </property> - <item> - <widget class="QLineEdit" name="authorLineEdit"/> - </item> - </layout> - </widget> - </item> - <item row="5" column="1"> - <widget class="QGroupBox" name="translationsGroupBox"> - <property name="title"> - <string>Translations</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> + <layout class="QVBoxLayout" name="verticalLayout_3"> <item> - <widget class="QCheckBox" name="idBasedTranslationsCheckBox"> + <widget class="QCheckBox" name="connectSlotsByNameCheckBox"> <property name="text"> - <string>ID-based</string> + <string>Connect slots by name</string> </property> </widget> </item> </layout> </widget> </item> - <item row="6" column="1"> - <spacer> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>111</width> - <height>115</height> - </size> - </property> - </spacer> - </item> </layout> </widget> <customwidgets> diff --git a/src/designer/src/components/formeditor/qdesigner_resource.cpp b/src/designer/src/components/formeditor/qdesigner_resource.cpp index 4b747d04c..dd1144d7c 100644 --- a/src/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/src/designer/src/components/formeditor/qdesigner_resource.cpp @@ -512,6 +512,8 @@ void QDesignerResource::saveDom(DomUI *ui, QWidget *widget) if (m_formWindow->useIdBasedTranslations()) ui->setAttributeIdbasedtr(true); + if (!m_formWindow->connectSlotsByName()) // Don't write out if true (default) + ui->setAttributeConnectslotsbyname(false); const QVariantMap designerFormData = m_formWindow->formData(); if (!designerFormData.empty()) { @@ -646,8 +648,12 @@ QWidget *QDesignerResource::create(DomUI *ui, QWidget *parentWidget) QDesignerWidgetItemInstaller wii; // Make sure we use QDesignerWidgetItem. QWidget *mainWidget = QAbstractFormBuilder::create(ui, parentWidget); - if (m_formWindow) + if (m_formWindow) { m_formWindow->setUseIdBasedTranslations(ui->attributeIdbasedtr()); + // Default to true unless set. + const bool connectSlotsByName = !ui->hasAttributeConnectslotsbyname() || ui->attributeConnectslotsbyname(); + m_formWindow->setConnectSlotsByName(connectSlotsByName); + } if (mainWidget && m_formWindow) { m_formWindow->setAuthor(ui->elementAuthor()); diff --git a/src/designer/src/lib/shared/formwindowbase.cpp b/src/designer/src/lib/shared/formwindowbase.cpp index ab3fcfbb0..8c35ea700 100644 --- a/src/designer/src/lib/shared/formwindowbase.cpp +++ b/src/designer/src/lib/shared/formwindowbase.cpp @@ -84,6 +84,7 @@ public: FormWindowBase::LineTerminatorMode m_lineTerminatorMode; FormWindowBase::ResourceFileSaveMode m_saveResourcesBehaviour; bool m_useIdBasedTranslations; + bool m_connectSlotsByName; }; FormWindowBasePrivate::FormWindowBasePrivate(QDesignerFormEditorInterface *core) : @@ -96,7 +97,8 @@ FormWindowBasePrivate::FormWindowBasePrivate(QDesignerFormEditorInterface *core) m_deviceProfile(QDesignerSharedSettings(core).currentDeviceProfile()), m_lineTerminatorMode(FormWindowBase::NativeLineTerminator), m_saveResourcesBehaviour(FormWindowBase::SaveAllResourceFiles), - m_useIdBasedTranslations(false) + m_useIdBasedTranslations(false), + m_connectSlotsByName(true) { } @@ -537,6 +539,16 @@ void FormWindowBase::setUseIdBasedTranslations(bool v) m_d->m_useIdBasedTranslations = v; } +bool FormWindowBase::connectSlotsByName() const +{ + return m_d->m_connectSlotsByName; +} + +void FormWindowBase::setConnectSlotsByName(bool v) +{ + m_d->m_connectSlotsByName = v; +} + QStringList FormWindowBase::checkContents() const { if (!mainContainer()) diff --git a/src/designer/src/lib/shared/formwindowbase_p.h b/src/designer/src/lib/shared/formwindowbase_p.h index b1e8a2f40..b240aa521 100644 --- a/src/designer/src/lib/shared/formwindowbase_p.h +++ b/src/designer/src/lib/shared/formwindowbase_p.h @@ -165,6 +165,9 @@ public: bool useIdBasedTranslations() const; void setUseIdBasedTranslations(bool v); + bool connectSlotsByName() const; + void setConnectSlotsByName(bool v); + public slots: void resourceSetActivated(QtResourceSet *resourceSet, bool resourceSetChanged); diff --git a/src/designer/src/lib/uilib/ui4.cpp b/src/designer/src/lib/uilib/ui4.cpp index 4afa1dce5..879426b0d 100644 --- a/src/designer/src/lib/uilib/ui4.cpp +++ b/src/designer/src/lib/uilib/ui4.cpp @@ -98,6 +98,10 @@ void DomUI::read(QXmlStreamReader &reader) setAttributeIdbasedtr(attribute.value() == QLatin1String("true")); continue; } + if (name == QLatin1String("connectslotsbyname")) { + setAttributeConnectslotsbyname(attribute.value() == QLatin1String("true")); + continue; + } if (name == QLatin1String("stdsetdef")) { setAttributeStdsetdef(attribute.value().toInt()); continue; @@ -231,6 +235,9 @@ void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const if (hasAttributeIdbasedtr()) writer.writeAttribute(QStringLiteral("idbasedtr"), (attributeIdbasedtr() ? QLatin1String("true") : QLatin1String("false"))); + if (hasAttributeConnectslotsbyname()) + writer.writeAttribute(QStringLiteral("connectslotsbyname"), (attributeConnectslotsbyname() ? QLatin1String("true") : QLatin1String("false"))); + if (hasAttributeStdsetdef()) writer.writeAttribute(QStringLiteral("stdsetdef"), QString::number(attributeStdsetdef())); diff --git a/src/designer/src/lib/uilib/ui4_p.h b/src/designer/src/lib/uilib/ui4_p.h index d1ed64b61..cbd5120c0 100644 --- a/src/designer/src/lib/uilib/ui4_p.h +++ b/src/designer/src/lib/uilib/ui4_p.h @@ -191,6 +191,11 @@ public: inline void setAttributeIdbasedtr(bool a) { m_attr_idbasedtr = a; m_has_attr_idbasedtr = true; } inline void clearAttributeIdbasedtr() { m_has_attr_idbasedtr = false; } + inline bool hasAttributeConnectslotsbyname() const { return m_has_attr_connectslotsbyname; } + inline bool attributeConnectslotsbyname() const { return m_attr_connectslotsbyname; } + inline void setAttributeConnectslotsbyname(bool a) { m_attr_connectslotsbyname = a; m_has_attr_connectslotsbyname = true; } + inline void clearAttributeConnectslotsbyname() { m_has_attr_connectslotsbyname = false; } + inline bool hasAttributeStdsetdef() const { return m_has_attr_stdsetdef; } inline int attributeStdsetdef() const { return m_attr_stdsetdef; } inline void setAttributeStdsetdef(int a) { m_attr_stdsetdef = a; m_has_attr_stdsetdef = true; } @@ -307,6 +312,9 @@ private: bool m_attr_idbasedtr = false; bool m_has_attr_idbasedtr = false; + bool m_attr_connectslotsbyname = false; + bool m_has_attr_connectslotsbyname = false; + int m_attr_stdsetdef = 0; bool m_has_attr_stdsetdef = false; |