diff options
author | hjk <hjk@qt.io> | 2018-03-01 09:26:46 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2018-04-06 06:27:52 +0000 |
commit | c69e4598ede68b1a698ec494331eaa083727c711 (patch) | |
tree | e7b72a4f856bc325e8139e2cbdf2c15a23973cf3 /src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp | |
parent | 27c51ed4c8cacb566bec04ce60b101913940d2e8 (diff) |
ProjectExplorer: Streamline *EnvironmentAspect interface
Register code/name combinations together.
Also make the otherwise implicitly preferred first entry
explicit in the API.
Change-Id: I80f68b01d53e2672480365d4efcb9d790b8363fd
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp')
-rw-r--r-- | src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp b/src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp index 7a2bc8c1ba4..2ad9d3da7e9 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp +++ b/src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp @@ -28,46 +28,32 @@ #include "remotelinuxenvironmentaspectwidget.h" #include "utils/algorithm.h" -static const char DISPLAY_KEY[] = "DISPLAY"; -static const char VERSION_KEY[] = "RemoteLinux.EnvironmentAspect.Version"; -static const int ENVIRONMENTASPECT_VERSION = 1; // Version was introduced in 4.3 with the value 1 +namespace RemoteLinux { -namespace { +const char DISPLAY_KEY[] = "DISPLAY"; +const char VERSION_KEY[] = "RemoteLinux.EnvironmentAspect.Version"; +const int ENVIRONMENTASPECT_VERSION = 1; // Version was introduced in 4.3 with the value 1 -bool displayAlreadySet(const QList<Utils::EnvironmentItem> &changes) +static bool displayAlreadySet(const QList<Utils::EnvironmentItem> &changes) { return Utils::contains(changes, [](const Utils::EnvironmentItem &item) { return item.name == DISPLAY_KEY; }); } -} // anonymous namespace - -namespace RemoteLinux { +enum BaseEnvironmentBase { + CleanBaseEnvironment = 0, + RemoteBaseEnvironment = 1 +}; -// -------------------------------------------------------------------- -// RemoteLinuxEnvironmentAspect: -// -------------------------------------------------------------------- RemoteLinuxEnvironmentAspect::RemoteLinuxEnvironmentAspect(ProjectExplorer::RunConfiguration *rc) : ProjectExplorer::EnvironmentAspect(rc) { - setRunConfigWidgetCreator([this] { return new RemoteLinuxEnvironmentAspectWidget(this); }); -} - -QList<int> RemoteLinuxEnvironmentAspect::possibleBaseEnvironments() const -{ - return QList<int>() << static_cast<int>(RemoteBaseEnvironment) - << static_cast<int>(CleanBaseEnvironment); -} + addSupportedBaseEnvironment(CleanBaseEnvironment, tr("Clean Environment")); + addPreferredBaseEnvironment(RemoteBaseEnvironment, tr("System Environment")); -QString RemoteLinuxEnvironmentAspect::baseEnvironmentDisplayName(int base) const -{ - if (base == static_cast<int>(CleanBaseEnvironment)) - return tr("Clean Environment"); - else if (base == static_cast<int>(RemoteBaseEnvironment)) - return tr("System Environment"); - return QString(); + setRunConfigWidgetCreator([this] { return new RemoteLinuxEnvironmentAspectWidget(this); }); } Utils::Environment RemoteLinuxEnvironmentAspect::baseEnvironment() const |