Commit 765489f9 authored by hjk's avatar hjk
Browse files

fakevim: work on settings dialog

parent c826e6dc
......@@ -121,8 +121,10 @@ void FakeVimSettings::insertItem(int code, SavedAction *item,
void FakeVimSettings::readSettings(QSettings *settings)
{
foreach (SavedAction *item, m_items)
foreach (SavedAction *item, m_items) {
qDebug() << "ITRM: " << item->toString();
item->readSettings(settings);
}
}
void FakeVimSettings::writeSettings(QSettings *settings)
......@@ -133,7 +135,7 @@ void FakeVimSettings::writeSettings(QSettings *settings)
SavedAction *FakeVimSettings::item(int code)
{
QTC_ASSERT(m_items.value(code, 0), return 0);
QTC_ASSERT(m_items.value(code, 0), qDebug() << "CODE: " << code; return 0);
return m_items.value(code, 0);
}
......@@ -147,44 +149,55 @@ FakeVimSettings *theFakeVimSettings()
SavedAction *item = 0;
bool plain = false;
item = new SavedAction(instance);
item->setText(QObject::tr("FakeVim properties..."));
instance->insertItem(SettingsDialog, item);
item->setText(QObject::tr("Use vim-style editing"));
item->setSettingsKey("FakeVim", "UseFakeVim");
instance->insertItem(ConfigUseFakeVim, item);
item = new SavedAction(instance);
item->setDefaultValue(plain ? false : true);
item->setDefaultValue(false);
item->setSettingsKey("FakeVim", "StartOfLine");
instance->insertItem(ConfigStartOfLine, item, "startofline", "sol");
item = new SavedAction(instance);
item->setDefaultValue(plain ? 8 : 4);
item->setDefaultValue(8);
item->setSettingsKey("FakeVim", "TabStop");
instance->insertItem(ConfigTabStop, item, "tabstop", "ts");
item = new SavedAction(instance);
item->setDefaultValue(plain ? false : true);
item->setDefaultValue(false);
item->setSettingsKey("FakeVim", "SmartTab");
instance->insertItem(ConfigSmartTab, item, "smarttab", "sta");
item = new SavedAction(instance);
item->setDefaultValue(true);
item->setSettingsKey("FakeVim", "HlSearch");
instance->insertItem(ConfigHlSearch, item, "hlsearch", "hls");
item = new SavedAction(instance);
item->setDefaultValue(plain ? 8 : 4);
item->setDefaultValue(8);
item->setSettingsKey("FakeVim", "ShiftWidth");
instance->insertItem(ConfigShiftWidth, item, "shiftwidth", "sw");
item = new SavedAction(instance);
item->setDefaultValue(plain ? false : true);
item->setDefaultValue(false);
item->setSettingsKey("FakeVim", "ExpandTab");
instance->insertItem(ConfigExpandTab, item, "expandtab", "et");
item = new SavedAction(instance);
item->setDefaultValue(plain ? true : false);
item->setDefaultValue(false);
item->setSettingsKey("FakeVim", "AutoIndent");
instance->insertItem(ConfigAutoIndent, item, "autoindent", "ai");
item = new SavedAction(instance);
item->setDefaultValue(plain ? "" : "indent,eol,start");
item->setDefaultValue("indent,eol,start");
item->setSettingsKey("FakeVim", "Backspace");
instance->insertItem(ConfigBackspace, item, "backspace", "bs");
item = new SavedAction(instance);
item->setText(QObject::tr("FakeVim properties..."));
instance->insertItem(SettingsDialog, item);
return instance;
}
......
......@@ -159,7 +159,7 @@ QWidget *FakeVimOptionPage::createPage(QWidget *parent)
m_ui.checkBoxAutoIndent);
connect(m_ui.pushButtonCopyTextEditorSettings, SIGNAL(clicked()),
this, SLOT(copyTextEditorSetting()));
this, SLOT(copyTextEditorSettings()));
connect(m_ui.pushButtonSetQtStyle, SIGNAL(clicked()),
this, SLOT(setQtStyle()));
connect(m_ui.pushButtonSetPlainStyle, SIGNAL(clicked()),
......@@ -187,6 +187,7 @@ void FakeVimOptionPage::setQtStyle()
m_ui.lineEditShiftWidth->setText("4");
m_ui.checkBoxSmartTab->setChecked(true);
m_ui.checkBoxAutoIndent->setChecked(true);
m_ui.lineEditBackspace->setText("indent,eol,start");
}
void FakeVimOptionPage::setPlainStyle()
......@@ -196,6 +197,7 @@ void FakeVimOptionPage::setPlainStyle()
m_ui.lineEditShiftWidth->setText("8");
m_ui.checkBoxSmartTab->setChecked(false);
m_ui.checkBoxAutoIndent->setChecked(false);
m_ui.lineEditBackspace->setText(QString());
}
} // namespace Internal
......@@ -242,6 +244,7 @@ private slots:
private:
FakeVimPlugin *q;
QAction *m_installHandlerAction;
FakeVimOptionPage *m_fakeVimOptionsPage;
};
} // namespace Internal
......@@ -251,6 +254,7 @@ FakeVimPluginPrivate::FakeVimPluginPrivate(FakeVimPlugin *plugin)
{
q = plugin;
m_installHandlerAction = 0;
m_fakeVimOptionsPage = 0;
}
FakeVimPluginPrivate::~FakeVimPluginPrivate()
......@@ -259,6 +263,10 @@ FakeVimPluginPrivate::~FakeVimPluginPrivate()
void FakeVimPluginPrivate::shutdown()
{
q->removeObject(m_fakeVimOptionsPage);
delete m_fakeVimOptionsPage;
m_fakeVimOptionsPage = 0;
theFakeVimSettings()->writeSettings(Core::ICore::instance()->settings());
}
bool FakeVimPluginPrivate::initialize()
......@@ -271,6 +279,10 @@ bool FakeVimPluginPrivate::initialize()
m_installHandlerAction = new QAction(this);
m_installHandlerAction->setText(tr("Set vi-Style Keyboard Action Handler"));
m_fakeVimOptionsPage = new FakeVimOptionPage;
q->addObject(m_fakeVimOptionsPage);
theFakeVimSettings()->readSettings(Core::ICore::instance()->settings());
Core::Command *cmd = 0;
cmd = actionManager->registerAction(m_installHandlerAction,
......@@ -328,13 +340,7 @@ void FakeVimPluginPrivate::installHandler(Core::IEditor *editor)
handler->setupWidget();
handler->setExtraData(editor);
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(widget)) {
using namespace TextEditor;
using namespace FakeVim::Constants;
handler->setCurrentFileName(editor->file()->fileName());
TabSettings settings = bt->tabSettings();
}
handler->setCurrentFileName(editor->file()->fileName());
}
void FakeVimPluginPrivate::installHandlerOnCurrentEditor()
......
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