forked from qt-creator/qt-creator
Haskell: Use IOptionPage::setWidgetCreator() for settings
Change-Id: I4565cfca2bc58fd78e4c35fa1abda43532c113b6 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -7,31 +7,24 @@
|
|||||||
#include "haskellmanager.h"
|
#include "haskellmanager.h"
|
||||||
#include "haskelltr.h"
|
#include "haskelltr.h"
|
||||||
|
|
||||||
|
#include <utils/pathchooser.h>
|
||||||
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
namespace Haskell {
|
using namespace Utils;
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
OptionsPage::OptionsPage()
|
namespace Haskell::Internal {
|
||||||
|
|
||||||
|
class HaskellOptionsPageWidget : public Core::IOptionsPageWidget
|
||||||
{
|
{
|
||||||
setId(Constants::OPTIONS_GENERAL);
|
public:
|
||||||
setDisplayName(Tr::tr("General"));
|
HaskellOptionsPageWidget()
|
||||||
setCategory("J.Z.Haskell");
|
{
|
||||||
setDisplayCategory(Tr::tr("Haskell"));
|
|
||||||
setCategoryIconPath(":/haskell/images/settingscategory_haskell.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *OptionsPage::widget()
|
|
||||||
{
|
|
||||||
using namespace Utils;
|
|
||||||
if (!m_widget) {
|
|
||||||
m_widget = new QWidget;
|
|
||||||
auto topLayout = new QVBoxLayout;
|
auto topLayout = new QVBoxLayout;
|
||||||
m_widget->setLayout(topLayout);
|
setLayout(topLayout);
|
||||||
auto generalBox = new QGroupBox(Tr::tr("General"));
|
auto generalBox = new QGroupBox(Tr::tr("General"));
|
||||||
topLayout->addWidget(generalBox);
|
topLayout->addWidget(generalBox);
|
||||||
topLayout->addStretch(10);
|
topLayout->addStretch(10);
|
||||||
@@ -45,19 +38,23 @@ QWidget *OptionsPage::widget()
|
|||||||
m_stackPath->setCommandVersionArguments({"--version"});
|
m_stackPath->setCommandVersionArguments({"--version"});
|
||||||
boxLayout->addWidget(m_stackPath);
|
boxLayout->addWidget(m_stackPath);
|
||||||
}
|
}
|
||||||
return m_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OptionsPage::apply()
|
void apply() final
|
||||||
|
{
|
||||||
|
HaskellManager::setStackExecutable(m_stackPath->rawFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointer<Utils::PathChooser> m_stackPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
OptionsPage::OptionsPage()
|
||||||
{
|
{
|
||||||
if (!m_widget)
|
setId(Constants::OPTIONS_GENERAL);
|
||||||
return;
|
setDisplayName(Tr::tr("General"));
|
||||||
HaskellManager::setStackExecutable(m_stackPath->rawFilePath());
|
setCategory("J.Z.Haskell");
|
||||||
|
setDisplayCategory(Tr::tr("Haskell"));
|
||||||
|
setCategoryIconPath(":/haskell/images/settingscategory_haskell.png");
|
||||||
|
setWidgetCreator([] { return new HaskellOptionsPageWidget; });
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsPage::finish()
|
} // Haskell::Internal
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Haskell
|
|
||||||
|
@@ -4,28 +4,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
#include <utils/pathchooser.h>
|
|
||||||
|
|
||||||
#include <QPointer>
|
namespace Haskell::Internal {
|
||||||
|
|
||||||
namespace Haskell {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class OptionsPage : public Core::IOptionsPage
|
class OptionsPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OptionsPage();
|
OptionsPage();
|
||||||
|
|
||||||
QWidget *widget() override;
|
|
||||||
void apply() override;
|
|
||||||
void finish() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QPointer<QWidget> m_widget;
|
|
||||||
QPointer<Utils::PathChooser> m_stackPath;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // Haskell::Internal
|
||||||
} // namespace Haskell
|
|
||||||
|
Reference in New Issue
Block a user