From 9c3b390f081aff3a9777d4bb002e5c5b3bc2473e Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Tue, 11 Aug 2015 21:53:00 +0100 Subject: Fix up merge mess --- src/mainwindow.cpp | 7 ++++--- src/organizercore.cpp | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index abf91d8f..422207bb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -983,7 +983,7 @@ void MainWindow::startExeAction() selectedExecutable.m_Arguments, selectedExecutable.m_WorkingDirectory.length() != 0 ? selectedExecutable.m_WorkingDirectory : selectedExecutable.m_BinaryInfo.absolutePath(), - selectedExecutable.closeOnExecution(), + selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE, selectedExecutable.m_SteamAppID); } else { qCritical("not an action?"); @@ -1643,7 +1643,7 @@ void MainWindow::on_startButton_clicked() selectedExecutable.m_Arguments, selectedExecutable.m_WorkingDirectory.length() != 0 ? selectedExecutable.m_WorkingDirectory : selectedExecutable.m_BinaryInfo.absolutePath(), - selectedExecutable.closeOnExecution(), + selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE, selectedExecutable.m_SteamAppID); } @@ -3560,8 +3560,9 @@ void MainWindow::addAsExecutable() binaryInfo.absoluteFilePath(), arguments, targetInfo.absolutePath(), + ExecutableInfo::CloseMOStyle::DEFAULT_STAY, QString(), - Executable::SettableFlags()); + Executable::CustomExecutable); refreshExecutablesList(); } } break; diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 3d996b01..e23c8d31 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -229,7 +229,7 @@ QSettings::Status OrganizerCore::storeSettings(const QString &fileName) settings.setValue("binary", item.m_BinaryInfo.absoluteFilePath()); settings.setValue("arguments", item.m_Arguments); settings.setValue("workingDirectory", item.m_WorkingDirectory); - settings.setValue("closeOnStart", item.closeOnExecution()); + settings.setValue("closeOnStart", item.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE); settings.setValue("steamAppID", item.m_SteamAppID); } } @@ -328,21 +328,22 @@ void OrganizerCore::updateExecutablesList(QSettings &settings) for (int i = 0; i < numCustomExecutables; ++i) { settings.setArrayIndex(i); - Executable::OtherFlags other; - if (settings.value("custom", true).toBool()) other |= Executable::CustomExecutable; - if (settings.value("toolbar", false).toBool()) other |= Executable::ShowInToolbar; + ExecutableInfo::CloseMOStyle closeMO = + settings.value("closeOnStart").toBool() ? ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE + : ExecutableInfo::CloseMOStyle::DEFAULT_STAY; - Executable::SettableFlags settable; - if (settings.value("closeOnStart", false).toBool()) settable |= Executable::CloseOnExecution; - if (settings.value("ownicon", false).toBool()) settable |= Executable::UseApplicationIcon; + Executable::Flags flags; + if (settings.value("custom", true).toBool()) flags |= Executable::CustomExecutable; + 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(), - settable, - other); + flags); } settings.endArray(); -- cgit v1.3.1 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/editexecutablesdialog.cpp | 24 ++++++++--------- src/executableslist.cpp | 62 ++++++++++++++++++++++++++++++++++++------- src/executableslist.h | 32 ++++++++++++++++------ src/mainwindow.cpp | 18 +++++++------ src/organizercore.cpp | 14 +++++----- 5 files changed, 106 insertions(+), 44 deletions(-) (limited to 'src') 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(m_OrganizerCore.executablesList()->size()))) { + if (index == 0 || + index > static_cast(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(); -- cgit v1.3.1