diff options
author | hjk <hjk@qt.io> | 2020-01-08 11:35:47 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2020-01-27 07:15:16 +0000 |
commit | 37188ee3a1fce6f04432b0d6fd76559142de81f0 (patch) | |
tree | 9defcccf0258ab4214ca8d9d068d6b8a5a199041 /src/plugins/nim | |
parent | 3e67c2ce92dc6ce589e29ac877bb62f6a3177607 (diff) | |
download | qt-creator-37188ee3a1fce6f04432b0d6fd76559142de81f0.tar.gz |
Nim: Use new settings page convenience functions
Change-Id: Ie6e317724cfacbd6b565931056fb88d3773a5bed
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/nim')
-rw-r--r-- | src/plugins/nim/settings/nimcodestylesettingspage.cpp | 64 | ||||
-rw-r--r-- | src/plugins/nim/settings/nimcodestylesettingspage.h | 11 |
2 files changed, 25 insertions, 50 deletions
diff --git a/src/plugins/nim/settings/nimcodestylesettingspage.cpp b/src/plugins/nim/settings/nimcodestylesettingspage.cpp index 93c67050a7..54ed03f234 100644 --- a/src/plugins/nim/settings/nimcodestylesettingspage.cpp +++ b/src/plugins/nim/settings/nimcodestylesettingspage.cpp @@ -29,66 +29,52 @@ #include "../nimconstants.h" -#include <extensionsystem/pluginmanager.h> #include <texteditor/simplecodestylepreferences.h> #include <texteditor/codestyleeditor.h> #include <texteditor/texteditorsettings.h> #include <texteditor/tabsettings.h> -#include <utils/qtcassert.h> -#include <QWidget> +#include <QVBoxLayout> using namespace TextEditor; namespace Nim { -NimCodeStyleSettingsPage::NimCodeStyleSettingsPage() - : m_nimCodeStylePreferences(nullptr) - , m_widget(nullptr) +class NimCodeStyleSettingsWidget : public Core::IOptionsPageWidget { - setId(Nim::Constants::C_NIMCODESTYLESETTINGSPAGE_ID); - setDisplayName(tr(Nim::Constants::C_NIMCODESTYLESETTINGSPAGE_DISPLAY)); - setCategory(Nim::Constants::C_NIMCODESTYLESETTINGSPAGE_CATEGORY); - setDisplayCategory(tr("Nim")); - setCategoryIconPath(":/nim/images/settingscategory_nim.png"); -} - -NimCodeStyleSettingsPage::~NimCodeStyleSettingsPage() -{ - deleteWidget(); -} - -QWidget *NimCodeStyleSettingsPage::widget() -{ - if (!m_widget) { +public: + NimCodeStyleSettingsWidget() + { auto originalTabPreferences = qobject_cast<SimpleCodeStylePreferences *>(NimSettings::globalCodeStyle()); - m_nimCodeStylePreferences = new SimpleCodeStylePreferences(m_widget); + m_nimCodeStylePreferences = new SimpleCodeStylePreferences(this); m_nimCodeStylePreferences->setDelegatingPool(originalTabPreferences->delegatingPool()); m_nimCodeStylePreferences->setTabSettings(originalTabPreferences->tabSettings()); m_nimCodeStylePreferences->setCurrentDelegate(originalTabPreferences->currentDelegate()); m_nimCodeStylePreferences->setId(originalTabPreferences->id()); + auto factory = TextEditorSettings::codeStyleFactory(Nim::Constants::C_NIMLANGUAGE_ID); - m_widget = new CodeStyleEditor(factory, m_nimCodeStylePreferences); - } - return m_widget; -} -void NimCodeStyleSettingsPage::apply() -{ + auto editor = new CodeStyleEditor(factory, m_nimCodeStylePreferences); -} + auto layout = new QVBoxLayout(this); + layout->addWidget(editor); + } -void NimCodeStyleSettingsPage::finish() -{ - deleteWidget(); -} +private: + void apply() final {} + void finish() final {} + + TextEditor::SimpleCodeStylePreferences *m_nimCodeStylePreferences; +}; -void NimCodeStyleSettingsPage::deleteWidget() +NimCodeStyleSettingsPage::NimCodeStyleSettingsPage() { - if (m_widget) { - delete m_widget; - m_widget = nullptr; - } + setId(Nim::Constants::C_NIMCODESTYLESETTINGSPAGE_ID); + setDisplayName(tr(Nim::Constants::C_NIMCODESTYLESETTINGSPAGE_DISPLAY)); + setCategory(Nim::Constants::C_NIMCODESTYLESETTINGSPAGE_CATEGORY); + setDisplayCategory(tr("Nim")); + setCategoryIconPath(":/nim/images/settingscategory_nim.png"); + setWidgetCreator([] { return new NimCodeStyleSettingsWidget; }); } -} +} // Nim diff --git a/src/plugins/nim/settings/nimcodestylesettingspage.h b/src/plugins/nim/settings/nimcodestylesettingspage.h index 2f1f779ecb..e1b1bb046c 100644 --- a/src/plugins/nim/settings/nimcodestylesettingspage.h +++ b/src/plugins/nim/settings/nimcodestylesettingspage.h @@ -42,17 +42,6 @@ class NimCodeStyleSettingsPage : public Core::IOptionsPage public: NimCodeStyleSettingsPage(); - ~NimCodeStyleSettingsPage() override; - - QWidget *widget() override; - void apply() override; - void finish() override; - -private: - void deleteWidget(); - - TextEditor::SimpleCodeStylePreferences *m_nimCodeStylePreferences; - TextEditor::CodeStyleEditor *m_widget; }; } |