forked from qt-creator/qt-creator
Qbs: Use IOptionPage::setWidgetCreator() for settings
Change-Id: Idae8c17a8922b60ad9dee3595176d11e0b96fee8 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -26,8 +26,7 @@
|
|||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
namespace QbsProjectManager {
|
namespace QbsProjectManager::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class ProfileTreeItem : public Utils::TypedTreeItem<ProfileTreeItem, ProfileTreeItem>
|
class ProfileTreeItem : public Utils::TypedTreeItem<ProfileTreeItem, ProfileTreeItem>
|
||||||
{
|
{
|
||||||
@@ -53,7 +52,6 @@ private:
|
|||||||
|
|
||||||
class ProfileModel : public Utils::TreeModel<ProfileTreeItem>
|
class ProfileModel : public Utils::TreeModel<ProfileTreeItem>
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
ProfileModel() : TreeModel(static_cast<QObject *>(nullptr))
|
ProfileModel() : TreeModel(static_cast<QObject *>(nullptr))
|
||||||
{
|
{
|
||||||
@@ -91,13 +89,14 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class QbsProfilesSettingsWidget : public QWidget
|
class QbsProfilesSettingsWidget : public Core::IOptionsPageWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
QbsProfilesSettingsWidget();
|
QbsProfilesSettingsWidget();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void apply() final {}
|
||||||
|
|
||||||
void refreshKitsList();
|
void refreshKitsList();
|
||||||
void displayCurrentProfile();
|
void displayCurrentProfile();
|
||||||
|
|
||||||
@@ -112,19 +111,7 @@ QbsProfilesSettingsPage::QbsProfilesSettingsPage()
|
|||||||
setId("Y.QbsProfiles");
|
setId("Y.QbsProfiles");
|
||||||
setDisplayName(Tr::tr("Profiles"));
|
setDisplayName(Tr::tr("Profiles"));
|
||||||
setCategory(Constants::QBS_SETTINGS_CATEGORY);
|
setCategory(Constants::QBS_SETTINGS_CATEGORY);
|
||||||
}
|
setWidgetCreator([] { return new QbsProfilesSettingsWidget; });
|
||||||
|
|
||||||
QWidget *QbsProfilesSettingsPage::widget()
|
|
||||||
{
|
|
||||||
if (!m_widget)
|
|
||||||
m_widget = new QbsProfilesSettingsWidget;
|
|
||||||
return m_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QbsProfilesSettingsPage::finish()
|
|
||||||
{
|
|
||||||
delete m_widget;
|
|
||||||
m_widget = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QbsProfilesSettingsWidget::QbsProfilesSettingsWidget()
|
QbsProfilesSettingsWidget::QbsProfilesSettingsWidget()
|
||||||
@@ -211,7 +198,4 @@ void QbsProfilesSettingsWidget::displayCurrentProfile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // QbsProjectManager::Internal
|
||||||
} // namespace QbsProjectManager
|
|
||||||
|
|
||||||
#include "qbsprofilessettingspage.moc"
|
|
||||||
|
@@ -5,22 +5,12 @@
|
|||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
namespace QbsProjectManager {
|
namespace QbsProjectManager::Internal {
|
||||||
namespace Internal {
|
|
||||||
class QbsProfilesSettingsWidget;
|
|
||||||
|
|
||||||
class QbsProfilesSettingsPage : public Core::IOptionsPage
|
class QbsProfilesSettingsPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QbsProfilesSettingsPage();
|
QbsProfilesSettingsPage();
|
||||||
|
|
||||||
private:
|
|
||||||
QWidget *widget() override;
|
|
||||||
void apply() override { }
|
|
||||||
void finish() override;
|
|
||||||
|
|
||||||
QbsProfilesSettingsWidget *m_widget = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // QbsProjectManager::Internal
|
||||||
} // namespace QbsProjectManager
|
|
||||||
|
@@ -21,8 +21,7 @@
|
|||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace QbsProjectManager {
|
namespace QbsProjectManager::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
const char QBS_EXE_KEY[] = "QbsProjectManager/QbsExecutable";
|
const char QBS_EXE_KEY[] = "QbsProjectManager/QbsExecutable";
|
||||||
const char QBS_DEFAULT_INSTALL_DIR_KEY[] = "QbsProjectManager/DefaultInstallDir";
|
const char QBS_DEFAULT_INSTALL_DIR_KEY[] = "QbsProjectManager/DefaultInstallDir";
|
||||||
@@ -142,10 +141,10 @@ void QbsSettings::storeSettings() const
|
|||||||
s->setValue(USE_CREATOR_SETTINGS_KEY, m_settings.useCreatorSettings);
|
s->setValue(USE_CREATOR_SETTINGS_KEY, m_settings.useCreatorSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
class QbsSettingsPage::SettingsWidget : public QWidget
|
class QbsSettingsPageWidget : public Core::IOptionsPageWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SettingsWidget()
|
QbsSettingsPageWidget()
|
||||||
{
|
{
|
||||||
m_qbsExePathChooser.setExpectedKind(PathChooser::ExistingCommand);
|
m_qbsExePathChooser.setExpectedKind(PathChooser::ExistingCommand);
|
||||||
m_qbsExePathChooser.setFilePath(QbsSettings::qbsExecutableFilePath());
|
m_qbsExePathChooser.setFilePath(QbsSettings::qbsExecutableFilePath());
|
||||||
@@ -166,7 +165,7 @@ public:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply()
|
void apply() final
|
||||||
{
|
{
|
||||||
QbsSettingsData settings = QbsSettings::rawSettingsData();
|
QbsSettingsData settings = QbsSettings::rawSettingsData();
|
||||||
if (m_qbsExePathChooser.filePath() != QbsSettings::qbsExecutableFilePath())
|
if (m_qbsExePathChooser.filePath() != QbsSettings::qbsExecutableFilePath())
|
||||||
@@ -197,26 +196,7 @@ QbsSettingsPage::QbsSettingsPage()
|
|||||||
setCategory(Constants::QBS_SETTINGS_CATEGORY);
|
setCategory(Constants::QBS_SETTINGS_CATEGORY);
|
||||||
setDisplayCategory(Tr::tr(Constants::QBS_SETTINGS_TR_CATEGORY));
|
setDisplayCategory(Tr::tr(Constants::QBS_SETTINGS_TR_CATEGORY));
|
||||||
setCategoryIconPath(":/qbsprojectmanager/images/settingscategory_qbsprojectmanager.png");
|
setCategoryIconPath(":/qbsprojectmanager/images/settingscategory_qbsprojectmanager.png");
|
||||||
|
setWidgetCreator([] { return new QbsSettingsPageWidget; });
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *QbsSettingsPage::widget()
|
} // QbsProjectManager::Internal
|
||||||
{
|
|
||||||
if (!m_widget)
|
|
||||||
m_widget = new SettingsWidget;
|
|
||||||
return m_widget;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void QbsSettingsPage::apply()
|
|
||||||
{
|
|
||||||
if (m_widget)
|
|
||||||
m_widget->apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QbsSettingsPage::finish()
|
|
||||||
{
|
|
||||||
delete m_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace QbsProjectManager
|
|
||||||
|
@@ -4,16 +4,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
#include <utils/fileutils.h>
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <utils/filepath.h>
|
||||||
#include <QPointer>
|
|
||||||
#include <QVersionNumber>
|
#include <QVersionNumber>
|
||||||
|
|
||||||
namespace QbsProjectManager {
|
namespace QbsProjectManager::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class QbsSettingsData {
|
class QbsSettingsData
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
Utils::FilePath qbsExecutableFilePath;
|
Utils::FilePath qbsExecutableFilePath;
|
||||||
QString defaultInstallDirTemplate;
|
QString defaultInstallDirTemplate;
|
||||||
@@ -51,18 +50,8 @@ private:
|
|||||||
|
|
||||||
class QbsSettingsPage : public Core::IOptionsPage
|
class QbsSettingsPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
QbsSettingsPage();
|
QbsSettingsPage();
|
||||||
|
|
||||||
private:
|
|
||||||
QWidget *widget() override;
|
|
||||||
void apply() override;
|
|
||||||
void finish() override;
|
|
||||||
|
|
||||||
class SettingsWidget;
|
|
||||||
QPointer<SettingsWidget> m_widget;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // QbsProjectManager::Internal
|
||||||
} // namespace QbsProjectManager
|
|
||||||
|
Reference in New Issue
Block a user