diff options
| author | Tannin <devnull@localhost> | 2015-08-09 15:16:57 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2015-08-09 15:16:57 +0200 |
| commit | a7d6eb75c20d185c45a0bff309c68e1efaae990e (patch) | |
| tree | 93414a893ec3b1c6effe162e05c8a4418ff5011d /src | |
| parent | 6f09cf2205fdf9ce87b6219883585508b3cf2667 (diff) | |
reverted most changes of changeset 626da419828a as I don't agree with them
Diffstat (limited to 'src')
| -rw-r--r-- | src/editexecutablesdialog.cpp | 20 | ||||
| -rw-r--r-- | src/executableslist.cpp | 41 | ||||
| -rw-r--r-- | src/executableslist.h | 63 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 9 | ||||
| -rw-r--r-- | src/organizercore.cpp | 20 |
5 files changed, 60 insertions, 93 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/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<int>(m_OrganizerCore.executablesList()->size()))) {
+ if ((index == 0) || (index >= static_cast<int>(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();
|
