Commit 292d4bc3 authored by hjk's avatar hjk
Browse files

Fixes: fakevim: provide an option in the text editor settings

parent 34fb3d86
......@@ -2043,7 +2043,6 @@ FakeVimHandler::FakeVimHandler(QWidget *widget, QObject *parent)
FakeVimHandler::~FakeVimHandler()
{
qDebug() << "DELETING HANDLER" << this;
delete d;
}
......
......@@ -183,12 +183,6 @@ bool FakeVimPluginPrivate::initialize()
return true;
}
void FakeVimPluginPrivate::installHandler()
{
if (Core::IEditor *editor = m_core->editorManager()->currentEditor())
installHandler(editor);
}
void FakeVimPluginPrivate::installHandler(Core::IEditor *editor)
{
QWidget *widget = editor->widget();
......@@ -230,6 +224,8 @@ void FakeVimPluginPrivate::installHandler(Core::IEditor *editor)
void FakeVimPluginPrivate::writeFile(bool *handled,
const QString &fileName, const QString &contents)
{
Q_UNUSED(contents);
FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
if (!handler)
return;
......@@ -260,6 +256,16 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
Q_UNUSED(editor);
//qDebug() << "OPENING: " << editor << editor->widget();
//installHandler(editor);
#if 1
QSettings *s = ICore::instance()->settings();
bool automatic = s->value("textInteractionSettings/UseVim").toBool();
//qDebug() << "USE VIM: " << automatic;
if (automatic)
installHandler(editor);
#endif
#if 0
QWidget *widget = editor->widget();
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(widget)) {
InteractionSettings settings = bt->interactionSettings();
......@@ -267,6 +273,7 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
if (settings.m_useVim)
installHandler(editor);
}
#endif
}
void FakeVimPluginPrivate::editorAboutToClose(Core::IEditor *editor)
......
......@@ -416,7 +416,7 @@ public:
};
// the blocks list must be sorted
void setIfdefedOutBlocks(const QList<BaseTextEditor::BlockRange> &blocks);
void setIfdefedOutBlocks(const QList<BlockRange> &blocks);
public slots:
virtual void setTabSettings(const TextEditor::TabSettings &);
......
......@@ -115,10 +115,11 @@ void GeneralSettingsPage::apply()
newInteractionSettings);
Core::ICore *core = Core::ICore::instance();
QSettings *s = core->settings();
if (newTabSettings != m_d->m_tabSettings) {
m_d->m_tabSettings = newTabSettings;
if (QSettings *s = core->settings())
if (s)
m_d->m_tabSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
emit tabSettingsChanged(newTabSettings);
......@@ -126,7 +127,7 @@ void GeneralSettingsPage::apply()
if (newStorageSettings != m_d->m_storageSettings) {
m_d->m_storageSettings = newStorageSettings;
if (QSettings *s = core->settings())
if (s)
m_d->m_storageSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
emit storageSettingsChanged(newStorageSettings);
......@@ -134,7 +135,7 @@ void GeneralSettingsPage::apply()
if (newDisplaySettings != m_d->m_displaySettings) {
m_d->m_displaySettings = newDisplaySettings;
if (QSettings *s = core->settings())
if (s)
m_d->m_displaySettings.toSettings(m_d->m_parameters.settingsPrefix, s);
emit displaySettingsChanged(newDisplaySettings);
......@@ -142,10 +143,9 @@ void GeneralSettingsPage::apply()
if (newInteractionSettings != m_d->m_interactionSettings) {
m_d->m_interactionSettings = newInteractionSettings;
if (QSettings *s = core->settings())
if (s)
m_d->m_interactionSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
emit interactionSettingsChanged(newInteractionSettings);
}
}
......
......@@ -83,7 +83,6 @@ 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,
......
......@@ -38,7 +38,7 @@
namespace TextEditor {
static const char *useVimKey = "useVim";
static const char *useVimKey = "UseVim";
static const char *groupPostfix = "InteractionSettings";
InteractionSettings::InteractionSettings()
......
......@@ -43,10 +43,9 @@ using namespace QuickOpen;
using namespace TextEditor;
using namespace TextEditor::Internal;
LineNumberFilter::LineNumberFilter(EditorManager *editorManager, QObject *parent):
IQuickOpenFilter(parent)
LineNumberFilter::LineNumberFilter(QObject *parent)
: IQuickOpenFilter(parent)
{
m_editorManager = editorManager;
setShortcutString("l");
setIncludedByDefault(true);
}
......@@ -65,17 +64,19 @@ void LineNumberFilter::accept(FilterEntry selection) const
{
ITextEditor *editor = currentTextEditor();
if (editor) {
m_editorManager->ensureEditorManagerVisible();
m_editorManager->addCurrentPositionToNavigationHistory(true);
Core::EditorManager *editorManager = Core::EditorManager::instance();
editorManager->ensureEditorManagerVisible();
editorManager->addCurrentPositionToNavigationHistory(true);
editor->gotoLine(selection.internalData.toInt());
m_editorManager->addCurrentPositionToNavigationHistory();
editorManager->addCurrentPositionToNavigationHistory();
editor->widget()->setFocus();
}
}
ITextEditor *LineNumberFilter::currentTextEditor() const
{
if (!m_editorManager->currentEditor())
Core::EditorManager *editorManager = Core::EditorManager::instance();
if (!editorManager->currentEditor())
return 0;
return qobject_cast<TextEditor::ITextEditor*>(m_editorManager->currentEditor());
return qobject_cast<TextEditor::ITextEditor*>(editorManager->currentEditor());
}
......@@ -38,13 +38,7 @@
#include <QtCore/QString>
#include <QtCore/QList>
#include <QtCore/QByteArray>
#include <QtCore/QFutureInterface>
#include <QtGui/QWidget>
namespace Core {
class EditorManager;
}
namespace TextEditor {
......@@ -57,7 +51,8 @@ class LineNumberFilter : public QuickOpen::IQuickOpenFilter
Q_OBJECT
public:
LineNumberFilter(Core::EditorManager *editorManager, QObject *parent = 0);
explicit LineNumberFilter(QObject *parent = 0);
QString trName() const { return tr("Line in current document"); }
QString name() const { return "Line in current document"; }
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::High; }
......@@ -67,8 +62,6 @@ public:
private:
ITextEditor *currentTextEditor() const;
Core::EditorManager *m_editorManager;
};
} // namespace Internal
......
......@@ -42,6 +42,7 @@
#include "plaintexteditorfactory.h"
#include "plaintexteditor.h"
#include "storagesettings.h"
#include "interactionsettings.h"
#include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h>
......@@ -104,7 +105,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
addAutoReleasedObject(m_wizard);
m_settings = new TextEditorSettings(this, this);
m_settings = new TextEditorSettings(this);
// Add plain text editor factory
m_editorFactory = new PlainTextEditorFactory;
......@@ -112,7 +113,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
// Goto line functionality for quick open
Core::ICore *core = Core::ICore::instance();
m_lineNumberFilter = new LineNumberFilter(core->editorManager());
m_lineNumberFilter = new LineNumberFilter;
addAutoReleasedObject(m_lineNumberFilter);
int contextId = core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR);
......
......@@ -51,8 +51,7 @@ using namespace TextEditor::Constants;
TextEditorSettings *TextEditorSettings::m_instance = 0;
TextEditorSettings::TextEditorSettings(Internal::TextEditorPlugin *plugin,
QObject *parent)
TextEditorSettings::TextEditorSettings(QObject *parent)
: QObject(parent)
{
QTC_ASSERT(!m_instance, return);
......
......@@ -46,11 +46,6 @@ class FontSettings;
struct TabSettings;
struct StorageSettings;
struct DisplaySettings;
struct InteractionSettings;
namespace Internal {
class TextEditorPlugin;
}
/**
* This class provides a central place for basic text editor settings. These
......@@ -62,7 +57,7 @@ class TEXTEDITOR_EXPORT TextEditorSettings : public QObject
Q_OBJECT
public:
TextEditorSettings(Internal::TextEditorPlugin *plugin, QObject *parent);
explicit TextEditorSettings(QObject *parent);
~TextEditorSettings();
static TextEditorSettings *instance();
......@@ -71,14 +66,12 @@ 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;
......
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