Commit 5dbcc615 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

Split up general text editor settings

The page had grown too large so now the display settings have been split
off onto their own page.
parent e33c2193
......@@ -15,33 +15,42 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="caseSensitive">
<property name="text">
<string>&amp;Case-sensitive completion</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="autoInsertBraces">
<property name="text">
<string>&amp;Automatically insert braces</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="partiallyComplete">
<property name="text">
<string>Autocomplete common &amp;prefix</string>
</property>
<property name="checked">
<bool>true</bool>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Completion Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="caseSensitive">
<property name="text">
<string>&amp;Case-sensitive completion</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="autoInsertBraces">
<property name="text">
<string>&amp;Automatically insert braces</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="partiallyComplete">
<property name="text">
<string>Autocomplete common &amp;prefix</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
......
......@@ -31,72 +31,68 @@
**
***************************************************************************/
#include "displaysettings.h"
#include "generalsettingspage.h"
#include "behaviorsettingspage.h"
#include "interactionsettings.h"
#include "storagesettings.h"
#include "tabsettings.h"
#include "ui_generalsettingspage.h"
#include "ui_behaviorsettingspage.h"
#include <coreplugin/icore.h>
#include <QtCore/QSettings>
#include <QtCore/QDebug>
using namespace TextEditor;
struct GeneralSettingsPage::GeneralSettingsPagePrivate
struct BehaviorSettingsPage::BehaviorSettingsPagePrivate
{
explicit GeneralSettingsPagePrivate(const GeneralSettingsPageParameters &p);
explicit BehaviorSettingsPagePrivate(const BehaviorSettingsPageParameters &p);
const GeneralSettingsPageParameters m_parameters;
Ui::generalSettingsPage m_page;
const BehaviorSettingsPageParameters m_parameters;
Ui::BehaviorSettingsPage m_page;
TabSettings m_tabSettings;
StorageSettings m_storageSettings;
DisplaySettings m_displaySettings;
InteractionSettings m_interactionSettings;
};
GeneralSettingsPage::GeneralSettingsPagePrivate::GeneralSettingsPagePrivate
(const GeneralSettingsPageParameters &p)
BehaviorSettingsPage::BehaviorSettingsPagePrivate::BehaviorSettingsPagePrivate
(const BehaviorSettingsPageParameters &p)
: m_parameters(p)
{
if (const QSettings *s = Core::ICore::instance()->settings()) {
m_tabSettings.fromSettings(m_parameters.settingsPrefix, s);
m_storageSettings.fromSettings(m_parameters.settingsPrefix, s);
m_displaySettings.fromSettings(m_parameters.settingsPrefix, s);
m_interactionSettings.fromSettings(m_parameters.settingsPrefix, s);
}
}
GeneralSettingsPage::GeneralSettingsPage(const GeneralSettingsPageParameters &p,
BehaviorSettingsPage::BehaviorSettingsPage(const BehaviorSettingsPageParameters &p,
QObject *parent)
: Core::IOptionsPage(parent),
m_d(new GeneralSettingsPagePrivate(p))
m_d(new BehaviorSettingsPagePrivate(p))
{
}
GeneralSettingsPage::~GeneralSettingsPage()
BehaviorSettingsPage::~BehaviorSettingsPage()
{
delete m_d;
}
QString GeneralSettingsPage::name() const
QString BehaviorSettingsPage::name() const
{
return m_d->m_parameters.name;
}
QString GeneralSettingsPage::category() const
QString BehaviorSettingsPage::category() const
{
return m_d->m_parameters.category;
return m_d->m_parameters.category;
}
QString GeneralSettingsPage::trCategory() const
QString BehaviorSettingsPage::trCategory() const
{
return m_d->m_parameters.trCategory;
}
QWidget *GeneralSettingsPage::createPage(QWidget *parent)
QWidget *BehaviorSettingsPage::createPage(QWidget *parent)
{
QWidget *w = new QWidget(parent);
m_d->m_page.setupUi(w);
......@@ -104,15 +100,13 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent)
return w;
}
void GeneralSettingsPage::apply()
void BehaviorSettingsPage::apply()
{
TabSettings newTabSettings;
StorageSettings newStorageSettings;
DisplaySettings newDisplaySettings;
InteractionSettings newInteractionSettings;
settingsFromUI(newTabSettings, newStorageSettings, newDisplaySettings,
newInteractionSettings);
settingsFromUI(newTabSettings, newStorageSettings, newInteractionSettings);
Core::ICore *core = Core::ICore::instance();
QSettings *s = core->settings();
......@@ -133,105 +127,61 @@ void GeneralSettingsPage::apply()
emit storageSettingsChanged(newStorageSettings);
}
if (newDisplaySettings != m_d->m_displaySettings) {
m_d->m_displaySettings = newDisplaySettings;
if (s)
m_d->m_displaySettings.toSettings(m_d->m_parameters.settingsPrefix, s);
emit displaySettingsChanged(newDisplaySettings);
}
if (newInteractionSettings != m_d->m_interactionSettings) {
m_d->m_interactionSettings = newInteractionSettings;
if (s)
m_d->m_interactionSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
}
}
void GeneralSettingsPage::settingsFromUI(TabSettings &rc,
void BehaviorSettingsPage::settingsFromUI(TabSettings &tabSettings,
StorageSettings &storageSettings,
DisplaySettings &displaySettings,
InteractionSettings &interactionSettings) const
{
rc.m_spacesForTabs = m_d->m_page.insertSpaces->isChecked();
rc.m_autoIndent = m_d->m_page.autoIndent->isChecked();
rc.m_smartBackspace = m_d->m_page.smartBackspace->isChecked();
rc.m_tabSize = m_d->m_page.tabSize->value();
rc.m_indentSize = m_d->m_page.indentSize->value();
tabSettings.m_spacesForTabs = m_d->m_page.insertSpaces->isChecked();
tabSettings.m_autoIndent = m_d->m_page.autoIndent->isChecked();
tabSettings.m_smartBackspace = m_d->m_page.smartBackspace->isChecked();
tabSettings.m_tabSize = m_d->m_page.tabSize->value();
tabSettings.m_indentSize = m_d->m_page.indentSize->value();
storageSettings.m_cleanWhitespace = m_d->m_page.cleanWhitespace->isChecked();
storageSettings.m_inEntireDocument = m_d->m_page.inEntireDocument->isChecked();
storageSettings.m_cleanIndentation = m_d->m_page.cleanIndentation->isChecked();
storageSettings.m_addFinalNewLine = m_d->m_page.addFinalNewLine->isChecked();
displaySettings.m_displayLineNumbers = m_d->m_page.displayLineNumbers->isChecked();
displaySettings.m_textWrapping = m_d->m_page.enableTextWrapping->isChecked();
displaySettings.m_showWrapColumn = m_d->m_page.showWrapColumn->isChecked();
displaySettings.m_wrapColumn = m_d->m_page.wrapColumn->value();
displaySettings.m_visualizeWhitespace = m_d->m_page.visualizeWhitespace->isChecked();
displaySettings.m_displayFoldingMarkers = m_d->m_page.displayFoldingMarkers->isChecked();
displaySettings.m_highlightCurrentLine = m_d->m_page.highlightCurrentLine->isChecked();
interactionSettings.m_useVim = m_d->m_page.useVim->isChecked();
}
void GeneralSettingsPage::settingsToUI()
void BehaviorSettingsPage::settingsToUI()
{
TabSettings rc = m_d->m_tabSettings;
m_d->m_page.insertSpaces->setChecked(rc.m_spacesForTabs);
m_d->m_page.autoIndent->setChecked(rc.m_autoIndent);
m_d->m_page.smartBackspace->setChecked(rc.m_smartBackspace);
m_d->m_page.tabSize->setValue(rc.m_tabSize);
m_d->m_page.indentSize->setValue(rc.m_indentSize);
StorageSettings storageSettings = m_d->m_storageSettings;
const TabSettings &tabSettings = m_d->m_tabSettings;
m_d->m_page.insertSpaces->setChecked(tabSettings.m_spacesForTabs);
m_d->m_page.autoIndent->setChecked(tabSettings.m_autoIndent);
m_d->m_page.smartBackspace->setChecked(tabSettings.m_smartBackspace);
m_d->m_page.tabSize->setValue(tabSettings.m_tabSize);
m_d->m_page.indentSize->setValue(tabSettings.m_indentSize);
const StorageSettings &storageSettings = m_d->m_storageSettings;
m_d->m_page.cleanWhitespace->setChecked(storageSettings.m_cleanWhitespace);
m_d->m_page.inEntireDocument->setChecked(storageSettings.m_inEntireDocument);
m_d->m_page.cleanIndentation->setChecked(storageSettings.m_cleanIndentation);
m_d->m_page.addFinalNewLine->setChecked(storageSettings.m_addFinalNewLine);
DisplaySettings displaySettings = m_d->m_displaySettings;
m_d->m_page.displayLineNumbers->setChecked(displaySettings.m_displayLineNumbers);
m_d->m_page.enableTextWrapping->setChecked(displaySettings.m_textWrapping);
m_d->m_page.showWrapColumn->setChecked(displaySettings.m_showWrapColumn);
m_d->m_page.wrapColumn->setValue(displaySettings.m_wrapColumn);
m_d->m_page.visualizeWhitespace->setChecked(displaySettings.m_visualizeWhitespace);
m_d->m_page.displayFoldingMarkers->setChecked(displaySettings.m_displayFoldingMarkers);
m_d->m_page.highlightCurrentLine->setChecked(displaySettings.m_highlightCurrentLine);
InteractionSettings interactionSettings = m_d->m_interactionSettings;
const InteractionSettings &interactionSettings = m_d->m_interactionSettings;
m_d->m_page.useVim->setChecked(interactionSettings.m_useVim);
}
TabSettings GeneralSettingsPage::tabSettings() const
TabSettings BehaviorSettingsPage::tabSettings() const
{
return m_d->m_tabSettings;
}
StorageSettings GeneralSettingsPage::storageSettings() const
StorageSettings BehaviorSettingsPage::storageSettings() const
{
return m_d->m_storageSettings;
}
DisplaySettings GeneralSettingsPage::displaySettings() const
{
return m_d->m_displaySettings;
}
InteractionSettings GeneralSettingsPage::interactionSettings() const
InteractionSettings BehaviorSettingsPage::interactionSettings() const
{
return m_d->m_interactionSettings;
}
void GeneralSettingsPage::setDisplaySettings(const DisplaySettings &newDisplaySettings)
{
if (newDisplaySettings != m_d->m_displaySettings) {
m_d->m_displaySettings = newDisplaySettings;
Core::ICore *core = Core::ICore::instance();
if (QSettings *s = core->settings())
m_d->m_displaySettings.toSettings(m_d->m_parameters.settingsPrefix, s);
emit displaySettingsChanged(newDisplaySettings);
}
}
......@@ -31,8 +31,8 @@
**
***************************************************************************/
#ifndef GENERALSETTINGSPAGE_H
#define GENERALSETTINGSPAGE_H
#ifndef BEHAVIORSETTINGSPAGE_H
#define BEHAVIORSETTINGSPAGE_H
#include "texteditor_global.h"
......@@ -44,10 +44,9 @@ namespace TextEditor {
struct TabSettings;
struct StorageSettings;
struct DisplaySettings;
struct InteractionSettings;
struct TEXTEDITOR_EXPORT GeneralSettingsPageParameters
struct BehaviorSettingsPageParameters
{
QString name;
QString category;
......@@ -55,13 +54,13 @@ struct TEXTEDITOR_EXPORT GeneralSettingsPageParameters
QString settingsPrefix;
};
class TEXTEDITOR_EXPORT GeneralSettingsPage : public Core::IOptionsPage
class BehaviorSettingsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
GeneralSettingsPage(const GeneralSettingsPageParameters &p, QObject *parent);
virtual ~GeneralSettingsPage();
BehaviorSettingsPage(const BehaviorSettingsPageParameters &p, QObject *parent);
virtual ~BehaviorSettingsPage();
// IOptionsPage
QString name() const;
......@@ -74,27 +73,21 @@ public:
TabSettings tabSettings() const;
StorageSettings storageSettings() const;
DisplaySettings displaySettings() const;
InteractionSettings interactionSettings() const;
void setDisplaySettings(const DisplaySettings &);
signals:
void tabSettingsChanged(const TextEditor::TabSettings &);
void storageSettingsChanged(const TextEditor::StorageSettings &);
void displaySettingsChanged(const TextEditor::DisplaySettings &);
private:
void settingsFromUI(TabSettings &rc,
StorageSettings &storageSettings,
DisplaySettings &displaySettings,
InteractionSettings &interactionSettings
) const;
InteractionSettings &interactionSettings) const;
void settingsToUI();
struct GeneralSettingsPagePrivate;
GeneralSettingsPagePrivate *m_d;
struct BehaviorSettingsPagePrivate;
BehaviorSettingsPagePrivate *m_d;
};
} // namespace TextEditor
#endif // GENERALSETTINGSPAGE_H
#endif // BEHAVIORSETTINGSPAGE_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TextEditor::generalSettingsPage</class>
<widget class="QWidget" name="TextEditor::generalSettingsPage">
<class>TextEditor::BehaviorSettingsPage</class>
<widget class="QWidget" name="TextEditor::BehaviorSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>514</width>
<height>475</height>
<width>484</width>
<height>398</height>
</rect>
</property>
<property name="windowTitle">
......@@ -255,71 +255,6 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBoxDisplaySettings">
<property name="title">
<string>Display Settings</string>
</property>
<layout class="QGridLayout">
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="showWrapColumn">
<property name="text">
<string>Display right &amp;margin at column</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="wrapColumn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="enableTextWrapping">
<property name="text">
<string>Enable text &amp;wrapping</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="displayLineNumbers">
<property name="text">
<string>Display line &amp;numbers</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="visualizeWhitespace">
<property name="text">
<string>&amp;Visualize whitespace</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="displayFoldingMarkers">
<property name="text">
<string>Display &amp;folding markers</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="highlightCurrentLine">
<property name="text">
<string>Highlight current &amp;line</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBoxInteractionSettings">
<property name="title">
<string>Interaction Settings</string>
......@@ -335,7 +270,7 @@
</layout>
</widget>
</item>
<item row="4" column="0">
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -373,20 +308,14 @@
<signal>toggled(bool)</signal>
<receiver>cleanIndentation</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>showWrapColumn</sender>
<signal>toggled(bool)</signal>
<receiver>wrapColumn</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>399</x>
<y>308</y>
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>474</x>
<y>308</y>
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
......
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#include "displaysettingspage.h"
#include "displaysettings.h"
#include "ui_displaysettingspage.h"
#include <coreplugin/icore.h>
#include <QtCore/QSettings>
using namespace TextEditor;
struct DisplaySettingsPage::DisplaySettingsPagePrivate
{
explicit DisplaySettingsPagePrivate(const DisplaySettingsPageParameters &p);
const DisplaySettingsPageParameters m_parameters;
Ui::DisplaySettingsPage m_page;
DisplaySettings m_displaySettings;
};
DisplaySettingsPage::DisplaySettingsPagePrivate::DisplaySettingsPagePrivate
(const DisplaySettingsPageParameters &p)
: m_parameters(p)
{
if (const QSettings *s = Core::ICore::instance()->settings()) {
m_displaySettings.fromSettings(m_parameters.settingsPrefix, s);
}
}
DisplaySettingsPage::DisplaySettingsPage(const DisplaySettingsPageParameters &p,
QObject *parent)
: Core::IOptionsPage(parent),
m_d(new DisplaySettingsPagePrivate(p))
{
}
DisplaySettingsPage::~DisplaySettingsPage()
{
delete m_d;
}
QString DisplaySettingsPage::name() const
{
return m_d->m_parameters.name;
}
QString DisplaySettingsPage::category() const
{
return m_d->m_parameters.category;
}
QString DisplaySettingsPage::trCategory() const
{
return m_d->m_parameters.trCategory;
}
QWidget *DisplaySettingsPage::createPage(QWidget *parent)
{
QWidget *w = new QWidget(parent);
m_d->m_page.setupUi(w);
settingsToUI();
return w;
}
void DisplaySettingsPage::apply()
{
DisplaySettings newDisplaySettings;
settingsFromUI(newDisplaySettings);
Core::ICore *core = Core::ICore::instance();
QSettings *s = core->settings();
if (newDisplaySettings != m_d->m_displaySettings) {
m_d->m_displaySettings = newDisplaySettings;
if (s)
m_d->m_displaySettings.toSettings(m_d->m_parameters.settingsPrefix, s);
emit displaySettingsChanged(newDisplaySettings);
}
}
void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const
{
displaySettings.m_displayLineNumbers = m_d->m_page.displayLineNumbers->isChecked();
displaySettings.m_textWrapping = m_d->m_page.enableTextWrapping->isChecked();
displaySettings.m_showWrapColumn = m_d->m_page.showWrapColumn->isChecked();
displaySettings.m_wrapColumn = m_d->m_page.wrapColumn->value();
displaySettings.m_visualizeWhitespace = m_d->m_page.visualizeWhitespace->isChecked();
displaySettings.m_displayFoldingMarkers = m_d->m_page.displayFoldingMarkers->isChecked();
displaySettings.m_highlightCurrentLine = m_d->m_page.highlightCurrentLine->isChecked();
}
void DisplaySettingsPage::settingsToUI()
{
const DisplaySettings &displaySettings = m_d->m_displaySettings;
m_d->m_page.displayLineNumbers->setChecked(displaySettings.m_displayLineNumbers);
m_d->m_page.enableTextWrapping->setChecked(displaySettings.m_textWrapping);
m_d->m_page.showWrapColumn->setChecked(displaySettings.m_showWrapColumn);
m_d->m_page.wrapColumn->setValue(displaySettings.m_wrapColumn);
m_d->m_page.visualizeWhitespace->setChecked(displaySettings.m_visualizeWhitespace);
m_d->m_page.displayFoldingMarkers->setChecked(displaySettings.m_displayFoldingMarkers);
m_d->m_page.highlightCurrentLine->setChecked(displaySettings.m_highlightCurrentLine);
}
DisplaySettings DisplaySettingsPage::displaySettings() const
{
return m_d->m_displaySettings;
}
void DisplaySettingsPage::setDisplaySettings(const DisplaySettings &newDisplaySettings)
{
if (newDisplaySettings != m_d->m_displaySettings) {
m_d->m_displaySettings = newDisplaySettings;
Core::ICore *core = Core::ICore::instance();
if (QSettings *s = core->settings())
m_d->m_displaySettings.toSettings(m_d->m_parameters.settingsPrefix, s);
emit displaySettingsChanged(newDisplaySettings);
}
}
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#ifndef DISPLAYSETTINGSPAGE_H
#define DISPLAYSETTINGSPAGE_H
#include "texteditor_global.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <QtCore/QObject>
namespace TextEditor {
struct DisplaySettings;
struct DisplaySettingsPageParameters
{