forked from qt-creator/qt-creator
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:
committed by
Thorbjørn Lindeijer
parent
2a58049e6a
commit
ea13309b9a
@@ -159,6 +159,7 @@ void BehaviorSettingsPage::settingsFromUI(TabSettings &tabSettings,
|
|||||||
BehaviorSettings &behaviorSettings) const
|
BehaviorSettings &behaviorSettings) const
|
||||||
{
|
{
|
||||||
tabSettings.m_spacesForTabs = m_d->m_page.insertSpaces->isChecked();
|
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_autoIndent = m_d->m_page.autoIndent->isChecked();
|
||||||
tabSettings.m_smartBackspace = m_d->m_page.smartBackspace->isChecked();
|
tabSettings.m_smartBackspace = m_d->m_page.smartBackspace->isChecked();
|
||||||
tabSettings.m_tabSize = m_d->m_page.tabSize->value();
|
tabSettings.m_tabSize = m_d->m_page.tabSize->value();
|
||||||
@@ -179,6 +180,7 @@ void BehaviorSettingsPage::settingsToUI()
|
|||||||
{
|
{
|
||||||
const TabSettings &tabSettings = m_d->m_tabSettings;
|
const TabSettings &tabSettings = m_d->m_tabSettings;
|
||||||
m_d->m_page.insertSpaces->setChecked(tabSettings.m_spacesForTabs);
|
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.autoIndent->setChecked(tabSettings.m_autoIndent);
|
||||||
m_d->m_page.smartBackspace->setChecked(tabSettings.m_smartBackspace);
|
m_d->m_page.smartBackspace->setChecked(tabSettings.m_smartBackspace);
|
||||||
m_d->m_page.tabSize->setValue(tabSettings.m_tabSize);
|
m_d->m_page.tabSize->setValue(tabSettings.m_tabSize);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>615</width>
|
<width>615</width>
|
||||||
<height>421</height>
|
<height>461</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
@@ -27,13 +27,46 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<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">
|
<widget class="QCheckBox" name="autoIndent">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable automatic &indentation</string>
|
<string>Enable automatic &indentation</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QCheckBox" name="smartBackspace">
|
<widget class="QCheckBox" name="smartBackspace">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Backspace will go back one indentation level instead of one space.</string>
|
<string>Backspace will go back one indentation level instead of one space.</string>
|
||||||
@@ -75,6 +108,42 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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&s</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="QLabel" name="labelIndentSize">
|
<widget class="QLabel" name="labelIndentSize">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -107,42 +176,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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&s</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -328,7 +361,6 @@
|
|||||||
<tabstop>insertSpaces</tabstop>
|
<tabstop>insertSpaces</tabstop>
|
||||||
<tabstop>tabSize</tabstop>
|
<tabstop>tabSize</tabstop>
|
||||||
<tabstop>autoIndent</tabstop>
|
<tabstop>autoIndent</tabstop>
|
||||||
<tabstop>indentSize</tabstop>
|
|
||||||
<tabstop>smartBackspace</tabstop>
|
<tabstop>smartBackspace</tabstop>
|
||||||
<tabstop>tabKeyBehavior</tabstop>
|
<tabstop>tabKeyBehavior</tabstop>
|
||||||
<tabstop>cleanWhitespace</tabstop>
|
<tabstop>cleanWhitespace</tabstop>
|
||||||
@@ -345,12 +377,12 @@
|
|||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>47</x>
|
<x>67</x>
|
||||||
<y>184</y>
|
<y>252</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>91</x>
|
<x>148</x>
|
||||||
<y>212</y>
|
<y>281</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
@@ -361,12 +393,28 @@
|
|||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>20</x>
|
<x>40</x>
|
||||||
<y>20</y>
|
<y>251</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>20</x>
|
<x>77</x>
|
||||||
<y>20</y>
|
<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>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include <QtGui/QTextDocument>
|
#include <QtGui/QTextDocument>
|
||||||
|
|
||||||
static const char *spacesForTabsKey = "SpacesForTabs";
|
static const char *spacesForTabsKey = "SpacesForTabs";
|
||||||
|
static const char *autoSpacesForTabsKey = "AutoSpacesForTabs";
|
||||||
static const char *smartBackspaceKey = "SmartBackspace";
|
static const char *smartBackspaceKey = "SmartBackspace";
|
||||||
static const char *autoIndentKey = "AutoIndent";
|
static const char *autoIndentKey = "AutoIndent";
|
||||||
static const char *tabSizeKey = "TabSize";
|
static const char *tabSizeKey = "TabSize";
|
||||||
@@ -65,6 +66,7 @@ void TabSettings::toSettings(const QString &category, QSettings *s) const
|
|||||||
group.insert(0, category);
|
group.insert(0, category);
|
||||||
s->beginGroup(group);
|
s->beginGroup(group);
|
||||||
s->setValue(QLatin1String(spacesForTabsKey), m_spacesForTabs);
|
s->setValue(QLatin1String(spacesForTabsKey), m_spacesForTabs);
|
||||||
|
s->setValue(QLatin1String(autoSpacesForTabsKey), m_autoSpacesForTabs);
|
||||||
s->setValue(QLatin1String(autoIndentKey), m_autoIndent);
|
s->setValue(QLatin1String(autoIndentKey), m_autoIndent);
|
||||||
s->setValue(QLatin1String(smartBackspaceKey), m_smartBackspace);
|
s->setValue(QLatin1String(smartBackspaceKey), m_smartBackspace);
|
||||||
s->setValue(QLatin1String(tabSizeKey), m_tabSize);
|
s->setValue(QLatin1String(tabSizeKey), m_tabSize);
|
||||||
@@ -84,6 +86,7 @@ void TabSettings::fromSettings(const QString &category, const QSettings *s)
|
|||||||
*this = TabSettings(); // Assign defaults
|
*this = TabSettings(); // Assign defaults
|
||||||
|
|
||||||
m_spacesForTabs = s->value(group + QLatin1String(spacesForTabsKey), m_spacesForTabs).toBool();
|
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_autoIndent = s->value(group + QLatin1String(autoIndentKey), m_autoIndent).toBool();
|
||||||
m_smartBackspace = s->value(group + QLatin1String(smartBackspaceKey), m_smartBackspace).toBool();
|
m_smartBackspace = s->value(group + QLatin1String(smartBackspaceKey), m_smartBackspace).toBool();
|
||||||
m_tabSize = s->value(group + QLatin1String(tabSizeKey), m_tabSize).toInt();
|
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
|
bool TabSettings::equals(const TabSettings &ts) const
|
||||||
{
|
{
|
||||||
return m_spacesForTabs == ts.m_spacesForTabs
|
return m_spacesForTabs == ts.m_spacesForTabs
|
||||||
|
&& m_autoSpacesForTabs == ts.m_autoSpacesForTabs
|
||||||
&& m_autoIndent == ts.m_autoIndent
|
&& m_autoIndent == ts.m_autoIndent
|
||||||
&& m_smartBackspace == ts.m_smartBackspace
|
&& m_smartBackspace == ts.m_smartBackspace
|
||||||
&& m_tabSize == ts.m_tabSize
|
&& m_tabSize == ts.m_tabSize
|
||||||
|
|||||||
Reference in New Issue
Block a user