summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2015-08-11 19:31:48 +0200
committerTannin <devnull@localhost>2015-08-11 19:31:48 +0200
commit217ca284fe22fd358c2a892fadeeed530c240513 (patch)
treee05b053ae010bf2a80f984774ddda4cb470d4fd9
parentb0d86c9e01659a5058184932e423308dad9c7c29 (diff)
parent0aecc3427a37e4d572c8b111a4b18185e63a7c80 (diff)
Merge
-rw-r--r--src/editexecutablesdialog.cpp20
-rw-r--r--src/executableslist.cpp41
-rw-r--r--src/executableslist.h63
-rw-r--r--src/modlist.cpp2
-rw-r--r--src/selfupdater.cpp16
5 files changed, 55 insertions, 87 deletions
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<Executable>::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/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;
}
}
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;