forked from qt-creator/qt-creator
Fixes: fakevim: add flags to settings page
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
#include <texteditor/basetextmark.h>
|
||||
#include <texteditor/itexteditor.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
#include <texteditor/interactionsettings.h>
|
||||
#include <texteditor/tabsettings.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
|
||||
@@ -229,14 +230,12 @@ void FakeVimPluginPrivate::installHandler(Core::IEditor *editor)
|
||||
void FakeVimPluginPrivate::writeFile(bool *handled,
|
||||
const QString &fileName, const QString &contents)
|
||||
{
|
||||
//qDebug() << "HANDLING WRITE FILE" << fileName << sender();
|
||||
FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
|
||||
if (!handler)
|
||||
return;
|
||||
|
||||
Core::IEditor *editor = qobject_cast<Core::IEditor *>(handler->extraData());
|
||||
if (editor && editor->file()->fileName() == fileName) {
|
||||
//qDebug() << "HANDLING CORE SAVE";
|
||||
// Handle that as a special case for nicer interaction with core
|
||||
Core::IFile *file = editor->file();
|
||||
m_core->fileManager()->blockFileChange(file);
|
||||
@@ -261,6 +260,13 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
||||
Q_UNUSED(editor);
|
||||
//qDebug() << "OPENING: " << editor << editor->widget();
|
||||
//installHandler(editor);
|
||||
QWidget *widget = editor->widget();
|
||||
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(widget)) {
|
||||
InteractionSettings settings = bt->interactionSettings();
|
||||
qDebug() << "USE VIM: " << settings.m_useVim;
|
||||
if (settings.m_useVim)
|
||||
installHandler(editor);
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::editorAboutToClose(Core::IEditor *editor)
|
||||
|
@@ -2709,6 +2709,10 @@ const DisplaySettings &BaseTextEditor::displaySettings() const
|
||||
return d->m_displaySettings;
|
||||
}
|
||||
|
||||
const InteractionSettings &BaseTextEditor::interactionSettings() const
|
||||
{
|
||||
return d->m_interactionSettings;
|
||||
}
|
||||
|
||||
|
||||
void BaseTextEditor::indentOrUnindent(bool doIndent)
|
||||
|
@@ -37,6 +37,7 @@
|
||||
|
||||
#include "displaysettings.h"
|
||||
#include "tabsettings.h"
|
||||
#include "interactionsettings.h"
|
||||
#include "itexteditable.h"
|
||||
|
||||
#include <QtGui/QPlainTextEdit>
|
||||
@@ -88,7 +89,8 @@ struct TEXTEDITOR_EXPORT Parenthesis
|
||||
|
||||
|
||||
|
||||
class TEXTEDITOR_EXPORT TextBlockUserData : public QTextBlockUserData {
|
||||
class TEXTEDITOR_EXPORT TextBlockUserData : public QTextBlockUserData
|
||||
{
|
||||
public:
|
||||
|
||||
enum CollapseMode { NoCollapse , CollapseThis, CollapseAfter };
|
||||
@@ -382,9 +384,9 @@ public:
|
||||
virtual void extraAreaMouseEvent(QMouseEvent *);
|
||||
virtual void extraAreaLeaveEvent(QEvent *);
|
||||
|
||||
|
||||
const TabSettings &tabSettings() const;
|
||||
const DisplaySettings &displaySettings() const;
|
||||
const InteractionSettings &interactionSettings() const;
|
||||
|
||||
void markBlocksAsChanged(QList<int> blockNumbers);
|
||||
|
||||
@@ -402,9 +404,12 @@ public:
|
||||
void setExtraSelections(ExtraSelectionKind kind, const QList<QTextEdit::ExtraSelection> &selections);
|
||||
QList<QTextEdit::ExtraSelection> extraSelections(ExtraSelectionKind kind) const;
|
||||
|
||||
struct BlockRange {
|
||||
BlockRange():first(0), last(-1){}
|
||||
BlockRange(int first_position, int last_position):first(first_position), last(last_position){}
|
||||
struct BlockRange
|
||||
{
|
||||
BlockRange() : first(0), last(-1) {}
|
||||
BlockRange(int first_position, int last_position)
|
||||
: first(first_position), last(last_position)
|
||||
{}
|
||||
int first;
|
||||
int last;
|
||||
inline bool isNull() const { return last < first; }
|
||||
@@ -413,7 +418,6 @@ public:
|
||||
// the blocks list must be sorted
|
||||
void setIfdefedOutBlocks(const QList<BaseTextEditor::BlockRange> &blocks);
|
||||
|
||||
|
||||
public slots:
|
||||
virtual void setTabSettings(const TextEditor::TabSettings &);
|
||||
virtual void setDisplaySettings(const TextEditor::DisplaySettings &);
|
||||
@@ -442,8 +446,6 @@ protected slots:
|
||||
virtual void slotCursorPositionChanged();
|
||||
virtual void slotUpdateBlockNotify(const QTextBlock &);
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
void requestBlockUpdate(const QTextBlock &);
|
||||
void requestAutoCompletion(ITextEditable *editor, bool forced);
|
||||
|
@@ -165,6 +165,7 @@ public:
|
||||
|
||||
QWidget *m_extraArea;
|
||||
DisplaySettings m_displaySettings;
|
||||
InteractionSettings m_interactionSettings;
|
||||
|
||||
int extraAreaSelectionAnchorBlockNumber;
|
||||
int extraAreaToggleMarkBlockNumber;
|
||||
|
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "displaysettings.h"
|
||||
#include "generalsettingspage.h"
|
||||
#include "interactionsettings.h"
|
||||
#include "storagesettings.h"
|
||||
#include "tabsettings.h"
|
||||
#include "ui_generalsettingspage.h"
|
||||
@@ -53,6 +54,7 @@ struct GeneralSettingsPage::GeneralSettingsPagePrivate
|
||||
TabSettings m_tabSettings;
|
||||
StorageSettings m_storageSettings;
|
||||
DisplaySettings m_displaySettings;
|
||||
InteractionSettings m_interactionSettings;
|
||||
};
|
||||
|
||||
GeneralSettingsPage::GeneralSettingsPagePrivate::GeneralSettingsPagePrivate
|
||||
@@ -63,6 +65,7 @@ GeneralSettingsPage::GeneralSettingsPagePrivate::GeneralSettingsPagePrivate
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +109,11 @@ void GeneralSettingsPage::apply()
|
||||
TabSettings newTabSettings;
|
||||
StorageSettings newStorageSettings;
|
||||
DisplaySettings newDisplaySettings;
|
||||
InteractionSettings newInteractionSettings;
|
||||
|
||||
settingsFromUI(newTabSettings, newStorageSettings, newDisplaySettings,
|
||||
newInteractionSettings);
|
||||
|
||||
settingsFromUI(newTabSettings, newStorageSettings, newDisplaySettings);
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
|
||||
if (newTabSettings != m_d->m_tabSettings) {
|
||||
@@ -133,11 +139,20 @@ void GeneralSettingsPage::apply()
|
||||
|
||||
emit displaySettingsChanged(newDisplaySettings);
|
||||
}
|
||||
|
||||
if (newInteractionSettings != m_d->m_interactionSettings) {
|
||||
m_d->m_interactionSettings = newInteractionSettings;
|
||||
if (QSettings *s = core->settings())
|
||||
m_d->m_interactionSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
|
||||
|
||||
emit interactionSettingsChanged(newInteractionSettings);
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::settingsFromUI(TabSettings &rc,
|
||||
StorageSettings &storageSettings,
|
||||
DisplaySettings &displaySettings) const
|
||||
DisplaySettings &displaySettings,
|
||||
InteractionSettings &interactionSettings) const
|
||||
{
|
||||
rc.m_spacesForTabs = m_d->m_page.insertSpaces->isChecked();
|
||||
rc.m_autoIndent = m_d->m_page.autoIndent->isChecked();
|
||||
@@ -156,6 +171,8 @@ void GeneralSettingsPage::settingsFromUI(TabSettings &rc,
|
||||
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()
|
||||
@@ -180,6 +197,9 @@ void GeneralSettingsPage::settingsToUI()
|
||||
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;
|
||||
m_d->m_page.useVim->setChecked(interactionSettings.m_useVim);
|
||||
}
|
||||
|
||||
TabSettings GeneralSettingsPage::tabSettings() const
|
||||
@@ -197,6 +217,11 @@ DisplaySettings GeneralSettingsPage::displaySettings() const
|
||||
return m_d->m_displaySettings;
|
||||
}
|
||||
|
||||
InteractionSettings GeneralSettingsPage::interactionSettings() const
|
||||
{
|
||||
return m_d->m_interactionSettings;
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::setDisplaySettings(const DisplaySettings &newDisplaySettings)
|
||||
{
|
||||
if (newDisplaySettings != m_d->m_displaySettings) {
|
||||
|
@@ -45,6 +45,7 @@ namespace TextEditor {
|
||||
struct TabSettings;
|
||||
struct StorageSettings;
|
||||
struct DisplaySettings;
|
||||
struct InteractionSettings;
|
||||
|
||||
struct TEXTEDITOR_EXPORT GeneralSettingsPageParameters
|
||||
{
|
||||
@@ -74,6 +75,7 @@ public:
|
||||
TabSettings tabSettings() const;
|
||||
StorageSettings storageSettings() const;
|
||||
DisplaySettings displaySettings() const;
|
||||
InteractionSettings interactionSettings() const;
|
||||
|
||||
void setDisplaySettings(const DisplaySettings &);
|
||||
|
||||
@@ -81,11 +83,14 @@ signals:
|
||||
void tabSettingsChanged(const TextEditor::TabSettings &);
|
||||
void storageSettingsChanged(const TextEditor::StorageSettings &);
|
||||
void displaySettingsChanged(const TextEditor::DisplaySettings &);
|
||||
void interactionSettingsChanged(const TextEditor::InteractionSettings &);
|
||||
|
||||
private:
|
||||
void settingsFromUI(TabSettings &rc,
|
||||
StorageSettings &storageSettings,
|
||||
DisplaySettings &displaySettings) const;
|
||||
DisplaySettings &displaySettings,
|
||||
InteractionSettings &interactionSettings
|
||||
) const;
|
||||
void settingsToUI();
|
||||
struct GeneralSettingsPagePrivate;
|
||||
GeneralSettingsPagePrivate *m_d;
|
||||
|
@@ -296,7 +296,7 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxVim">
|
||||
<widget class="QCheckBox" name="useVim">
|
||||
<property name="text">
|
||||
<string>Use "vi" style editing</string>
|
||||
</property>
|
||||
|
73
src/plugins/texteditor/interactionsettings.cpp
Normal file
73
src/plugins/texteditor/interactionsettings.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** 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 "interactionsettings.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
static const char *useVimKey = "useVim";
|
||||
static const char *groupPostfix = "InteractionSettings";
|
||||
|
||||
InteractionSettings::InteractionSettings()
|
||||
: m_useVim(false)
|
||||
{
|
||||
}
|
||||
|
||||
void InteractionSettings::toSettings(const QString &category, QSettings *s) const
|
||||
{
|
||||
QString group = QLatin1String(groupPostfix);
|
||||
if (!category.isEmpty())
|
||||
group.insert(0, category);
|
||||
s->beginGroup(group);
|
||||
s->setValue(QLatin1String(useVimKey), m_useVim);
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
void InteractionSettings::fromSettings(const QString &category, const QSettings *s)
|
||||
{
|
||||
QString group = QLatin1String(groupPostfix);
|
||||
if (!category.isEmpty())
|
||||
group.insert(0, category);
|
||||
group += QLatin1Char('/');
|
||||
m_useVim = s->value(group + QLatin1String(useVimKey), m_useVim).toBool();
|
||||
}
|
||||
|
||||
bool InteractionSettings::equals(const InteractionSettings &ts) const
|
||||
{
|
||||
return m_useVim == ts.m_useVim;
|
||||
}
|
||||
|
||||
} // namespace TextEditor
|
62
src/plugins/texteditor/interactionsettings.h
Normal file
62
src/plugins/texteditor/interactionsettings.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** 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 INTERACTIONSETTINGS_H
|
||||
#define INTERACTIONSETTINGS_H
|
||||
|
||||
#include "texteditor_global.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
struct TEXTEDITOR_EXPORT InteractionSettings
|
||||
{
|
||||
InteractionSettings();
|
||||
|
||||
void toSettings(const QString &category, QSettings *s) const;
|
||||
void fromSettings(const QString &category, const QSettings *s);
|
||||
|
||||
bool equals(const InteractionSettings &ts) const;
|
||||
|
||||
bool m_useVim;
|
||||
};
|
||||
|
||||
inline bool operator==(const InteractionSettings &t1, const InteractionSettings &t2) { return t1.equals(t2); }
|
||||
inline bool operator!=(const InteractionSettings &t1, const InteractionSettings &t2) { return !t1.equals(t2); }
|
||||
|
||||
} // namespace TextEditor
|
||||
|
||||
#endif // INTERACTIONSETTINGS_H
|
@@ -33,18 +33,18 @@
|
||||
|
||||
#include "tabsettings.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QTextCursor>
|
||||
#include <QtGui/QTextDocument>
|
||||
#include <QDebug>
|
||||
|
||||
static const char* spacesForTabsKey = "SpacesForTabs";
|
||||
static const char* smartBackspaceKey = "SmartBackspace";
|
||||
static const char* autoIndentKey = "AutoIndent";
|
||||
static const char* tabSizeKey = "TabSize";
|
||||
static const char* indentSizeKey = "IndentSize";
|
||||
static const char* groupPostfix = "TabSettings";
|
||||
static const char *spacesForTabsKey = "SpacesForTabs";
|
||||
static const char *smartBackspaceKey = "SmartBackspace";
|
||||
static const char *autoIndentKey = "AutoIndent";
|
||||
static const char *tabSizeKey = "TabSize";
|
||||
static const char *indentSizeKey = "IndentSize";
|
||||
static const char *groupPostfix = "TabSettings";
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
|
@@ -13,6 +13,7 @@ SOURCES += texteditorplugin.cpp \
|
||||
completionsupport.cpp \
|
||||
completionwidget.cpp \
|
||||
fontsettingspage.cpp \
|
||||
interactionsettings.cpp \
|
||||
tabsettings.cpp \
|
||||
storagesettings.cpp \
|
||||
displaysettings.cpp \
|
||||
@@ -37,6 +38,7 @@ HEADERS += texteditorplugin.h \
|
||||
texteditoractionhandler.h \
|
||||
fontsettingspage.h \
|
||||
icompletioncollector.h \
|
||||
interactionsettings.h \
|
||||
texteditorconstants.h \
|
||||
tabsettings.h \
|
||||
storagesettings.h \
|
||||
|
@@ -46,6 +46,7 @@ class FontSettings;
|
||||
struct TabSettings;
|
||||
struct StorageSettings;
|
||||
struct DisplaySettings;
|
||||
struct InteractionSettings;
|
||||
|
||||
namespace Internal {
|
||||
class TextEditorPlugin;
|
||||
@@ -70,12 +71,14 @@ public:
|
||||
TabSettings tabSettings() const;
|
||||
StorageSettings storageSettings() const;
|
||||
DisplaySettings displaySettings() const;
|
||||
InteractionSettings interactionSettings() const;
|
||||
|
||||
signals:
|
||||
void fontSettingsChanged(const TextEditor::FontSettings &);
|
||||
void tabSettingsChanged(const TextEditor::TabSettings &);
|
||||
void storageSettingsChanged(const TextEditor::StorageSettings &);
|
||||
void displaySettingsChanged(const TextEditor::DisplaySettings &);
|
||||
void interactionSettingsChanged(const TextEditor::InteractionSettings &);
|
||||
|
||||
private:
|
||||
TextEditor::FontSettingsPage *m_fontSettingsPage;
|
||||
|
Reference in New Issue
Block a user