summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/editexecutablesdialog.cpp25
-rw-r--r--src/executableslist.cpp28
-rw-r--r--src/executableslist.h26
-rw-r--r--src/mainwindow.cpp1
4 files changed, 54 insertions, 26 deletions
diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp
index 5d86208c..3705bbd5 100644
--- a/src/editexecutablesdialog.cpp
+++ b/src/editexecutablesdialog.cpp
@@ -91,18 +91,19 @@ void EditExecutablesDialog::resetInput()
void EditExecutablesDialog::saveExecutable()
{
- m_ExecutablesList.addExecutable(ui->titleEdit->text(),
- QDir::fromNativeSeparators(ui->binaryEdit->text()),
- ui->argumentsEdit->text(),
- QDir::fromNativeSeparators(ui->workingDirEdit->text()),
- (ui->closeCheckBox->checkState() == Qt::Checked) ?
- ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE
- : ExecutableInfo::CloseMOStyle::DEFAULT_STAY,
- ui->overwriteAppIDBox->isChecked() ?
- ui->appIDOverwriteEdit->text() : "",
- ui->useAppIconCheckBox->isChecked() ?
- Executable::UseApplicationIcon : Executable::Flags());
-}
+ m_ExecutablesList.updateExecutable(ui->titleEdit->text(),
+ QDir::fromNativeSeparators(ui->binaryEdit->text()),
+ ui->argumentsEdit->text(),
+ QDir::fromNativeSeparators(ui->workingDirEdit->text()),
+ (ui->closeCheckBox->checkState() == Qt::Checked) ?
+ ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE
+ : ExecutableInfo::CloseMOStyle::DEFAULT_STAY,
+ ui->overwriteAppIDBox->isChecked() ?
+ ui->appIDOverwriteEdit->text() : "",
+ Executable::UseApplicationIcon,
+ ui->useAppIconCheckBox->isChecked() ?
+ Executable::UseApplicationIcon : Executable::Flags());
+ }
void EditExecutablesDialog::delayedRefresh()
diff --git a/src/executableslist.cpp b/src/executableslist.cpp
index 76fe73d7..7002ccc4 100644
--- a/src/executableslist.cpp
+++ b/src/executableslist.cpp
@@ -129,23 +129,26 @@ 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::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_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;
existingExe->m_Arguments = arguments;
existingExe->m_WorkingDirectory = workingDirectory;
@@ -197,8 +200,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;
+ }
}
diff --git a/src/executableslist.h b/src/executableslist.h
index 907b37aa..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)
@@ -140,7 +142,27 @@ public:
const QString &workingDirectory,
MOBase::ExecutableInfo::CloseMOStyle closeMO,
const QString &steamAppID,
- Executable::Flags flags);
+ Executable::Flags flags)
+ {
+ updateExecutable(title, executableName, arguments, workingDirectory, closeMO, steamAppID, Executable::AllFlags, flags);
+ }
+
+ /**
+ * @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 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 4c59d636..f0f944a8 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -3563,6 +3563,7 @@ void MainWindow::addAsExecutable()
tr("Please enter a name for the executable"), QLineEdit::Normal,
targetInfo.baseName());
if (!name.isEmpty()) {
+ //Note: If this already exists, you'll lose custom settings
m_OrganizerCore.executablesList()->addExecutable(name,
binaryInfo.absoluteFilePath(),
arguments,