mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-04-29 14:14:34 +02:00
chore:fixed some codeql warnings
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
9a57fddaaf
commit
f7fd6f566f
@ -15,7 +15,7 @@
|
||||
DataMigrationTask::DataMigrationTask(const QString& sourcePath, const QString& targetPath, const IPathMatcher::Ptr pathMatcher)
|
||||
: Task(), m_sourcePath(sourcePath), m_targetPath(targetPath), m_pathMatcher(pathMatcher), m_copy(sourcePath, targetPath)
|
||||
{
|
||||
m_copy.matcher(m_pathMatcher.get()).whitelist(true);
|
||||
m_copy.matcher(m_pathMatcher).whitelist(true);
|
||||
}
|
||||
|
||||
void DataMigrationTask::executeTask()
|
||||
|
@ -115,7 +115,7 @@ class copy : public QObject {
|
||||
m_followSymlinks = follow;
|
||||
return *this;
|
||||
}
|
||||
copy& matcher(const IPathMatcher* filter)
|
||||
copy& matcher(IPathMatcher::Ptr filter)
|
||||
{
|
||||
m_matcher = filter;
|
||||
return *this;
|
||||
@ -147,7 +147,7 @@ class copy : public QObject {
|
||||
|
||||
private:
|
||||
bool m_followSymlinks = true;
|
||||
const IPathMatcher* m_matcher = nullptr;
|
||||
IPathMatcher::Ptr m_matcher = nullptr;
|
||||
bool m_whitelist = false;
|
||||
bool m_overwrite = false;
|
||||
QDir m_src;
|
||||
@ -209,7 +209,7 @@ class create_link : public QObject {
|
||||
m_useHardLinks = useHard;
|
||||
return *this;
|
||||
}
|
||||
create_link& matcher(const IPathMatcher* filter)
|
||||
create_link& matcher(IPathMatcher::Ptr filter)
|
||||
{
|
||||
m_matcher = filter;
|
||||
return *this;
|
||||
@ -260,7 +260,7 @@ class create_link : public QObject {
|
||||
|
||||
private:
|
||||
bool m_useHardLinks = false;
|
||||
const IPathMatcher* m_matcher = nullptr;
|
||||
IPathMatcher::Ptr m_matcher = nullptr;
|
||||
bool m_whitelist = false;
|
||||
bool m_recursive = true;
|
||||
|
||||
@ -488,7 +488,7 @@ class clone : public QObject {
|
||||
m_src.setPath(src);
|
||||
m_dst.setPath(dst);
|
||||
}
|
||||
clone& matcher(const IPathMatcher* filter)
|
||||
clone& matcher(IPathMatcher::Ptr filter)
|
||||
{
|
||||
m_matcher = filter;
|
||||
return *this;
|
||||
@ -514,7 +514,7 @@ class clone : public QObject {
|
||||
bool operator()(const QString& offset, bool dryRun = false);
|
||||
|
||||
private:
|
||||
const IPathMatcher* m_matcher = nullptr;
|
||||
IPathMatcher::Ptr m_matcher = nullptr;
|
||||
bool m_whitelist = false;
|
||||
QDir m_src;
|
||||
QDir m_dst;
|
||||
|
@ -43,7 +43,7 @@ void InstanceCopyTask::executeTask()
|
||||
m_copyFuture = QtConcurrent::run(QThreadPool::globalInstance(), [this] {
|
||||
if (m_useClone) {
|
||||
FS::clone folderClone(m_origInstance->instanceRoot(), m_stagingPath);
|
||||
folderClone.matcher(m_matcher.get());
|
||||
folderClone.matcher(m_matcher);
|
||||
|
||||
folderClone(true);
|
||||
setProgress(0, folderClone.totalCloned());
|
||||
@ -72,7 +72,7 @@ void InstanceCopyTask::executeTask()
|
||||
}
|
||||
FS::create_link folderLink(m_origInstance->instanceRoot(), m_stagingPath);
|
||||
int depth = m_linkRecursively ? -1 : 0; // we need to at least link the top level instead of the instance folder
|
||||
folderLink.linkRecursively(true).setMaxDepth(depth).useHardLinks(m_useHardLinks).matcher(m_matcher.get());
|
||||
folderLink.linkRecursively(true).setMaxDepth(depth).useHardLinks(m_useHardLinks).matcher(m_matcher);
|
||||
|
||||
folderLink(true);
|
||||
setProgress(0, m_progressTotal + folderLink.totalToLink());
|
||||
@ -127,7 +127,7 @@ void InstanceCopyTask::executeTask()
|
||||
return !there_were_errors;
|
||||
}
|
||||
FS::copy folderCopy(m_origInstance->instanceRoot(), m_stagingPath);
|
||||
folderCopy.followSymlinks(false).matcher(m_matcher.get());
|
||||
folderCopy.followSymlinks(false).matcher(m_matcher);
|
||||
|
||||
folderCopy(true);
|
||||
setProgress(0, folderCopy.totalCopied());
|
||||
|
@ -28,7 +28,7 @@ class InstanceCopyTask : public InstanceTask {
|
||||
InstancePtr m_origInstance;
|
||||
QFuture<bool> m_copyFuture;
|
||||
QFutureWatcher<bool> m_copyFutureWatcher;
|
||||
std::unique_ptr<IPathMatcher> m_matcher;
|
||||
IPathMatcher::Ptr m_matcher;
|
||||
bool m_keepPlaytime;
|
||||
bool m_useLinks = false;
|
||||
bool m_useHardLinks = false;
|
||||
|
@ -24,7 +24,7 @@ class TestCheck : public QObject {
|
||||
TestCheck(QWidget* parent, QString path, QString args, int minMem, int maxMem, int permGen)
|
||||
: m_parent(parent), m_path(path), m_args(args), m_minMem(minMem), m_maxMem(maxMem), m_permGen(permGen)
|
||||
{}
|
||||
virtual ~TestCheck() {};
|
||||
virtual ~TestCheck() = default;
|
||||
|
||||
void run();
|
||||
|
||||
|
@ -193,8 +193,8 @@ QVariant VersionProxyModel::data(const QModelIndex& index, int role) const
|
||||
if (value.toBool()) {
|
||||
return tr("Recommended");
|
||||
} else if (hasLatest) {
|
||||
auto value = sourceModel()->data(parentIndex, BaseVersionList::LatestRole);
|
||||
if (value.toBool()) {
|
||||
auto latest = sourceModel()->data(parentIndex, BaseVersionList::LatestRole);
|
||||
if (latest.toBool()) {
|
||||
return tr("Latest");
|
||||
}
|
||||
}
|
||||
@ -203,33 +203,27 @@ QVariant VersionProxyModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
}
|
||||
case Qt::DecorationRole: {
|
||||
switch (column) {
|
||||
case Name: {
|
||||
if (hasRecommended) {
|
||||
auto recommenced = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
|
||||
if (recommenced.toBool()) {
|
||||
return APPLICATION->getThemedIcon("star");
|
||||
} else if (hasLatest) {
|
||||
auto latest = sourceModel()->data(parentIndex, BaseVersionList::LatestRole);
|
||||
if (latest.toBool()) {
|
||||
return APPLICATION->getThemedIcon("bug");
|
||||
}
|
||||
}
|
||||
QPixmap pixmap;
|
||||
QPixmapCache::find("placeholder", &pixmap);
|
||||
if (!pixmap) {
|
||||
QPixmap px(16, 16);
|
||||
px.fill(Qt::transparent);
|
||||
QPixmapCache::insert("placeholder", px);
|
||||
return px;
|
||||
}
|
||||
return pixmap;
|
||||
if (column == Name && hasRecommended) {
|
||||
auto recommenced = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
|
||||
if (recommenced.toBool()) {
|
||||
return APPLICATION->getThemedIcon("star");
|
||||
} else if (hasLatest) {
|
||||
auto latest = sourceModel()->data(parentIndex, BaseVersionList::LatestRole);
|
||||
if (latest.toBool()) {
|
||||
return APPLICATION->getThemedIcon("bug");
|
||||
}
|
||||
}
|
||||
default: {
|
||||
return QVariant();
|
||||
QPixmap pixmap;
|
||||
QPixmapCache::find("placeholder", &pixmap);
|
||||
if (!pixmap) {
|
||||
QPixmap px(16, 16);
|
||||
px.fill(Qt::transparent);
|
||||
QPixmapCache::insert("placeholder", px);
|
||||
return px;
|
||||
}
|
||||
return pixmap;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
default: {
|
||||
if (roles.contains((BaseVersionList::ModelRoles)role)) {
|
||||
|
@ -517,13 +517,9 @@ QVariant PackProfile::data(const QModelIndex& index, int role) const
|
||||
|
||||
switch (role) {
|
||||
case Qt::CheckStateRole: {
|
||||
switch (column) {
|
||||
case NameColumn: {
|
||||
return patch->isEnabled() ? Qt::Checked : Qt::Unchecked;
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
if (column == NameColumn)
|
||||
return patch->isEnabled() ? Qt::Checked : Qt::Unchecked;
|
||||
return QVariant();
|
||||
}
|
||||
case Qt::DisplayRole: {
|
||||
switch (column) {
|
||||
|
@ -208,13 +208,9 @@ QVariant WorldList::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
|
||||
case Qt::UserRole:
|
||||
switch (column) {
|
||||
case SizeColumn:
|
||||
return QVariant::fromValue<qlonglong>(world.bytes());
|
||||
|
||||
default:
|
||||
return data(index, Qt::DisplayRole);
|
||||
}
|
||||
if (column == SizeColumn)
|
||||
return QVariant::fromValue<qlonglong>(world.bytes());
|
||||
return data(index, Qt::DisplayRole);
|
||||
|
||||
case Qt::ToolTipRole: {
|
||||
if (column == InfoColumn) {
|
||||
|
@ -260,6 +260,30 @@ int AccountList::count() const
|
||||
return m_accounts.count();
|
||||
}
|
||||
|
||||
QString getAccountStatus(AccountState status)
|
||||
{
|
||||
switch (status) {
|
||||
case AccountState::Unchecked:
|
||||
return QObject::tr("Unchecked", "Account status");
|
||||
case AccountState::Offline:
|
||||
return QObject::tr("Offline", "Account status");
|
||||
case AccountState::Online:
|
||||
return QObject::tr("Ready", "Account status");
|
||||
case AccountState::Working:
|
||||
return QObject::tr("Working", "Account status");
|
||||
case AccountState::Errored:
|
||||
return QObject::tr("Errored", "Account status");
|
||||
case AccountState::Expired:
|
||||
return QObject::tr("Expired", "Account status");
|
||||
case AccountState::Disabled:
|
||||
return QObject::tr("Disabled", "Account status");
|
||||
case AccountState::Gone:
|
||||
return QObject::tr("Gone", "Account status");
|
||||
default:
|
||||
return QObject::tr("Unknown", "Account status");
|
||||
}
|
||||
}
|
||||
|
||||
QVariant AccountList::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
@ -273,13 +297,10 @@ QVariant AccountList::data(const QModelIndex& index, int role) const
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
switch (index.column()) {
|
||||
case ProfileNameColumn: {
|
||||
case ProfileNameColumn:
|
||||
return account->profileName();
|
||||
}
|
||||
|
||||
case NameColumn:
|
||||
return account->accountDisplayString();
|
||||
|
||||
case TypeColumn: {
|
||||
switch (account->accountType()) {
|
||||
case AccountType::MSA: {
|
||||
@ -291,39 +312,8 @@ QVariant AccountList::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
return tr("Unknown", "Account type");
|
||||
}
|
||||
|
||||
case StatusColumn: {
|
||||
switch (account->accountState()) {
|
||||
case AccountState::Unchecked: {
|
||||
return tr("Unchecked", "Account status");
|
||||
}
|
||||
case AccountState::Offline: {
|
||||
return tr("Offline", "Account status");
|
||||
}
|
||||
case AccountState::Online: {
|
||||
return tr("Ready", "Account status");
|
||||
}
|
||||
case AccountState::Working: {
|
||||
return tr("Working", "Account status");
|
||||
}
|
||||
case AccountState::Errored: {
|
||||
return tr("Errored", "Account status");
|
||||
}
|
||||
case AccountState::Expired: {
|
||||
return tr("Expired", "Account status");
|
||||
}
|
||||
case AccountState::Disabled: {
|
||||
return tr("Disabled", "Account status");
|
||||
}
|
||||
case AccountState::Gone: {
|
||||
return tr("Gone", "Account status");
|
||||
}
|
||||
default: {
|
||||
return tr("Unknown", "Account status");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case StatusColumn:
|
||||
return getAccountStatus(account->accountState());
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -335,11 +325,9 @@ QVariant AccountList::data(const QModelIndex& index, int role) const
|
||||
return QVariant::fromValue(account);
|
||||
|
||||
case Qt::CheckStateRole:
|
||||
if (index.column() == ProfileNameColumn) {
|
||||
if (index.column() == ProfileNameColumn)
|
||||
return account == m_defaultAccount ? Qt::Checked : Qt::Unchecked;
|
||||
} else {
|
||||
return QVariant();
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
default:
|
||||
return QVariant();
|
||||
@ -461,18 +449,14 @@ bool AccountList::loadList()
|
||||
|
||||
// Make sure the format version matches.
|
||||
auto listVersion = root.value("formatVersion").toVariant().toInt();
|
||||
switch (listVersion) {
|
||||
case AccountListVersion::MojangMSA: {
|
||||
return loadV3(root);
|
||||
} break;
|
||||
default: {
|
||||
QString newName = "accounts-old.json";
|
||||
qWarning() << "Unknown format version when loading account list. Existing one will be renamed to" << newName;
|
||||
// Attempt to rename the old version.
|
||||
file.rename(newName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (listVersion == AccountListVersion::MojangMSA)
|
||||
return loadV3(root);
|
||||
|
||||
QString newName = "accounts-old.json";
|
||||
qWarning() << "Unknown format version when loading account list. Existing one will be renamed to" << newName;
|
||||
// Attempt to rename the old version.
|
||||
file.rename(newName);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AccountList::loadV3(QJsonObject& root)
|
||||
|
@ -87,16 +87,12 @@ QVariant GameOptions::data(const QModelIndex& index, int role) const
|
||||
if (row < 0 || row >= int(contents.size()))
|
||||
return QVariant();
|
||||
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
if (column == 0) {
|
||||
return contents[row].key;
|
||||
} else {
|
||||
return contents[row].value;
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (column == 0)
|
||||
return contents[row].key;
|
||||
return contents[row].value;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int GameOptions::rowCount(const QModelIndex&) const
|
||||
|
@ -105,19 +105,16 @@ std::pair<Version, Version> DataPack::compatibleVersions() const
|
||||
int DataPack::compare(const Resource& other, SortType type) const
|
||||
{
|
||||
auto const& cast_other = static_cast<DataPack const&>(other);
|
||||
switch (type) {
|
||||
default:
|
||||
return Resource::compare(other, type);
|
||||
case SortType::PACK_FORMAT: {
|
||||
auto this_ver = packFormat();
|
||||
auto other_ver = cast_other.packFormat();
|
||||
if (type == SortType::PACK_FORMAT) {
|
||||
auto this_ver = packFormat();
|
||||
auto other_ver = cast_other.packFormat();
|
||||
|
||||
if (this_ver > other_ver)
|
||||
return 1;
|
||||
if (this_ver < other_ver)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
if (this_ver > other_ver)
|
||||
return 1;
|
||||
if (this_ver < other_ver)
|
||||
return -1;
|
||||
} else {
|
||||
return Resource::compare(other, type);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -145,12 +145,9 @@ QVariant ModFolderModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
return {};
|
||||
case Qt::CheckStateRole:
|
||||
switch (column) {
|
||||
case ActiveColumn:
|
||||
return at(row).enabled() ? Qt::Checked : Qt::Unchecked;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
if (column == ActiveColumn)
|
||||
return at(row).enabled() ? Qt::Checked : Qt::Unchecked;
|
||||
return QVariant();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -513,12 +513,9 @@ QVariant ResourceFolderModel::data(const QModelIndex& index, int role) const
|
||||
return {};
|
||||
}
|
||||
case Qt::CheckStateRole:
|
||||
switch (column) {
|
||||
case ActiveColumn:
|
||||
return m_resources[row]->enabled() ? Qt::Checked : Qt::Unchecked;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
if (column == ActiveColumn)
|
||||
return m_resources[row]->enabled() ? Qt::Checked : Qt::Unchecked;
|
||||
return {};
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
|
@ -128,12 +128,9 @@ QVariant ResourcePackFolderModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
return {};
|
||||
case Qt::CheckStateRole:
|
||||
switch (column) {
|
||||
case ActiveColumn:
|
||||
return at(row).enabled() ? Qt::Checked : Qt::Unchecked;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
if (column == ActiveColumn)
|
||||
return at(row).enabled() ? Qt::Checked : Qt::Unchecked;
|
||||
return {};
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class UserInteractionSupport {
|
||||
/**
|
||||
* Requests a user interaction to select which optional mods should be installed.
|
||||
*/
|
||||
virtual std::optional<QVector<QString>> chooseOptionalMods(PackVersion version, QVector<ATLauncher::VersionMod> mods) = 0;
|
||||
virtual std::optional<QVector<QString>> chooseOptionalMods(const PackVersion& version, QVector<ATLauncher::VersionMod> mods) = 0;
|
||||
|
||||
/**
|
||||
* Requests a user interaction to select a component version from a given version list
|
||||
|
@ -40,7 +40,7 @@ class PackFetchTask : public QObject {
|
||||
void failed(QString reason);
|
||||
void aborted();
|
||||
|
||||
void privateFileDownloadFinished(Modpack modpack);
|
||||
void privateFileDownloadFinished(const Modpack& modpack);
|
||||
void privateFileDownloadFailed(QString reason, QString packCode);
|
||||
};
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
||||
|
||||
namespace LegacyFTB {
|
||||
|
||||
PackInstallTask::PackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, Modpack pack, QString version)
|
||||
PackInstallTask::PackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, const Modpack& pack, QString version)
|
||||
{
|
||||
m_pack = pack;
|
||||
m_version = version;
|
||||
|
@ -18,7 +18,7 @@ class PackInstallTask : public InstanceTask {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, Modpack pack, QString version);
|
||||
explicit PackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, const Modpack& pack, QString version);
|
||||
virtual ~PackInstallTask() {}
|
||||
|
||||
bool canAbort() const override { return true; }
|
||||
|
@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <SeparatorPrefixTree.h>
|
||||
#include <QRegularExpression>
|
||||
#include "IPathMatcher.h"
|
||||
|
@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include "IPathMatcher.h"
|
||||
|
||||
|
@ -92,7 +92,7 @@ ProgressDialog::~ProgressDialog()
|
||||
{
|
||||
for (auto conn : this->m_taskConnections) {
|
||||
disconnect(conn);
|
||||
}
|
||||
}
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ class ProgressDialog : public QDialog {
|
||||
Ui::ProgressDialog* ui;
|
||||
|
||||
Task* m_task;
|
||||
|
||||
|
||||
QList<QMetaObject::Connection> m_taskConnections;
|
||||
|
||||
bool m_is_multi_step = false;
|
||||
|
@ -282,6 +282,7 @@ auto ResourceUpdateDialog::ensureMetadata() -> bool
|
||||
bool skip_rest = false;
|
||||
ModPlatform::ResourceProvider provider_rest = ModPlatform::ResourceProvider::MODRINTH;
|
||||
|
||||
// adds resource to list based on provider
|
||||
auto addToTmp = [&modrinth_tmp, &flame_tmp](Resource* resource, ModPlatform::ResourceProvider p) {
|
||||
switch (p) {
|
||||
case ModPlatform::ResourceProvider::MODRINTH:
|
||||
@ -293,6 +294,7 @@ auto ResourceUpdateDialog::ensureMetadata() -> bool
|
||||
}
|
||||
};
|
||||
|
||||
// ask the user on what provider to seach for the mod first
|
||||
for (auto candidate : m_candidates) {
|
||||
if (candidate->status() != ResourceStatus::NO_METADATA) {
|
||||
onMetadataEnsured(candidate);
|
||||
@ -335,6 +337,7 @@ auto ResourceUpdateDialog::ensureMetadata() -> bool
|
||||
addToTmp(candidate, response.chosen);
|
||||
}
|
||||
|
||||
// prepare task for the modrinth mods
|
||||
if (!modrinth_tmp.empty()) {
|
||||
auto modrinth_task = makeShared<EnsureMetadataTask>(modrinth_tmp, index_dir, ModPlatform::ResourceProvider::MODRINTH);
|
||||
connect(modrinth_task.get(), &EnsureMetadataTask::metadataReady, [this](Resource* candidate) { onMetadataEnsured(candidate); });
|
||||
@ -350,6 +353,7 @@ auto ResourceUpdateDialog::ensureMetadata() -> bool
|
||||
seq.addTask(modrinth_task);
|
||||
}
|
||||
|
||||
// prepare task for the flame mods
|
||||
if (!flame_tmp.empty()) {
|
||||
auto flame_task = makeShared<EnsureMetadataTask>(flame_tmp, index_dir, ModPlatform::ResourceProvider::FLAME);
|
||||
connect(flame_task.get(), &EnsureMetadataTask::metadataReady, [this](Resource* candidate) { onMetadataEnsured(candidate); });
|
||||
@ -367,6 +371,7 @@ auto ResourceUpdateDialog::ensureMetadata() -> bool
|
||||
|
||||
seq.addTask(m_second_try_metadata);
|
||||
|
||||
// execute all the tasks
|
||||
ProgressDialog checking_dialog(m_parent);
|
||||
checking_dialog.setSkipButton(true, tr("Abort"));
|
||||
checking_dialog.setWindowTitle(tr("Generating metadata..."));
|
||||
@ -477,13 +482,8 @@ void ResourceUpdateDialog::appendResource(CheckUpdateTask::Update const& info, Q
|
||||
auto changelog_area = new QTextBrowser();
|
||||
|
||||
QString text = info.changelog;
|
||||
switch (info.provider) {
|
||||
case ModPlatform::ResourceProvider::MODRINTH: {
|
||||
text = markdownToHTML(info.changelog.toUtf8());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
if (info.provider == ModPlatform::ResourceProvider::MODRINTH) {
|
||||
text = markdownToHTML(info.changelog.toUtf8());
|
||||
}
|
||||
|
||||
changelog_area->setHtml(StringUtils::htmlListPatch(text));
|
||||
|
@ -36,9 +36,9 @@
|
||||
*/
|
||||
|
||||
#include "ServersPage.h"
|
||||
#include "ServerPingTask.h"
|
||||
#include "ui/dialogs/CustomMessageBox.h"
|
||||
#include "ui_ServersPage.h"
|
||||
#include "ServerPingTask.h"
|
||||
|
||||
#include <FileSystem.h>
|
||||
#include <io/stream_reader.h>
|
||||
@ -49,10 +49,10 @@
|
||||
#include <tag_string.h>
|
||||
#include <sstream>
|
||||
|
||||
#include <tasks/ConcurrentTask.h>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QMenu>
|
||||
#include <QTimer>
|
||||
#include <tasks/ConcurrentTask.h>
|
||||
|
||||
static const int COLUMN_COUNT = 3; // 3 , TBD: latency and other nice things.
|
||||
|
||||
@ -113,8 +113,8 @@ struct Server {
|
||||
// Data - temporary
|
||||
bool m_checked = false;
|
||||
bool m_up = false;
|
||||
QString m_motd; // https://mctools.org/motd-creator
|
||||
std::optional<int> m_currentPlayers; // nullopt if not calculated/calculating
|
||||
QString m_motd; // https://mctools.org/motd-creator
|
||||
std::optional<int> m_currentPlayers; // nullopt if not calculated/calculating
|
||||
int m_maxPlayers = 0;
|
||||
};
|
||||
|
||||
@ -317,10 +317,10 @@ class ServersModel : public QAbstractListModel {
|
||||
if (row < 0 || row >= m_servers.size())
|
||||
return QVariant();
|
||||
|
||||
switch (column) {
|
||||
case 0:
|
||||
switch (role) {
|
||||
case Qt::DecorationRole: {
|
||||
switch (role) {
|
||||
case Qt::DecorationRole: {
|
||||
switch (column) {
|
||||
case 0: {
|
||||
auto& bytes = m_servers[row].m_icon;
|
||||
if (bytes.size()) {
|
||||
QPixmap px;
|
||||
@ -329,31 +329,32 @@ class ServersModel : public QAbstractListModel {
|
||||
}
|
||||
return APPLICATION->getThemedIcon("unknown_server");
|
||||
}
|
||||
case Qt::DisplayRole:
|
||||
return m_servers[row].m_name;
|
||||
case ServerPtrRole:
|
||||
return QVariant::fromValue<void*>((void*)&m_servers[row]);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case 1:
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
case 1:
|
||||
return m_servers[row].m_address;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
case 2:
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
case 2:
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (m_servers[row].m_currentPlayers) {
|
||||
return *m_servers[row].m_currentPlayers;
|
||||
} else {
|
||||
return "...";
|
||||
}
|
||||
default:
|
||||
} else {
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
}
|
||||
case Qt::DisplayRole:
|
||||
if (column == 0)
|
||||
return m_servers[row].m_name;
|
||||
else
|
||||
return QVariant();
|
||||
case ServerPtrRole:
|
||||
if (column == 0)
|
||||
return QVariant::fromValue<void*>((void*)&m_servers[row]);
|
||||
else
|
||||
return QVariant();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -447,22 +448,22 @@ class ServersModel : public QAbstractListModel {
|
||||
}
|
||||
|
||||
m_currentQueryTask = ConcurrentTask::Ptr(
|
||||
new ConcurrentTask("Query servers status", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt())
|
||||
);
|
||||
new ConcurrentTask("Query servers status", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt()));
|
||||
int row = 0;
|
||||
for (Server &server : m_servers) {
|
||||
for (Server& server : m_servers) {
|
||||
// reset current players
|
||||
server.m_currentPlayers = {};
|
||||
emit dataChanged(index(row, 0), index(row, COLUMN_COUNT - 1));
|
||||
|
||||
// Start task to query server status
|
||||
auto target = MinecraftTarget::parse(server.m_address, false);
|
||||
auto *task = new ServerPingTask(target.address, target.port);
|
||||
auto* task = new ServerPingTask(target.address, target.port);
|
||||
m_currentQueryTask->addTask(Task::Ptr(task));
|
||||
|
||||
// Update the model when the task is done
|
||||
connect(task, &Task::finished, this, [this, task, row]() {
|
||||
if (m_servers.size() < row) return;
|
||||
if (m_servers.size() < row)
|
||||
return;
|
||||
m_servers[row].m_currentPlayers = task->m_outputOnlinePlayers;
|
||||
emit dataChanged(index(row, 0), index(row, COLUMN_COUNT - 1));
|
||||
});
|
||||
@ -717,7 +718,7 @@ void ServersPage::openedImpl()
|
||||
|
||||
ui->toolBar->setVisibilityState(m_wide_bar_setting->get().toByteArray());
|
||||
|
||||
// ping servers
|
||||
// ping servers
|
||||
m_model->queryServersStatus();
|
||||
}
|
||||
|
||||
|
@ -166,12 +166,9 @@ void WorldListPage::retranslate()
|
||||
|
||||
bool WorldListPage::worldListFilter(QKeyEvent* keyEvent)
|
||||
{
|
||||
switch (keyEvent->key()) {
|
||||
case Qt::Key_Delete:
|
||||
on_actionRemove_triggered();
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
if (keyEvent->key() == Qt::Key_Delete) {
|
||||
on_actionRemove_triggered();
|
||||
return true;
|
||||
}
|
||||
return QWidget::eventFilter(ui->worldTreeView, keyEvent);
|
||||
}
|
||||
|
@ -45,7 +45,9 @@
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
|
||||
AtlOptionalModListModel::AtlOptionalModListModel(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
|
||||
AtlOptionalModListModel::AtlOptionalModListModel(QWidget* parent,
|
||||
const ATLauncher::PackVersion& version,
|
||||
QVector<ATLauncher::VersionMod> mods)
|
||||
: QAbstractListModel(parent), m_version(version), m_mods(mods)
|
||||
{
|
||||
// fill mod index
|
||||
@ -233,7 +235,7 @@ void AtlOptionalModListModel::clearAll()
|
||||
emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn), AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
|
||||
}
|
||||
|
||||
void AtlOptionalModListModel::toggleMod(ATLauncher::VersionMod mod, int index)
|
||||
void AtlOptionalModListModel::toggleMod(const ATLauncher::VersionMod& mod, int index)
|
||||
{
|
||||
auto enable = !m_selection[mod.name];
|
||||
|
||||
@ -251,7 +253,7 @@ void AtlOptionalModListModel::toggleMod(ATLauncher::VersionMod mod, int index)
|
||||
setMod(mod, index, enable);
|
||||
}
|
||||
|
||||
void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool enable, bool shouldEmit)
|
||||
void AtlOptionalModListModel::setMod(const ATLauncher::VersionMod& mod, int index, bool enable, bool shouldEmit)
|
||||
{
|
||||
if (m_selection[mod.name] == enable)
|
||||
return;
|
||||
@ -313,7 +315,7 @@ void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool
|
||||
}
|
||||
}
|
||||
|
||||
AtlOptionalModDialog::AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
|
||||
AtlOptionalModDialog::AtlOptionalModDialog(QWidget* parent, const ATLauncher::PackVersion& version, QVector<ATLauncher::VersionMod> mods)
|
||||
: QDialog(parent), ui(new Ui::AtlOptionalModDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -55,7 +55,7 @@ class AtlOptionalModListModel : public QAbstractListModel {
|
||||
DescriptionColumn,
|
||||
};
|
||||
|
||||
AtlOptionalModListModel(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
|
||||
AtlOptionalModListModel(QWidget* parent, const ATLauncher::PackVersion& version, QVector<ATLauncher::VersionMod> mods);
|
||||
|
||||
QVector<QString> getResult();
|
||||
|
||||
@ -78,8 +78,8 @@ class AtlOptionalModListModel : public QAbstractListModel {
|
||||
void clearAll();
|
||||
|
||||
private:
|
||||
void toggleMod(ATLauncher::VersionMod mod, int index);
|
||||
void setMod(ATLauncher::VersionMod mod, int index, bool enable, bool shouldEmit = true);
|
||||
void toggleMod(const ATLauncher::VersionMod& mod, int index);
|
||||
void setMod(const ATLauncher::VersionMod& mod, int index, bool enable, bool shouldEmit = true);
|
||||
|
||||
private:
|
||||
NetJob::Ptr m_jobPtr;
|
||||
@ -97,7 +97,7 @@ class AtlOptionalModDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
|
||||
AtlOptionalModDialog(QWidget* parent, const ATLauncher::PackVersion& version, QVector<ATLauncher::VersionMod> mods);
|
||||
~AtlOptionalModDialog() override;
|
||||
|
||||
QVector<QString> getResult() { return listModel->getResult(); }
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
AtlUserInteractionSupportImpl::AtlUserInteractionSupportImpl(QWidget* parent) : m_parent(parent) {}
|
||||
|
||||
std::optional<QVector<QString>> AtlUserInteractionSupportImpl::chooseOptionalMods(ATLauncher::PackVersion version,
|
||||
std::optional<QVector<QString>> AtlUserInteractionSupportImpl::chooseOptionalMods(const ATLauncher::PackVersion& version,
|
||||
QVector<ATLauncher::VersionMod> mods)
|
||||
{
|
||||
AtlOptionalModDialog optionalModDialog(m_parent, version, mods);
|
||||
|
@ -48,7 +48,8 @@ class AtlUserInteractionSupportImpl : public QObject, public ATLauncher::UserInt
|
||||
|
||||
private:
|
||||
QString chooseVersion(Meta::VersionList::Ptr vlist, QString minecraftVersion) override;
|
||||
std::optional<QVector<QString>> chooseOptionalMods(ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods) override;
|
||||
std::optional<QVector<QString>> chooseOptionalMods(const ATLauncher::PackVersion& version,
|
||||
QVector<ATLauncher::VersionMod> mods) override;
|
||||
void displayMessage(QString message) override;
|
||||
|
||||
private:
|
||||
|
@ -106,9 +106,6 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
|
||||
auto pack = m_modpacks.at(pos);
|
||||
if (role == Qt::ToolTipRole) {
|
||||
}
|
||||
|
||||
switch (role) {
|
||||
case Qt::ToolTipRole:
|
||||
return tr("Minecraft %1").arg(pack.mcVersion);
|
||||
|
@ -213,7 +213,7 @@ void ListModel::fill(ModpackList modpacks_)
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void ListModel::addPack(Modpack modpack)
|
||||
void ListModel::addPack(const Modpack& modpack)
|
||||
{
|
||||
beginResetModel();
|
||||
this->modpacks.append(modpack);
|
||||
|
@ -62,7 +62,7 @@ class ListModel : public QAbstractListModel {
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
void fill(ModpackList modpacks);
|
||||
void addPack(Modpack modpack);
|
||||
void addPack(const Modpack& modpack);
|
||||
void clear();
|
||||
void remove(int row);
|
||||
|
||||
|
@ -213,7 +213,7 @@ void Page::ftbPackDataDownloadAborted()
|
||||
CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)->show();
|
||||
}
|
||||
|
||||
void Page::ftbPrivatePackDataDownloadSuccessfully(Modpack pack)
|
||||
void Page::ftbPrivatePackDataDownloadSuccessfully(const Modpack& pack)
|
||||
{
|
||||
privateListModel->addPack(pack);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class Page : public QWidget, public ModpackProviderBasePage {
|
||||
void ftbPackDataDownloadFailed(QString reason);
|
||||
void ftbPackDataDownloadAborted();
|
||||
|
||||
void ftbPrivatePackDataDownloadSuccessfully(Modpack pack);
|
||||
void ftbPrivatePackDataDownloadSuccessfully(const Modpack& pack);
|
||||
void ftbPrivatePackDataDownloadFailed(QString reason, QString packCode);
|
||||
|
||||
void onSortingSelectionChanged(QString data);
|
||||
|
@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
class FocusLineEdit : public QLineEdit {
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTest>
|
||||
#include <memory>
|
||||
|
||||
#include <tasks/Task.h>
|
||||
|
||||
@ -42,7 +43,7 @@ class LinkTask : public Task {
|
||||
|
||||
~LinkTask() { delete m_lnk; }
|
||||
|
||||
void matcher(const IPathMatcher* filter) { m_lnk->matcher(filter); }
|
||||
void matcher(IPathMatcher::Ptr filter) { m_lnk->matcher(filter); }
|
||||
|
||||
void linkRecursively(bool recursive)
|
||||
{
|
||||
@ -203,8 +204,8 @@ class FileSystemTest : public QObject {
|
||||
qDebug() << tempDir.path();
|
||||
qDebug() << target_dir.path();
|
||||
FS::copy c(folder, target_dir.path());
|
||||
RegexpMatcher re("[.]?mcmeta");
|
||||
c.matcher(&re);
|
||||
RegexpMatcher::Ptr re = std::make_shared<RegexpMatcher>("[.]?mcmeta");
|
||||
c.matcher(re);
|
||||
c();
|
||||
|
||||
for (auto entry : target_dir.entryList()) {
|
||||
@ -236,8 +237,8 @@ class FileSystemTest : public QObject {
|
||||
qDebug() << tempDir.path();
|
||||
qDebug() << target_dir.path();
|
||||
FS::copy c(folder, target_dir.path());
|
||||
RegexpMatcher re("[.]?mcmeta");
|
||||
c.matcher(&re);
|
||||
RegexpMatcher::Ptr re = std::make_shared<RegexpMatcher>("[.]?mcmeta");
|
||||
c.matcher(re);
|
||||
c.whitelist(true);
|
||||
c();
|
||||
|
||||
@ -429,8 +430,8 @@ class FileSystemTest : public QObject {
|
||||
qDebug() << target_dir.path();
|
||||
|
||||
LinkTask lnk_tsk(folder, target_dir.path());
|
||||
RegexpMatcher re("[.]?mcmeta");
|
||||
lnk_tsk.matcher(&re);
|
||||
RegexpMatcher::Ptr re = std::make_shared<RegexpMatcher>("[.]?mcmeta");
|
||||
lnk_tsk.matcher(re);
|
||||
lnk_tsk.linkRecursively(true);
|
||||
QObject::connect(&lnk_tsk, &Task::finished, [&lnk_tsk] {
|
||||
QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been.");
|
||||
@ -476,8 +477,8 @@ class FileSystemTest : public QObject {
|
||||
qDebug() << target_dir.path();
|
||||
|
||||
LinkTask lnk_tsk(folder, target_dir.path());
|
||||
RegexpMatcher re("[.]?mcmeta");
|
||||
lnk_tsk.matcher(&re);
|
||||
RegexpMatcher::Ptr re = std::make_shared<RegexpMatcher>("[.]?mcmeta");
|
||||
lnk_tsk.matcher(re);
|
||||
lnk_tsk.linkRecursively(true);
|
||||
lnk_tsk.whitelist(true);
|
||||
QObject::connect(&lnk_tsk, &Task::finished, [&lnk_tsk] {
|
||||
|
Loading…
x
Reference in New Issue
Block a user