forked from qt-creator/qt-creator
ProjectExplorer: Use IOptionPage convenience in DeviceSettingsPage
Change-Id: I1ce83abb2eb620eb171c4cec23da5609f367c8e9 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -30,7 +30,6 @@
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QString>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
namespace Internal {
|
||||
@@ -43,23 +42,7 @@ DeviceSettingsPage::DeviceSettingsPage()
|
||||
setDisplayCategory(QCoreApplication::translate("ProjectExplorer", "Devices"));
|
||||
setCategoryIcon(Utils::Icon({{":/projectexplorer/images/settingscategory_devices.png",
|
||||
Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint));
|
||||
}
|
||||
|
||||
QWidget *DeviceSettingsPage::widget()
|
||||
{
|
||||
if (!m_widget)
|
||||
m_widget = new DeviceSettingsWidget;
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
void DeviceSettingsPage::apply()
|
||||
{
|
||||
m_widget->saveSettings();
|
||||
}
|
||||
|
||||
void DeviceSettingsPage::finish()
|
||||
{
|
||||
delete m_widget;
|
||||
setWidgetCreator([] { return new DeviceSettingsWidget; });
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -27,26 +27,15 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
namespace Internal {
|
||||
|
||||
class DeviceSettingsWidget;
|
||||
|
||||
class DeviceSettingsPage : public Core::IOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DeviceSettingsPage();
|
||||
|
||||
QWidget *widget() override;
|
||||
void apply() override;
|
||||
void finish() override;
|
||||
|
||||
private:
|
||||
QPointer<DeviceSettingsWidget> m_widget;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -31,6 +31,8 @@
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
@@ -45,16 +47,19 @@ namespace Internal {
|
||||
namespace Ui { class DeviceSettingsWidget; }
|
||||
class NameValidator;
|
||||
|
||||
class DeviceSettingsWidget : public QWidget
|
||||
class DeviceSettingsWidget : public Core::IOptionsPageWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DeviceSettingsWidget();
|
||||
~DeviceSettingsWidget() override;
|
||||
~DeviceSettingsWidget() final;
|
||||
|
||||
private:
|
||||
void apply() final { saveSettings(); }
|
||||
void finish() final {}
|
||||
|
||||
void saveSettings();
|
||||
|
||||
private:
|
||||
void handleDeviceUpdated(Core::Id id);
|
||||
void currentDeviceChanged(int index);
|
||||
void addDevice();
|
||||
|
Reference in New Issue
Block a user