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