Commit fa281be8 authored by Leandro Melo's avatar Leandro Melo Committed by hjk

Editor: New option for surrounding auto brackets

Notice that this option already existed in the auto completer. However,
from the user perspective it was synchronized with auto insert brackets.

Task-number: QTCREATORBUG-5835
Change-Id: Ia87a2ca38d89dba51380a4fdb58a5a3689ed9265
Reviewed-on: http://codereview.qt-project.org/4885Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 05ceaa45
......@@ -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();
......
......@@ -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>&amp;Automatically insert brackets</string>
<string>Autocomplete common &amp;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 &amp;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 &amp;prefix</string>
<string>&amp;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 &amp;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 &amp;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>
......
......@@ -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)
......
......@@ -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
;
......
......@@ -69,6 +69,7 @@ public:
CaseSensitivity m_caseSensitivity;
CompletionTrigger m_completionTrigger;
bool m_autoInsertBrackets;
bool m_surroundingAutoBrackets;
bool m_partiallyComplete;
bool m_spaceAfterFunctionName;
};
......
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