Commit 9454fe56 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Create a single parent options page for the Text Editor category

Trying to clean up a little.
parent 872a75ef
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "ui_completionsettingspage.h" #include "ui_completionsettingspage.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <texteditor/texteditorconstants.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <QtCore/QTextStream> #include <QtCore/QTextStream>
...@@ -60,21 +59,6 @@ QString CompletionSettingsPage::displayName() const ...@@ -60,21 +59,6 @@ QString CompletionSettingsPage::displayName() const
return tr("Completion"); return tr("Completion");
} }
QString CompletionSettingsPage::category() const
{
return QLatin1String(TextEditor::Constants::TEXT_EDITOR_SETTINGS_CATEGORY);
}
QString CompletionSettingsPage::displayCategory() const
{
return QCoreApplication::translate("Text Editor", TextEditor::Constants::TEXT_EDITOR_SETTINGS_TR_CATEGORY);
}
QIcon CompletionSettingsPage::categoryIcon() const
{
return QIcon(QLatin1String(TextEditor::Constants::TEXT_EDITOR_SETTINGS_CATEGORY_ICON));
}
QWidget *CompletionSettingsPage::createPage(QWidget *parent) QWidget *CompletionSettingsPage::createPage(QWidget *parent)
{ {
QWidget *w = new QWidget(parent); QWidget *w = new QWidget(parent);
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#ifndef COMPLETIONSETTINGSPAGE_H #ifndef COMPLETIONSETTINGSPAGE_H
#define COMPLETIONSETTINGSPAGE_H #define COMPLETIONSETTINGSPAGE_H
#include <coreplugin/dialogs/ioptionspage.h> #include <texteditor/texteditoroptionspage.h>
#include "cppcodecompletion.h" #include "cppcodecompletion.h"
...@@ -41,7 +41,7 @@ QT_END_NAMESPACE ...@@ -41,7 +41,7 @@ QT_END_NAMESPACE
namespace CppTools { namespace CppTools {
namespace Internal { namespace Internal {
class CompletionSettingsPage : public Core::IOptionsPage class CompletionSettingsPage : public TextEditor::TextEditorOptionsPage
{ {
Q_OBJECT Q_OBJECT
...@@ -51,9 +51,6 @@ public: ...@@ -51,9 +51,6 @@ public:
QString id() const; QString id() const;
QString displayName() const; QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent); QWidget *createPage(QWidget *parent);
void apply(); void apply();
......
...@@ -68,7 +68,7 @@ BehaviorSettingsPage::BehaviorSettingsPagePrivate::BehaviorSettingsPagePrivate ...@@ -68,7 +68,7 @@ BehaviorSettingsPage::BehaviorSettingsPagePrivate::BehaviorSettingsPagePrivate
BehaviorSettingsPage::BehaviorSettingsPage(const BehaviorSettingsPageParameters &p, BehaviorSettingsPage::BehaviorSettingsPage(const BehaviorSettingsPageParameters &p,
QObject *parent) QObject *parent)
: Core::IOptionsPage(parent), : TextEditorOptionsPage(parent),
m_d(new BehaviorSettingsPagePrivate(p)) m_d(new BehaviorSettingsPagePrivate(p))
{ {
} }
...@@ -88,21 +88,6 @@ QString BehaviorSettingsPage::displayName() const ...@@ -88,21 +88,6 @@ QString BehaviorSettingsPage::displayName() const
return m_d->m_parameters.displayName; return m_d->m_parameters.displayName;
} }
QString BehaviorSettingsPage::category() const
{
return m_d->m_parameters.category;
}
QString BehaviorSettingsPage::displayCategory() const
{
return m_d->m_parameters.displayCategory;
}
QIcon BehaviorSettingsPage::categoryIcon() const
{
return m_d->m_parameters.categoryIcon;
}
QWidget *BehaviorSettingsPage::createPage(QWidget *parent) QWidget *BehaviorSettingsPage::createPage(QWidget *parent)
{ {
QWidget *w = new QWidget(parent); QWidget *w = new QWidget(parent);
......
...@@ -32,9 +32,7 @@ ...@@ -32,9 +32,7 @@
#include "texteditor_global.h" #include "texteditor_global.h"
#include <coreplugin/dialogs/ioptionspage.h> #include "texteditoroptionspage.h"
#include <QtCore/QObject>
namespace TextEditor { namespace TextEditor {
...@@ -46,13 +44,10 @@ struct BehaviorSettingsPageParameters ...@@ -46,13 +44,10 @@ struct BehaviorSettingsPageParameters
{ {
QString id; QString id;
QString displayName; QString displayName;
QString category;
QString displayCategory;
QIcon categoryIcon;
QString settingsPrefix; QString settingsPrefix;
}; };
class BehaviorSettingsPage : public Core::IOptionsPage class BehaviorSettingsPage : public TextEditorOptionsPage
{ {
Q_OBJECT Q_OBJECT
...@@ -63,20 +58,16 @@ public: ...@@ -63,20 +58,16 @@ public:
// IOptionsPage // IOptionsPage
QString id() const; QString id() const;
QString displayName() const; QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent); QWidget *createPage(QWidget *parent);
void apply(); void apply();
void finish() { } void finish() { }
bool matches(const QString &s) const;
const TabSettings &tabSettings() const; const TabSettings &tabSettings() const;
const StorageSettings &storageSettings() const; const StorageSettings &storageSettings() const;
const BehaviorSettings &behaviorSettings() const; const BehaviorSettings &behaviorSettings() const;
virtual bool matches(const QString &s) const;
signals: signals:
void tabSettingsChanged(const TextEditor::TabSettings &); void tabSettingsChanged(const TextEditor::TabSettings &);
void storageSettingsChanged(const TextEditor::StorageSettings &); void storageSettingsChanged(const TextEditor::StorageSettings &);
......
...@@ -59,7 +59,7 @@ DisplaySettingsPage::DisplaySettingsPagePrivate::DisplaySettingsPagePrivate ...@@ -59,7 +59,7 @@ DisplaySettingsPage::DisplaySettingsPagePrivate::DisplaySettingsPagePrivate
DisplaySettingsPage::DisplaySettingsPage(const DisplaySettingsPageParameters &p, DisplaySettingsPage::DisplaySettingsPage(const DisplaySettingsPageParameters &p,
QObject *parent) QObject *parent)
: Core::IOptionsPage(parent), : TextEditorOptionsPage(parent),
m_d(new DisplaySettingsPagePrivate(p)) m_d(new DisplaySettingsPagePrivate(p))
{ {
} }
...@@ -79,21 +79,6 @@ QString DisplaySettingsPage::displayName() const ...@@ -79,21 +79,6 @@ QString DisplaySettingsPage::displayName() const
return m_d->m_parameters.displayName; return m_d->m_parameters.displayName;
} }
QString DisplaySettingsPage::category() const
{
return m_d->m_parameters.category;
}
QString DisplaySettingsPage::displayCategory() const
{
return m_d->m_parameters.displayCategory;
}
QIcon DisplaySettingsPage::categoryIcon() const
{
return m_d->m_parameters.categoryIcon;
}
QWidget *DisplaySettingsPage::createPage(QWidget *parent) QWidget *DisplaySettingsPage::createPage(QWidget *parent)
{ {
QWidget *w = new QWidget(parent); QWidget *w = new QWidget(parent);
......
...@@ -32,9 +32,7 @@ ...@@ -32,9 +32,7 @@
#include "texteditor_global.h" #include "texteditor_global.h"
#include <coreplugin/dialogs/ioptionspage.h> #include "texteditoroptionspage.h"
#include <QtCore/QObject>
namespace TextEditor { namespace TextEditor {
...@@ -44,13 +42,10 @@ struct DisplaySettingsPageParameters ...@@ -44,13 +42,10 @@ struct DisplaySettingsPageParameters
{ {
QString id; QString id;
QString displayName; QString displayName;
QString category;
QString displayCategory;
QIcon categoryIcon;
QString settingsPrefix; QString settingsPrefix;
}; };
class DisplaySettingsPage : public Core::IOptionsPage class DisplaySettingsPage : public TextEditorOptionsPage
{ {
Q_OBJECT Q_OBJECT
...@@ -61,9 +56,6 @@ public: ...@@ -61,9 +56,6 @@ public:
// IOptionsPage // IOptionsPage
QString id() const; QString id() const;
QString displayName() const; QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent); QWidget *createPage(QWidget *parent);
void apply(); void apply();
......
...@@ -117,17 +117,14 @@ class FontSettingsPagePrivate ...@@ -117,17 +117,14 @@ class FontSettingsPagePrivate
public: public:
FontSettingsPagePrivate(const TextEditor::FormatDescriptions &fd, FontSettingsPagePrivate(const TextEditor::FormatDescriptions &fd,
const QString &id, const QString &id,
const QString &name, const QString &displayName,
const QString &category, const QString &category);
const QString &trCategory);
~FontSettingsPagePrivate(); ~FontSettingsPagePrivate();
public: public:
const QString m_id; const QString m_id;
const QString m_displayName; const QString m_displayName;
const QString m_settingsGroup; const QString m_settingsGroup;
const QString m_category;
const QString m_displayCategory;
TextEditor::FormatDescriptions m_descriptions; TextEditor::FormatDescriptions m_descriptions;
FontSettings m_value; FontSettings m_value;
...@@ -178,13 +175,10 @@ static QString createColorSchemeFileName(const QString &pattern) ...@@ -178,13 +175,10 @@ static QString createColorSchemeFileName(const QString &pattern)
FontSettingsPagePrivate::FontSettingsPagePrivate(const TextEditor::FormatDescriptions &fd, FontSettingsPagePrivate::FontSettingsPagePrivate(const TextEditor::FormatDescriptions &fd,
const QString &id, const QString &id,
const QString &displayName, const QString &displayName,
const QString &category, const QString &category) :
const QString &trCategory) :
m_id(id), m_id(id),
m_displayName(displayName), m_displayName(displayName),
m_settingsGroup(Utils::settingsKey(category)), m_settingsGroup(Utils::settingsKey(category)),
m_category(category),
m_displayCategory(trCategory),
m_descriptions(fd), m_descriptions(fd),
m_schemeListModel(new SchemeListModel), m_schemeListModel(new SchemeListModel),
m_refreshingSchemeList(false) m_refreshingSchemeList(false)
...@@ -313,11 +307,9 @@ QColor FormatDescription::background() const ...@@ -313,11 +307,9 @@ QColor FormatDescription::background() const
// ------------ FontSettingsPage // ------------ FontSettingsPage
FontSettingsPage::FontSettingsPage(const FormatDescriptions &fd, FontSettingsPage::FontSettingsPage(const FormatDescriptions &fd,
const QString &id, const QString &id,
const QString &category,
const QString &trCategory,
QObject *parent) : QObject *parent) :
Core::IOptionsPage(parent), TextEditorOptionsPage(parent),
d_ptr(new FontSettingsPagePrivate(fd, id, tr("Font && Colors"), category, trCategory)) d_ptr(new FontSettingsPagePrivate(fd, id, tr("Font && Colors"), category()))
{ {
} }
...@@ -336,21 +328,6 @@ QString FontSettingsPage::displayName() const ...@@ -336,21 +328,6 @@ QString FontSettingsPage::displayName() const
return d_ptr->m_displayName; return d_ptr->m_displayName;
} }
QString FontSettingsPage::category() const
{
return d_ptr->m_category;
}
QString FontSettingsPage::displayCategory() const
{
return d_ptr->m_displayCategory;
}
QIcon FontSettingsPage::categoryIcon() const
{
return QIcon(QLatin1String(Constants::TEXT_EDITOR_SETTINGS_CATEGORY_ICON));
}
QWidget *FontSettingsPage::createPage(QWidget *parent) QWidget *FontSettingsPage::createPage(QWidget *parent)
{ {
QWidget *w = new QWidget(parent); QWidget *w = new QWidget(parent);
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "fontsettings.h" #include "fontsettings.h"
#include <coreplugin/dialogs/ioptionspage.h> #include "texteditoroptionspage.h"
#include <QtCore/QString> #include <QtCore/QString>
...@@ -77,24 +77,19 @@ private: ...@@ -77,24 +77,19 @@ private:
typedef QList<FormatDescription> FormatDescriptions; typedef QList<FormatDescription> FormatDescriptions;
class TEXTEDITOR_EXPORT FontSettingsPage : public Core::IOptionsPage class TEXTEDITOR_EXPORT FontSettingsPage : public TextEditorOptionsPage
{ {
Q_OBJECT Q_OBJECT
public: public:
FontSettingsPage(const FormatDescriptions &fd, FontSettingsPage(const FormatDescriptions &fd,
const QString &id, const QString &id,
const QString &category,
const QString &trCategory,
QObject *parent = 0); QObject *parent = 0);
~FontSettingsPage(); ~FontSettingsPage();
QString id() const; QString id() const;
QString displayName() const; QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent); QWidget *createPage(QWidget *parent);
void apply(); void apply();
......
...@@ -32,7 +32,8 @@ SOURCES += texteditorplugin.cpp \ ...@@ -32,7 +32,8 @@ SOURCES += texteditorplugin.cpp \
colorscheme.cpp \ colorscheme.cpp \
colorschemeedit.cpp \ colorschemeedit.cpp \
itexteditor.cpp \ itexteditor.cpp \
texteditoroverlay.cpp texteditoroverlay.cpp \
texteditoroptionspage.cpp
HEADERS += texteditorplugin.h \ HEADERS += texteditorplugin.h \
textfilewizard.h \ textfilewizard.h \
...@@ -67,7 +68,8 @@ HEADERS += texteditorplugin.h \ ...@@ -67,7 +68,8 @@ HEADERS += texteditorplugin.h \
findincurrentfile.h \ findincurrentfile.h \
colorscheme.h \ colorscheme.h \
colorschemeedit.h \ colorschemeedit.h \
texteditoroverlay.h texteditoroverlay.h \
texteditoroptionspage.h
FORMS += behaviorsettingspage.ui \ FORMS += behaviorsettingspage.ui \
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "texteditoroptionspage.h"
#include "texteditorconstants.h"
#include <QCoreApplication>
using namespace TextEditor;
TextEditorOptionsPage::TextEditorOptionsPage(QObject *parent) :
Core::IOptionsPage(parent)
{
}
QString TextEditorOptionsPage::category() const
{
return QLatin1String(Constants::TEXT_EDITOR_SETTINGS_CATEGORY);
}
QString TextEditorOptionsPage::displayCategory() const
{
return QCoreApplication::translate("TextEditor", Constants::TEXT_EDITOR_SETTINGS_TR_CATEGORY);
}
QIcon TextEditorOptionsPage::categoryIcon() const
{
return QIcon(QLatin1String(Constants::TEXT_EDITOR_SETTINGS_CATEGORY_ICON));
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef TEXTEDITOROPTIONSPAGE_H
#define TEXTEDITOROPTIONSPAGE_H
#include <coreplugin/dialogs/ioptionspage.h>
#include "texteditor_global.h"
namespace TextEditor {
/**
* An abstract options page in the Text Editor category.
*/
class TEXTEDITOR_EXPORT TextEditorOptionsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
explicit TextEditorOptionsPage(QObject *parent = 0);
// IOptionsPage
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
};
} // namespace TextEditor
#endif // TEXTEDITOROPTIONSPAGE_H
...@@ -102,22 +102,15 @@ TextEditorSettings::TextEditorSettings(QObject *parent) ...@@ -102,22 +102,15 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
formatDescriptions.append(FormatDescription(QLatin1String(C_DIFF_FILE), tr("Diff File"), Qt::darkBlue)); formatDescriptions.append(FormatDescription(QLatin1String(C_DIFF_FILE), tr("Diff File"), Qt::darkBlue));
formatDescriptions.append(FormatDescription(QLatin1String(C_DIFF_LOCATION), tr("Diff Location"), Qt::blue)); formatDescriptions.append(FormatDescription(QLatin1String(C_DIFF_LOCATION), tr("Diff Location"), Qt::blue));
const QString category = QLatin1String(Constants::TEXT_EDITOR_SETTINGS_CATEGORY);
const QString displayCategory = QCoreApplication::translate("TextEditor", Constants::TEXT_EDITOR_SETTINGS_TR_CATEGORY);
const QIcon categoryIcon = QIcon(QLatin1String(Constants::TEXT_EDITOR_SETTINGS_CATEGORY_ICON));
m_fontSettingsPage = new FontSettingsPage(formatDescriptions, m_fontSettingsPage = new FontSettingsPage(formatDescriptions,
QLatin1String("A.FontSettings"), QLatin1String("A.FontSettings"),
category, displayCategory, this); this);
pm->addObject(m_fontSettingsPage); pm->addObject(m_fontSettingsPage);
// Add the GUI used to configure the tab, storage and interaction settings // Add the GUI used to configure the tab, storage and interaction settings
TextEditor::BehaviorSettingsPageParameters behaviorSettingsPageParameters; TextEditor::BehaviorSettingsPageParameters behaviorSettingsPageParameters;
behaviorSettingsPageParameters.id = QLatin1String("B.BehaviourSettings"); behaviorSettingsPageParameters.id = QLatin1String("B.BehaviourSettings");
behaviorSettingsPageParameters.displayName = tr("Behavior");