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);
m_ui->categoryTab->setCurrentIndex(0);
m_ui->tabSettingsWidget->setFlat(true);
}
CppCodeStylePreferencesWidget::~CppCodeStylePreferencesWidget()

View File

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

View File

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

View File

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

View File

@@ -32,7 +32,7 @@
namespace TextEditor {
TabSettingsWidget::TabSettingsWidget(QWidget *parent) :
QWidget(parent),
QGroupBox(parent),
ui(new Internal::Ui::TabSettingsWidget)
{
ui->setupUi(this);
@@ -91,13 +91,6 @@ void TabSettingsWidget::codingStyleLinkActivated(const QString &linkString)
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)
{
ui->codingStyleWarning->setVisible(visible);

View File

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

View File

@@ -1,160 +1,181 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TextEditor::Internal::TabSettingsWidget</class>
<widget class="QWidget" name="TextEditor::Internal::TabSettingsWidget">
<widget class="QGroupBox" name="TextEditor::Internal::TabSettingsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>335</width>
<height>224</height>
<width>254</width>
<height>189</height>
</rect>
</property>
<property name="windowTitle">
<string/>
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="tabsAndIndentationGroupBox">
<property name="title">
<string>Tabs And Indentation</string>
<property name="title">
<string>Tabs And Indentation</string>
</property>
<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>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<spacer name="horizontalSpacer">
<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 row="2" column="1">
<widget class="QComboBox" name="tabPolicy">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Spaces Only</string>
</property>
</item>
<item>
<property name="text">
<string>Tabs Only</string>
</property>
</item>
<item>
<property name="text">
<string>Mixed</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="tabSizeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ta&amp;b size:</string>
</property>
<property name="buddy">
<cstring>tabSize</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="tabSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="indentSizeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Indent size:</string>
</property>
<property name="buddy">
<cstring>indentSize</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="indentSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</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;
<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">
<spacer name="horizontalSpacer">
<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 row="2" column="1">
<widget class="QComboBox" name="tabPolicy">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Spaces Only</string>
</property>
</item>
<item>
<property name="text">
<string>Tabs Only</string>
</property>
</item>
<item>
<property name="text">
<string>Mixed</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="tabSizeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ta&amp;b size:</string>
</property>
<property name="buddy">
<cstring>tabSize</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="tabSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="indentSizeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Indent size:</string>
</property>
<property name="buddy">
<cstring>indentSize</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="indentSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</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.
&lt;ul&gt;
@@ -179,52 +200,22 @@ Influences the indentation of continuation lines.
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item>
<property name="text">
<string>Not At All</string>
</property>
</item>
<item>
<property name="text">
<string>With Spaces</string>
</property>
</item>
<item>
<property name="text">
<string>With Regular Indent</string>
</property>
</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>
</property>
<item>
<property name="text">
<string>Not At All</string>
</property>
</item>
<item>
<property name="text">
<string>With Spaces</string>
</property>
</item>
<item>
<property name="text">
<string>With Regular Indent</string>
</property>
</item>
</widget>
</item>
</layout>