Commit 52575f1c authored by Eike Ziller's avatar Eike Ziller

Add hint to text editor settings pointing to coding style

The tab and indentation settings in Text Editor > Behavior are only used
for non-code files. Add a hint with links to the respective coding style
settings.

Change-Id: I1d7c1154269c4914d511ef6ef3308a2b1f933d52
Reviewed-by: default avatarLeena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 43969c4e
......@@ -44,6 +44,11 @@
#include <coreplugin/editormanager/editormanager.h>
#include <utils/hostosinfo.h>
// for opening the respective coding style preferences
#include <cpptools/cpptoolsconstants.h>
#include <qmljseditor/qmljseditorconstants.h>
#include <qmljstools/qmljstoolsconstants.h>
#include <QSettings>
#include <QTextCodec>
......@@ -122,6 +127,11 @@ QWidget *BehaviorSettingsPage::createPage(QWidget *parent)
d->m_pageCodeStyle->setCurrentDelegate(d->m_codeStyle->currentDelegate());
d->m_page->behaviorWidget->setCodeStyle(d->m_pageCodeStyle);
TabSettingsWidget *tabSettingsWidget = d->m_page->behaviorWidget->tabSettingsWidget();
tabSettingsWidget->setCodingStyleWarningVisible(true);
connect(tabSettingsWidget, SIGNAL(codingStyleLinkClicked(TextEditor::TabSettingsWidget::CodingStyleLink)),
this, SLOT(openCodingStylePreferences(TextEditor::TabSettingsWidget::CodingStyleLink)));
settingsToUI();
if (d->m_searchKeywords.isEmpty())
......@@ -258,3 +268,18 @@ bool BehaviorSettingsPage::matches(const QString &s) const
{
return d->m_searchKeywords.contains(s, Qt::CaseInsensitive);
}
void BehaviorSettingsPage::openCodingStylePreferences(TabSettingsWidget::CodingStyleLink link)
{
switch (link) {
case TextEditor::TabSettingsWidget::CppLink:
Core::ICore::showOptionsDialog(CppTools::Constants::CPP_SETTINGS_CATEGORY,
CppTools::Constants::CPP_CODE_STYLE_SETTINGS_ID);
break;
case TextEditor::TabSettingsWidget::QtQuickLink:
Core::ICore::showOptionsDialog(QmlJSEditor::Constants::SETTINGS_CATEGORY_QML,
QmlJSTools::Constants::QML_JS_CODE_STYLE_SETTINGS_ID);
break;
}
}
......@@ -33,6 +33,7 @@
#include "texteditor_global.h"
#include "texteditoroptionspage.h"
#include "tabsettingswidget.h"
namespace TextEditor {
......@@ -79,6 +80,9 @@ signals:
void behaviorSettingsChanged(const TextEditor::BehaviorSettings &);
void extraEncodingSettingsChanged(const TextEditor::ExtraEncodingSettings &);
private slots:
void openCodingStylePreferences(TextEditor::TabSettingsWidget::CodingStyleLink link);
private:
void settingsFromUI(TypingSettings *typingSettings,
StorageSettings *storageSettings,
......
......@@ -30,6 +30,8 @@
#include "behaviorsettingswidget.h"
#include "ui_behaviorsettingswidget.h"
#include "tabsettingswidget.h"
#include <texteditor/typingsettings.h>
#include <texteditor/storagesettings.h>
#include <texteditor/behaviorsettings.h>
......@@ -243,6 +245,11 @@ QString BehaviorSettingsWidget::collectUiKeywords() const
return keywords;
}
TabSettingsWidget *BehaviorSettingsWidget::tabSettingsWidget() const
{
return d->m_ui.tabPreferencesWidget->tabSettingsWidget();
}
void BehaviorSettingsWidget::slotTypingSettingsChanged()
{
TypingSettings settings;
......
......@@ -41,6 +41,7 @@ QT_END_NAMESPACE
namespace TextEditor {
class ICodeStylePreferences;
class TabSettingsWidget;
class TypingSettings;
class StorageSettings;
class BehaviorSettings;
......@@ -77,6 +78,8 @@ public:
QString collectUiKeywords() const;
TabSettingsWidget *tabSettingsWidget() const;
signals:
void typingSettingsChanged(const TextEditor::TypingSettings &settings);
void storageSettingsChanged(const TextEditor::StorageSettings &settings);
......
......@@ -101,7 +101,12 @@ QString SimpleCodeStylePreferencesWidget::searchKeywords() const
void SimpleCodeStylePreferencesWidget::setFlat(bool on)
{
m_tabSettingsWidget->setFlat(on);
m_tabSettingsWidget->setFlat(on);
}
TabSettingsWidget *SimpleCodeStylePreferencesWidget::tabSettingsWidget() const
{
return m_tabSettingsWidget;
}
} // namespace TextEditor
......@@ -55,6 +55,7 @@ public:
QString searchKeywords() const;
void setFlat(bool on);
TabSettingsWidget *tabSettingsWidget() const;
private slots:
void slotCurrentPreferencesChanged(TextEditor::ICodeStylePreferences *preferences);
......
......@@ -40,7 +40,10 @@ TabSettingsWidget::TabSettingsWidget(QWidget *parent) :
ui(new Internal::Ui::TabSettingsWidget)
{
ui->setupUi(this);
ui->codingStyleWarning->setVisible(false);
connect(ui->codingStyleWarning, SIGNAL(linkActivated(QString)),
this, SLOT(codingStyleLinkActivated(QString)));
connect(ui->tabPolicy, SIGNAL(currentIndexChanged(int)),
this, SLOT(slotSettingsChanged()));
connect(ui->tabSize, SIGNAL(valueChanged(int)),
......@@ -83,6 +86,14 @@ void TabSettingsWidget::slotSettingsChanged()
emit settingsChanged(tabSettings());
}
void TabSettingsWidget::codingStyleLinkActivated(const QString &linkString)
{
if (linkString == QLatin1String("C++"))
emit codingStyleLinkClicked(CppLink);
else if (linkString == QLatin1String("QtQuick"))
emit codingStyleLinkClicked(QtQuickLink);
}
void TabSettingsWidget::setFlat(bool on)
{
ui->tabsAndIndentationGroupBox->setFlat(on);
......@@ -105,6 +116,11 @@ QString TabSettingsWidget::searchKeywords() const
return rc;
}
void TabSettingsWidget::setCodingStyleWarningVisible(bool visible)
{
ui->codingStyleWarning->setVisible(visible);
}
void TabSettingsWidget::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
......
......@@ -45,6 +45,11 @@ class TEXTEDITOR_EXPORT TabSettingsWidget : public QWidget
Q_OBJECT
public:
enum CodingStyleLink {
CppLink,
QtQuickLink
};
explicit TabSettingsWidget(QWidget *parent = 0);
~TabSettingsWidget();
......@@ -52,18 +57,21 @@ public:
void setFlat(bool on);
QString searchKeywords() const;
void setCodingStyleWarningVisible(bool visible);
public slots:
void setTabSettings(const TextEditor::TabSettings& s);
signals:
void settingsChanged(const TextEditor::TabSettings &);
void codingStyleLinkClicked(TextEditor::TabSettingsWidget::CodingStyleLink link);
protected:
void changeEvent(QEvent *e);
private slots:
void slotSettingsChanged();
void codingStyleLinkActivated(const QString &linkString);
private:
Internal::Ui::TabSettingsWidget *ui;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>314</width>
<height>219</height>
<width>335</width>
<height>224</height>
</rect>
</property>
<property name="windowTitle">
......@@ -23,14 +23,7 @@
<string>Tabs And Indentation</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="tabPolicyLabel">
<property name="text">
<string>Tab policy:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -46,7 +39,7 @@
</property>
</spacer>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="tabPolicy">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
......@@ -71,7 +64,7 @@
</item>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="tabSizeLabel">
......@@ -152,14 +145,7 @@
</item>
</layout>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="continuationAlignBehaviorLabel">
<property name="text">
<string>Align continuation lines:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QComboBox" name="continuationAlignBehavior">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
......@@ -211,6 +197,33 @@ Influences the indentation of continuation lines.
</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>
</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment