summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/editexecutablesdialog.cpp3
-rw-r--r--src/executableslist.cpp64
-rw-r--r--src/executableslist.h40
-rw-r--r--src/mainwindow.cpp17
-rw-r--r--src/organizercore.cpp11
5 files changed, 50 insertions, 85 deletions
diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp
index c77ac243..3705bbd5 100644
--- a/src/editexecutablesdialog.cpp
+++ b/src/editexecutablesdialog.cpp
@@ -91,7 +91,7 @@ void EditExecutablesDialog::resetInput()
void EditExecutablesDialog::saveExecutable()
{
- m_ExecutablesList.updateOrAddExecutable(ui->titleEdit->text(),
+ m_ExecutablesList.updateExecutable(ui->titleEdit->text(),
QDir::fromNativeSeparators(ui->binaryEdit->text()),
ui->argumentsEdit->text(),
QDir::fromNativeSeparators(ui->workingDirEdit->text()),
@@ -100,6 +100,7 @@ void EditExecutablesDialog::saveExecutable()
: ExecutableInfo::CloseMOStyle::DEFAULT_STAY,
ui->overwriteAppIDBox->isChecked() ?
ui->appIDOverwriteEdit->text() : "",
+ Executable::UseApplicationIcon,
ui->useAppIconCheckBox->isChecked() ?
Executable::UseApplicationIcon : Executable::Flags());
}
diff --git a/src/executableslist.cpp b/src/executableslist.cpp
index 8a16e206..7002ccc4 100644
--- a/src/executableslist.cpp
+++ b/src/executableslist.cpp
@@ -129,60 +129,24 @@ void ExecutablesList::addExecutable(const Executable &executable)
}
-void ExecutablesList::configureExecutable(const QString &title,
- const QString &executableName,
- const QString &arguments,
- const QString &workingDirectory,
- ExecutableInfo::CloseMOStyle closeMO,
- const QString &steamAppID,
- Executable::Flags flags)
+void ExecutablesList::updateExecutable(const QString &title,
+ const QString &executableName,
+ const QString &arguments,
+ const QString &workingDirectory,
+ ExecutableInfo::CloseMOStyle closeMO,
+ const QString &steamAppID,
+ Executable::Flags mask,
+ Executable::Flags flags)
{
QFileInfo file(executableName);
auto existingExe = findExe(title);
+ flags &= mask;
if (existingExe != m_Executables.end()) {
existingExe->m_Title = title;
existingExe->m_CloseMO = closeMO;
- existingExe->m_Flags = flags;
- if (flags & Executable::CustomExecutable) {
- // for pre-configured executables don't overwrite settings we didn't store
- 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 | flags;
- m_Executables.push_back(newExe);
- }
-}
-
-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;
- }
+ existingExe->m_Flags &= ~mask;
+ existingExe->m_Flags |= flags;
// for pre-configured executables don't overwrite settings we didn't store
if (existingExe->isCustom()) {
existingExe->m_BinaryInfo = file;
@@ -198,16 +162,12 @@ void ExecutablesList::updateOrAddExecutable(const QString &title,
newExe.m_Arguments = arguments;
newExe.m_WorkingDirectory = workingDirectory;
newExe.m_SteamAppID = steamAppID;
- newExe.m_Flags = Executable::CustomExecutable;
- if (usesApplicationIcon) {
- newExe.m_Flags |= Executable::UseApplicationIcon;
- }
+ newExe.m_Flags = Executable::CustomExecutable | flags;
m_Executables.push_back(newExe);
}
}
-
void ExecutablesList::remove(const QString &title)
{
for (std::vector<Executable>::iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) {
diff --git a/src/executableslist.h b/src/executableslist.h
index b8e2afe6..37e903e5 100644
--- a/src/executableslist.h
+++ b/src/executableslist.h
@@ -42,7 +42,9 @@ struct Executable {
enum Flag {
CustomExecutable = 0x01,
ShowInToolbar = 0x02,
- UseApplicationIcon = 0x04
+ UseApplicationIcon = 0x04,
+
+ AllFlags = 0xff //I know, I know
};
Q_DECLARE_FLAGS(Flags, Flag)
@@ -127,36 +129,40 @@ public:
void addExecutable(const Executable &executable);
/**
- * @brief update an existing executable or add a new one to the list
+ * @brief add a new executable to the list
*
* @param title name displayed in the UI
* @param executableName the actual filename to execute
* @param arguments arguments to pass to the executable
* @param closeMO if true, MO will be closed when the binary is started
**/
- void updateOrAddExecutable(const QString &title,
- const QString &executableName,
- const QString &arguments,
- const QString &workingDirectory,
- MOBase::ExecutableInfo::CloseMOStyle closeMO,
- const QString &steamAppID,
- bool usesApplicationIcon);
+ void addExecutable(const QString &title,
+ const QString &executableName,
+ const QString &arguments,
+ const QString &workingDirectory,
+ MOBase::ExecutableInfo::CloseMOStyle closeMO,
+ const QString &steamAppID,
+ Executable::Flags flags)
+ {
+ updateExecutable(title, executableName, arguments, workingDirectory, closeMO, steamAppID, Executable::AllFlags, flags);
+ }
/**
- * @brief U[date executable list with configured settings
+ * @brief Update an executable to the list
*
* @param title name displayed in the UI
* @param executableName the actual filename to execute
* @param arguments arguments to pass to the executable
* @param closeMO if true, MO will be closed when the binary is started
**/
- void configureExecutable(const QString &title,
- const QString &executableName,
- const QString &arguments,
- const QString &workingDirectory,
- MOBase::ExecutableInfo::CloseMOStyle closeMO,
- const QString &steamAppID,
- Executable::Flags flags);
+ void updateExecutable(const QString &title,
+ const QString &executableName,
+ const QString &arguments,
+ const QString &workingDirectory,
+ MOBase::ExecutableInfo::CloseMOStyle closeMO,
+ const QString &steamAppID,
+ Executable::Flags mask,
+ Executable::Flags flags);
/**
* @brief remove the executable with the specified file name. This needs to be an absolute file path
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 28596127..a0a56406 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1755,8 +1755,7 @@ void MainWindow::on_executablesListBox_currentIndexChanged(int index)
if (executablesList->isEnabled()) {
//I think the 2nd test is impossible
- if (index == 0 ||
- index > static_cast<int>(m_OrganizerCore.executablesList()->size())) {
+ if ((index == 0) || (index > static_cast<int>(m_OrganizerCore.executablesList()->size()))) {
if (modifyExecutablesDialog()) {
setExecutableIndex(previousIndex);
}
@@ -3563,13 +3562,13 @@ void MainWindow::addAsExecutable()
targetInfo.baseName());
if (!name.isEmpty()) {
//Note: If this already exists, you'll lose custom settings
- m_OrganizerCore.executablesList()->configureExecutable(name,
- binaryInfo.absoluteFilePath(),
- arguments,
- targetInfo.absolutePath(),
- ExecutableInfo::CloseMOStyle::DEFAULT_STAY,
- QString(),
- Executable::CustomExecutable);
+ m_OrganizerCore.executablesList()->addExecutable(name,
+ binaryInfo.absoluteFilePath(),
+ arguments,
+ targetInfo.absolutePath(),
+ ExecutableInfo::CloseMOStyle::DEFAULT_STAY,
+ QString(),
+ Executable::CustomExecutable);
refreshExecutablesList();
}
} break;
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index b3bcc917..cea1a868 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -336,14 +336,13 @@ void OrganizerCore::updateExecutablesList(QSettings &settings)
if (settings.value("toolbar", false).toBool()) flags |= Executable::ShowInToolbar;
if (settings.value("ownicon", false).toBool()) flags |= Executable::UseApplicationIcon;
- if (settings.value("ownicon", false).toBool()) flags |= Executable::UseApplicationIcon;
- m_ExecutablesList.configureExecutable(settings.value("title").toString(),
- settings.value("binary").toString(),
- settings.value("arguments").toString(),
- settings.value("workingDirectory", "").toString(),
+ m_ExecutablesList.addExecutable(settings.value("title").toString(),
+ settings.value("binary").toString(),
+ settings.value("arguments").toString(),
+ settings.value("workingDirectory", "").toString(),
closeMO,
- settings.value("steamAppID", "").toString(),
+ settings.value("steamAppID", "").toString(),
flags);
}