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 <projectexplorer/projectexplorerconstants.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -43,23 +42,7 @@ DeviceSettingsPage::DeviceSettingsPage()
|
|||||||
setDisplayCategory(QCoreApplication::translate("ProjectExplorer", "Devices"));
|
setDisplayCategory(QCoreApplication::translate("ProjectExplorer", "Devices"));
|
||||||
setCategoryIcon(Utils::Icon({{":/projectexplorer/images/settingscategory_devices.png",
|
setCategoryIcon(Utils::Icon({{":/projectexplorer/images/settingscategory_devices.png",
|
||||||
Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint));
|
Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint));
|
||||||
}
|
setWidgetCreator([] { return new DeviceSettingsWidget; });
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -27,26 +27,15 @@
|
|||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
#include <QPointer>
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class DeviceSettingsWidget;
|
|
||||||
|
|
||||||
class DeviceSettingsPage : public Core::IOptionsPage
|
class DeviceSettingsPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DeviceSettingsPage();
|
DeviceSettingsPage();
|
||||||
|
|
||||||
QWidget *widget() override;
|
|
||||||
void apply() override;
|
|
||||||
void finish() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QPointer<DeviceSettingsWidget> m_widget;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
@@ -45,16 +47,19 @@ namespace Internal {
|
|||||||
namespace Ui { class DeviceSettingsWidget; }
|
namespace Ui { class DeviceSettingsWidget; }
|
||||||
class NameValidator;
|
class NameValidator;
|
||||||
|
|
||||||
class DeviceSettingsWidget : public QWidget
|
class DeviceSettingsWidget : public Core::IOptionsPageWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DeviceSettingsWidget();
|
DeviceSettingsWidget();
|
||||||
~DeviceSettingsWidget() override;
|
~DeviceSettingsWidget() final;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void apply() final { saveSettings(); }
|
||||||
|
void finish() final {}
|
||||||
|
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|
||||||
private:
|
|
||||||
void handleDeviceUpdated(Core::Id id);
|
void handleDeviceUpdated(Core::Id id);
|
||||||
void currentDeviceChanged(int index);
|
void currentDeviceChanged(int index);
|
||||||
void addDevice();
|
void addDevice();
|
||||||
|
Reference in New Issue
Block a user