forked from qt-creator/qt-creator
TextEditor: inline tabsettingswidget.ui
Change-Id: I9afe5978df1b1313c9d88493dcec9cfe3b7a6af9 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -90,7 +90,7 @@ add_qtc_plugin(TextEditor
|
|||||||
storagesettings.cpp storagesettings.h
|
storagesettings.cpp storagesettings.h
|
||||||
syntaxhighlighter.cpp syntaxhighlighter.h
|
syntaxhighlighter.cpp syntaxhighlighter.h
|
||||||
tabsettings.cpp tabsettings.h
|
tabsettings.cpp tabsettings.h
|
||||||
tabsettingswidget.cpp tabsettingswidget.h tabsettingswidget.ui
|
tabsettingswidget.cpp tabsettingswidget.h
|
||||||
textdocument.cpp textdocument.h
|
textdocument.cpp textdocument.h
|
||||||
textdocumentlayout.cpp textdocumentlayout.h
|
textdocumentlayout.cpp textdocumentlayout.h
|
||||||
texteditor.cpp texteditor.h
|
texteditor.cpp texteditor.h
|
||||||
|
@@ -24,56 +24,135 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "tabsettingswidget.h"
|
#include "tabsettingswidget.h"
|
||||||
#include "ui_tabsettingswidget.h"
|
|
||||||
#include "tabsettings.h"
|
#include "tabsettings.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QSpinBox>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
|
QString continuationTooltip()
|
||||||
|
{
|
||||||
|
// FIXME: This is unfair towards translators.
|
||||||
|
return QCoreApplication::translate("TextEditor::Internal::TabSettingsWidget",
|
||||||
|
"<html><head/><body>\n"
|
||||||
|
"Influences the indentation of continuation lines.\n"
|
||||||
|
"\n"
|
||||||
|
"<ul>\n"
|
||||||
|
"<li>Not At All: Do not align at all. Lines will only be indented to the current logical indentation depth.\n"
|
||||||
|
"<pre>\n"
|
||||||
|
"(tab)int i = foo(a, b\n"
|
||||||
|
"(tab)c, d);\n"
|
||||||
|
"</pre>\n"
|
||||||
|
"</li>\n"
|
||||||
|
"\n"
|
||||||
|
"<li>With Spaces: Always use spaces for alignment, regardless of the other indentation settings.\n"
|
||||||
|
"<pre>\n"
|
||||||
|
"(tab)int i = foo(a, b\n"
|
||||||
|
"(tab) c, d);\n"
|
||||||
|
"</pre>\n"
|
||||||
|
"</li>\n"
|
||||||
|
"\n"
|
||||||
|
"<li>With Regular Indent: Use tabs and/or spaces for alignment, as configured above.\n"
|
||||||
|
"<pre>\n"
|
||||||
|
"(tab)int i = foo(a, b\n"
|
||||||
|
"(tab)(tab)(tab) c, d);\n"
|
||||||
|
"</pre>\n"
|
||||||
|
"</li>\n"
|
||||||
|
"</ul></body></html>");
|
||||||
|
}
|
||||||
|
|
||||||
TabSettingsWidget::TabSettingsWidget(QWidget *parent) :
|
TabSettingsWidget::TabSettingsWidget(QWidget *parent) :
|
||||||
QGroupBox(parent),
|
QGroupBox(parent)
|
||||||
ui(new Internal::Ui::TabSettingsWidget)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
resize(254, 189);
|
||||||
ui->codingStyleWarning->setVisible(false);
|
setTitle(tr("Tabs And Indentation"));
|
||||||
|
|
||||||
auto comboIndexChanged = QOverload<int>::of(&QComboBox::currentIndexChanged);
|
m_codingStyleWarning = new QLabel(
|
||||||
auto spinValueChanged = QOverload<int>::of(&QSpinBox::valueChanged);
|
tr("<i>Code indentation is configured in <a href=\"C++\">C++</a> "
|
||||||
connect(ui->codingStyleWarning, &QLabel::linkActivated,
|
"and <a href=\"QtQuick\">Qt Quick</a> settings.</i>"));
|
||||||
|
m_codingStyleWarning->setVisible(false);
|
||||||
|
m_codingStyleWarning->setWordWrap(true);
|
||||||
|
m_codingStyleWarning->setToolTip(
|
||||||
|
tr("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."));
|
||||||
|
|
||||||
|
m_tabPolicy = new QComboBox(this);
|
||||||
|
m_tabPolicy->setMinimumContentsLength(28);
|
||||||
|
m_tabPolicy->addItem(tr("Spaces Only"));
|
||||||
|
m_tabPolicy->addItem(tr("Tabs Only"));
|
||||||
|
m_tabPolicy->addItem(tr("Mixed"));
|
||||||
|
|
||||||
|
auto tabSizeLabel = new QLabel(tr("Ta&b size:"));
|
||||||
|
|
||||||
|
m_tabSize = new QSpinBox(this);
|
||||||
|
m_tabSize->setRange(1, 20);
|
||||||
|
|
||||||
|
auto indentSizeLabel = new QLabel(tr("&Indent size:"));
|
||||||
|
|
||||||
|
m_indentSize = new QSpinBox(this);
|
||||||
|
m_indentSize->setRange(1, 20);
|
||||||
|
|
||||||
|
m_continuationAlignBehavior = new QComboBox;
|
||||||
|
m_continuationAlignBehavior->addItem(tr("Not At All"));
|
||||||
|
m_continuationAlignBehavior->addItem(tr("With Spaces"));
|
||||||
|
m_continuationAlignBehavior->addItem(tr("With Regular Indent"));
|
||||||
|
m_continuationAlignBehavior->setToolTip(continuationTooltip());
|
||||||
|
|
||||||
|
tabSizeLabel->setBuddy(m_tabSize);
|
||||||
|
indentSizeLabel->setBuddy(m_indentSize);
|
||||||
|
|
||||||
|
using namespace Utils::Layouting;
|
||||||
|
const auto indent = [](QWidget *inner) { return Row { Space(30), inner }; };
|
||||||
|
|
||||||
|
Column {
|
||||||
|
m_codingStyleWarning,
|
||||||
|
tr("Tab policy:"),
|
||||||
|
indent(m_tabPolicy),
|
||||||
|
Row { tabSizeLabel, m_tabSize, indentSizeLabel, m_indentSize, st },
|
||||||
|
tr("Align continuation lines:"),
|
||||||
|
indent(m_continuationAlignBehavior)
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
connect(m_codingStyleWarning, &QLabel::linkActivated,
|
||||||
this, &TabSettingsWidget::codingStyleLinkActivated);
|
this, &TabSettingsWidget::codingStyleLinkActivated);
|
||||||
connect(ui->tabPolicy, comboIndexChanged,
|
connect(m_tabPolicy, &QComboBox::currentIndexChanged,
|
||||||
this, &TabSettingsWidget::slotSettingsChanged);
|
this, &TabSettingsWidget::slotSettingsChanged);
|
||||||
connect(ui->tabSize, spinValueChanged,
|
connect(m_tabSize, &QSpinBox::valueChanged,
|
||||||
this, &TabSettingsWidget::slotSettingsChanged);
|
this, &TabSettingsWidget::slotSettingsChanged);
|
||||||
connect(ui->indentSize, spinValueChanged,
|
connect(m_indentSize, &QSpinBox::valueChanged,
|
||||||
this, &TabSettingsWidget::slotSettingsChanged);
|
this, &TabSettingsWidget::slotSettingsChanged);
|
||||||
connect(ui->continuationAlignBehavior, comboIndexChanged,
|
connect(m_continuationAlignBehavior, &QComboBox::currentIndexChanged,
|
||||||
this, &TabSettingsWidget::slotSettingsChanged);
|
this, &TabSettingsWidget::slotSettingsChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
TabSettingsWidget::~TabSettingsWidget()
|
TabSettingsWidget::~TabSettingsWidget() = default;
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TabSettingsWidget::setTabSettings(const TextEditor::TabSettings& s)
|
void TabSettingsWidget::setTabSettings(const TabSettings &s)
|
||||||
{
|
{
|
||||||
QSignalBlocker blocker(this);
|
QSignalBlocker blocker(this);
|
||||||
ui->tabPolicy->setCurrentIndex(s.m_tabPolicy);
|
m_tabPolicy->setCurrentIndex(s.m_tabPolicy);
|
||||||
ui->tabSize->setValue(s.m_tabSize);
|
m_tabSize->setValue(s.m_tabSize);
|
||||||
ui->indentSize->setValue(s.m_indentSize);
|
m_indentSize->setValue(s.m_indentSize);
|
||||||
ui->continuationAlignBehavior->setCurrentIndex(s.m_continuationAlignBehavior);
|
m_continuationAlignBehavior->setCurrentIndex(s.m_continuationAlignBehavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
TabSettings TabSettingsWidget::tabSettings() const
|
TabSettings TabSettingsWidget::tabSettings() const
|
||||||
{
|
{
|
||||||
TabSettings set;
|
TabSettings set;
|
||||||
|
|
||||||
set.m_tabPolicy = (TabSettings::TabPolicy)(ui->tabPolicy->currentIndex());
|
set.m_tabPolicy = TabSettings::TabPolicy(m_tabPolicy->currentIndex());
|
||||||
set.m_tabSize = ui->tabSize->value();
|
set.m_tabSize = m_tabSize->value();
|
||||||
set.m_indentSize = ui->indentSize->value();
|
set.m_indentSize = m_indentSize->value();
|
||||||
set.m_continuationAlignBehavior = (TabSettings::ContinuationAlignBehavior)(ui->continuationAlignBehavior->currentIndex());
|
set.m_continuationAlignBehavior =
|
||||||
|
TabSettings::ContinuationAlignBehavior(m_continuationAlignBehavior->currentIndex());
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
@@ -93,7 +172,7 @@ void TabSettingsWidget::codingStyleLinkActivated(const QString &linkString)
|
|||||||
|
|
||||||
void TabSettingsWidget::setCodingStyleWarningVisible(bool visible)
|
void TabSettingsWidget::setCodingStyleWarningVisible(bool visible)
|
||||||
{
|
{
|
||||||
ui->codingStyleWarning->setVisible(visible);
|
m_codingStyleWarning->setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace TextEditor
|
} // TextEditor
|
||||||
|
@@ -29,9 +29,13 @@
|
|||||||
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
|
||||||
namespace TextEditor {
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QComboBox;
|
||||||
|
class QLabel;
|
||||||
|
class QSpinBox;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Internal { namespace Ui { class TabSettingsWidget; } }
|
namespace TextEditor {
|
||||||
|
|
||||||
class TabSettings;
|
class TabSettings;
|
||||||
|
|
||||||
@@ -61,7 +65,11 @@ private:
|
|||||||
void slotSettingsChanged();
|
void slotSettingsChanged();
|
||||||
void codingStyleLinkActivated(const QString &linkString);
|
void codingStyleLinkActivated(const QString &linkString);
|
||||||
|
|
||||||
Internal::Ui::TabSettingsWidget *ui;
|
QLabel *m_codingStyleWarning;
|
||||||
|
QComboBox *m_tabPolicy;
|
||||||
|
QSpinBox *m_tabSize;
|
||||||
|
QSpinBox *m_indentSize;
|
||||||
|
QComboBox *m_continuationAlignBehavior;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
@@ -1,231 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>TextEditor::Internal::TabSettingsWidget</class>
|
|
||||||
<widget class="QGroupBox" name="TextEditor::Internal::TabSettingsWidget">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>254</width>
|
|
||||||
<height>189</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<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>
|
|
||||||
<property name="text">
|
|
||||||
<string><i>Code indentation is configured in <a href="C++">C++</a> and <a href="QtQuick">Qt Quick</a> settings.</i></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&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>&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><html><head/><body>
|
|
||||||
Influences the indentation of continuation lines.
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Not At All: Do not align at all. Lines will only be indented to the current logical indentation depth.
|
|
||||||
<pre>
|
|
||||||
(tab)int i = foo(a, b
|
|
||||||
(tab)c, d);
|
|
||||||
</pre>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>With Spaces: Always use spaces for alignment, regardless of the other indentation settings.
|
|
||||||
<pre>
|
|
||||||
(tab)int i = foo(a, b
|
|
||||||
(tab) c, d);
|
|
||||||
</pre>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>With Regular Indent: Use tabs and/or spaces for alignment, as configured above.
|
|
||||||
<pre>
|
|
||||||
(tab)int i = foo(a, b
|
|
||||||
(tab)(tab)(tab) c, d);
|
|
||||||
</pre>
|
|
||||||
</li>
|
|
||||||
</ul></body></html></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>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<tabstops>
|
|
||||||
<tabstop>tabPolicy</tabstop>
|
|
||||||
<tabstop>tabSize</tabstop>
|
|
||||||
<tabstop>indentSize</tabstop>
|
|
||||||
<tabstop>continuationAlignBehavior</tabstop>
|
|
||||||
</tabstops>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
@@ -119,7 +119,6 @@ Project {
|
|||||||
"tabsettings.h",
|
"tabsettings.h",
|
||||||
"tabsettingswidget.cpp",
|
"tabsettingswidget.cpp",
|
||||||
"tabsettingswidget.h",
|
"tabsettingswidget.h",
|
||||||
"tabsettingswidget.ui",
|
|
||||||
"textdocument.cpp",
|
"textdocument.cpp",
|
||||||
"textdocument.h",
|
"textdocument.h",
|
||||||
"textdocumentlayout.cpp",
|
"textdocumentlayout.cpp",
|
||||||
|
Reference in New Issue
Block a user