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,28 +1,42 @@
<?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="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="tabsAndIndentationGroupBox">
<property name="title"> <property name="title">
<string>Tabs And Indentation</string> <string>Tabs And Indentation</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<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>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="tabPolicyLabel">
<property name="text">
<string>Tab policy:</string>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
@@ -145,6 +159,13 @@
</item> </item>
</layout> </layout>
</item> </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"> <item row="5" column="1">
<widget class="QComboBox" name="continuationAlignBehavior"> <widget class="QComboBox" name="continuationAlignBehavior">
<property name="sizePolicy"> <property name="sizePolicy">
@@ -197,36 +218,6 @@ Influences the indentation of continuation lines.
</item> </item>
</widget> </widget>
</item> </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>
</item>
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>