Vcs: Convert settings pages to latest style

Last change in that area for this year.

Change-Id: Ibae9f1869cb20faf85c0c1669b84751ad022b8fd
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2023-07-18 12:57:17 +02:00
parent 89a64a19e8
commit 9a69c78ca5
17 changed files with 128 additions and 60 deletions

View File

@@ -215,7 +215,6 @@ public:
void createRepositoryActions(const Core::Context &context); void createRepositoryActions(const Core::Context &context);
// Variables // Variables
BazaarSettings m_setting;
BazaarClient m_client; BazaarClient m_client;
VcsSubmitEditorFactory m_submitEditorFactory { VcsSubmitEditorFactory m_submitEditorFactory {

View File

@@ -6,6 +6,7 @@
#include "bazaartr.h" #include "bazaartr.h"
#include "constants.h" #include "constants.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <utils/layoutbuilder.h> #include <utils/layoutbuilder.h>
@@ -16,21 +17,16 @@ using namespace Utils;
namespace Bazaar::Internal { namespace Bazaar::Internal {
static BazaarSettings *theSettings;
BazaarSettings &settings() BazaarSettings &settings()
{ {
return *theSettings; static BazaarSettings theSettings;
return theSettings;
} }
BazaarSettings::BazaarSettings() BazaarSettings::BazaarSettings()
{ {
theSettings = this; setAutoApply(false);
setSettingsGroup(Constants::BAZAAR); setSettingsGroup(Constants::BAZAAR);
setId(VcsBase::Constants::VCS_ID_BAZAAR);
setDisplayName(Tr::tr("Bazaar"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
binaryPath.setExpectedKind(PathChooser::ExistingCommand); binaryPath.setExpectedKind(PathChooser::ExistingCommand);
binaryPath.setDefaultValue(Constants::BAZAARDEFAULT); binaryPath.setDefaultValue(Constants::BAZAARDEFAULT);
@@ -92,4 +88,20 @@ BazaarSettings::BazaarSettings()
}); });
} }
// BazaarSettingsPage
class BazaarSettingsPage final : public Core::IOptionsPage
{
public:
BazaarSettingsPage()
{
setId(VcsBase::Constants::VCS_ID_BAZAAR);
setDisplayName(Tr::tr("Bazaar"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
setSettingsProvider([] { return &settings(); });
}
};
const BazaarSettingsPage settingsPage;
} // Bazaar::Internal } // Bazaar::Internal

View File

@@ -288,7 +288,6 @@ private:
bool commit(const QString &messageFile, const QStringList &subVersionFileList); bool commit(const QString &messageFile, const QStringList &subVersionFileList);
void cleanCommitMessageFile(); void cleanCommitMessageFile();
CvsSettings m_setting;
CvsClient *m_client = nullptr; CvsClient *m_client = nullptr;
QString m_commitMessageFileName; QString m_commitMessageFileName;

View File

@@ -5,6 +5,7 @@
#include "cvstr.h" #include "cvstr.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
@@ -17,22 +18,17 @@ using namespace Utils;
namespace Cvs::Internal { namespace Cvs::Internal {
static CvsSettings *theSettings;
CvsSettings &settings() CvsSettings &settings()
{ {
return *theSettings; static CvsSettings theSettings;
return theSettings;
} }
CvsSettings::CvsSettings() CvsSettings::CvsSettings()
{ {
theSettings = this; setAutoApply(false);
setSettingsGroup("CVS"); setSettingsGroup("CVS");
setId(VcsBase::Constants::VCS_ID_CVS);
setDisplayName(Tr::tr("CVS"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
binaryPath.setDefaultValue("cvs" QTC_HOST_EXE_SUFFIX); binaryPath.setDefaultValue("cvs" QTC_HOST_EXE_SUFFIX);
binaryPath.setExpectedKind(PathChooser::ExistingCommand); binaryPath.setExpectedKind(PathChooser::ExistingCommand);
binaryPath.setHistoryCompleter(QLatin1String("Cvs.Command.History")); binaryPath.setHistoryCompleter(QLatin1String("Cvs.Command.History"));
@@ -97,4 +93,20 @@ QStringList CvsSettings::addOptions(const QStringList &args) const
return rc; return rc;
} }
// CvsSettingsPage
class CvsSettingsPage final : Core::IOptionsPage
{
public:
CvsSettingsPage()
{
setId(VcsBase::Constants::VCS_ID_CVS);
setDisplayName(Tr::tr("CVS"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
setSettingsProvider([] { return &settings(); });
}
};
const CvsSettingsPage settingsPage;
} // Cvs::Internal } // Cvs::Internal

View File

@@ -187,7 +187,6 @@ public:
bool pullOrPush(SyncMode mode); bool pullOrPush(SyncMode mode);
// Variables // Variables
FossilSettings m_settings;
FossilClient m_client; FossilClient m_client;
VcsSubmitEditorFactory submitEditorFactory { VcsSubmitEditorFactory submitEditorFactory {

View File

@@ -6,6 +6,7 @@
#include "constants.h" #include "constants.h"
#include "fossiltr.h" #include "fossiltr.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <utils/layoutbuilder.h> #include <utils/layoutbuilder.h>
@@ -17,21 +18,16 @@ using namespace Utils;
namespace Fossil::Internal { namespace Fossil::Internal {
static FossilSettings *theSettings;
FossilSettings &settings() FossilSettings &settings()
{ {
return *theSettings; static FossilSettings theSettings;
return theSettings;
} }
FossilSettings::FossilSettings() FossilSettings::FossilSettings()
{ {
theSettings = this; setAutoApply(false);
setSettingsGroup(Constants::FOSSIL); setSettingsGroup(Constants::FOSSIL);
setId(Constants::VCS_ID_FOSSIL);
setDisplayName(Tr::tr("Fossil"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
binaryPath.setExpectedKind(PathChooser::ExistingCommand); binaryPath.setExpectedKind(PathChooser::ExistingCommand);
binaryPath.setDefaultValue(Constants::FOSSILDEFAULT); binaryPath.setDefaultValue(Constants::FOSSILDEFAULT);
@@ -121,4 +117,20 @@ FossilSettings::FossilSettings()
}); });
} }
// FossilSettingsPage
class FossilSettingsPage final : public Core::IOptionsPage
{
public:
FossilSettingsPage()
{
setId(Constants::VCS_ID_FOSSIL);
setDisplayName(Tr::tr("Fossil"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
setSettingsProvider([] { return &settings(); });
}
};
const FossilSettingsPage settingsPage;
} // Fossil::Internal } // Fossil::Internal

View File

@@ -7,7 +7,7 @@
namespace Fossil::Internal { namespace Fossil::Internal {
class FossilSettings : public VcsBase::VcsBaseSettings class FossilSettings final : public VcsBase::VcsBaseSettings
{ {
public: public:
FossilSettings(); FossilSettings();

View File

@@ -399,7 +399,6 @@ public:
void onApplySettings(); void onApplySettings();
GitSettings setting;
CommandLocator *m_commandLocator = nullptr; CommandLocator *m_commandLocator = nullptr;
QAction *m_menuAction = nullptr; QAction *m_menuAction = nullptr;

View File

@@ -5,6 +5,8 @@
#include "gittr.h" #include "gittr.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/layoutbuilder.h> #include <utils/layoutbuilder.h>
@@ -17,20 +19,15 @@ using namespace VcsBase;
namespace Git::Internal { namespace Git::Internal {
static GitSettings *theSettings;
GitSettings &settings() GitSettings &settings()
{ {
return *theSettings; static GitSettings theSettings;
return theSettings;
} }
GitSettings::GitSettings() GitSettings::GitSettings()
{ {
theSettings = this; setAutoApply(false);
setId(VcsBase::Constants::VCS_ID_GIT);
setDisplayName(Tr::tr("Git"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
setSettingsGroup("Git"); setSettingsGroup("Git");
path.setDisplayStyle(StringAspect::LineEditDisplay); path.setDisplayStyle(StringAspect::LineEditDisplay);
@@ -175,4 +172,20 @@ FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const
return resolvedBinPath; return resolvedBinPath;
} }
// GitSettingsPage
class GitSettingsPage final : public Core::IOptionsPage
{
public:
GitSettingsPage()
{
setId(VcsBase::Constants::VCS_ID_GIT);
setDisplayName(Tr::tr("Git"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
setSettingsProvider([] { return &settings(); });
}
};
const GitSettingsPage settingsPage;
} // Git::Internal } // Git::Internal

View File

@@ -15,7 +15,7 @@ enum CommitType
}; };
// Todo: Add user name and password? // Todo: Add user name and password?
class GitSettings : public VcsBase::VcsBaseSettings class GitSettings final : public VcsBase::VcsBaseSettings
{ {
public: public:
GitSettings(); GitSettings();

View File

@@ -169,7 +169,6 @@ private:
void createRepositoryActions(const Core::Context &context); void createRepositoryActions(const Core::Context &context);
// Variables // Variables
MercurialSettings m_settings;
MercurialClient m_client; MercurialClient m_client;
Core::CommandLocator *m_commandLocator = nullptr; Core::CommandLocator *m_commandLocator = nullptr;

View File

@@ -6,6 +6,8 @@
#include "constants.h" #include "constants.h"
#include "mercurialtr.h" #include "mercurialtr.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <utils/layoutbuilder.h> #include <utils/layoutbuilder.h>
#include <vcsbase/vcsbaseconstants.h> #include <vcsbase/vcsbaseconstants.h>
@@ -14,20 +16,15 @@ using namespace Utils;
namespace Mercurial::Internal { namespace Mercurial::Internal {
static MercurialSettings *theSettings;
MercurialSettings &settings() MercurialSettings &settings()
{ {
return *theSettings; static MercurialSettings theSettings;
return theSettings;
} }
MercurialSettings::MercurialSettings() MercurialSettings::MercurialSettings()
{ {
theSettings = this; setAutoApply(false);
setId(VcsBase::Constants::VCS_ID_MERCURIAL);
setDisplayName(Tr::tr("Mercurial"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
setSettingsGroup("Mercurial"); setSettingsGroup("Mercurial");
binaryPath.setExpectedKind(PathChooser::ExistingCommand); binaryPath.setExpectedKind(PathChooser::ExistingCommand);
@@ -75,4 +72,20 @@ MercurialSettings::MercurialSettings()
}); });
} }
// MercurialSettingsPage
class MercurialSettingsPage final : public Core::IOptionsPage
{
public:
MercurialSettingsPage()
{
setId(VcsBase::Constants::VCS_ID_MERCURIAL);
setDisplayName(Tr::tr("Mercurial"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
setSettingsProvider([] { return &settings(); });
}
};
const MercurialSettingsPage settingsPage;
} // Mercurial::Internal } // Mercurial::Internal

View File

@@ -7,7 +7,7 @@
namespace Mercurial::Internal { namespace Mercurial::Internal {
class MercurialSettings : public VcsBase::VcsBaseSettings class MercurialSettings final : public VcsBase::VcsBaseSettings
{ {
public: public:
MercurialSettings(); MercurialSettings();

View File

@@ -261,7 +261,6 @@ private:
const QStringList m_svnDirectories; const QStringList m_svnDirectories;
SubversionSettings m_settings;
SubversionClient *m_client = nullptr; SubversionClient *m_client = nullptr;
QString m_commitMessageFileName; QString m_commitMessageFileName;
FilePath m_commitRepository; FilePath m_commitRepository;

View File

@@ -5,6 +5,8 @@
#include "subversiontr.h" #include "subversiontr.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/layoutbuilder.h> #include <utils/layoutbuilder.h>
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
@@ -16,20 +18,15 @@ using namespace VcsBase;
namespace Subversion::Internal { namespace Subversion::Internal {
static SubversionSettings *theSettings;
SubversionSettings &settings() SubversionSettings &settings()
{ {
return *theSettings; static SubversionSettings theSettings;
return theSettings;
} }
SubversionSettings::SubversionSettings() SubversionSettings::SubversionSettings()
{ {
theSettings = this; setAutoApply(false);
setId(VcsBase::Constants::VCS_ID_SUBVERSION);
setDisplayName(Tr::tr("Subversion"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
setSettingsGroup("Subversion"); setSettingsGroup("Subversion");
binaryPath.setExpectedKind(PathChooser::ExistingCommand); binaryPath.setExpectedKind(PathChooser::ExistingCommand);
@@ -104,4 +101,19 @@ bool SubversionSettings::hasAuthentication() const
return useAuthentication() && !userName().isEmpty(); return useAuthentication() && !userName().isEmpty();
} }
// SubversionSettingsPage
class SubversionSettingsPage final : public Core::IOptionsPage
{
public:
SubversionSettingsPage()
{
setId(VcsBase::Constants::VCS_ID_SUBVERSION);
setDisplayName(Tr::tr("Subversion"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
}
};
const SubversionSettingsPage settingsPage;
} // Subversion::Internal } // Subversion::Internal

View File

@@ -7,7 +7,7 @@
namespace Subversion::Internal { namespace Subversion::Internal {
class SubversionSettings : public VcsBase::VcsBaseSettings class SubversionSettings final : public VcsBase::VcsBaseSettings
{ {
public: public:
SubversionSettings(); SubversionSettings();

View File

@@ -5,11 +5,11 @@
#include "vcsbase_global.h" #include "vcsbase_global.h"
#include <coreplugin/dialogs/ioptionspage.h> #include <utils/aspects.h>
namespace VcsBase { namespace VcsBase {
class VCSBASE_EXPORT VcsBaseSettings : public Core::PagedSettings class VCSBASE_EXPORT VcsBaseSettings : public Utils::AspectContainer
{ {
public: public:
VcsBaseSettings(); VcsBaseSettings();