forked from qt-creator/qt-creator
Vcs: Unify options pages for VcsBaseClientImpl based VCSes
Change-Id: Ia5dd7746f5857e7254251e3510c0987737cfad6d Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -139,8 +139,7 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString *
|
||||
m_client = new MercurialClient;
|
||||
initializeVcs(new MercurialControl(m_client), context);
|
||||
|
||||
optionsPage = new OptionsPage();
|
||||
addAutoReleasedObject(optionsPage);
|
||||
addAutoReleasedObject(new OptionsPage(versionControl()));
|
||||
|
||||
connect(m_client, SIGNAL(changed(QVariant)), versionControl(), SLOT(changed(QVariant)));
|
||||
connect(m_client, SIGNAL(needUpdate()), this, SLOT(update()));
|
||||
|
||||
@@ -45,8 +45,7 @@ using namespace VcsBase;
|
||||
namespace Mercurial {
|
||||
namespace Internal {
|
||||
|
||||
OptionsPageWidget::OptionsPageWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
OptionsPageWidget::OptionsPageWidget(QWidget *parent) : VcsClientOptionsPageWidget(parent)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
m_ui.commandChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
||||
@@ -74,38 +73,12 @@ void OptionsPageWidget::setSettings(const VcsBaseClientSettings &s)
|
||||
m_ui.timeout->setValue(s.intValue(MercurialSettings::timeoutKey));
|
||||
}
|
||||
|
||||
OptionsPage::OptionsPage()
|
||||
OptionsPage::OptionsPage(Core::IVersionControl *control) :
|
||||
VcsClientOptionsPage(control, MercurialPlugin::client())
|
||||
{
|
||||
setId(VcsBase::Constants::VCS_ID_MERCURIAL);
|
||||
setDisplayName(tr("Mercurial"));
|
||||
}
|
||||
|
||||
QWidget *OptionsPage::widget()
|
||||
{
|
||||
if (!optionsPageWidget)
|
||||
optionsPageWidget = new OptionsPageWidget;
|
||||
optionsPageWidget->setSettings(MercurialPlugin::client()->settings());
|
||||
return optionsPageWidget;
|
||||
}
|
||||
|
||||
void OptionsPage::apply()
|
||||
{
|
||||
if (!optionsPageWidget)
|
||||
return;
|
||||
|
||||
const VcsBaseClientSettings newSettings = optionsPageWidget->settings();
|
||||
VcsBaseClientSettings &s = MercurialPlugin::instance()->client()->settings();
|
||||
if (s != newSettings) {
|
||||
s = newSettings;
|
||||
s.writeSettings(Core::ICore::settings());
|
||||
emit settingsChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OptionsPage::finish()
|
||||
{
|
||||
delete optionsPageWidget;
|
||||
setWidgetFactory([]() { return new OptionsPageWidget; });
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -45,7 +45,7 @@ class VcsBaseClientSettings;
|
||||
namespace Mercurial {
|
||||
namespace Internal {
|
||||
|
||||
class OptionsPageWidget : public QWidget
|
||||
class OptionsPageWidget : public VcsBase::VcsClientOptionsPageWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -60,22 +60,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class OptionsPage : public VcsBase::VcsBaseOptionsPage
|
||||
class OptionsPage : public VcsBase::VcsClientOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OptionsPage();
|
||||
|
||||
QWidget *widget();
|
||||
void apply();
|
||||
void finish();
|
||||
|
||||
signals:
|
||||
void settingsChanged();
|
||||
|
||||
private:
|
||||
QPointer<OptionsPageWidget> optionsPageWidget;
|
||||
OptionsPage(Core::IVersionControl *control);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user