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;
|
||||
|
||||
Reference in New Issue
Block a user