Commit f6c8fafc authored by hjk's avatar hjk

Deprecate 'CurrentSession' in macros.

It's just 'Session' now. The old values will continue to work
but not offered in the variable choosers.

Change-Id: I7e7a62f04abfd895d21cc3c07c4f89056d90b596
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent e569ab8f
......@@ -358,23 +358,27 @@ void MacroExpander::registerIntVariable(const QByteArray &variable,
* \sa registerVariable(), registerIntVariable(), registerPrefix()
*/
void MacroExpander::registerFileVariables(const QByteArray &prefix,
const QString &heading, const StringFunction &base)
const QString &heading, const StringFunction &base, bool visibleInChooser)
{
registerVariable(prefix + kFilePathPostfix,
tr("%1: Full path including file name.").arg(heading),
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).filePath(); });
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).filePath(); },
visibleInChooser);
registerVariable(prefix + kPathPostfix,
tr("%1: Full path excluding file name.").arg(heading),
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).path(); });
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).path(); },
visibleInChooser);
registerVariable(prefix + kFileNamePostfix,
tr("%1: File name without path.").arg(heading),
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).fileName(); });
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).fileName(); },
visibleInChooser);
registerVariable(prefix + kFileBaseNamePostfix,
tr("%1: File base name without path and suffix.").arg(heading),
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).baseName(); });
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).baseName(); },
visibleInChooser);
}
void MacroExpander::registerExtraResolver(const MacroExpander::ResolverFunction &value)
......
......@@ -81,7 +81,8 @@ public:
const QString &description, const IntFunction &value);
void registerFileVariables(const QByteArray &prefix,
const QString &heading, const StringFunction &value);
const QString &heading, const StringFunction &value,
bool visibleInChooser = true);
void registerExtraResolver(const ResolverFunction &value);
......
......@@ -1228,13 +1228,16 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
return tr("unknown");
});
expander->registerFileVariables(Constants::VAR_CURRENTSESSION_PREFIX,
tr("File where current session is saved."),
[]() { return SessionManager::sessionNameToFileName(SessionManager::activeSession()).toString(); });
expander->registerVariable(Constants::VAR_CURRENTSESSION_NAME,
tr("Name of current session."),
[]() { return SessionManager::activeSession(); });
QString fileDescription = tr("File where current session is saved.");
auto fileHandler = [] { return SessionManager::sessionNameToFileName(SessionManager::activeSession()).toString(); };
expander->registerFileVariables("Session", fileDescription, fileHandler);
expander->registerFileVariables("CurrentSession", fileDescription, fileHandler, false);
QString nameDescription = tr("Name of current session.");
auto nameHandler = [] { return SessionManager::activeSession(); };
expander->registerVariable("Session:Name", nameDescription, nameHandler);
expander->registerVariable("CurrentSession:Name", nameDescription, nameHandler, false);
return true;
}
......
......@@ -247,8 +247,6 @@ const char VAR_CURRENTKIT_FILESYSTEMNAME[] = "CurrentKit:FileSystemName";
const char VAR_CURRENTKIT_ID[] = "CurrentKit:Id";
const char VAR_CURRENTBUILD_NAME[] = "CurrentBuild:Name";
const char VAR_CURRENTBUILD_TYPE[] = "CurrentBuild:Type";
const char VAR_CURRENTSESSION_PREFIX[] = "CurrentSession";
const char VAR_CURRENTSESSION_NAME[] = "CurrentSession:Name";
const char VAR_CURRENTDEVICE_HOSTADDRESS[] = "CurrentDevice:HostAddress";
const char VAR_CURRENTDEVICE_SSHPORT[] = "CurrentDevice:SshPort";
const char VAR_CURRENTDEVICE_USERNAME[] = "CurrentDevice:UserName";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment