forked from qt-creator/qt-creator
Settings page for the generic highlighter.
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** 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 "highlightersettings.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QLatin1String>
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QProcess>
|
||||
#endif
|
||||
|
||||
namespace TextEditor {
|
||||
namespace Internal {
|
||||
|
||||
void applyDefaults(HighlighterSettings *settings)
|
||||
{
|
||||
settings->m_definitionFilesPath.clear();
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
static const QLatin1String kateSyntax("/share/apps/katepart/syntax");
|
||||
|
||||
// Wild guess.
|
||||
QDir dir(QLatin1String("/usr") + kateSyntax);
|
||||
if (dir.exists()) {
|
||||
settings->m_definitionFilesPath = dir.path();
|
||||
} else {
|
||||
// Try kde-config.
|
||||
QProcess process;
|
||||
process.start(QLatin1String("kde-config"), QStringList(QLatin1String("--prefix")));
|
||||
if (process.waitForStarted(5000)) {
|
||||
process.waitForFinished(5000);
|
||||
QString output = QString::fromLocal8Bit(process.readAllStandardOutput());
|
||||
output.remove(QLatin1Char('\n'));
|
||||
dir.setPath(output + kateSyntax);
|
||||
if (dir.exists())
|
||||
settings->m_definitionFilesPath = dir.path();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (settings->m_definitionFilesPath.isEmpty())
|
||||
settings->m_definitionFilesPath = Core::ICore::instance()->resourcePath() +
|
||||
QLatin1String("/generic-highlighter");
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace TextEditor
|
||||
|
||||
namespace {
|
||||
|
||||
static const QLatin1String kDefinitionFilesPath("DefinitionFilesPath");
|
||||
static const QLatin1String kGroupPostfix("HighlighterSettings");
|
||||
|
||||
QString groupSpecifier(const QString &postFix, const QString &category)
|
||||
{
|
||||
if (category.isEmpty())
|
||||
return postFix;
|
||||
return QString(category + postFix);
|
||||
}
|
||||
|
||||
} // namespace anonymous
|
||||
|
||||
using namespace TextEditor;
|
||||
using namespace Internal;
|
||||
|
||||
HighlighterSettings::HighlighterSettings()
|
||||
{}
|
||||
|
||||
void HighlighterSettings::toSettings(const QString &category, QSettings *s) const
|
||||
{
|
||||
const QString &group = groupSpecifier(kGroupPostfix, category);
|
||||
s->beginGroup(group);
|
||||
s->setValue(kDefinitionFilesPath, m_definitionFilesPath);
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
void HighlighterSettings::fromSettings(const QString &category, QSettings *s)
|
||||
{
|
||||
const QString &group = groupSpecifier(kGroupPostfix, category);
|
||||
s->beginGroup(group);
|
||||
|
||||
if (!s->contains(kDefinitionFilesPath))
|
||||
applyDefaults(this);
|
||||
else
|
||||
m_definitionFilesPath = s->value(kDefinitionFilesPath, QString()).toString();
|
||||
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
bool HighlighterSettings::equals(const HighlighterSettings &highlighterSettings) const
|
||||
{
|
||||
return m_definitionFilesPath == highlighterSettings.m_definitionFilesPath;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** 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 HIGHLIGHTERSETTINGS_H
|
||||
#define HIGHLIGHTERSETTINGS_H
|
||||
|
||||
#include <QtCore/QString>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
struct HighlighterSettings
|
||||
{
|
||||
HighlighterSettings();
|
||||
|
||||
void toSettings(const QString &category, QSettings *s) const;
|
||||
void fromSettings(const QString &category, QSettings *s);
|
||||
|
||||
bool equals(const HighlighterSettings &highlighterSettings) const;
|
||||
|
||||
QString m_definitionFilesPath;
|
||||
};
|
||||
|
||||
inline bool operator==(const HighlighterSettings &a, const HighlighterSettings &b)
|
||||
{ return a.equals(b); }
|
||||
|
||||
inline bool operator!=(const HighlighterSettings &a, const HighlighterSettings &b)
|
||||
{ return !a.equals(b); }
|
||||
|
||||
namespace Internal {
|
||||
void applyDefaults(HighlighterSettings *settings);
|
||||
}
|
||||
|
||||
} // namespace TextEditor
|
||||
|
||||
#endif // HIGHLIGHTERSETTINGS_H
|
||||
@@ -0,0 +1,156 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** 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 "highlightersettingspage.h"
|
||||
#include "highlightersettings.h"
|
||||
#include "manager.h"
|
||||
#include "ui_highlightersettingspage.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
using namespace TextEditor;
|
||||
using namespace Internal;
|
||||
|
||||
struct HighlighterSettingsPage::HighlighterSettingsPagePrivate
|
||||
{
|
||||
explicit HighlighterSettingsPagePrivate(const QString &id);
|
||||
|
||||
const QString m_id;
|
||||
const QString m_displayName;
|
||||
const QString m_settingsPrefix;
|
||||
|
||||
QString m_searchKeywords;
|
||||
|
||||
HighlighterSettings m_settings;
|
||||
|
||||
Ui::HighlighterSettingsPage m_page;
|
||||
};
|
||||
|
||||
HighlighterSettingsPage::HighlighterSettingsPagePrivate::
|
||||
HighlighterSettingsPagePrivate(const QString &id) :
|
||||
m_id(id),
|
||||
m_displayName(tr("Generic Highlighter")),
|
||||
m_settingsPrefix(QLatin1String("text"))
|
||||
{}
|
||||
|
||||
HighlighterSettingsPage::HighlighterSettingsPage(const QString &id, QObject *parent) :
|
||||
TextEditorOptionsPage(parent),
|
||||
m_d(new HighlighterSettingsPagePrivate(id))
|
||||
{
|
||||
if (QSettings *s = Core::ICore::instance()->settings())
|
||||
m_d->m_settings.fromSettings(m_d->m_settingsPrefix, s);
|
||||
|
||||
connect(this, SIGNAL(definitionsLocationChanged()),
|
||||
Manager::instance(), SLOT(registerMimeTypes()));
|
||||
}
|
||||
|
||||
HighlighterSettingsPage::~HighlighterSettingsPage()
|
||||
{
|
||||
delete m_d;
|
||||
}
|
||||
|
||||
QString HighlighterSettingsPage::id() const
|
||||
{
|
||||
return m_d->m_id;
|
||||
}
|
||||
|
||||
QString HighlighterSettingsPage::displayName() const
|
||||
{
|
||||
return m_d->m_displayName;
|
||||
}
|
||||
|
||||
QWidget *HighlighterSettingsPage::createPage(QWidget *parent)
|
||||
{
|
||||
QWidget *w = new QWidget(parent);
|
||||
m_d->m_page.setupUi(w);
|
||||
|
||||
settingsToUI();
|
||||
|
||||
if (m_d->m_searchKeywords.isEmpty()) {
|
||||
QTextStream(&m_d->m_searchKeywords) << m_d->m_page.definitionFilesGroupBox->title()
|
||||
<< m_d->m_page.locationLabel->text();
|
||||
}
|
||||
|
||||
connect(m_d->m_page.resetButton, SIGNAL(clicked()), this, SLOT(reset()));
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
void HighlighterSettingsPage::apply()
|
||||
{
|
||||
if (settingsChanged())
|
||||
settingsFromUI();
|
||||
}
|
||||
|
||||
bool HighlighterSettingsPage::matches(const QString &s) const
|
||||
{
|
||||
return m_d->m_searchKeywords.contains(s, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
const HighlighterSettings &HighlighterSettingsPage::highlighterSettings() const
|
||||
{
|
||||
return m_d->m_settings;
|
||||
}
|
||||
|
||||
void HighlighterSettingsPage::settingsFromUI()
|
||||
{
|
||||
bool locationChanged = false;
|
||||
if (m_d->m_settings.m_definitionFilesPath != m_d->m_page.definitionFilesPath->path())
|
||||
locationChanged = true;
|
||||
|
||||
m_d->m_settings.m_definitionFilesPath = m_d->m_page.definitionFilesPath->path();
|
||||
if (QSettings *s = Core::ICore::instance()->settings())
|
||||
m_d->m_settings.toSettings(m_d->m_settingsPrefix, s);
|
||||
|
||||
if (locationChanged)
|
||||
emit definitionsLocationChanged();
|
||||
}
|
||||
|
||||
void HighlighterSettingsPage::settingsToUI(const HighlighterSettings *settings)
|
||||
{
|
||||
if (settings) {
|
||||
m_d->m_page.definitionFilesPath->setPath(settings->m_definitionFilesPath);
|
||||
} else {
|
||||
m_d->m_page.definitionFilesPath->setPath(m_d->m_settings.m_definitionFilesPath);
|
||||
}
|
||||
}
|
||||
|
||||
void HighlighterSettingsPage::reset()
|
||||
{
|
||||
HighlighterSettings defaultSettings;
|
||||
applyDefaults(&defaultSettings);
|
||||
settingsToUI(&defaultSettings);
|
||||
}
|
||||
|
||||
bool HighlighterSettingsPage::settingsChanged() const
|
||||
{
|
||||
if (m_d->m_settings.m_definitionFilesPath != m_d->m_page.definitionFilesPath->path())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** 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 HIGHLIGHTERSETTINGSPAGE_H
|
||||
#define HIGHLIGHTERSETTINGSPAGE_H
|
||||
|
||||
#include "texteditoroptionspage.h"
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
struct HighlighterSettings;
|
||||
|
||||
class HighlighterSettingsPage : public TextEditorOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HighlighterSettingsPage(const QString &id, QObject *parent);
|
||||
virtual ~HighlighterSettingsPage();
|
||||
|
||||
QString id() const;
|
||||
QString displayName() const;
|
||||
|
||||
QWidget *createPage(QWidget *parent);
|
||||
void apply();
|
||||
void finish() {}
|
||||
bool matches(const QString &s) const;
|
||||
|
||||
const HighlighterSettings &highlighterSettings() const;
|
||||
|
||||
signals:
|
||||
void definitionsLocationChanged();
|
||||
|
||||
private slots:
|
||||
void reset();
|
||||
|
||||
private:
|
||||
void settingsFromUI();
|
||||
void settingsToUI(const HighlighterSettings *settings = 0);
|
||||
|
||||
bool settingsChanged() const;
|
||||
|
||||
struct HighlighterSettingsPagePrivate;
|
||||
HighlighterSettingsPagePrivate *m_d;
|
||||
};
|
||||
|
||||
} // namespace TextEditor
|
||||
|
||||
#endif // HIGHLIGHTERSETTINGSPAGE_H
|
||||
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>HighlighterSettingsPage</class>
|
||||
<widget class="QWidget" name="HighlighterSettingsPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>453</width>
|
||||
<height>230</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="definitionFilesGroupBox">
|
||||
<property name="title">
|
||||
<string>Syntax Definition Files</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="locationLabel">
|
||||
<property name="text">
|
||||
<string>Location:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="Utils::PathChooser" name="definitionFilesPath" native="true">
|
||||
<zorder>locationLabel</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="resetButton">
|
||||
<property name="toolTip">
|
||||
<string>Reset to default</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>R</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../coreplugin/core.qrc">
|
||||
<normaloff>:/core/images/reset.png</normaloff>:/core/images/reset.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>locationLabel</zorder>
|
||||
<zorder>definitionFilesPath</zorder>
|
||||
<zorder>resetButton</zorder>
|
||||
<zorder>resetButton</zorder>
|
||||
<zorder>resetButton</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>146</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Utils::PathChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">utils/pathchooser.h</header>
|
||||
<container>1</container>
|
||||
<slots>
|
||||
<signal>editingFinished()</signal>
|
||||
<signal>browsingFinished()</signal>
|
||||
</slots>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../coreplugin/core.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "texteditorplugin.h"
|
||||
#include "texteditorsettings.h"
|
||||
#include "plaintexteditorfactory.h"
|
||||
#include "highlightersettings.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -133,6 +134,7 @@ bool Manager::isBuildingDefinition(const QString &id) const
|
||||
|
||||
void Manager::registerMimeTypes()
|
||||
{
|
||||
clear();
|
||||
QFuture<Core::MimeType> future =
|
||||
QtConcurrent::run(&Manager::gatherDefinitionsMimeTypes, this);
|
||||
m_watcher.setFuture(future);
|
||||
@@ -142,8 +144,8 @@ void Manager::registerMimeTypes()
|
||||
|
||||
void Manager::gatherDefinitionsMimeTypes(QFutureInterface<Core::MimeType> &future)
|
||||
{
|
||||
QDir definitionsDir(Core::ICore::instance()->resourcePath() +
|
||||
QLatin1String("/generic-highlighter"));
|
||||
const HighlighterSettings &settings = TextEditorSettings::instance()->highlighterSettings();
|
||||
QDir definitionsDir(settings.m_definitionFilesPath);
|
||||
|
||||
QStringList filter(QLatin1String("*.xml"));
|
||||
definitionsDir.setNameFilters(filter);
|
||||
@@ -247,3 +249,11 @@ void Manager::parseDefinitionMetadata(const QFileInfo &fileInfo,
|
||||
reader.clear();
|
||||
definitionFile.close();
|
||||
}
|
||||
|
||||
void Manager::clear()
|
||||
{
|
||||
m_priorityComp.m_priorityById.clear();
|
||||
m_idByName.clear();
|
||||
m_idByMimeType.clear();
|
||||
m_definitions.clear();
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QFileInfo;
|
||||
class QStringList;
|
||||
class QDir;
|
||||
template <class> class QFutureInterface;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -63,14 +64,17 @@ public:
|
||||
bool isBuildingDefinition(const QString &id) const;
|
||||
const QSharedPointer<HighlightDefinition> &definition(const QString &id);
|
||||
|
||||
private slots:
|
||||
public slots:
|
||||
void registerMimeTypes();
|
||||
|
||||
private slots:
|
||||
void registerMimeType(int index) const;
|
||||
|
||||
private:
|
||||
Manager();
|
||||
Q_DISABLE_COPY(Manager)
|
||||
|
||||
void clear();
|
||||
void gatherDefinitionsMimeTypes(QFutureInterface<Core::MimeType> &future);
|
||||
void parseDefinitionMetadata(const QFileInfo &fileInfo,
|
||||
QString *comment,
|
||||
|
||||
@@ -52,7 +52,9 @@ SOURCES += texteditorplugin.cpp \
|
||||
generichighlighter/highlightdefinition.cpp \
|
||||
generichighlighter/highlighter.cpp \
|
||||
generichighlighter/manager.cpp \
|
||||
generichighlighter/highlightdefinitionhandler.cpp
|
||||
generichighlighter/highlightdefinitionhandler.cpp \
|
||||
generichighlighter/highlightersettingspage.cpp \
|
||||
generichighlighter/highlightersettings.cpp
|
||||
|
||||
HEADERS += texteditorplugin.h \
|
||||
textfilewizard.h \
|
||||
@@ -107,12 +109,15 @@ HEADERS += texteditorplugin.h \
|
||||
generichighlighter/highlightdefinition.h \
|
||||
generichighlighter/highlighter.h \
|
||||
generichighlighter/manager.h \
|
||||
generichighlighter/highlightdefinitionhandler.h
|
||||
generichighlighter/highlightdefinitionhandler.h \
|
||||
generichighlighter/highlightersettingspage.h \
|
||||
generichighlighter/highlightersettings.h
|
||||
|
||||
|
||||
FORMS += behaviorsettingspage.ui \
|
||||
displaysettingspage.ui \
|
||||
fontsettingspage.ui \
|
||||
colorschemeedit.ui
|
||||
colorschemeedit.ui \
|
||||
generichighlighter/highlightersettingspage.ui
|
||||
RESOURCES += texteditor.qrc
|
||||
OTHER_FILES += TextEditor.pluginspec TextEditor.mimetypes.xml
|
||||
|
||||
@@ -71,9 +71,6 @@ TextEditorPlugin::TextEditorPlugin()
|
||||
{
|
||||
QTC_ASSERT(!m_instance, return);
|
||||
m_instance = this;
|
||||
|
||||
connect(Core::ICore::instance(), SIGNAL(coreOpened()),
|
||||
Manager::instance(), SLOT(registerMimeTypes()));
|
||||
}
|
||||
|
||||
TextEditorPlugin::~TextEditorPlugin()
|
||||
@@ -145,6 +142,10 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
quickFixCommand->setDefaultKeySequence(QKeySequence(tr("Alt+Return")));
|
||||
connect(quickFixShortcut, SIGNAL(activated()), this, SLOT(invokeQuickFix()));
|
||||
|
||||
// Generic highlighter.
|
||||
connect(Core::ICore::instance(), SIGNAL(coreOpened()),
|
||||
Manager::instance(), SLOT(registerMimeTypes()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "storagesettings.h"
|
||||
#include "tabsettings.h"
|
||||
#include "texteditorplugin.h"
|
||||
#include "highlightersettingspage.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
@@ -60,6 +61,7 @@ public:
|
||||
FontSettingsPage *m_fontSettingsPage;
|
||||
BehaviorSettingsPage *m_behaviorSettingsPage;
|
||||
DisplaySettingsPage *m_displaySettingsPage;
|
||||
HighlighterSettingsPage *m_highlighterSettingsPage;
|
||||
|
||||
CompletionSettings m_completionSettings;
|
||||
|
||||
@@ -160,6 +162,10 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
|
||||
m_d->m_displaySettingsPage = new DisplaySettingsPage(displaySettingsPageParameters, this);
|
||||
pm->addObject(m_d->m_displaySettingsPage);
|
||||
|
||||
m_d->m_highlighterSettingsPage =
|
||||
new HighlighterSettingsPage(QLatin1String("E.HighlighterSettings"), this);
|
||||
pm->addObject(m_d->m_highlighterSettingsPage);
|
||||
|
||||
connect(m_d->m_fontSettingsPage, SIGNAL(changed(TextEditor::FontSettings)),
|
||||
this, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)));
|
||||
connect(m_d->m_behaviorSettingsPage, SIGNAL(tabSettingsChanged(TextEditor::TabSettings)),
|
||||
@@ -182,6 +188,7 @@ TextEditorSettings::~TextEditorSettings()
|
||||
pm->removeObject(m_d->m_fontSettingsPage);
|
||||
pm->removeObject(m_d->m_behaviorSettingsPage);
|
||||
pm->removeObject(m_d->m_displaySettingsPage);
|
||||
pm->removeObject(m_d->m_highlighterSettingsPage);
|
||||
|
||||
delete m_d;
|
||||
|
||||
@@ -258,6 +265,11 @@ const CompletionSettings &TextEditorSettings::completionSettings() const
|
||||
return m_d->m_completionSettings;
|
||||
}
|
||||
|
||||
const HighlighterSettings &TextEditorSettings::highlighterSettings() const
|
||||
{
|
||||
return m_d->m_highlighterSettingsPage->highlighterSettings();
|
||||
}
|
||||
|
||||
void TextEditorSettings::setCompletionSettings(const TextEditor::CompletionSettings &settings)
|
||||
{
|
||||
if (m_d->m_completionSettings == settings)
|
||||
|
||||
@@ -37,15 +37,13 @@
|
||||
namespace TextEditor {
|
||||
|
||||
class BaseTextEditor;
|
||||
class BehaviorSettingsPage;
|
||||
class DisplaySettingsPage;
|
||||
class FontSettingsPage;
|
||||
class FontSettings;
|
||||
struct TabSettings;
|
||||
struct StorageSettings;
|
||||
struct BehaviorSettings;
|
||||
struct DisplaySettings;
|
||||
struct CompletionSettings;
|
||||
struct HighlighterSettings;
|
||||
|
||||
namespace Internal {
|
||||
class TextEditorSettingsPrivate;
|
||||
@@ -74,6 +72,7 @@ public:
|
||||
const BehaviorSettings &behaviorSettings() const;
|
||||
const DisplaySettings &displaySettings() const;
|
||||
const CompletionSettings &completionSettings() const;
|
||||
const HighlighterSettings &highlighterSettings() const;
|
||||
|
||||
void setCompletionSettings(const TextEditor::CompletionSettings &);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user