summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/editexecutablesdialog.cpp24
-rw-r--r--src/executableslist.cpp62
-rw-r--r--src/executableslist.h32
-rw-r--r--src/mainwindow.cpp18
-rw-r--r--src/organizercore.cpp11
5 files changed, 105 insertions, 42 deletions
diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp
index 5d86208c..c77ac243 100644
--- a/src/editexecutablesdialog.cpp
+++ b/src/editexecutablesdialog.cpp
@@ -91,18 +91,18 @@ 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.updateOrAddExecutable(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());
+ }
void EditExecutablesDialog::delayedRefresh()
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;
+ }
}
diff --git a/src/executableslist.h b/src/executableslist.h
index 907b37aa..b8e2afe6 100644
--- a/src/executableslist.h
+++ b/src/executableslist.h
@@ -127,20 +127,36 @@ public:
void addExecutable(const Executable &executable);
/**
- * @brief add a new executable to the list
+ * @brief update an existing executable or add a new one 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);
+
+ /**
+ * @brief U[date executable list with configured settings
*
* @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 addExecutable(const QString &title,
- const QString &executableName,
- const QString &arguments,
- const QString &workingDirectory,
- MOBase::ExecutableInfo::CloseMOStyle closeMO,
- const QString &steamAppID,
- Executable::Flags flags);
+ void configureExecutable(const QString &title,
+ const QString &executableName,
+ const QString &arguments,
+ const QString &workingDirectory,
+ MOBase::ExecutableInfo::CloseMOStyle closeMO,
+ const QString &steamAppID,
+ 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 c726991c..28596127 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1755,7 +1755,8 @@ 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);
}
@@ -3561,13 +3562,14 @@ void MainWindow::addAsExecutable()
tr("Please enter a name for the executable"), QLineEdit::Normal,
targetInfo.baseName());
if (!name.isEmpty()) {
- m_OrganizerCore.executablesList()->addExecutable(name,
- binaryInfo.absoluteFilePath(),
- arguments,
- targetInfo.absolutePath(),
- ExecutableInfo::CloseMOStyle::DEFAULT_STAY,
- QString(),
- Executable::CustomExecutable);
+ //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);
refreshExecutablesList();
}
} break;
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index cea1a868..b3bcc917 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -336,13 +336,14 @@ 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.addExecutable(settings.value("title").toString(),
- settings.value("binary").toString(),
- settings.value("arguments").toString(),
- settings.value("workingDirectory", "").toString(),
+ m_ExecutablesList.configureExecutable(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);
}