From 4b522f40e88e1350434aaa7d77fc60cb7ca36930 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Wed, 30 Jan 2019 20:32:48 -0600 Subject: Make logs more consistent in format and content --- src/executableslist.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/executableslist.cpp') diff --git a/src/executableslist.cpp b/src/executableslist.cpp index 21cb6ed4..ae4ebdbf 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -75,7 +75,7 @@ const Executable &ExecutablesList::find(const QString &title) const return exe; } } - throw std::runtime_error(QString("invalid name %1").arg(title).toLocal8Bit().constData()); + throw std::runtime_error(QString("invalid executable name: %1").arg(title).toLocal8Bit().constData()); } @@ -86,7 +86,7 @@ Executable &ExecutablesList::find(const QString &title) return exe; } } - throw std::runtime_error(QString("invalid executable name %1").arg(title).toLocal8Bit().constData()); + throw std::runtime_error(QString("invalid executable name: %1").arg(title).toLocal8Bit().constData()); } -- cgit v1.3.1 From 105a112f3c6ba58b1e9ffc5dad99483a7528e33e Mon Sep 17 00:00:00 2001 From: Al Date: Sun, 10 Mar 2019 17:46:36 +0100 Subject: Add "Explore Virtual Folder" (name subject to change) as a default executable. --- src/executableslist.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/executableslist.cpp') diff --git a/src/executableslist.cpp b/src/executableslist.cpp index ae4ebdbf..c7786c20 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -25,6 +25,8 @@ along with Mod Organizer. If not, see . #include #include #include +#include + #include @@ -53,6 +55,17 @@ void ExecutablesList::init(IPluginGame const *game) info.steamAppID()); } } + ExecutableInfo explorerpp = ExecutableInfo("Explore Virtual Folder", QFileInfo(QCoreApplication::applicationDirPath() + "/explorer++/Explorer++.exe" )) + .withArgument(QString("\"%1\"").arg(QDir::toNativeSeparators(game->dataDirectory().absolutePath()))); + + if (explorerpp.isValid()) { + addExecutableInternal(explorerpp.title(), + explorerpp.binary().absoluteFilePath(), + explorerpp.arguments().join(" "), + explorerpp.workingDirectory().absolutePath(), + explorerpp.steamAppID()); + } + } void ExecutablesList::getExecutables(std::vector::iterator &begin, std::vector::iterator &end) -- cgit v1.3.1 From 149c38d54d2a841af929b432b83804fafdc1e588 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Mon, 15 Apr 2019 04:11:06 -0500 Subject: Add protection against non-existent working directory for executables --- src/editexecutablesdialog.cpp | 30 +++++++++++++++++++++++++++--- src/editexecutablesdialog.h | 4 ++++ src/executableslist.cpp | 10 +++++++--- 3 files changed, 38 insertions(+), 6 deletions(-) (limited to 'src/executableslist.cpp') diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index d1371a76..177661ff 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -83,8 +83,33 @@ void EditExecutablesDialog::refreshExecutablesWidget() void EditExecutablesDialog::on_binaryEdit_textChanged(const QString &name) { - QFileInfo fileInfo(name); - ui->addButton->setEnabled(fileInfo.exists() && fileInfo.isFile()); + updateButtonStates(); +} + +void EditExecutablesDialog::on_workingDirEdit_textChanged(const QString &dir) +{ + updateButtonStates(); +} + +void EditExecutablesDialog::updateButtonStates() +{ + bool enabled = true; + + QString filePath(ui->binaryEdit->text()); + QFileInfo fileInfo(filePath); + if (!fileInfo.exists()) + enabled = false; + if (!fileInfo.isFile()) + enabled = false; + + QString dirPath(ui->workingDirEdit->text()); + if (!dirPath.isEmpty()) { + QDir dirInfo(dirPath); + if (!dirInfo.exists()) + enabled = false; + } + + ui->addButton->setEnabled(enabled); } void EditExecutablesDialog::resetInput() @@ -293,7 +318,6 @@ bool EditExecutablesDialog::executableChanged() && fileInfo.isFile(); } } - void EditExecutablesDialog::on_executablesListBox_itemSelectionChanged() { if (ui->executablesListBox->selectedItems().size() == 0) { diff --git a/src/editexecutablesdialog.h b/src/editexecutablesdialog.h index 0169b8ca..bee3cba6 100644 --- a/src/editexecutablesdialog.h +++ b/src/editexecutablesdialog.h @@ -74,6 +74,8 @@ private slots: void on_binaryEdit_textChanged(const QString &arg1); + void on_workingDirEdit_textChanged(const QString &arg1); + void on_addButton_clicked(); void on_browseButton_clicked(); @@ -106,6 +108,8 @@ private: bool executableChanged(); + void updateButtonStates(); + private: Ui::EditExecutablesDialog *ui; diff --git a/src/executableslist.cpp b/src/executableslist.cpp index c7786c20..4b2e380b 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -57,7 +57,7 @@ void ExecutablesList::init(IPluginGame const *game) } ExecutableInfo explorerpp = ExecutableInfo("Explore Virtual Folder", QFileInfo(QCoreApplication::applicationDirPath() + "/explorer++/Explorer++.exe" )) .withArgument(QString("\"%1\"").arg(QDir::toNativeSeparators(game->dataDirectory().absolutePath()))); - + if (explorerpp.isValid()) { addExecutableInternal(explorerpp.title(), explorerpp.binary().absoluteFilePath(), @@ -65,7 +65,7 @@ void ExecutablesList::init(IPluginGame const *game) explorerpp.workingDirectory().absolutePath(), explorerpp.steamAppID()); } - + } void ExecutablesList::getExecutables(std::vector::iterator &begin, std::vector::iterator &end) @@ -152,6 +152,7 @@ void ExecutablesList::updateExecutable(const QString &title, Executable::Flags flags) { QFileInfo file(executableName); + QDir dir(workingDirectory); auto existingExe = findExe(title); flags &= mask; @@ -165,8 +166,11 @@ void ExecutablesList::updateExecutable(const QString &title, // don't overwrite a valid binary with an invalid one existingExe->m_BinaryInfo = file; } + if (dir.exists()) { + // don't overwrite a valid working directory with an invalid one + existingExe->m_WorkingDirectory = workingDirectory; + } existingExe->m_Arguments = arguments; - existingExe->m_WorkingDirectory = workingDirectory; existingExe->m_SteamAppID = steamAppID; } } else { -- cgit v1.3.1