From a7d6eb75c20d185c45a0bff309c68e1efaae990e Mon Sep 17 00:00:00 2001 From: Tannin Date: Sun, 9 Aug 2015 15:16:57 +0200 Subject: reverted most changes of changeset 626da419828a as I don't agree with them --- src/editexecutablesdialog.cpp | 20 +++++++++----- src/executableslist.cpp | 41 +++++++++++++--------------- src/executableslist.h | 63 +++++++++---------------------------------- src/mainwindow.cpp | 9 ++++--- src/organizercore.cpp | 20 +++++++------- 5 files changed, 60 insertions(+), 93 deletions(-) (limited to 'src') diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index 998a4507..5d86208c 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -91,16 +91,17 @@ void EditExecutablesDialog::resetInput() void EditExecutablesDialog::saveExecutable() { - Executable::SettableFlags flags; - if (ui->closeCheckBox->isChecked()) flags |= Executable::CloseOnExecution; - if (ui->useAppIconCheckBox->isChecked()) flags |= Executable::UseApplicationIcon; 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() : "", - flags); + ui->useAppIconCheckBox->isChecked() ? + Executable::UseApplicationIcon : Executable::Flags()); } @@ -212,7 +213,7 @@ bool EditExecutablesDialog::executableChanged() || selectedExecutable.m_SteamAppID != ui->appIDOverwriteEdit->text() || selectedExecutable.m_WorkingDirectory != QDir::fromNativeSeparators(ui->workingDirEdit->text()) || selectedExecutable.m_BinaryInfo.absoluteFilePath() != QDir::fromNativeSeparators(ui->binaryEdit->text()) - || selectedExecutable.closeOnExecution() != ui->closeCheckBox->isChecked() + || (selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE) != ui->closeCheckBox->isChecked() || selectedExecutable.usesOwnIcon() != ui->useAppIconCheckBox->isChecked(); } else { return false; @@ -279,7 +280,14 @@ void EditExecutablesDialog::on_executablesListBox_clicked(const QModelIndex &cur ui->binaryEdit->setText(QDir::toNativeSeparators(selectedExecutable.m_BinaryInfo.absoluteFilePath())); ui->argumentsEdit->setText(selectedExecutable.m_Arguments); ui->workingDirEdit->setText(QDir::toNativeSeparators(selectedExecutable.m_WorkingDirectory)); - ui->closeCheckBox->setChecked(selectedExecutable.closeOnExecution()); + ui->closeCheckBox->setChecked(selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE); + if (selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::NEVER_CLOSE) { + ui->closeCheckBox->setEnabled(false); + ui->closeCheckBox->setToolTip(tr("MO must be kept running or this application will not work correctly.")); + } else { + ui->closeCheckBox->setEnabled(true); + ui->closeCheckBox->setToolTip(tr("If checked, MO will be closed once the specified executable is run.")); + } ui->removeButton->setEnabled(selectedExecutable.isCustom()); ui->overwriteAppIDBox->setChecked(!selectedExecutable.m_SteamAppID.isEmpty()); if (!selectedExecutable.m_SteamAppID.isEmpty()) { diff --git a/src/executableslist.cpp b/src/executableslist.cpp index ffb87703..76fe73d7 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -48,6 +48,7 @@ void ExecutablesList::init(IPluginGame *game) info.binary().absoluteFilePath(), info.arguments().join(" "), info.workingDirectory().absolutePath(), + info.closeMO(), info.steamAppID()); } } @@ -132,22 +133,19 @@ void ExecutablesList::addExecutable(const QString &title, const QString &executableName, const QString &arguments, const QString &workingDirectory, + ExecutableInfo::CloseMOStyle closeMO, const QString &steamAppID, - Executable::SettableFlags settable, - bool set_other, - Executable::OtherFlags other) + Executable::Flags flags) { QFileInfo file(executableName); auto existingExe = findExe(title); if (existingExe != m_Executables.end()) { existingExe->m_Title = title; - existingExe->m_SettableFlags = settable; - if (set_other) { - existingExe->m_OtherFlags = other; - } - // for pre-configured executables don't overwrite settings we didn't store - if (existingExe->isCustom()) { + 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; @@ -156,12 +154,12 @@ void ExecutablesList::addExecutable(const QString &title, } 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_SettableFlags = settable; - newExe.m_OtherFlags = Executable::CustomExecutable | other; + newExe.m_Flags = Executable::CustomExecutable | flags; m_Executables.push_back(newExe); } } @@ -178,22 +176,20 @@ void ExecutablesList::remove(const QString &title) } -void ExecutablesList::addExecutableInternal(const QString &title, - const QString &executableName, - const QString &arguments, - const QString &workingDirectory, - const QString &steamAppID) +void ExecutablesList::addExecutableInternal(const QString &title, const QString &executableName, + const QString &arguments, const QString &workingDirectory, + ExecutableInfo::CloseMOStyle closeMO, const QString &steamAppID) { QFileInfo file(executableName); if (file.exists()) { Executable newExe; + newExe.m_CloseMO = closeMO; newExe.m_BinaryInfo = file; newExe.m_Title = title; newExe.m_Arguments = arguments; newExe.m_WorkingDirectory = workingDirectory; newExe.m_SteamAppID = steamAppID; - newExe.m_SettableFlags = 0; - newExe.m_OtherFlags = 0; + newExe.m_Flags = 0; m_Executables.push_back(newExe); } } @@ -201,9 +197,8 @@ void ExecutablesList::addExecutableInternal(const QString &title, void Executable::showOnToolbar(bool state) { - if (state) { - m_OtherFlags |= ShowInToolbar; - } else { - m_OtherFlags &= ~ShowInToolbar; - } + if (state) + m_Flags |= ShowInToolbar; + else + m_Flags &= ~ShowInToolbar; } diff --git a/src/executableslist.h b/src/executableslist.h index 4aba4ce2..907b37aa 100644 --- a/src/executableslist.h +++ b/src/executableslist.h @@ -35,38 +35,27 @@ struct Executable { QString m_Title; QFileInfo m_BinaryInfo; QString m_Arguments; + MOBase::ExecutableInfo::CloseMOStyle m_CloseMO; QString m_SteamAppID; QString m_WorkingDirectory; - //These flags are set by other parts of the system and can't be - //changed when modifying from the custom executable window - enum OtherFlag__ { + enum Flag { CustomExecutable = 0x01, - ShowInToolbar = 0x02 + ShowInToolbar = 0x02, + UseApplicationIcon = 0x04 }; - Q_DECLARE_FLAGS(OtherFlags, OtherFlag__) - OtherFlags m_OtherFlags; + Q_DECLARE_FLAGS(Flags, Flag) - //These flags can be changed from the Custom Executable window. - enum SettableFlag__ { - CloseOnExecution = 0x01, - UseApplicationIcon = 0x02 - }; - Q_DECLARE_FLAGS(SettableFlags, SettableFlag__) - - SettableFlags m_SettableFlags; + Flags m_Flags; - bool isCustom() const { return m_OtherFlags.testFlag(CustomExecutable); } + bool isCustom() const { return m_Flags.testFlag(CustomExecutable); } - bool shownOnToolbar() const { return m_OtherFlags.testFlag(ShowInToolbar); } + bool shownOnToolbar() const { return m_Flags.testFlag(ShowInToolbar); } void showOnToolbar(bool state); - bool usesOwnIcon() const { return m_SettableFlags.testFlag(UseApplicationIcon); } - - bool closeOnExecution() const { return m_SettableFlags.testFlag(CloseOnExecution); } - + bool usesOwnIcon() const { return m_Flags.testFlag(UseApplicationIcon); } }; @@ -149,24 +138,9 @@ public: const QString &executableName, const QString &arguments, const QString &workingDirectory, + MOBase::ExecutableInfo::CloseMOStyle closeMO, const QString &steamAppID, - Executable::SettableFlags settable - ) - { - addExecutable(title, executableName, arguments, workingDirectory, steamAppID, settable, false, 0); - } - - void addExecutable(const QString &title, - const QString &executableName, - const QString &arguments, - const QString &workingDirectory, - const QString &steamAppID, - Executable::SettableFlags settable, - Executable::OtherFlags other - ) - { - addExecutable(title, executableName, arguments, workingDirectory, steamAppID, settable, true, other); - } + Executable::Flags flags); /** * @brief remove the executable with the specified file name. This needs to be an absolute file path @@ -203,18 +177,8 @@ private: std::vector::iterator findExe(const QString &title); - void addExecutable(const QString &title, - const QString &executableName, - const QString &arguments, - const QString &workingDirectory, - const QString &steamAppID, - Executable::SettableFlags settable, - bool set_other, - Executable::OtherFlags other - ); - void addExecutableInternal(const QString &title, const QString &executableName, const QString &arguments, - const QString &workingDirectory, + const QString &workingDirectory, MOBase::ExecutableInfo::CloseMOStyle closeMO, const QString &steamAppID); private: @@ -223,7 +187,6 @@ private: }; -Q_DECLARE_OPERATORS_FOR_FLAGS(Executable::OtherFlags) -Q_DECLARE_OPERATORS_FOR_FLAGS(Executable::SettableFlags) +Q_DECLARE_OPERATORS_FOR_FLAGS(Executable::Flags) #endif // EXECUTABLESLIST_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index abf91d8f..5ecebb1e 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); } @@ -1755,7 +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(m_OrganizerCore.executablesList()->size()))) { + if ((index == 0) || (index >= static_cast(m_OrganizerCore.executablesList()->size()))) { if (modifyExecutablesDialog()) { setExecutableIndex(previousIndex); } @@ -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..46065937 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); } } @@ -327,22 +327,22 @@ void OrganizerCore::updateExecutablesList(QSettings &settings) int numCustomExecutables = settings.beginReadArray("customExecutables"); for (int i = 0; i < numCustomExecutables; ++i) { settings.setArrayIndex(i); + ExecutableInfo::CloseMOStyle closeMO = + settings.value("closeOnStart").toBool() ? ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE + : ExecutableInfo::CloseMOStyle::DEFAULT_STAY; - Executable::OtherFlags other; - if (settings.value("custom", true).toBool()) other |= Executable::CustomExecutable; - if (settings.value("toolbar", false).toBool()) other |= Executable::ShowInToolbar; - - 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 b6627ff5e08063a2aeb035adfb6f1e973ad45dc5 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sun, 9 Aug 2015 17:11:18 +0200 Subject: small code cleanup --- src/selfupdater.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index 9c151746..ed34bfc2 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -234,7 +234,7 @@ void SelfUpdater::installUpdate() { const QString mopath = QDir::fromNativeSeparators(ToQString(GameInfo::instance().getOrganizerDirectory())); - QString backupPath = mopath.mid(0).append("/update_backup"); + QString backupPath = mopath + "/update_backup"; QDir().mkdir(backupPath); // rename files that are currently open so we can unpack the update @@ -259,10 +259,10 @@ void SelfUpdater::installUpdate() } else if (outputName != "ModOrganizer") { data[i]->addOutputFileName(ToWString(outputName).c_str()); } - QFileInfo file(mopath.mid(0).append("/").append(outputName)); + QFileInfo file(mopath + "/" + outputName); if (file.exists() && file.isFile()) { - if (!shellMove(QStringList(mopath.mid(0).append("/").append(outputName)), - QStringList(backupPath.mid(0).append("/").append(outputName)))) { + if (!shellMove(QStringList(mopath + "/" + outputName), + QStringList(backupPath + "/" + outputName))) { reportError(tr("failed to move outdated files: %1. Please update manually.").arg(windowsErrorString(::GetLastError()))); return; } @@ -284,10 +284,10 @@ void SelfUpdater::installUpdate() QMessageBox::information(m_Parent, tr("Update"), tr("Update installed, Mod Organizer will now be restarted.")); QProcess newProcess; - if (QFile::exists(mopath.mid(0).append("/ModOrganizer.exe"))) { - newProcess.startDetached(mopath.mid(0).append("/ModOrganizer.exe"), QStringList("update")); + if (QFile::exists(mopath + "/ModOrganizer.exe")) { + newProcess.startDetached(mopath + "/ModOrganizer.exe", QStringList("update")); } else { - newProcess.startDetached(mopath.mid(0).append("/ModOrganiser.exe"), QStringList("update")); + newProcess.startDetached(mopath + "/ModOrganiser.exe", QStringList("update")); } emit restart(); } @@ -378,7 +378,7 @@ void SelfUpdater::nxmFilesAvailable(int, QVariant userData, QVariant resultData, QString mainFileName; int mainFileSize = 0; - foreach(QVariant file, result) { + for(QVariant file : result) { QVariantMap fileInfo = file.toMap(); if (!fileInfo["uri"].toString().endsWith(".7z")) { continue; -- cgit v1.3.1 From 0aecc3427a37e4d572c8b111a4b18185e63a7c80 Mon Sep 17 00:00:00 2001 From: Tannin Date: Tue, 11 Aug 2015 19:23:12 +0200 Subject: small bugfix --- src/modlist.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/modlist.cpp b/src/modlist.cpp index fa34004d..197250a3 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -887,6 +887,8 @@ bool ModList::dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int return dropURLs(mimeData, row, parent); } else if (mimeData->hasText()) { return dropMod(mimeData, row, parent); + } else { + return false; } } -- cgit v1.3.1