Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting and Github Actions #16

Merged
merged 4 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -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']
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
988523cac10641c510fd711d80d59c82d473f6a5
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Build Installer Bundle Plugin

on:
push:
branches: master
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
runs-on: windows-2022
steps:
- name: Build Installer Bundle Plugin
uses: ModOrganizer2/build-with-mob-action@master
with:
mo2-dependencies: cmake_common uibase
16 changes: 16 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Lint Installer Bundle 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: "."
40 changes: 0 additions & 40 deletions appveyor.yml

This file was deleted.

54 changes: 26 additions & 28 deletions src/installerbundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.

using namespace MOBase;

InstallerBundle::InstallerBundle() {}

InstallerBundle::InstallerBundle()
{
}


bool InstallerBundle::init(IOrganizer *organizer)
bool InstallerBundle::init(IOrganizer* organizer)
{
m_Organizer = organizer;
return true;
Expand Down Expand Up @@ -65,9 +61,10 @@ VersionInfo InstallerBundle::version() const

QList<PluginSetting> InstallerBundle::settings() const
{
return {
PluginSetting("auto_reinstall", "when reinstalling from an archive containing multiple mods, automatically select the previously installed", true)
};
return {PluginSetting("auto_reinstall",
"when reinstalling from an archive containing multiple mods, "
"automatically select the previously installed",
true)};
}

unsigned int InstallerBundle::priority() const
Expand All @@ -80,13 +77,14 @@ bool InstallerBundle::isManualInstaller() const
return false;
}

void InstallerBundle::onInstallationStart(QString const& archive, bool reinstallation, IModInterface* currentMod)
void InstallerBundle::onInstallationStart(QString const& archive, bool reinstallation,
IModInterface* currentMod)
{
// We reset some field and fetch the previously installed file:
m_InstallationFile = archive;
m_InstallerUsed = false;
m_SelectedFile = "";
m_PreviousFile = "";
m_InstallerUsed = false;
m_SelectedFile = "";
m_PreviousFile = "";

if (reinstallation && m_Organizer->pluginSetting(name(), "auto_reinstall").toBool()) {
m_PreviousFile = currentMod->pluginSetting(name(), "archive", QString()).toString();
Expand All @@ -102,7 +100,8 @@ void InstallerBundle::onInstallationEnd(EInstallResult result, IModInterface* ne
}
}

std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> InstallerBundle::findObjects(std::shared_ptr<const IFileTree> tree) const
std::vector<std::shared_ptr<const MOBase::FileTreeEntry>>
InstallerBundle::findObjects(std::shared_ptr<const IFileTree> tree) const
{
std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> entries;
// Check if we have an archive:
Expand All @@ -112,11 +111,11 @@ std::vector<std::shared_ptr<const MOBase::FileTreeEntry>> InstallerBundle::findO
int nDirs = 0;
for (auto entry : *tree) {
if (entry->isFile()) {
if (managerExtensions.contains(entry->suffix(), FileNameComparator::CaseSensitivity)) {
if (managerExtensions.contains(entry->suffix(),
FileNameComparator::CaseSensitivity)) {
entries.push_back(entry);
}
}
else {
} else {
nDirs++;
}
}
Expand All @@ -140,8 +139,9 @@ bool InstallerBundle::isArchiveSupported(std::shared_ptr<const IFileTree> tree)
return !findObjects(tree).empty();
}

IPluginInstaller::EInstallResult InstallerBundle::install(
GuessedValue<QString>& modName, std::shared_ptr<IFileTree>& tree, QString&, int &modId)
IPluginInstaller::EInstallResult
InstallerBundle::install(GuessedValue<QString>& modName,
std::shared_ptr<IFileTree>& tree, QString&, int& modId)
{
// Find a valid "object":
auto entries = findObjects(tree);
Expand All @@ -152,23 +152,20 @@ IPluginInstaller::EInstallResult InstallerBundle::install(
std::shared_ptr<const FileTreeEntry> entry = nullptr;
if (entries.size() == 1) {
entry = entries[0];
}
else {
} else {
if (!m_PreviousFile.isEmpty()) {
entry = tree->find(m_PreviousFile);
}

if (entry == nullptr) {
MultiArchiveDialog dialog(entries, parentWidget());
if (dialog.exec() == QDialog::Accepted) {
entry = dialog.selectedEntry();
entry = dialog.selectedEntry();
m_SelectedFile = entry->pathFrom(tree);
}
else {
} else {
if (dialog.manualRequested()) {
return IPluginInstaller::RESULT_MANUALREQUESTED;
}
else {
} else {
return IPluginInstaller::RESULT_CANCELED;
}
}
Expand All @@ -183,13 +180,14 @@ IPluginInstaller::EInstallResult InstallerBundle::install(

// Extract it:
QString tempFile = manager()->extractFile(entry);
IPluginInstaller::EInstallResult res = manager()->installArchive(modName, tempFile, modId);
IPluginInstaller::EInstallResult res =
manager()->installArchive(modName, tempFile, modId);
if (res == IPluginInstaller::RESULT_SUCCESS) {
res = IPluginInstaller::RESULT_SUCCESSCANCEL;
}
return res;
}

#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_EXPORT_PLUGIN2(installerBundle, InstallerBundle)
#endif
Loading
Loading