diff options
| author | LostDragonist <lost.dragonist@gmail.com> | 2019-05-03 21:32:33 -0500 |
|---|---|---|
| committer | LostDragonist <lost.dragonist@gmail.com> | 2019-05-03 21:32:33 -0500 |
| commit | 179a73857125ee604f42b0d5c2d765183c86d2c7 (patch) | |
| tree | b9b3f9d62bd5640de839d150a53ab8ef119dab9c /src/forcedloaddialogwidget.cpp | |
| parent | e2b799bd6b5cfd51969fefd1dab5e5b1b7e5f81c (diff) | |
| parent | 907c5468424b48774f5da2a6b5f96f26590987b0 (diff) | |
Merge pull request #695 from ModOrganizer2/Develop
Stage for Release 2.2.0
Diffstat (limited to 'src/forcedloaddialogwidget.cpp')
| -rw-r--r-- | src/forcedloaddialogwidget.cpp | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/src/forcedloaddialogwidget.cpp b/src/forcedloaddialogwidget.cpp new file mode 100644 index 00000000..10069c35 --- /dev/null +++ b/src/forcedloaddialogwidget.cpp @@ -0,0 +1,108 @@ +#include "forcedloaddialogwidget.h" +#include "ui_forcedloaddialogwidget.h" + +#include <QFileDialog> + +#include "executableinfo.h" + +using namespace MOBase; + +ForcedLoadDialogWidget::ForcedLoadDialogWidget(const IPluginGame *game, QWidget *parent) : + QWidget(parent), + ui(new Ui::ForcedLoadDialogWidget), + m_GamePlugin(game) +{ + ui->setupUi(this); +} + +ForcedLoadDialogWidget::~ForcedLoadDialogWidget() +{ + delete ui; +} + +bool ForcedLoadDialogWidget::getEnabled() +{ + return ui->enabledBox->isChecked(); +} + +bool ForcedLoadDialogWidget::getForced() +{ + return m_Forced; +} + +QString ForcedLoadDialogWidget::getLibraryPath() +{ + return ui->libraryPathEdit->text(); +} + +QString ForcedLoadDialogWidget::getProcess() +{ + return ui->processEdit->text(); +} + +void ForcedLoadDialogWidget::setEnabled(bool enabled) +{ + ui->enabledBox->setChecked(enabled); +} + +void ForcedLoadDialogWidget::setForced(bool forced) +{ + m_Forced = forced; + ui->libraryPathBrowseButton->setEnabled(!forced); + ui->libraryPathEdit->setEnabled(!forced); + ui->processBrowseButton->setEnabled(!forced); + ui->processEdit->setEnabled(!forced); +} + +void ForcedLoadDialogWidget::setLibraryPath(QString &path) +{ + ui->libraryPathEdit->setText(path); +} + +void ForcedLoadDialogWidget::setProcess(QString &name) +{ + ui->processEdit->setText(name); +} + +void ForcedLoadDialogWidget::on_enabledBox_toggled() +{ + // anything to do? +} + +void ForcedLoadDialogWidget::on_libraryPathBrowseButton_clicked() +{ + QDir gameDir(m_GamePlugin->gameDirectory()); + QString startPath = gameDir.absolutePath(); + QString result = QFileDialog::getOpenFileName(nullptr, "Select a library...", startPath, "Dynamic link library (*.dll)", nullptr, QFileDialog::ReadOnly); + if (!result.isEmpty()) { + QFileInfo fileInfo(result); + QString relativePath = gameDir.relativeFilePath(fileInfo.filePath()); + QString filePath = fileInfo.filePath(); + if (!relativePath.startsWith("..")) { + filePath = relativePath; + } + + if (fileInfo.exists()) { + ui->libraryPathEdit->setText(filePath); + } else { + qCritical("%ls does not exist", filePath.toStdWString().c_str()); + } + } +} + +void ForcedLoadDialogWidget::on_processBrowseButton_clicked() +{ + QDir gameDir(m_GamePlugin->gameDirectory()); + QString startPath = gameDir.absolutePath(); + QString result = QFileDialog::getOpenFileName(nullptr, "Select a process...", startPath, "Executable (*.exe)", nullptr, QFileDialog::ReadOnly); + if (!result.isEmpty()) { + QFileInfo fileInfo(result); + QString fileName = fileInfo.fileName(); + + if (fileInfo.exists()) { + ui->processEdit->setText(fileName); + } else { + qCritical("%ls does not exist", fileInfo.filePath().toStdWString().c_str()); + } + } +} |
