Add a checkbox for 'auto-determine spaces or tabs from the previous line'

Merge-request: 1766
Reviewed-by: Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
This commit is contained in:
Roopesh Chander
2009-10-04 00:26:21 +05:30
committed by Thorbjørn Lindeijer
parent 2a58049e6a
commit ea13309b9a
3 changed files with 101 additions and 47 deletions

View File

@@ -159,6 +159,7 @@ void BehaviorSettingsPage::settingsFromUI(TabSettings &tabSettings,
BehaviorSettings &behaviorSettings) const
{
tabSettings.m_spacesForTabs = m_d->m_page.insertSpaces->isChecked();
tabSettings.m_autoSpacesForTabs = m_d->m_page.autoInsertSpaces->isChecked();
tabSettings.m_autoIndent = m_d->m_page.autoIndent->isChecked();
tabSettings.m_smartBackspace = m_d->m_page.smartBackspace->isChecked();
tabSettings.m_tabSize = m_d->m_page.tabSize->value();
@@ -179,6 +180,7 @@ void BehaviorSettingsPage::settingsToUI()
{
const TabSettings &tabSettings = m_d->m_tabSettings;
m_d->m_page.insertSpaces->setChecked(tabSettings.m_spacesForTabs);
m_d->m_page.autoInsertSpaces->setChecked(tabSettings.m_autoSpacesForTabs);
m_d->m_page.autoIndent->setChecked(tabSettings.m_autoIndent);
m_d->m_page.smartBackspace->setChecked(tabSettings.m_smartBackspace);
m_d->m_page.tabSize->setValue(tabSettings.m_tabSize);

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>615</width>
<height>421</height>
<height>461</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
@@ -27,13 +27,46 @@
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_5">
<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="autoInsertSpaces">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Automatically determine whether to insert spaces or tabs based on the previous line in the file</string>
</property>
<property name="text">
<string>Based on the previous line</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="autoIndent">
<property name="text">
<string>Enable automatic &amp;indentation</string>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QCheckBox" name="smartBackspace">
<property name="toolTip">
<string>Backspace will go back one indentation level instead of one space.</string>
@@ -75,6 +108,42 @@
</property>
</widget>
</item>
<item row="0" column="1" rowspan="5">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="4" rowspan="4">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="indentBraces">
<property name="toolTip">
<string>Braces will be flush with indented block, except first indent level.</string>
</property>
<property name="text">
<string>Indent brace&amp;s</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="labelIndentSize">
<property name="sizePolicy">
@@ -107,42 +176,6 @@
</property>
</widget>
</item>
<item row="0" column="1" rowspan="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="4" rowspan="4">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="indentBraces">
<property name="toolTip">
<string>Braces will be flush with indented block, except first indent level.</string>
</property>
<property name="text">
<string>Indent brace&amp;s</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
@@ -328,7 +361,6 @@
<tabstop>insertSpaces</tabstop>
<tabstop>tabSize</tabstop>
<tabstop>autoIndent</tabstop>
<tabstop>indentSize</tabstop>
<tabstop>smartBackspace</tabstop>
<tabstop>tabKeyBehavior</tabstop>
<tabstop>cleanWhitespace</tabstop>
@@ -345,12 +377,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>47</x>
<y>184</y>
<x>67</x>
<y>252</y>
</hint>
<hint type="destinationlabel">
<x>91</x>
<y>212</y>
<x>148</x>
<y>281</y>
</hint>
</hints>
</connection>
@@ -361,12 +393,28 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
<x>40</x>
<y>251</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
<x>77</x>
<y>310</y>
</hint>
</hints>
</connection>
<connection>
<sender>insertSpaces</sender>
<signal>toggled(bool)</signal>
<receiver>autoInsertSpaces</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>105</x>
<y>49</y>
</hint>
<hint type="destinationlabel">
<x>105</x>
<y>78</y>
</hint>
</hints>
</connection>

View File

@@ -36,6 +36,7 @@
#include <QtGui/QTextDocument>
static const char *spacesForTabsKey = "SpacesForTabs";
static const char *autoSpacesForTabsKey = "AutoSpacesForTabs";
static const char *smartBackspaceKey = "SmartBackspace";
static const char *autoIndentKey = "AutoIndent";
static const char *tabSizeKey = "TabSize";
@@ -65,6 +66,7 @@ void TabSettings::toSettings(const QString &category, QSettings *s) const
group.insert(0, category);
s->beginGroup(group);
s->setValue(QLatin1String(spacesForTabsKey), m_spacesForTabs);
s->setValue(QLatin1String(autoSpacesForTabsKey), m_autoSpacesForTabs);
s->setValue(QLatin1String(autoIndentKey), m_autoIndent);
s->setValue(QLatin1String(smartBackspaceKey), m_smartBackspace);
s->setValue(QLatin1String(tabSizeKey), m_tabSize);
@@ -84,6 +86,7 @@ void TabSettings::fromSettings(const QString &category, const QSettings *s)
*this = TabSettings(); // Assign defaults
m_spacesForTabs = s->value(group + QLatin1String(spacesForTabsKey), m_spacesForTabs).toBool();
m_autoSpacesForTabs = s->value(group + QLatin1String(autoSpacesForTabsKey), m_autoSpacesForTabs).toBool();
m_autoIndent = s->value(group + QLatin1String(autoIndentKey), m_autoIndent).toBool();
m_smartBackspace = s->value(group + QLatin1String(smartBackspaceKey), m_smartBackspace).toBool();
m_tabSize = s->value(group + QLatin1String(tabSizeKey), m_tabSize).toInt();
@@ -316,6 +319,7 @@ void TabSettings::reindentLine(QTextBlock block, int delta) const
bool TabSettings::equals(const TabSettings &ts) const
{
return m_spacesForTabs == ts.m_spacesForTabs
&& m_autoSpacesForTabs == ts.m_autoSpacesForTabs
&& m_autoIndent == ts.m_autoIndent
&& m_smartBackspace == ts.m_smartBackspace
&& m_tabSize == ts.m_tabSize