Fix layout of the code style settings editor

Fixes: QTCREATORBUG-23227
Change-Id: I1ae650ba1e66c9444ef0d7fe17d003e5d6662b77
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2019-11-01 12:06:43 +01:00
parent 4a00f53c17
commit f6659f24df
7 changed files with 186 additions and 262 deletions

View File

@@ -161,8 +161,6 @@ CppCodeStylePreferencesWidget::CppCodeStylePreferencesWidget(QWidget *parent)
this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged); this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged);
m_ui->categoryTab->setCurrentIndex(0); m_ui->categoryTab->setCurrentIndex(0);
m_ui->tabSettingsWidget->setFlat(true);
} }
CppCodeStylePreferencesWidget::~CppCodeStylePreferencesWidget() CppCodeStylePreferencesWidget::~CppCodeStylePreferencesWidget()

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>463</width> <width>463</width>
<height>314</height> <height>317</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -69,19 +69,7 @@
<property name="title"> <property name="title">
<string>Indent</string> <string>Indent</string>
</property> </property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QCheckBox" name="indentAccessSpecifiers"> <widget class="QCheckBox" name="indentAccessSpecifiers">
<property name="text"> <property name="text">
@@ -155,19 +143,7 @@
<property name="title"> <property name="title">
<string>Indent Braces</string> <string>Indent Braces</string>
</property> </property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QCheckBox" name="indentClassBraces"> <widget class="QCheckBox" name="indentClassBraces">
<property name="text"> <property name="text">
@@ -238,19 +214,7 @@
<property name="title"> <property name="title">
<string>Indent within &quot;switch&quot;</string> <string>Indent within &quot;switch&quot;</string>
</property> </property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QCheckBox" name="indentSwitchLabels"> <widget class="QCheckBox" name="indentSwitchLabels">
<property name="text"> <property name="text">
@@ -317,19 +281,7 @@
<property name="title"> <property name="title">
<string>Align</string> <string>Align</string>
</property> </property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QCheckBox" name="alignAssignments"> <widget class="QCheckBox" name="alignAssignments">
<property name="toolTip"> <property name="toolTip">
@@ -414,9 +366,6 @@ if they would align to the next line</string>
<property name="title"> <property name="title">
<string>Bind '*' and '&amp;&amp;' in types/declarations to</string> <string>Bind '*' and '&amp;&amp;' in types/declarations to</string>
</property> </property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_6">
<item> <item>
<widget class="QCheckBox" name="bindStarToIdentifier"> <widget class="QCheckBox" name="bindStarToIdentifier">

View File

