diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..6098e1f --- /dev/null +++ b/.clang-format @@ -0,0 +1,41 @@ +--- +# We'll use defaults from the LLVM style, but with 4 columns indentation. +BasedOnStyle: LLVM +IndentWidth: 2 +--- +Language: Cpp +DeriveLineEnding: false +UseCRLF: true +DerivePointerAlignment: false +PointerAlignment: Left +AlignConsecutiveAssignments: true +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Empty +AlwaysBreakTemplateDeclarations: Yes +AccessModifierOffset: -2 +AlignTrailingComments: true +SpacesBeforeTrailingComments: 2 +NamespaceIndentation: Inner +MaxEmptyLinesToKeep: 1 +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: true + AfterControlStatement: false + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: true +ColumnLimit: 88 +ForEachMacros: ['Q_FOREACH', 'foreach'] diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..c32a336 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1 @@ +4b30cfb8a268d8c0472b148943dd588114916182 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f869712 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files you want to always be normalized and converted +# to native line endings on checkout. +*.cpp text eol=crlf +*.h text eol=crlf diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..1d7b60a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,16 @@ +name: Build Installer Quick Plugin + +on: + push: + branches: master + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: windows-2022 + steps: + - name: Build Installer Quick Plugin + uses: ModOrganizer2/build-with-mob-action@master + with: + mo2-dependencies: cmake_common uibase diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..6b4d6c4 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,16 @@ +name: Lint Installer Quick Plugin + +on: + push: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Check format + uses: ModOrganizer2/check-formatting-action@master + with: + check-path: "." diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index a045cc4..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,40 +0,0 @@ -version: 1.0.{build} -skip_branch_with_pr: true -image: Visual Studio 2019 -environment: - WEBHOOK_URL: - secure: gOKbXaZM9ImtMD5XrYITvdyZUW/az082G9OIN1EC1Vbg57wBaeLhi49uGjxPw5GVujHku6kxN6ab89zhbS5GVeluR76GM83IbKV4Sh7udXzoYZZdg6YudtYHzdhCgUeiedpswbuczTq9ceIkkfSEWZuh/lMAAVVwvcGsJAnoPFw= -build_script: -- pwsh: >- - $ErrorActionPreference = 'Stop' - - git clone --depth=1 --no-single-branch https://github.com/ModOrganizer2/modorganizer-umbrella.git c:\projects\modorganizer-umbrella - - New-Item -ItemType Directory -Path c:\projects\modorganizer-build - - cd c:\projects\modorganizer-umbrella - - ($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH -eq $null) ? ($branch = $env:APPVEYOR_REPO_BRANCH) : ($branch = $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH) - - git checkout $(git show-ref --verify --quiet refs/remotes/origin/${branch} || echo '-b') ${branch} - - C:\Python37-x64\python.exe unimake.py -d c:\projects\modorganizer-build -s Appveyor_Build=True ${env:APPVEYOR_PROJECT_NAME} - - if($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode ) } -artifacts: -- path: vsbuild\src\RelWithDebInfo\installer_quick.dll - name: installer_quick_dll -- path: vsbuild\src\RelWithDebInfo\installer_quick.pdb - name: installer_quick_pdb -- path: vsbuild\src\RelWithDebInfo\installer_quick.lib - name: installer_quick_lib -on_success: - - ps: Set-Location -Path $env:APPVEYOR_BUILD_FOLDER - - ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1 - - ps: ./send.ps1 success $env:WEBHOOK_URL -on_failure: - - ps: Set-Location -Path $env:APPVEYOR_BUILD_FOLDER - - ps: Push-AppveyorArtifact ${env:APPVEYOR_BUILD_FOLDER}\stdout.log - - ps: Push-AppveyorArtifact ${env:APPVEYOR_BUILD_FOLDER}\stderr.log - - ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1 - - ps: ./send.ps1 failure $env:WEBHOOK_URL \ No newline at end of file diff --git a/src/installerquick.cpp b/src/installerquick.cpp index 1ff4ff3..56da3ef 100644 --- a/src/installerquick.cpp +++ b/src/installerquick.cpp @@ -1,187 +1,175 @@ -#include "installerquick.h" - -#include "iplugingame.h" -#include "igamefeatures.h" -#include "log.h" - -#include -#include - - -#include "simpleinstalldialog.h" - - -using namespace MOBase; - - -InstallerQuick::InstallerQuick() - : m_MOInfo(nullptr) -{ -} - -bool InstallerQuick::init(IOrganizer* moInfo) -{ - m_MOInfo = moInfo; - // Note: Cannot retrieve the checker here because the game might - // not be initialized yet. - return true; -} - -QString InstallerQuick::name() const -{ - return "Simple Installer"; -} - -QString InstallerQuick::localizedName() const -{ - return tr("Simple Installer"); -} - -QString InstallerQuick::author() const -{ - return "Tannin"; -} - -QString InstallerQuick::description() const -{ - return tr("Installer for very simple archives"); -} - -VersionInfo InstallerQuick::version() const -{ - return VersionInfo(1, 3, 0, VersionInfo::RELEASE_FINAL); -} - -QList InstallerQuick::settings() const -{ - return { - PluginSetting("silent", "simple plugins will be installed without any user interaction", QVariant(false)) - }; -} - -unsigned int InstallerQuick::priority() const -{ - return 50; -} - - -bool InstallerQuick::isManualInstaller() const -{ - return false; -} - - -bool InstallerQuick::isDataTextArchiveTopLayer( - std::shared_ptr tree, QString const& dataFolderName, ModDataChecker* checker) const -{ - // A "DataText" archive is defined as having exactly one folder named like `dataFolderName` - // and one or more "useless" files (text files, pdf, or images). - static const std::set txtExtensions{ - "txt", "pdf", "md", "jpg", "jpeg", "png", "bmp" - }; - bool dataFound = false; - bool txtFound = false; - for (auto entry : *tree) { - if (entry->isDir()) { - // If data was already found, or this is a directory not named "data", fail: - if (dataFound || entry->compare(dataFolderName) != 0) { - return false; - } - dataFound = true; - } - else { - if (txtExtensions.count(entry->suffix()) == 0) { - return false; - } - txtFound = true; - } - } - return dataFound && txtFound; -} - - -std::shared_ptr InstallerQuick::getSimpleArchiveBase( - std::shared_ptr dataTree, QString const& dataFolderName, ModDataChecker* checker) const -{ - if (!checker) { - return nullptr; - } - while (true) { - if (checker->dataLooksValid(dataTree) == ModDataChecker::CheckReturn::VALID || - isDataTextArchiveTopLayer(dataTree, dataFolderName, checker)) { - return dataTree; - } - else if (dataTree->size() == 1 && dataTree->at(0)->isDir()) { - dataTree = dataTree->at(0)->astree(); - } - else { - log::debug("Archive is not a simple archive."); - return nullptr; - } - } -} - - -bool InstallerQuick::isArchiveSupported(std::shared_ptr tree) const -{ - auto checker = m_MOInfo->gameFeatures()->gameFeature(); - if (!checker) { - return false; - } - if (getSimpleArchiveBase(tree, m_MOInfo->managedGame()->dataDirectory().dirName(), checker.get()) != nullptr) { - return true; - } - return checker->dataLooksValid(tree) == ModDataChecker::CheckReturn::FIXABLE; -} - - -IPluginInstaller::EInstallResult InstallerQuick::install(GuessedValue& modName, std::shared_ptr& tree, - QString&, int&) -{ - const QString dataFolderName = m_MOInfo->managedGame()->dataDirectory().dirName(); - auto checker = m_MOInfo->gameFeatures()->gameFeature(); - - auto base = std::const_pointer_cast(getSimpleArchiveBase(tree, dataFolderName, checker.get())); - if (base == nullptr) { - tree = checker->fix(tree); - } - else { - tree = base; - } - if (tree != nullptr) { - SimpleInstallDialog dialog(modName, parentWidget()); - if (m_MOInfo->pluginSetting(name(), "silent").toBool() || dialog.exec() == QDialog::Accepted) { - modName.update(dialog.getName(), GUESS_USER); - - // If we have a data+txt archive, we move files to the data folder and - // switch to the data folder. We need to check that we actually have a - // checker here, otherwise it is anyway impossible that isDataTextArchiveTopLayer() - // returned true. - if (checker && isDataTextArchiveTopLayer(tree, dataFolderName, checker.get())) { - auto dataTree = tree->findDirectory(dataFolderName); - dataTree->detach(); - dataTree->merge(tree); - tree = dataTree; - } - return RESULT_SUCCESS; - } - else { - if (dialog.manualRequested()) { - modName.update(dialog.getName(), GUESS_USER); - return RESULT_MANUALREQUESTED; - } - else { - return RESULT_CANCELED; - } - } - } - else { - // install shouldn't even have even have been called - qCritical("unsupported archive for quick installer"); - return RESULT_FAILED; - } -} - -#if QT_VERSION < QT_VERSION_CHECK(5,0,0) -Q_EXPORT_PLUGIN2(installerQuick, InstallerQuick) -#endif +#include "installerquick.h" + +#include "igamefeatures.h" +#include "iplugingame.h" +#include "log.h" + +#include +#include + +#include "simpleinstalldialog.h" + +using namespace MOBase; + +InstallerQuick::InstallerQuick() : m_MOInfo(nullptr) {} + +bool InstallerQuick::init(IOrganizer* moInfo) +{ + m_MOInfo = moInfo; + // Note: Cannot retrieve the checker here because the game might + // not be initialized yet. + return true; +} + +QString InstallerQuick::name() const +{ + return "Simple Installer"; +} + +QString InstallerQuick::localizedName() const +{ + return tr("Simple Installer"); +} + +QString InstallerQuick::author() const +{ + return "Tannin"; +} + +QString InstallerQuick::description() const +{ + return tr("Installer for very simple archives"); +} + +VersionInfo InstallerQuick::version() const +{ + return VersionInfo(1, 3, 0, VersionInfo::RELEASE_FINAL); +} + +QList InstallerQuick::settings() const +{ + return {PluginSetting("silent", + "simple plugins will be installed without any user interaction", + QVariant(false))}; +} + +unsigned int InstallerQuick::priority() const +{ + return 50; +} + +bool InstallerQuick::isManualInstaller() const +{ + return false; +} + +bool InstallerQuick::isDataTextArchiveTopLayer(std::shared_ptr tree, + QString const& dataFolderName, + ModDataChecker* checker) const +{ + // A "DataText" archive is defined as having exactly one folder named like + // `dataFolderName` and one or more "useless" files (text files, pdf, or images). + static const std::set txtExtensions{ + "txt", "pdf", "md", "jpg", "jpeg", "png", "bmp"}; + bool dataFound = false; + bool txtFound = false; + for (auto entry : *tree) { + if (entry->isDir()) { + // If data was already found, or this is a directory not named "data", fail: + if (dataFound || entry->compare(dataFolderName) != 0) { + return false; + } + dataFound = true; + } else { + if (txtExtensions.count(entry->suffix()) == 0) { + return false; + } + txtFound = true; + } + } + return dataFound && txtFound; +} + +std::shared_ptr +InstallerQuick::getSimpleArchiveBase(std::shared_ptr dataTree, + QString const& dataFolderName, + ModDataChecker* checker) const +{ + if (!checker) { + return nullptr; + } + while (true) { + if (checker->dataLooksValid(dataTree) == ModDataChecker::CheckReturn::VALID || + isDataTextArchiveTopLayer(dataTree, dataFolderName, checker)) { + return dataTree; + } else if (dataTree->size() == 1 && dataTree->at(0)->isDir()) { + dataTree = dataTree->at(0)->astree(); + } else { + log::debug("Archive is not a simple archive."); + return nullptr; + } + } +} + +bool InstallerQuick::isArchiveSupported(std::shared_ptr tree) const +{ + auto checker = m_MOInfo->gameFeatures()->gameFeature(); + if (!checker) { + return false; + } + if (getSimpleArchiveBase(tree, m_MOInfo->managedGame()->dataDirectory().dirName(), + checker.get()) != nullptr) { + return true; + } + return checker->dataLooksValid(tree) == ModDataChecker::CheckReturn::FIXABLE; +} + +IPluginInstaller::EInstallResult +InstallerQuick::install(GuessedValue& modName, + std::shared_ptr& tree, QString&, int&) +{ + const QString dataFolderName = m_MOInfo->managedGame()->dataDirectory().dirName(); + auto checker = m_MOInfo->gameFeatures()->gameFeature(); + + auto base = std::const_pointer_cast( + getSimpleArchiveBase(tree, dataFolderName, checker.get())); + if (base == nullptr) { + tree = checker->fix(tree); + } else { + tree = base; + } + if (tree != nullptr) { + SimpleInstallDialog dialog(modName, parentWidget()); + if (m_MOInfo->pluginSetting(name(), "silent").toBool() || + dialog.exec() == QDialog::Accepted) { + modName.update(dialog.getName(), GUESS_USER); + + // If we have a data+txt archive, we move files to the data folder and + // switch to the data folder. We need to check that we actually have a + // checker here, otherwise it is anyway impossible that + // isDataTextArchiveTopLayer() returned true. + if (checker && isDataTextArchiveTopLayer(tree, dataFolderName, checker.get())) { + auto dataTree = tree->findDirectory(dataFolderName); + dataTree->detach(); + dataTree->merge(tree); + tree = dataTree; + } + return RESULT_SUCCESS; + } else { + if (dialog.manualRequested()) { + modName.update(dialog.getName(), GUESS_USER); + return RESULT_MANUALREQUESTED; + } else { + return RESULT_CANCELED; + } + } + } else { + // install shouldn't even have even have been called + qCritical("unsupported archive for quick installer"); + return RESULT_FAILED; + } +} + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +Q_EXPORT_PLUGIN2(installerQuick, InstallerQuick) +#endif diff --git a/src/installerquick.h b/src/installerquick.h index 737276d..fff7406 100644 --- a/src/installerquick.h +++ b/src/installerquick.h @@ -1,75 +1,77 @@ -#ifndef INSTALLERQUICK_H -#define INSTALLERQUICK_H - -#include -#include - -class InstallerQuick : public MOBase::IPluginInstallerSimple -{ - Q_OBJECT - Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerSimple) -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - Q_PLUGIN_METADATA(IID "org.tannin.InstallerQuick" FILE "installerquick.json") -#endif - -public: - - InstallerQuick(); - - // Plugin functions: - virtual bool init(MOBase::IOrganizer* moInfo) override; - virtual QString name() const override; - virtual QString localizedName() const override; - virtual QString author() const override; - virtual QString description() const override; - virtual MOBase::VersionInfo version() const override; - virtual QList settings() const override; - - // Installer functions: - virtual unsigned int priority() const override; - virtual bool isManualInstaller() const override; - virtual bool isArchiveSupported(std::shared_ptr tree) const override; - - // Simple installer functions: - virtual EInstallResult install( - MOBase::GuessedValue& modName, std::shared_ptr& tree, - QString& version, int& modID) override; - -private: - - /** - * @brief Check if the archive is a "DataText" archive. - * - * A "DataText" archive is defined as having exactly one folder named like the data folder of - * the game (`dataFolderName`) and one or more text or PDF files (standard package from french modding site). - * - * @param tree The tree to check. - * @param dataFolderName Name of the data folder (e.g., "data" for gamebryo games). - * @param checker The mod data checker, or a null pointer if none is available. - * - * @return true if the tree represents a "DataText" archive, false otherwise. - */ - bool isDataTextArchiveTopLayer( - std::shared_ptr tree, QString const& dataFolderName, MOBase::ModDataChecker* checker) const; - - /** - * @brief Get the base of the archive. - * - * The base of the archive is either a "DataText" folder (i.e., a folder containing TXT or PDF files and - * a valid data folder), or an actual data folder. - * - * @param tree The tree to check. - * @param dataFolderName Name of the data folder (e.g., "data" for gamebryo games). - * @param checker The mod data checker, or a null pointer if none is available. - * - * @return the "base" of the archive, or a null pointer if none was found. - */ - std::shared_ptr getSimpleArchiveBase( - std::shared_ptr dataTree, QString const& dataFolderName, MOBase::ModDataChecker* checker) const; - -private: - - const MOBase::IOrganizer* m_MOInfo; -}; - -#endif // INSTALLERQUICK_H +#ifndef INSTALLERQUICK_H +#define INSTALLERQUICK_H + +#include +#include + +class InstallerQuick : public MOBase::IPluginInstallerSimple +{ + Q_OBJECT + Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerSimple) +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + Q_PLUGIN_METADATA(IID "org.tannin.InstallerQuick" FILE "installerquick.json") +#endif + +public: + InstallerQuick(); + + // Plugin functions: + virtual bool init(MOBase::IOrganizer* moInfo) override; + virtual QString name() const override; + virtual QString localizedName() const override; + virtual QString author() const override; + virtual QString description() const override; + virtual MOBase::VersionInfo version() const override; + virtual QList settings() const override; + + // Installer functions: + virtual unsigned int priority() const override; + virtual bool isManualInstaller() const override; + virtual bool + isArchiveSupported(std::shared_ptr tree) const override; + + // Simple installer functions: + virtual EInstallResult install(MOBase::GuessedValue& modName, + std::shared_ptr& tree, + QString& version, int& modID) override; + +private: + /** + * @brief Check if the archive is a "DataText" archive. + * + * A "DataText" archive is defined as having exactly one folder named like the data + * folder of the game (`dataFolderName`) and one or more text or PDF files (standard + * package from french modding site). + * + * @param tree The tree to check. + * @param dataFolderName Name of the data folder (e.g., "data" for gamebryo games). + * @param checker The mod data checker, or a null pointer if none is available. + * + * @return true if the tree represents a "DataText" archive, false otherwise. + */ + bool isDataTextArchiveTopLayer(std::shared_ptr tree, + QString const& dataFolderName, + MOBase::ModDataChecker* checker) const; + + /** + * @brief Get the base of the archive. + * + * The base of the archive is either a "DataText" folder (i.e., a folder containing + * TXT or PDF files and a valid data folder), or an actual data folder. + * + * @param tree The tree to check. + * @param dataFolderName Name of the data folder (e.g., "data" for gamebryo games). + * @param checker The mod data checker, or a null pointer if none is available. + * + * @return the "base" of the archive, or a null pointer if none was found. + */ + std::shared_ptr + getSimpleArchiveBase(std::shared_ptr dataTree, + QString const& dataFolderName, + MOBase::ModDataChecker* checker) const; + +private: + const MOBase::IOrganizer* m_MOInfo; +}; + +#endif // INSTALLERQUICK_H diff --git a/src/simpleinstalldialog.cpp b/src/simpleinstalldialog.cpp index d65737d..c82ed9f 100644 --- a/src/simpleinstalldialog.cpp +++ b/src/simpleinstalldialog.cpp @@ -1,69 +1,69 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Mod Organizer is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Mod Organizer. If not, see . -*/ - -#include "simpleinstalldialog.h" -#include "ui_simpleinstalldialog.h" -#include - -#include -#include - -using namespace MOBase; - - -SimpleInstallDialog::SimpleInstallDialog(const GuessedValue &preset, QWidget *parent) - : QDialog(parent), ui(new Ui::SimpleInstallDialog), m_Manual(false) -{ - ui->setupUi(this); - - for (auto iter = preset.variants().begin(); iter != preset.variants().end(); ++iter) { - ui->nameCombo->addItem(*iter); - } - - ui->nameCombo->setCurrentIndex(ui->nameCombo->findText(preset)); - - setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); - ui->nameCombo->completer()->setCaseSensitivity(Qt::CaseSensitive); -} - -SimpleInstallDialog::~SimpleInstallDialog() -{ - delete ui; -} - -QString SimpleInstallDialog::getName() const -{ - return ui->nameCombo->currentText(); -} - -void SimpleInstallDialog::on_okBtn_clicked() -{ - this->accept(); -} - -void SimpleInstallDialog::on_cancelBtn_clicked() -{ - this->reject(); -} - -void SimpleInstallDialog::on_manualBtn_clicked() -{ - m_Manual = true; - this->reject(); -} +/* +Copyright (C) 2012 Sebastian Herbord. All rights reserved. + +This file is part of Mod Organizer. + +Mod Organizer is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mod Organizer is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mod Organizer. If not, see . +*/ + +#include "simpleinstalldialog.h" +#include "ui_simpleinstalldialog.h" +#include + +#include +#include + +using namespace MOBase; + +SimpleInstallDialog::SimpleInstallDialog(const GuessedValue& preset, + QWidget* parent) + : QDialog(parent), ui(new Ui::SimpleInstallDialog), m_Manual(false) +{ + ui->setupUi(this); + + for (auto iter = preset.variants().begin(); iter != preset.variants().end(); ++iter) { + ui->nameCombo->addItem(*iter); + } + + ui->nameCombo->setCurrentIndex(ui->nameCombo->findText(preset)); + + setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); + ui->nameCombo->completer()->setCaseSensitivity(Qt::CaseSensitive); +} + +SimpleInstallDialog::~SimpleInstallDialog() +{ + delete ui; +} + +QString SimpleInstallDialog::getName() const +{ + return ui->nameCombo->currentText(); +} + +void SimpleInstallDialog::on_okBtn_clicked() +{ + this->accept(); +} + +void SimpleInstallDialog::on_cancelBtn_clicked() +{ + this->reject(); +} + +void SimpleInstallDialog::on_manualBtn_clicked() +{ + m_Manual = true; + this->reject(); +} diff --git a/src/simpleinstalldialog.h b/src/simpleinstalldialog.h index 28230e3..08491a6 100644 --- a/src/simpleinstalldialog.h +++ b/src/simpleinstalldialog.h @@ -1,70 +1,72 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Mod Organizer is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Mod Organizer. If not, see . -*/ - -#ifndef SIMPLEINSTALLDIALOG_H -#define SIMPLEINSTALLDIALOG_H - -#include -#include - -namespace Ui { - class SimpleInstallDialog; -} - -/** - * @brief Dialog for the installation of a simple archive - * a simple archive is one that doesn't require any manual changes to work correctly - **/ -class SimpleInstallDialog : public QDialog -{ - Q_OBJECT - -public: - /** - * @brief constructor - * - * @param preset suggested name for the mod - * @param parent parent widget - **/ - explicit SimpleInstallDialog(const MOBase::GuessedValue &preset, QWidget *parent = 0); - ~SimpleInstallDialog(); - - /** - * @return true if the user requested the manual installation dialog - **/ - bool manualRequested() const { return m_Manual; } - /** - * @return the (user-modified) mod name - **/ - QString getName() const; - -private slots: - - void on_okBtn_clicked(); - - void on_cancelBtn_clicked(); - - void on_manualBtn_clicked(); - -private: - Ui::SimpleInstallDialog *ui; - bool m_Manual; -}; - -#endif // SIMPLEINSTALLDIALOG_H +/* +Copyright (C) 2012 Sebastian Herbord. All rights reserved. + +This file is part of Mod Organizer. + +Mod Organizer is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mod Organizer is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mod Organizer. If not, see . +*/ + +#ifndef SIMPLEINSTALLDIALOG_H +#define SIMPLEINSTALLDIALOG_H + +#include +#include + +namespace Ui +{ +class SimpleInstallDialog; +} + +/** + * @brief Dialog for the installation of a simple archive + * a simple archive is one that doesn't require any manual changes to work correctly + **/ +class SimpleInstallDialog : public QDialog +{ + Q_OBJECT + +public: + /** + * @brief constructor + * + * @param preset suggested name for the mod + * @param parent parent widget + **/ + explicit SimpleInstallDialog(const MOBase::GuessedValue& preset, + QWidget* parent = 0); + ~SimpleInstallDialog(); + + /** + * @return true if the user requested the manual installation dialog + **/ + bool manualRequested() const { return m_Manual; } + /** + * @return the (user-modified) mod name + **/ + QString getName() const; + +private slots: + + void on_okBtn_clicked(); + + void on_cancelBtn_clicked(); + + void on_manualBtn_clicked(); + +private: + Ui::SimpleInstallDialog* ui; + bool m_Manual; +}; + +#endif // SIMPLEINSTALLDIALOG_H