forked from qt-creator/qt-creator
Copilot: Take advantage of IOptionPage::setWidgetCreator()
Less boilerplate for the implementation add user code access to IOptionPage::{apply,finish} is planned to be removed. Change-Id: I03bbde071fdf673bee0568baa9ae9fab8d816590 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -17,11 +17,10 @@ using namespace LanguageClient;
|
||||
|
||||
namespace Copilot {
|
||||
|
||||
class CopilotOptionsPageWidget : public QWidget
|
||||
class CopilotOptionsPageWidget : public Core::IOptionsPageWidget
|
||||
{
|
||||
public:
|
||||
CopilotOptionsPageWidget(QWidget *parent = nullptr)
|
||||
: QWidget(parent)
|
||||
CopilotOptionsPageWidget()
|
||||
{
|
||||
using namespace Layouting;
|
||||
|
||||
@@ -73,6 +72,12 @@ file from the Copilot neovim plugin.
|
||||
updateAuthWidget);
|
||||
updateAuthWidget();
|
||||
}
|
||||
|
||||
void apply() final
|
||||
{
|
||||
CopilotSettings::instance().apply();
|
||||
CopilotSettings::instance().writeSettings(Core::ICore::settings());
|
||||
}
|
||||
};
|
||||
|
||||
CopilotOptionsPage::CopilotOptionsPage()
|
||||
@@ -82,25 +87,9 @@ CopilotOptionsPage::CopilotOptionsPage()
|
||||
setCategory("ZY.Copilot");
|
||||
setDisplayCategory("Copilot");
|
||||
setCategoryIconPath(":/copilot/images/settingscategory_copilot.png");
|
||||
setWidgetCreator([] { return new CopilotOptionsPageWidget; });
|
||||
}
|
||||
|
||||
CopilotOptionsPage::~CopilotOptionsPage() {}
|
||||
|
||||
void CopilotOptionsPage::init() {}
|
||||
|
||||
QWidget *CopilotOptionsPage::widget()
|
||||
{
|
||||
return new CopilotOptionsPageWidget();
|
||||
}
|
||||
|
||||
void CopilotOptionsPage::apply()
|
||||
{
|
||||
CopilotSettings::instance().apply();
|
||||
CopilotSettings::instance().writeSettings(Core::ICore::settings());
|
||||
}
|
||||
|
||||
void CopilotOptionsPage::finish() {}
|
||||
|
||||
CopilotOptionsPage &CopilotOptionsPage::instance()
|
||||
{
|
||||
static CopilotOptionsPage settingsPage;
|
||||
|
@@ -11,15 +11,8 @@ class CopilotOptionsPage : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
CopilotOptionsPage();
|
||||
~CopilotOptionsPage() override;
|
||||
|
||||
static CopilotOptionsPage &instance();
|
||||
|
||||
void init();
|
||||
|
||||
QWidget *widget() override;
|
||||
void apply() override;
|
||||
void finish() override;
|
||||
};
|
||||
|
||||
} // namespace Copilot
|
||||
} // Copilot
|
||||
|
@@ -50,7 +50,7 @@ void CopilotPlugin::initialize()
|
||||
|
||||
void CopilotPlugin::extensionsInitialized()
|
||||
{
|
||||
CopilotOptionsPage::instance().init();
|
||||
(void)CopilotOptionsPage::instance();
|
||||
}
|
||||
|
||||
void CopilotPlugin::restartClient()
|
||||
|
@@ -9,8 +9,6 @@
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace TextEditor { class TextEditorWidget; }
|
||||
|
||||
namespace Copilot {
|
||||
namespace Internal {
|
||||
|
||||
|
Reference in New Issue
Block a user