diff --git a/src/plugins/cpptools/completionsettingspage.cpp b/src/plugins/cpptools/completionsettingspage.cpp index 17e2b42f8a3a1affc5ba8f359e1150b43c877262..9ae1b077b9296da792756ca2f549f0d08a7f1169 100644 --- a/src/plugins/cpptools/completionsettingspage.cpp +++ b/src/plugins/cpptools/completionsettingspage.cpp @@ -100,12 +100,14 @@ QWidget *CompletionSettingsPage::createPage(QWidget *parent) m_page->caseSensitivity->setCurrentIndex(caseSensitivityIndex); m_page->completionTrigger->setCurrentIndex(completionTriggerIndex); m_page->autoInsertBrackets->setChecked(settings.m_autoInsertBrackets); + m_page->surroundSelectedText->setChecked(settings.m_surroundingAutoBrackets); m_page->partiallyComplete->setChecked(settings.m_partiallyComplete); m_page->spaceAfterFunctionName->setChecked(settings.m_spaceAfterFunctionName); if (m_searchKeywords.isEmpty()) { QTextStream(&m_searchKeywords) << m_page->caseSensitivityLabel->text() << ' ' << m_page->autoInsertBrackets->text() + << ' ' << m_page->surroundSelectedText->text() << ' ' << m_page->completionTriggerLabel->text() << ' ' << m_page->partiallyComplete->text() << ' ' << m_page->spaceAfterFunctionName->text(); @@ -123,6 +125,7 @@ void CompletionSettingsPage::apply() settings.m_caseSensitivity = caseSensitivity(); settings.m_completionTrigger = completionTrigger(); settings.m_autoInsertBrackets = m_page->autoInsertBrackets->isChecked(); + settings.m_surroundingAutoBrackets = m_page->surroundSelectedText->isChecked(); settings.m_partiallyComplete = m_page->partiallyComplete->isChecked(); settings.m_spaceAfterFunctionName = m_page->spaceAfterFunctionName->isChecked(); diff --git a/src/plugins/cpptools/completionsettingspage.ui b/src/plugins/cpptools/completionsettingspage.ui index 8570db4d0d178272ec0a373aa9cd4678e86d8e96..7c2e2eff606479fb140b5d32772916b885872072 100644 --- a/src/plugins/cpptools/completionsettingspage.ui +++ b/src/plugins/cpptools/completionsettingspage.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>359</width> - <height>244</height> + <width>363</width> + <height>241</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout"> @@ -27,7 +27,7 @@ </property> </widget> </item> - <item row="0" column="2"> + <item row="0" column="1"> <widget class="QComboBox" name="caseSensitivity"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> @@ -52,7 +52,7 @@ </item> </widget> </item> - <item row="0" column="3" colspan="2"> + <item row="0" column="2" colspan="2"> <spacer name="horizontalSpacer"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -65,14 +65,14 @@ </property> </spacer> </item> - <item row="1" column="0" colspan="2"> + <item row="1" column="0"> <widget class="QLabel" name="completionTriggerLabel"> <property name="text"> <string>Activate completion:</string> </property> </widget> </item> - <item row="1" column="2" colspan="2"> + <item row="1" column="1" colspan="2"> <widget class="QComboBox" name="completionTrigger"> <item> <property name="text"> @@ -91,7 +91,7 @@ </item> </widget> </item> - <item row="1" column="4"> + <item row="1" column="3"> <spacer name="horizontalSpacer_3"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -104,42 +104,95 @@ </property> </spacer> </item> - <item row="3" column="0" colspan="3"> - <widget class="QCheckBox" name="autoInsertBrackets"> + <item row="2" column="0"> + <widget class="QCheckBox" name="partiallyComplete"> <property name="toolTip"> - <string>Automatically insert brackets and semicolons when appropriate.</string> + <string>Insert the common prefix of available completion items.</string> </property> <property name="text"> - <string>&Automatically insert brackets</string> + <string>Autocomplete common &prefix</string> </property> <property name="checked"> <bool>true</bool> </property> </widget> </item> - <item row="5" column="0" colspan="3"> - <widget class="QCheckBox" name="spaceAfterFunctionName"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="text"> - <string>Insert &space after function name</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QCheckBox" name="partiallyComplete"> + <item row="3" column="0"> + <widget class="QCheckBox" name="autoInsertBrackets"> <property name="toolTip"> - <string>Insert the common prefix of available completion items.</string> + <string>Automatically insert brackets and semicolons when appropriate.</string> </property> <property name="text"> - <string>Autocomplete common &prefix</string> + <string>&Automatically insert brackets</string> </property> <property name="checked"> <bool>true</bool> </property> </widget> </item> + <item row="4" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>30</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QCheckBox" name="surroundSelectedText"> + <property name="toolTip"> + <string>Automatically surround text selections with brackets.</string> + </property> + <property name="text"> + <string>Surround selected &text</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="5" column="0" colspan="2"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <spacer name="horizontalSpacer_4"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>30</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QCheckBox" name="spaceAfterFunctionName"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Insert &space after function name</string> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> </item> @@ -167,12 +220,28 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>248</x> - <y>132</y> + <x>267</x> + <y>131</y> + </hint> + <hint type="destinationlabel"> + <x>265</x> + <y>182</y> + </hint> + </hints> + </connection> + <connection> + <sender>autoInsertBrackets</sender> + <signal>toggled(bool)</signal> + <receiver>surroundSelectedText</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>109</x> + <y>123</y> </hint> <hint type="destinationlabel"> - <x>246</x> - <y>164</y> + <x>119</x> + <y>156</y> </hint> </hints> </connection> diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 03c0b963441274570304efe3416f7dd90734e202..913d4112761937ba9671fe19ea86843237692c04 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -5536,7 +5536,8 @@ void BaseTextEditorWidget::setStorageSettings(const StorageSettings &storageSett void BaseTextEditorWidget::setCompletionSettings(const TextEditor::CompletionSettings &completionSettings) { d->m_autoCompleter->setAutoParenthesesEnabled(completionSettings.m_autoInsertBrackets); - d->m_autoCompleter->setSurroundWithEnabled(completionSettings.m_autoInsertBrackets); + d->m_autoCompleter->setSurroundWithEnabled(completionSettings.m_autoInsertBrackets + && completionSettings.m_surroundingAutoBrackets); } void BaseTextEditorWidget::setExtraEncodingSettings(const ExtraEncodingSettings &extraEncodingSettings) diff --git a/src/plugins/texteditor/completionsettings.cpp b/src/plugins/texteditor/completionsettings.cpp index d72bd1acf8ad56e8c4a9f2da1cf66d9d5a202d1d..d96f338c37258ffc16f0a039da11d13e562b67da 100644 --- a/src/plugins/texteditor/completionsettings.cpp +++ b/src/plugins/texteditor/completionsettings.cpp @@ -38,6 +38,7 @@ static const char groupPostfix[] = "Completion"; static const char caseSensitivityKey[] = "CaseSensitivity"; static const char completionTriggerKey[] = "CompletionTrigger"; static const char autoInsertBracesKey[] = "AutoInsertBraces"; +static const char surroundingAutoBracketsKey[] = "SurroundingAutoBrackets"; static const char partiallyCompleteKey[] = "PartiallyComplete"; static const char spaceAfterFunctionNameKey[] = "SpaceAfterFunctionName"; @@ -47,6 +48,7 @@ CompletionSettings::CompletionSettings() : m_caseSensitivity(CaseInsensitive) , m_completionTrigger(AutomaticCompletion) , m_autoInsertBrackets(true) + , m_surroundingAutoBrackets(true) , m_partiallyComplete(true) , m_spaceAfterFunctionName(false) { @@ -62,6 +64,7 @@ void CompletionSettings::toSettings(const QString &category, QSettings *s) const s->setValue(QLatin1String(caseSensitivityKey), (int) m_caseSensitivity); s->setValue(QLatin1String(completionTriggerKey), (int) m_completionTrigger); s->setValue(QLatin1String(autoInsertBracesKey), m_autoInsertBrackets); + s->setValue(QLatin1String(surroundingAutoBracketsKey), m_surroundingAutoBrackets); s->setValue(QLatin1String(partiallyCompleteKey), m_partiallyComplete); s->setValue(QLatin1String(spaceAfterFunctionNameKey), m_spaceAfterFunctionName); s->endGroup(); @@ -79,6 +82,7 @@ void CompletionSettings::fromSettings(const QString &category, const QSettings * m_caseSensitivity = (CaseSensitivity) s->value(group + QLatin1String(caseSensitivityKey), m_caseSensitivity).toInt(); m_completionTrigger = (CompletionTrigger) s->value(group + QLatin1String(completionTriggerKey), m_completionTrigger).toInt(); m_autoInsertBrackets = s->value(group + QLatin1String(autoInsertBracesKey), m_autoInsertBrackets).toBool(); + m_surroundingAutoBrackets = s->value(group + QLatin1String(surroundingAutoBracketsKey), m_surroundingAutoBrackets).toBool(); m_partiallyComplete = s->value(group + QLatin1String(partiallyCompleteKey), m_partiallyComplete).toBool(); m_spaceAfterFunctionName = s->value(group + QLatin1String(spaceAfterFunctionNameKey), m_spaceAfterFunctionName).toBool(); } @@ -88,6 +92,7 @@ bool CompletionSettings::equals(const CompletionSettings &cs) const return m_caseSensitivity == cs.m_caseSensitivity && m_completionTrigger == cs.m_completionTrigger && m_autoInsertBrackets == cs.m_autoInsertBrackets + && m_surroundingAutoBrackets == cs.m_surroundingAutoBrackets && m_partiallyComplete == cs.m_partiallyComplete && m_spaceAfterFunctionName == cs.m_spaceAfterFunctionName ; diff --git a/src/plugins/texteditor/completionsettings.h b/src/plugins/texteditor/completionsettings.h index 16c2d03a7142e22f95395faa1b7f2f32292a141d..b3d8ace7b08d139d14d771d21dedc39a487c4b0a 100644 --- a/src/plugins/texteditor/completionsettings.h +++ b/src/plugins/texteditor/completionsettings.h @@ -69,6 +69,7 @@ public: CaseSensitivity m_caseSensitivity; CompletionTrigger m_completionTrigger; bool m_autoInsertBrackets; + bool m_surroundingAutoBrackets; bool m_partiallyComplete; bool m_spaceAfterFunctionName; };