From 8e7ac4e064c51cf8bdba7b036a027bdec1f8468f Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Thu, 13 Aug 2015 20:07:21 +0100 Subject: Fix the executable configuration flags going awry from Customise window --- src/executableslist.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 9 deletions(-) (limited to 'src/executableslist.cpp') diff --git a/src/executableslist.cpp b/src/executableslist.cpp index 76fe73d7..8a16e206 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -129,13 +129,13 @@ void ExecutablesList::addExecutable(const Executable &executable) } -void ExecutablesList::addExecutable(const QString &title, - const QString &executableName, - const QString &arguments, - const QString &workingDirectory, - ExecutableInfo::CloseMOStyle closeMO, - const QString &steamAppID, - Executable::Flags flags) +void ExecutablesList::configureExecutable(const QString &title, + const QString &executableName, + const QString &arguments, + const QString &workingDirectory, + ExecutableInfo::CloseMOStyle closeMO, + const QString &steamAppID, + Executable::Flags flags) { QFileInfo file(executableName); auto existingExe = findExe(title); @@ -164,6 +164,49 @@ void ExecutablesList::addExecutable(const QString &title, } } +void ExecutablesList::updateOrAddExecutable(const QString &title, + const QString &executableName, + const QString &arguments, + const QString &workingDirectory, + ExecutableInfo::CloseMOStyle closeMO, + const QString &steamAppID, + bool usesApplicationIcon) +{ + QFileInfo file(executableName); + auto existingExe = findExe(title); + + if (existingExe != m_Executables.end()) { + existingExe->m_Title = title; + existingExe->m_CloseMO = closeMO; + if (usesApplicationIcon) { + existingExe->m_Flags |= Executable::UseApplicationIcon; + } else { + existingExe->m_Flags &= ~Executable::UseApplicationIcon; + } + // for pre-configured executables don't overwrite settings we didn't store + if (existingExe->isCustom()) { + existingExe->m_BinaryInfo = file; + existingExe->m_Arguments = arguments; + existingExe->m_WorkingDirectory = workingDirectory; + existingExe->m_SteamAppID = steamAppID; + } + } else { + Executable newExe; + newExe.m_Title = title; + newExe.m_CloseMO = closeMO; + newExe.m_BinaryInfo = file; + newExe.m_Arguments = arguments; + newExe.m_WorkingDirectory = workingDirectory; + newExe.m_SteamAppID = steamAppID; + newExe.m_Flags = Executable::CustomExecutable; + if (usesApplicationIcon) { + newExe.m_Flags |= Executable::UseApplicationIcon; + } + m_Executables.push_back(newExe); + } +} + + void ExecutablesList::remove(const QString &title) { @@ -197,8 +240,9 @@ void ExecutablesList::addExecutableInternal(const QString &title, const QString void Executable::showOnToolbar(bool state) { - if (state) + if (state) { m_Flags |= ShowInToolbar; - else + } else { m_Flags &= ~ShowInToolbar; + } } -- cgit v1.3.1