aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/modplatform/atlauncher
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2023-08-14 18:16:53 +0200
committerSefa Eyeoglu <contact@scrumplex.net>2023-08-14 18:16:53 +0200
commit91ba4cf75ee30c64779edb5b7644e5a830de5026 (patch)
treeaa8c2433bfc3a54577aceeb706c4c2cd0986c95d /launcher/ui/pages/modplatform/atlauncher
parent779f70057b021e285afd60cc650a14cd5feacffd (diff)
downloadPrismLauncher-91ba4cf75ee30c64779edb5b7644e5a830de5026.tar.gz
PrismLauncher-91ba4cf75ee30c64779edb5b7644e5a830de5026.tar.bz2
PrismLauncher-91ba4cf75ee30c64779edb5b7644e5a830de5026.zip
chore: reformat
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'launcher/ui/pages/modplatform/atlauncher')
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp16
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h16
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp132
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h37
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp34
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlPage.h46
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp16
7 files changed, 125 insertions, 172 deletions
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp
index 0887ebee..9cd5eed5 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp
@@ -18,14 +18,14 @@
#include <QDebug>
-#include <modplatform/atlauncher/ATLPackIndex.h>
#include <Version.h>
+#include <modplatform/atlauncher/ATLPackIndex.h>
#include "StringUtils.h"
namespace Atl {
-FilterModel::FilterModel(QObject *parent) : QSortFilterProxyModel(parent)
+FilterModel::FilterModel(QObject* parent) : QSortFilterProxyModel(parent)
{
currentSorting = Sorting::ByPopularity;
sortings.insert(tr("Sort by Popularity"), Sorting::ByPopularity);
@@ -62,7 +62,7 @@ void FilterModel::setSearchTerm(const QString term)
invalidate();
}
-bool FilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
+bool FilterModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
{
if (searchTerm.isEmpty()) {
return true;
@@ -73,20 +73,18 @@ bool FilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParen
return pack.name.contains(searchTerm, Qt::CaseInsensitive);
}
-bool FilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
+bool FilterModel::lessThan(const QModelIndex& left, const QModelIndex& right) const
{
ATLauncher::IndexedPack leftPack = sourceModel()->data(left, Qt::UserRole).value<ATLauncher::IndexedPack>();
ATLauncher::IndexedPack rightPack = sourceModel()->data(right, Qt::UserRole).value<ATLauncher::IndexedPack>();
if (currentSorting == ByPopularity) {
return leftPack.position > rightPack.position;
- }
- else if (currentSorting == ByGameVersion) {
+ } else if (currentSorting == ByGameVersion) {
Version lv(leftPack.versions.at(0).minecraft);
Version rv(rightPack.versions.at(0).minecraft);
return lv < rv;
- }
- else if (currentSorting == ByName) {
+ } else if (currentSorting == ByName) {
return StringUtils::naturalCompare(leftPack.name, rightPack.name, Qt::CaseSensitive) >= 0;
}
@@ -95,4 +93,4 @@ bool FilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) co
return true;
}
-}
+} // namespace Atl
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h b/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h
index 5235ccdb..0ab46ed2 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h
@@ -20,10 +20,9 @@
namespace Atl {
-class FilterModel : public QSortFilterProxyModel
-{
+class FilterModel : public QSortFilterProxyModel {
Q_OBJECT
-public:
+ public:
FilterModel(QObject* parent = Q_NULLPTR);
enum Sorting {
ByPopularity,
@@ -36,15 +35,14 @@ public:
Sorting getCurrentSorting();
void setSearchTerm(QString term);
-protected:
- bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
- bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
+ protected:
+ bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
+ bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
-private:
+ private:
QMap<QString, Sorting> sortings;
Sorting currentSorting;
QString searchTerm;
-
};
-}
+} // namespace Atl
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp
index d9f3274d..868d9813 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp
@@ -38,17 +38,15 @@
#include <QInputDialog>
#include <QMessageBox>
+#include "Application.h"
#include "BuildConfig.h"
#include "Json.h"
#include "modplatform/atlauncher/ATLShareCode.h"
-#include "Application.h"
#include "net/ApiDownload.h"
AtlOptionalModListModel::AtlOptionalModListModel(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
- : QAbstractListModel(parent)
- , m_version(version)
- , m_mods(mods)
+ : QAbstractListModel(parent), m_version(version), m_mods(mods)
{
// fill mod index
for (int i = 0; i < m_mods.size(); i++) {
@@ -64,7 +62,8 @@ AtlOptionalModListModel::AtlOptionalModListModel(QWidget* parent, ATLauncher::Pa
}
}
-QVector<QString> AtlOptionalModListModel::getResult() {
+QVector<QString> AtlOptionalModListModel::getResult()
+{
QVector<QString> result;
for (const auto& mod : m_mods) {
@@ -76,16 +75,19 @@ QVector<QString> AtlOptionalModListModel::getResult() {
return result;
}
-int AtlOptionalModListModel::rowCount(const QModelIndex &parent) const {
+int AtlOptionalModListModel::rowCount(const QModelIndex& parent) const
+{
return parent.isValid() ? 0 : m_mods.size();
}
-int AtlOptionalModListModel::columnCount(const QModelIndex &parent) const {
+int AtlOptionalModListModel::columnCount(const QModelIndex& parent) const
+{
// Enabled, Name, Description
return parent.isValid() ? 0 : 3;
}
-QVariant AtlOptionalModListModel::data(const QModelIndex &index, int role) const {
+QVariant AtlOptionalModListModel::data(const QModelIndex& index, int role) const
+{
auto row = index.row();
auto mod = m_mods.at(row);
@@ -96,18 +98,15 @@ QVariant AtlOptionalModListModel::data(const QModelIndex &index, int role) const
if (index.column() == DescriptionColumn) {
return mod.description;
}
- }
- else if (role == Qt::ToolTipRole) {
+ } else if (role == Qt::ToolTipRole) {
if (index.column() == DescriptionColumn) {
return mod.description;
}
- }
- else if (role == Qt::ForegroundRole) {
+ } else if (role == Qt::ForegroundRole) {
if (!mod.colour.isEmpty() && m_version.colours.contains(mod.colour)) {
return QColor(QString("#%1").arg(m_version.colours[mod.colour]));
}
- }
- else if (role == Qt::CheckStateRole) {
+ } else if (role == Qt::CheckStateRole) {
if (index.column() == EnabledColumn) {
return m_selection[mod.name] ? Qt::Checked : Qt::Unchecked;
}
@@ -116,7 +115,8 @@ QVariant AtlOptionalModListModel::data(const QModelIndex &index, int role) const
return {};
}
-bool AtlOptionalModListModel::setData(const QModelIndex &index, [[maybe_unused]] const QVariant &value, int role) {
+bool AtlOptionalModListModel::setData(const QModelIndex& index, [[maybe_unused]] const QVariant& value, int role)
+{
if (role == Qt::CheckStateRole) {
auto row = index.row();
auto mod = m_mods.at(row);
@@ -128,7 +128,8 @@ bool AtlOptionalModListModel::setData(const QModelIndex &index, [[maybe_unused]]
return false;
}
-QVariant AtlOptionalModListModel::headerData(int section, Qt::Orientation orientation, int role) const {
+QVariant AtlOptionalModListModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
switch (section) {
case EnabledColumn:
@@ -143,7 +144,8 @@ QVariant AtlOptionalModListModel::headerData(int section, Qt::Orientation orient
return {};
}
-Qt::ItemFlags AtlOptionalModListModel::flags(const QModelIndex &index) const {
+Qt::ItemFlags AtlOptionalModListModel::flags(const QModelIndex& index) const
+{
auto flags = QAbstractListModel::flags(index);
if (index.isValid() && index.column() == EnabledColumn) {
flags |= Qt::ItemIsUserCheckable;
@@ -151,23 +153,23 @@ Qt::ItemFlags AtlOptionalModListModel::flags(const QModelIndex &index) const {
return flags;
}
-void AtlOptionalModListModel::useShareCode(const QString& code) {
+void AtlOptionalModListModel::useShareCode(const QString& code)
+{
m_jobPtr.reset(new NetJob("Atl::Request", APPLICATION->network()));
auto url = QString(BuildConfig.ATL_API_BASE_URL + "share-codes/" + code);
m_jobPtr->addNetAction(Net::ApiDownload::makeByteArray(QUrl(url), m_response));
- connect(m_jobPtr.get(), &NetJob::succeeded,
- this, &AtlOptionalModListModel::shareCodeSuccess);
- connect(m_jobPtr.get(), &NetJob::failed,
- this, &AtlOptionalModListModel::shareCodeFailure);
+ connect(m_jobPtr.get(), &NetJob::succeeded, this, &AtlOptionalModListModel::shareCodeSuccess);
+ connect(m_jobPtr.get(), &NetJob::failed, this, &AtlOptionalModListModel::shareCodeFailure);
m_jobPtr->start();
}
-void AtlOptionalModListModel::shareCodeSuccess() {
+void AtlOptionalModListModel::shareCodeSuccess()
+{
m_jobPtr.reset();
- QJsonParseError parse_error {};
+ QJsonParseError parse_error{};
auto doc = QJsonDocument::fromJson(*m_response, &parse_error);
if (parse_error.error != QJsonParseError::NoError) {
qWarning() << "Error while parsing JSON response from ATL at " << parse_error.offset << " reason: " << parse_error.errorString();
@@ -179,8 +181,7 @@ void AtlOptionalModListModel::shareCodeSuccess() {
ATLauncher::ShareCodeResponse response;
try {
ATLauncher::loadShareCodeResponse(response, obj);
- }
- catch (const JSONValidationError& e) {
+ } catch (const JSONValidationError& e) {
qDebug() << QString::fromUtf8(*m_response);
qWarning() << "Error while reading response from ATLauncher: " << e.cause();
return;
@@ -204,44 +205,44 @@ void AtlOptionalModListModel::shareCodeSuccess() {
m_selection[mod.name] = mod.selected;
}
- emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn),
- AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
+ emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn), AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
}
-void AtlOptionalModListModel::shareCodeFailure([[maybe_unused]] const QString& reason) {
+void AtlOptionalModListModel::shareCodeFailure([[maybe_unused]] const QString& reason)
+{
m_jobPtr.reset();
// fixme: plumb in an error message
}
-void AtlOptionalModListModel::selectRecommended() {
+void AtlOptionalModListModel::selectRecommended()
+{
for (const auto& mod : m_mods) {
m_selection[mod.name] = mod.recommended;
}
- emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn),
- AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
+ emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn), AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
}
-void AtlOptionalModListModel::clearAll() {
+void AtlOptionalModListModel::clearAll()
+{
for (const auto& mod : m_mods) {
m_selection[mod.name] = false;
}
- emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn),
- AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
+ emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn), AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
}
-void AtlOptionalModListModel::toggleMod(ATLauncher::VersionMod mod, int index) {
+void AtlOptionalModListModel::toggleMod(ATLauncher::VersionMod mod, int index)
+{
auto enable = !m_selection[mod.name];
// If there is a warning for the mod, display that first (if we would be enabling the mod)
if (enable && !mod.warning.isEmpty() && m_version.warnings.contains(mod.warning)) {
- auto message = QString("%1<br><br>%2")
- .arg(m_version.warnings[mod.warning], tr("Are you sure that you want to enable this mod?"));
+ auto message = QString("%1<br><br>%2").arg(m_version.warnings[mod.warning], tr("Are you sure that you want to enable this mod?"));
// fixme: avoid casting here
- auto result = QMessageBox::warning((QWidget*) this->parent(), tr("Warning"), message, QMessageBox::Yes | QMessageBox::No);
+ auto result = QMessageBox::warning((QWidget*)this->parent(), tr("Warning"), message, QMessageBox::Yes | QMessageBox::No);
if (result != QMessageBox::Yes) {
return;
}
@@ -250,15 +251,18 @@ void AtlOptionalModListModel::toggleMod(ATLauncher::VersionMod mod, int index) {
setMod(mod, index, enable);
}
-void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool enable, bool shouldEmit) {
- if (m_selection[mod.name] == enable) return;
+void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool enable, bool shouldEmit)
+{
+ if (m_selection[mod.name] == enable)
+ return;
m_selection[mod.name] = enable;
// disable other mods in the group, if applicable
if (enable && !mod.group.isEmpty()) {
for (int i = 0; i < m_mods.size(); i++) {
- if (index == i) continue;
+ if (index == i)
+ continue;
auto other = m_mods.at(i);
if (mod.group == other.group) {
@@ -283,8 +287,7 @@ void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool
if (enable) {
dependents.append(mod.name);
- }
- else {
+ } else {
dependents.removeAll(mod.name);
// if there are no longer any dependents, let's disable the mod
@@ -306,14 +309,12 @@ void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool
}
if (shouldEmit) {
- emit dataChanged(AtlOptionalModListModel::index(index, EnabledColumn),
- AtlOptionalModListModel::index(index, EnabledColumn));
+ emit dataChanged(AtlOptionalModListModel::index(index, EnabledColumn), AtlOptionalModListModel::index(index, EnabledColumn));
}
}
AtlOptionalModDialog::AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
- : QDialog(parent)
- , ui(new Ui::AtlOptionalModDialog)
+ : QDialog(parent), ui(new Ui::AtlOptionalModDialog)
{
ui->setupUi(this);
@@ -321,35 +322,24 @@ AtlOptionalModDialog::AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVers
ui->treeView->setModel(listModel);
ui->treeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- ui->treeView->header()->setSectionResizeMode(
- AtlOptionalModListModel::NameColumn, QHeaderView::ResizeToContents);
- ui->treeView->header()->setSectionResizeMode(
- AtlOptionalModListModel::DescriptionColumn, QHeaderView::Stretch);
-
- connect(ui->shareCodeButton, &QPushButton::clicked,
- this, &AtlOptionalModDialog::useShareCode);
- connect(ui->selectRecommendedButton, &QPushButton::clicked,
- listModel, &AtlOptionalModListModel::selectRecommended);
- connect(ui->clearAllButton, &QPushButton::clicked,
- listModel, &AtlOptionalModListModel::clearAll);
- connect(ui->installButton, &QPushButton::clicked,
- this, &QDialog::accept);
+ ui->treeView->header()->setSectionResizeMode(AtlOptionalModListModel::NameColumn, QHeaderView::ResizeToContents);
+ ui->treeView->header()->setSectionResizeMode(AtlOptionalModListModel::DescriptionColumn, QHeaderView::Stretch);
+
+ connect(ui->shareCodeButton, &QPushButton::clicked, this, &AtlOptionalModDialog::useShareCode);
+ connect(ui->selectRecommendedButton, &QPushButton::clicked, listModel, &AtlOptionalModListModel::selectRecommended);
+ connect(ui->clearAllButton, &QPushButton::clicked, listModel, &AtlOptionalModListModel::clearAll);
+ connect(ui->installButton, &QPushButton::clicked, this, &QDialog::accept);
}
-AtlOptionalModDialog::~AtlOptionalModDialog() {
+AtlOptionalModDialog::~AtlOptionalModDialog()
+{
delete ui;
}
-void AtlOptionalModDialog::useShareCode() {
+void AtlOptionalModDialog::useShareCode()
+{
bool ok;
- auto shareCode = QInputDialog::getText(
- this,
- tr("Select a share code"),
- tr("Share code:"),
- QLineEdit::Normal,
- "",
- &ok
- );
+ auto shareCode = QInputDialog::getText(this, tr("Select a share code"), tr("Share code:"), QLineEdit::Normal, "", &ok);
if (!ok) {
// If the user cancels the dialog, we don't need to show any error dialogs.
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h
index fe24d821..1adfdf03 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h
@@ -35,8 +35,8 @@
#pragma once
-#include <QDialog>
#include <QAbstractListModel>
+#include <QDialog>
#include "modplatform/atlauncher/ATLPackIndex.h"
#include "net/NetJob.h"
@@ -48,37 +48,36 @@ class AtlOptionalModDialog;
class AtlOptionalModListModel : public QAbstractListModel {
Q_OBJECT
-public:
- enum Columns
- {
+ public:
+ enum Columns {
EnabledColumn = 0,
NameColumn,
DescriptionColumn,
};
- AtlOptionalModListModel(QWidget *parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
+ AtlOptionalModListModel(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
QVector<QString> getResult();
- int rowCount(const QModelIndex &parent) const override;
- int columnCount(const QModelIndex &parent) const override;
+ int rowCount(const QModelIndex& parent) const override;
+ int columnCount(const QModelIndex& parent) const override;
- QVariant data(const QModelIndex &index, int role) const override;
- bool setData(const QModelIndex &index, const QVariant &value, int role) override;
+ QVariant data(const QModelIndex& index, int role) const override;
+ bool setData(const QModelIndex& index, const QVariant& value, int role) override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const override;
+ Qt::ItemFlags flags(const QModelIndex& index) const override;
void useShareCode(const QString& code);
-public slots:
+ public slots:
void shareCodeSuccess();
void shareCodeFailure(const QString& reason);
void selectRecommended();
void clearAll();
-private:
+ private:
void toggleMod(ATLauncher::VersionMod mod, int index);
void setMod(ATLauncher::VersionMod mod, int index, bool enable, bool shouldEmit = true);
@@ -97,18 +96,16 @@ private:
class AtlOptionalModDialog : public QDialog {
Q_OBJECT
-public:
- AtlOptionalModDialog(QWidget *parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
+ public:
+ AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
~AtlOptionalModDialog() override;
- QVector<QString> getResult() {
- return listModel->getResult();
- }
+ QVector<QString> getResult() { return listModel->getResult(); }
void useShareCode();
-private:
- Ui::AtlOptionalModDialog *ui;
+ private:
+ Ui::AtlOptionalModDialog* ui;
- AtlOptionalModListModel *listModel;
+ AtlOptionalModListModel* listModel;
};
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp
index 7c80ed2d..1e96a75d 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp
@@ -46,10 +46,7 @@
#include <QMessageBox>
-AtlPage::AtlPage(NewInstanceDialog* dialog, QWidget* parent)
- : QWidget(parent)
- , ui(new Ui::AtlPage)
- , dialog(dialog)
+AtlPage::AtlPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), ui(new Ui::AtlPage), dialog(dialog)
{
ui->setupUi(this);
@@ -65,8 +62,7 @@ AtlPage::AtlPage(NewInstanceDialog* dialog, QWidget* parent)
ui->versionSelectionBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
ui->versionSelectionBox->view()->parentWidget()->setMaximumHeight(300);
- for(int i = 0; i < filterModel->getAvailableSortings().size(); i++)
- {
+ for (int i = 0; i < filterModel->getAvailableSortings().size(); i++) {
ui->sortByBox->addItem(filterModel->getAvailableSortings().keys().at(i));
}
ui->sortByBox->setCurrentText(filterModel->translateCurrentSorting());
@@ -94,8 +90,7 @@ void AtlPage::retranslate()
void AtlPage::openedImpl()
{
- if(!initialized)
- {
+ if (!initialized) {
listModel->request();
initialized = true;
}
@@ -105,13 +100,11 @@ void AtlPage::openedImpl()
void AtlPage::suggestCurrent()
{
- if(!isOpened)
- {
+ if (!isOpened) {
return;
}
- if (selectedVersion.isEmpty())
- {
+ if (selectedVersion.isEmpty()) {
dialog->setSuggestedPack();
return;
}
@@ -121,10 +114,8 @@ void AtlPage::suggestCurrent()
auto editedLogoName = selected.safeName;
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/images/%1.png").arg(selected.safeName.toLower());
- listModel->getLogo(selected.safeName, url, [this, editedLogoName](QString logo)
- {
- dialog->setSuggestedIconFromFile(logo, editedLogoName);
- });
+ listModel->getLogo(selected.safeName, url,
+ [this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
}
void AtlPage::triggerSearch()
@@ -142,10 +133,8 @@ void AtlPage::onSelectionChanged(QModelIndex first, [[maybe_unused]] QModelIndex
{
ui->versionSelectionBox->clear();
- if(!first.isValid())
- {
- if(isOpened)
- {
+ if (!first.isValid()) {
+ if (isOpened) {
dialog->setSuggestedPack();
}
return;
@@ -155,7 +144,7 @@ void AtlPage::onSelectionChanged(QModelIndex first, [[maybe_unused]] QModelIndex
ui->packDescription->setHtml(selected.description.replace("\n", "<br>"));
- for(const auto& version : selected.versions) {
+ for (const auto& version : selected.versions) {
ui->versionSelectionBox->addItem(version.version);
}
@@ -164,8 +153,7 @@ void AtlPage::onSelectionChanged(QModelIndex first, [[maybe_unused]] QModelIndex
void AtlPage::onVersionSelectionChanged(QString version)
{
- if(version.isNull() || version.isEmpty())
- {
+ if (version.isNull() || version.isEmpty()) {
selectedVersion = "";
return;
}
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlPage.h b/launcher/ui/pages/modplatform/atlauncher/AtlPage.h
index 1b3b15c1..ac336ec1 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlPage.h
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlPage.h
@@ -38,52 +38,38 @@
#include "AtlFilterModel.h"
#include "AtlListModel.h"
-#include <QWidget>
#include <modplatform/atlauncher/ATLPackInstallTask.h>
+#include <QWidget>
#include "Application.h"
-#include "ui/pages/BasePage.h"
#include "tasks/Task.h"
+#include "ui/pages/BasePage.h"
-namespace Ui
-{
- class AtlPage;
+namespace Ui {
+class AtlPage;
}
class NewInstanceDialog;
-class AtlPage : public QWidget, public BasePage
-{
-Q_OBJECT
+class AtlPage : public QWidget, public BasePage {
+ Q_OBJECT
-public:
- explicit AtlPage(NewInstanceDialog* dialog, QWidget *parent = 0);
+ public:
+ explicit AtlPage(NewInstanceDialog* dialog, QWidget* parent = 0);
virtual ~AtlPage();
- virtual QString displayName() const override
- {
- return "ATLauncher";
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("atlauncher");
- }
- virtual QString id() const override
- {
- return "atl";
- }
- virtual QString helpPage() const override
- {
- return "ATL-platform";
- }
+ virtual QString displayName() const override { return "ATLauncher"; }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("atlauncher"); }
+ virtual QString id() const override { return "atl"; }
+ virtual QString helpPage() const override { return "ATL-platform"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
void openedImpl() override;
-private:
+ private:
void suggestCurrent();
-private slots:
+ private slots:
void triggerSearch();
void onSortingSelectionChanged(QString data);
@@ -91,8 +77,8 @@ private slots:
void onSelectionChanged(QModelIndex first, QModelIndex second);
void onVersionSelectionChanged(QString data);
-private:
- Ui::AtlPage *ui = nullptr;
+ private:
+ Ui::AtlPage* ui = nullptr;
NewInstanceDialog* dialog = nullptr;
Atl::ListModel* listModel = nullptr;
Atl::FilterModel* filterModel = nullptr;
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp
index 3d2d568a..9ed75bcc 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp
@@ -33,17 +33,16 @@
* limitations under the License.
*/
-#include <QMessageBox>
#include "AtlUserInteractionSupportImpl.h"
+#include <QMessageBox>
#include "AtlOptionalModDialog.h"
#include "ui/dialogs/VersionSelectDialog.h"
-AtlUserInteractionSupportImpl::AtlUserInteractionSupportImpl(QWidget *parent) : m_parent(parent)
-{
-}
+AtlUserInteractionSupportImpl::AtlUserInteractionSupportImpl(QWidget* parent) : m_parent(parent) {}
-std::optional<QVector<QString>> AtlUserInteractionSupportImpl::chooseOptionalMods(ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
+std::optional<QVector<QString>> AtlUserInteractionSupportImpl::chooseOptionalMods(ATLauncher::PackVersion version,
+ QVector<ATLauncher::VersionMod> mods)
{
AtlOptionalModDialog optionalModDialog(m_parent, version, mods);
auto result = optionalModDialog.exec();
@@ -59,8 +58,7 @@ QString AtlUserInteractionSupportImpl::chooseVersion(Meta::VersionList::Ptr vlis
if (minecraftVersion != nullptr) {
vselect.setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion);
vselect.setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion));
- }
- else {
+ } else {
vselect.setEmptyString(tr("No versions are currently available"));
}
vselect.setEmptyErrorString(tr("Couldn't load or download the version lists!"));
@@ -72,9 +70,7 @@ QString AtlUserInteractionSupportImpl::chooseVersion(Meta::VersionList::Ptr vlis
// filter by minecraft version, if the loader depends on a certain version.
if (minecraftVersion != nullptr) {
- auto iter = std::find_if(reqs.begin(), reqs.end(), [](const Meta::Require& req) {
- return req.uid == "net.minecraft";
- });
+ auto iter = std::find_if(reqs.begin(), reqs.end(), [](const Meta::Require& req) { return req.uid == "net.minecraft"; });
if (iter == reqs.end())
continue;
if (iter->equalsVersion != minecraftVersion)