@@ -89,11 +89,6 @@ void SimpleCodeStylePreferencesWidget::slotTabSettingsChanged(const TextEditor::
current->setTabSettings(settings); current->setTabSettings(settings);
} }
void SimpleCodeStylePreferencesWidget::setFlat(bool on)
{
m_tabSettingsWidget->setFlat(on);
}
TabSettingsWidget *SimpleCodeStylePreferencesWidget::tabSettingsWidget() const TabSettingsWidget *SimpleCodeStylePreferencesWidget::tabSettingsWidget() const
{ {
return m_tabSettingsWidget; return m_tabSettingsWidget;

View File

@@ -46,7 +46,6 @@ public:
void setPreferences(ICodeStylePreferences *tabPreferences); void setPreferences(ICodeStylePreferences *tabPreferences);
void setFlat(bool on);
TabSettingsWidget *tabSettingsWidget() const; TabSettingsWidget *tabSettingsWidget() const;
private: private:

View File

@@ -32,7 +32,7 @@
namespace TextEditor { namespace TextEditor {
TabSettingsWidget::TabSettingsWidget(QWidget *parent) : TabSettingsWidget::TabSettingsWidget(QWidget *parent) :
QWidget(parent), QGroupBox(parent),
ui(new Internal::Ui::TabSettingsWidget) ui(new Internal::Ui::TabSettingsWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -91,13 +91,6 @@ void TabSettingsWidget::codingStyleLinkActivated(const QString &linkString)
emit codingStyleLinkClicked(QtQuickLink); emit codingStyleLinkClicked(QtQuickLink);
} }
void TabSettingsWidget::setFlat(bool on)
{
ui->tabsAndIndentationGroupBox->setFlat(on);
const int margin = on ? 0 : -1;
ui->tabsAndIndentationGroupBox->layout()->setContentsMargins(margin, -1, margin, margin);
}
void TabSettingsWidget::setCodingStyleWarningVisible(bool visible) void TabSettingsWidget::setCodingStyleWarningVisible(bool visible)
{ {
ui->codingStyleWarning->setVisible(visible); ui->codingStyleWarning->setVisible(visible);

View File

@@ -27,7 +27,7 @@
#include "texteditor_global.h" #include "texteditor_global.h"
#include <QWidget> #include <QGroupBox>
namespace TextEditor { namespace TextEditor {
@@ -35,7 +35,7 @@ namespace Internal { namespace Ui { class TabSettingsWidget; } }
class TabSettings; class TabSettings;
class TEXTEDITOR_EXPORT TabSettingsWidget : public QWidget class TEXTEDITOR_EXPORT TabSettingsWidget : public QGroupBox
{ {
Q_OBJECT Q_OBJECT
@@ -50,7 +50,6 @@ public:
TabSettings tabSettings() const; TabSettings tabSettings() const;
void setFlat(bool on);
void setCodingStyleWarningVisible(bool visible); void setCodingStyleWarningVisible(bool visible);
void setTabSettings(const TextEditor::TabSettings& s); void setTabSettings(const TextEditor::TabSettings& s);

View File

@@ -1,160 +1,181 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>TextEditor::Internal::TabSettingsWidget</class> <class>TextEditor::Internal::TabSettingsWidget</class>
<widget class="QWidget" name="TextEditor::Internal::TabSettingsWidget"> <widget class="QGroupBox" name="TextEditor::Internal::TabSettingsWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>335</width> <width>254</width>
<height>224</height> <height>189</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string/> <string notr="true"/>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <property name="title">
<property name="margin"> <string>Tabs And Indentation</string>
<number>0</number> </property>
</property> <layout class="QGridLayout" name="gridLayout">
<item> <item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="tabsAndIndentationGroupBox"> <widget class="QLabel" name="codingStyleWarning">
<property name="title"> <property name="toolTip">
<string>Tabs And Indentation</string> <string>The text editor indentation setting is used for non-code files only. See the C++ and Qt Quick coding style settings to configure indentation for code files.</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <property name="text">
<item row="2" column="0"> <string>&lt;i&gt;Code indentation is configured in &lt;a href=&quot;C++&quot;&gt;C++&lt;/a&gt; and &lt;a href=&quot;QtQuick&quot;&gt;Qt Quick&lt;/a&gt; settings.&lt;/i&gt;</string>
<spacer name="horizontalSpacer"> </property>
<property name="orientation"> <property name="wordWrap">
<enum>Qt::Horizontal</enum> <bool>true</bool>
</property> </property>
<property name="sizeType"> </widget>
<enum>QSizePolicy::Fixed</enum> </item>
</property> <item row="1" column="0" colspan="2">
<property name="sizeHint" stdset="0"> <widget class="QLabel" name="tabPolicyLabel">
<size> <property name="text">
<width>30</width> <string>Tab policy:</string>
<height>20</height> </property>
</size> </widget>
</property> </item>
</spacer> <item row="2" column="0">
</item> <spacer name="horizontalSpacer">
<item row="2" column="1"> <property name="orientation">
<widget class="QComboBox" name="tabPolicy"> <enum>Qt::Horizontal</enum>
<property name="sizePolicy"> </property>
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <property name="sizeType">
<horstretch>0</horstretch> <enum>QSizePolicy::Fixed</enum>
<verstretch>0</verstretch> </property>
</sizepolicy> <property name="sizeHint" stdset="0">
</property> <size>
<item> <width>30</width>
<property name="text"> <height>20</height>
<string>Spaces Only</string> </size>
</property> </property>
</item> </spacer>
<item> </item>
<property name="text"> <item row="2" column="1">
<string>Tabs Only</string> <widget class="QComboBox" name="tabPolicy">
</property> <property name="sizePolicy">
</item> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<item> <horstretch>0</horstretch>
<property name="text"> <verstretch>0</verstretch>
<string>Mixed</string> </sizepolicy>
</property> </property>
</item> <item>
</widget> <property name="text">
</item> <string>Spaces Only</string>
<item row="3" column="0" colspan="2"> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> </item>
<item> <item>
<widget class="QLabel" name="tabSizeLabel"> <property name="text">
<property name="sizePolicy"> <string>Tabs Only</string>
<sizepolicy hsizetype="Maximum" vsizetype="Preferred"> </property>
<horstretch>0</horstretch> </item>
<verstretch>0</verstretch> <item>
</sizepolicy> <property name="text">
</property> <string>Mixed</string>
<property name="text"> </property>
<string>Ta&amp;b size:</string> </item>
</property> </widget>
<property name="buddy"> </item>
<cstring>tabSize</cstring> <item row="3" column="0" colspan="2">
</property> <layout class="QHBoxLayout" name="horizontalLayout">
</widget> <item>
</item> <widget class="QLabel" name="tabSizeLabel">
<item> <property name="sizePolicy">
<widget class="QSpinBox" name="tabSize"> <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<property name="sizePolicy"> <horstretch>0</horstretch>
<sizepolicy hsizetype="Maximum" vsizetype="Fixed"> <verstretch>0</verstretch>
<horstretch>0</horstretch> </sizepolicy>
<verstretch>0</verstretch> </property>
</sizepolicy> <property name="text">
</property> <string>Ta&amp;b size:</string>
<property name="minimum"> </property>
<number>1</number> <property name="buddy">
</property> <cstring>tabSize</cstring>
<property name="maximum"> </property>
<number>20</number> </widget>
</property> </item>
</widget> <item>
</item> <widget class="QSpinBox" name="tabSize">
<item> <property name="sizePolicy">
<widget class="QLabel" name="indentSizeLabel"> <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<property name="sizePolicy"> <horstretch>0</horstretch>
<sizepolicy hsizetype="Maximum" vsizetype="Preferred"> <verstretch>0</verstretch>
<horstretch>0</horstretch> </sizepolicy>
<verstretch>0</verstretch> </property>
</sizepolicy> <property name="minimum">
</property> <number>1</number>
<property name="text"> </property>
<string>&amp;Indent size:</string> <property name="maximum">
</property> <number>20</number>
<property name="buddy"> </property>
<cstring>indentSize</cstring> </widget>
</property> </item>
</widget> <item>
</item> <widget class="QLabel" name="indentSizeLabel">
<item> <property name="sizePolicy">
<widget class="QSpinBox" name="indentSize"> <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<property name="sizePolicy"> <horstretch>0</horstretch>
<sizepolicy hsizetype="Maximum" vsizetype="Fixed"> <verstretch>0</verstretch>
<horstretch>0</horstretch> </sizepolicy>
<verstretch>0</verstretch> </property>
</sizepolicy> <property name="text">
</property> <string>&amp;Indent size:</string>
<property name="minimum"> </property>
<number>1</number> <property name="buddy">
</property> <cstring>indentSize</cstring>
<property name="maximum"> </property>
<number>20</number> </widget>
</property> </item>
</widget> <item>
</item> <widget class="QSpinBox" name="indentSize">
<item> <property name="sizePolicy">
<spacer name="horizontalSpacer_2"> <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<property name="orientation"> <horstretch>0</horstretch>
<enum>Qt::Horizontal</enum> <verstretch>0</verstretch>
</property> </sizepolicy>
<property name="sizeHint" stdset="0"> </property>
<size> <property name="minimum">
<width>40</width> <number>1</number>
<height>20</height> </property>
</size> <property name="maximum">
</property> <number>20</number>
</spacer> </property>
</item> </widget>
</layout> </item>
</item> <item>
<item row="5" column="1"> <spacer name="horizontalSpacer_2">
<widget class="QComboBox" name="continuationAlignBehavior"> <property name="orientation">
<property name="sizePolicy"> <enum>Qt::Horizontal</enum>
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> </property>
<horstretch>0</horstretch> <property name="sizeHint" stdset="0">
<verstretch>0</verstretch> <size>
</sizepolicy> <width>40</width>
</property> <height>20</height>
<property name="toolTip"> </size>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt; </property>
</spacer>
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="continuationAlignBehaviorLabel">
<property name="text">
<string>Align continuation lines:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="continuationAlignBehavior">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;
Influences the indentation of continuation lines. Influences the indentation of continuation lines.
&lt;ul&gt; &lt;ul&gt;
@@ -179,52 +200,22 @@ Influences the indentation of continuation lines.
&lt;/pre&gt; &lt;/pre&gt;
&lt;/li&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string> &lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<item> <item>
<property name="text"> <property name="text">
<string>Not At All</string> <string>Not At All</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>With Spaces</string> <string>With Spaces</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>With Regular Indent</string> <string>With Regular Indent</string>
</property> </property>
</item> </item>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="tabPolicyLabel">
<property name="text">
<string>Tab policy:</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="continuationAlignBehaviorLabel">
<property name="text">
<string>Align continuation lines:</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="codingStyleWarning">
<property name="toolTip">
<string>The text editor indentation setting is used for non-code files only. See the C++ and Qt Quick coding style settings to configure indentation for code files.</string>
</property>
<property name="text">
<string>&lt;i&gt;Code indentation is configured in &lt;a href=&quot;C++&quot;&gt;C++&lt;/a&gt; and &lt;a href=&quot;QtQuick&quot;&gt;Qt Quick&lt;/a&gt; settings.&lt;/i&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>