diff options
| author | Tom Tanner <thosrtanner2@users.sourceforge.net> | 2015-08-13 20:07:21 +0100 |
|---|---|---|
| committer | Tom Tanner <thosrtanner2@users.sourceforge.net> | 2015-08-13 20:07:21 +0100 |
| commit | 8e7ac4e064c51cf8bdba7b036a027bdec1f8468f (patch) | |
| tree | 69a166505c7c89d9b57adefc41840ccf8afbaf40 | |
| parent | 9c3b390f081aff3a9777d4bb002e5c5b3bc2473e (diff) | |
Fix the executable configuration flags going awry from Customise window
| -rw-r--r-- | src/editexecutablesdialog.cpp | 24 | ||||
| -rw-r--r-- | src/executableslist.cpp | 62 | ||||
| -rw-r--r-- | src/executableslist.h | 32 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 18 | ||||
| -rw-r--r-- | src/organizercore.cpp | 14 |
5 files changed, 106 insertions, 44 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 422207bb..5eaa5755 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);
}
@@ -3556,13 +3557,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 e23c8d31..0b2d2610 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -337,13 +337,13 @@ void OrganizerCore::updateExecutablesList(QSettings &settings) if (settings.value("toolbar", false).toBool()) flags |= Executable::ShowInToolbar;
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(),
- closeMO,
- settings.value("steamAppID", "").toString(),
- flags);
+ m_ExecutablesList.configureExecutable(settings.value("title").toString(),
+ settings.value("binary").toString(),
+ settings.value("arguments").toString(),
+ settings.value("workingDirectory", "").toString(),
+ closeMO,
+ settings.value("steamAppID", "").toString(),
+ flags);
}
settings.endArray();
|
