forked from qt-creator/qt-creator
FakeVim: Use new IOptionsPage convenience functions
Change-Id: I739fe152a4f642a19c90be71bbe5adbc8747f402 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -371,29 +371,23 @@ public:
|
|||||||
setCategory(SETTINGS_CATEGORY);
|
setCategory(SETTINGS_CATEGORY);
|
||||||
setDisplayCategory(Tr::tr("FakeVim"));
|
setDisplayCategory(Tr::tr("FakeVim"));
|
||||||
setCategoryIconPath(":/fakevim/images/settingscategory_fakevim.png");
|
setCategoryIconPath(":/fakevim/images/settingscategory_fakevim.png");
|
||||||
|
setLayouter([this](QWidget *widget) { return layoutPage(widget); });
|
||||||
|
setSettings(fakeVimSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *widget() override;
|
|
||||||
void apply() override;
|
|
||||||
void finish() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void layoutPage(QWidget *);
|
||||||
void copyTextEditorSettings();
|
void copyTextEditorSettings();
|
||||||
void setQtStyle();
|
void setQtStyle();
|
||||||
void setPlainStyle();
|
void setPlainStyle();
|
||||||
void updateVimRcWidgets();
|
void updateVimRcWidgets();
|
||||||
|
|
||||||
QPointer<QWidget> m_widget;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QWidget *FakeVimOptionPage::widget()
|
void FakeVimOptionPage::layoutPage(QWidget *widget)
|
||||||
{
|
{
|
||||||
if (!m_widget) {
|
auto copyTextEditorSettings = new QPushButton(Tr::tr("Copy Text Editor Settings"));
|
||||||
m_widget = new QWidget;
|
auto setQtStyle = new QPushButton(Tr::tr("Set Qt Style"));
|
||||||
|
auto setPlainStyle = new QPushButton(Tr::tr("Set Plain Style"));
|
||||||
auto copyTextEditorSettings = new QPushButton(tr("Copy Text Editor Settings"));
|
|
||||||
auto setQtStyle = new QPushButton(tr("Set Qt Style"));
|
|
||||||
auto setPlainStyle = new QPushButton(tr("Set Plain Style"));
|
|
||||||
|
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
FakeVimSettings &s = *fakeVimSettings();
|
FakeVimSettings &s = *fakeVimSettings();
|
||||||
@@ -435,14 +429,14 @@ QWidget *FakeVimOptionPage::widget()
|
|||||||
s.useFakeVim,
|
s.useFakeVim,
|
||||||
|
|
||||||
Group {
|
Group {
|
||||||
Title(tr("Vim Behavior")),
|
Title(Tr::tr("Vim Behavior")),
|
||||||
bools,
|
bools,
|
||||||
ints,
|
ints,
|
||||||
strings
|
strings
|
||||||
},
|
},
|
||||||
|
|
||||||
Group {
|
Group {
|
||||||
Title(tr("Plugin Emulation")),
|
Title(Tr::tr("Plugin Emulation")),
|
||||||
s.emulateVimCommentary,
|
s.emulateVimCommentary,
|
||||||
s.emulateReplaceWithRegister,
|
s.emulateReplaceWithRegister,
|
||||||
s.emulateArgTextObj,
|
s.emulateArgTextObj,
|
||||||
@@ -453,7 +447,7 @@ QWidget *FakeVimOptionPage::widget()
|
|||||||
Row { copyTextEditorSettings, setQtStyle, setPlainStyle, Stretch() },
|
Row { copyTextEditorSettings, setQtStyle, setPlainStyle, Stretch() },
|
||||||
Stretch()
|
Stretch()
|
||||||
|
|
||||||
}.attachTo(m_widget, true);
|
}.attachTo(widget, true);
|
||||||
|
|
||||||
connect(copyTextEditorSettings, &QAbstractButton::clicked,
|
connect(copyTextEditorSettings, &QAbstractButton::clicked,
|
||||||
this, &FakeVimOptionPage::copyTextEditorSettings);
|
this, &FakeVimOptionPage::copyTextEditorSettings);
|
||||||
@@ -465,22 +459,6 @@ QWidget *FakeVimOptionPage::widget()
|
|||||||
this, &FakeVimOptionPage::updateVimRcWidgets);
|
this, &FakeVimOptionPage::updateVimRcWidgets);
|
||||||
updateVimRcWidgets();
|
updateVimRcWidgets();
|
||||||
}
|
}
|
||||||
return m_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeVimOptionPage::apply()
|
|
||||||
{
|
|
||||||
FakeVimSettings &s = *fakeVimSettings();
|
|
||||||
s.apply();
|
|
||||||
s.writeSettings(ICore::settings());
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeVimOptionPage::finish()
|
|
||||||
{
|
|
||||||
FakeVimSettings &s = *fakeVimSettings();
|
|
||||||
s.cancel();
|
|
||||||
delete m_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeVimOptionPage::copyTextEditorSettings()
|
void FakeVimOptionPage::copyTextEditorSettings()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user