Moving files around
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
6c5bb3817b
commit
3c58fb0677
@ -110,7 +110,7 @@ QHash<int, QByteArray> BaseVersionList::roleNames() const
|
|||||||
roles.insert(TypeRole, "type");
|
roles.insert(TypeRole, "type");
|
||||||
roles.insert(BranchRole, "branch");
|
roles.insert(BranchRole, "branch");
|
||||||
roles.insert(PathRole, "path");
|
roles.insert(PathRole, "path");
|
||||||
roles.insert(AliasRole, "alias");
|
roles.insert(JavaNameRole, "javaName");
|
||||||
roles.insert(ArchitectureRole, "architecture");
|
roles.insert(CPUArchitectureRole, "architecture");
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,8 @@ class BaseVersionList : public QAbstractListModel {
|
|||||||
TypeRole,
|
TypeRole,
|
||||||
BranchRole,
|
BranchRole,
|
||||||
PathRole,
|
PathRole,
|
||||||
AliasRole,
|
JavaNameRole,
|
||||||
ArchitectureRole,
|
CPUArchitectureRole,
|
||||||
SortRole
|
SortRole
|
||||||
};
|
};
|
||||||
using RoleList = QList<int>;
|
using RoleList = QList<int>;
|
||||||
|
@ -431,17 +431,17 @@ set(JAVA_SOURCES
|
|||||||
java/JavaVersion.h
|
java/JavaVersion.h
|
||||||
java/JavaVersion.cpp
|
java/JavaVersion.cpp
|
||||||
|
|
||||||
java/JavaRuntime.h
|
java/JavaMetadata.h
|
||||||
java/JavaRuntime.cpp
|
java/JavaMetadata.cpp
|
||||||
java/download/ArchiveJavaDownloader.cpp
|
java/download/ArchiveDownloadTask.cpp
|
||||||
java/download/ArchiveJavaDownloader.h
|
java/download/ArchiveDownloadTask.h
|
||||||
java/download/ManifestJavaDownloader.cpp
|
java/download/ManifestDownloadTask.cpp
|
||||||
java/download/ManifestJavaDownloader.h
|
java/download/ManifestDownloadTask.h
|
||||||
|
|
||||||
ui/java/JavaDownload.h
|
ui/java/JavaDownloader.h
|
||||||
ui/java/JavaDownload.cpp
|
ui/java/JavaDownloader.cpp
|
||||||
ui/java/ListModel.h
|
ui/java/VersionList.h
|
||||||
ui/java/ListModel.cpp
|
ui/java/VersionList.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(TRANSLATIONS_SOURCES
|
set(TRANSLATIONS_SOURCES
|
||||||
@ -1192,7 +1192,7 @@ qt_wrap_ui(LAUNCHER_UI
|
|||||||
ui/dialogs/ScrollMessageBox.ui
|
ui/dialogs/ScrollMessageBox.ui
|
||||||
ui/dialogs/BlockedModsDialog.ui
|
ui/dialogs/BlockedModsDialog.ui
|
||||||
ui/dialogs/ChooseProviderDialog.ui
|
ui/dialogs/ChooseProviderDialog.ui
|
||||||
ui/java/JavaDownload.ui
|
ui/java/JavaDownloader.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
qt_wrap_ui(PRISM_UPDATE_UI
|
qt_wrap_ui(PRISM_UPDATE_UI
|
||||||
|
@ -114,12 +114,12 @@ QVariant VersionProxyModel::headerData(int section, Qt::Orientation orientation,
|
|||||||
return tr("Branch");
|
return tr("Branch");
|
||||||
case Type:
|
case Type:
|
||||||
return tr("Type");
|
return tr("Type");
|
||||||
case Architecture:
|
case CPUArchitecture:
|
||||||
return tr("Architecture");
|
return tr("Architecture");
|
||||||
case Path:
|
case Path:
|
||||||
return tr("Path");
|
return tr("Path");
|
||||||
case Alias:
|
case JavaName:
|
||||||
return tr("Alias");
|
return tr("Java Name");
|
||||||
case Time:
|
case Time:
|
||||||
return tr("Released");
|
return tr("Released");
|
||||||
}
|
}
|
||||||
@ -133,11 +133,11 @@ QVariant VersionProxyModel::headerData(int section, Qt::Orientation orientation,
|
|||||||
return tr("The version's branch");
|
return tr("The version's branch");
|
||||||
case Type:
|
case Type:
|
||||||
return tr("The version's type");
|
return tr("The version's type");
|
||||||
case Architecture:
|
case CPUArchitecture:
|
||||||
return tr("CPU Architecture");
|
return tr("CPU Architecture");
|
||||||
case Path:
|
case Path:
|
||||||
return tr("Filesystem path to this version");
|
return tr("Filesystem path to this version");
|
||||||
case Alias:
|
case JavaName:
|
||||||
return tr("The alternative name of the java version");
|
return tr("The alternative name of the java version");
|
||||||
case Time:
|
case Time:
|
||||||
return tr("Release date of this version");
|
return tr("Release date of this version");
|
||||||
@ -169,12 +169,12 @@ QVariant VersionProxyModel::data(const QModelIndex& index, int role) const
|
|||||||
return sourceModel()->data(parentIndex, BaseVersionList::BranchRole);
|
return sourceModel()->data(parentIndex, BaseVersionList::BranchRole);
|
||||||
case Type:
|
case Type:
|
||||||
return sourceModel()->data(parentIndex, BaseVersionList::TypeRole);
|
return sourceModel()->data(parentIndex, BaseVersionList::TypeRole);
|
||||||
case Architecture:
|
case CPUArchitecture:
|
||||||
return sourceModel()->data(parentIndex, BaseVersionList::ArchitectureRole);
|
return sourceModel()->data(parentIndex, BaseVersionList::CPUArchitectureRole);
|
||||||
case Path:
|
case Path:
|
||||||
return sourceModel()->data(parentIndex, BaseVersionList::PathRole);
|
return sourceModel()->data(parentIndex, BaseVersionList::PathRole);
|
||||||
case Alias:
|
case JavaName:
|
||||||
return sourceModel()->data(parentIndex, BaseVersionList::AliasRole);
|
return sourceModel()->data(parentIndex, BaseVersionList::JavaNameRole);
|
||||||
case Time:
|
case Time:
|
||||||
return sourceModel()->data(parentIndex, Meta::VersionList::TimeRole).toDate();
|
return sourceModel()->data(parentIndex, Meta::VersionList::TimeRole).toDate();
|
||||||
default:
|
default:
|
||||||
@ -314,14 +314,14 @@ void VersionProxyModel::setSourceModel(QAbstractItemModel* replacingRaw)
|
|||||||
m_columns.push_back(ParentVersion);
|
m_columns.push_back(ParentVersion);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (roles.contains(BaseVersionList::ArchitectureRole)) {
|
if (roles.contains(BaseVersionList::CPUArchitectureRole)) {
|
||||||
m_columns.push_back(Architecture);
|
m_columns.push_back(CPUArchitecture);
|
||||||
}
|
}
|
||||||
if (roles.contains(BaseVersionList::PathRole)) {
|
if (roles.contains(BaseVersionList::PathRole)) {
|
||||||
m_columns.push_back(Path);
|
m_columns.push_back(Path);
|
||||||
}
|
}
|
||||||
if (roles.contains(BaseVersionList::AliasRole)) {
|
if (roles.contains(BaseVersionList::JavaNameRole)) {
|
||||||
m_columns.push_back(Alias);
|
m_columns.push_back(JavaName);
|
||||||
}
|
}
|
||||||
if (roles.contains(Meta::VersionList::TimeRole)) {
|
if (roles.contains(Meta::VersionList::TimeRole)) {
|
||||||
m_columns.push_back(Time);
|
m_columns.push_back(Time);
|
||||||
|
@ -9,7 +9,7 @@ class VersionFilterModel;
|
|||||||
class VersionProxyModel : public QAbstractProxyModel {
|
class VersionProxyModel : public QAbstractProxyModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum Column { Name, ParentVersion, Branch, Type, Architecture, Path, Time, Alias };
|
enum Column { Name, ParentVersion, Branch, Type, CPUArchitecture, Path, Time, JavaName };
|
||||||
using FilterMap = QHash<BaseVersionList::ModelRoles, std::shared_ptr<Filter>>;
|
using FilterMap = QHash<BaseVersionList::ModelRoles, std::shared_ptr<Filter>>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -108,7 +108,7 @@ QVariant JavaInstallList::data(const QModelIndex& index, int role) const
|
|||||||
return version->recommended;
|
return version->recommended;
|
||||||
case PathRole:
|
case PathRole:
|
||||||
return version->path;
|
return version->path;
|
||||||
case ArchitectureRole:
|
case CPUArchitectureRole:
|
||||||
return version->arch;
|
return version->arch;
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -117,7 +117,7 @@ QVariant JavaInstallList::data(const QModelIndex& index, int role) const
|
|||||||
|
|
||||||
BaseVersionList::RoleList JavaInstallList::providesRoles() const
|
BaseVersionList::RoleList JavaInstallList::providesRoles() const
|
||||||
{
|
{
|
||||||
return { VersionPointerRole, VersionIdRole, VersionRole, RecommendedRole, PathRole, ArchitectureRole };
|
return { VersionPointerRole, VersionIdRole, VersionRole, RecommendedRole, PathRole, CPUArchitectureRole };
|
||||||
}
|
}
|
||||||
|
|
||||||
void JavaInstallList::updateListData(QList<BaseVersion::Ptr> versions)
|
void JavaInstallList::updateListData(QList<BaseVersion::Ptr> versions)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "java/JavaRuntime.h"
|
#include "java/JavaMetadata.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -25,7 +25,7 @@
|
|||||||
#include "java/JavaVersion.h"
|
#include "java/JavaVersion.h"
|
||||||
#include "minecraft/ParseUtils.h"
|
#include "minecraft/ParseUtils.h"
|
||||||
|
|
||||||
namespace JavaRuntime {
|
namespace Java {
|
||||||
|
|
||||||
DownloadType parseDownloadType(QString javaDownload)
|
DownloadType parseDownloadType(QString javaDownload)
|
||||||
{
|
{
|
||||||
@ -44,9 +44,9 @@ QString downloadTypeToString(DownloadType javaDownload)
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
MetaPtr parseJavaMeta(const QJsonObject& in)
|
MetadataPtr parseJavaMeta(const QJsonObject& in)
|
||||||
{
|
{
|
||||||
auto meta = std::make_shared<Meta>();
|
auto meta = std::make_shared<Metadata>();
|
||||||
|
|
||||||
meta->m_name = Json::ensureString(in, "name", "");
|
meta->m_name = Json::ensureString(in, "name", "");
|
||||||
meta->vendor = Json::ensureString(in, "vendor", "");
|
meta->vendor = Json::ensureString(in, "vendor", "");
|
||||||
@ -74,7 +74,7 @@ MetaPtr parseJavaMeta(const QJsonObject& in)
|
|||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Meta::operator<(const Meta& rhs)
|
bool Metadata::operator<(const Metadata& rhs)
|
||||||
{
|
{
|
||||||
auto id = version;
|
auto id = version;
|
||||||
if (id < rhs.version) {
|
if (id < rhs.version) {
|
||||||
@ -86,32 +86,32 @@ bool Meta::operator<(const Meta& rhs)
|
|||||||
return StringUtils::naturalCompare(m_name, rhs.m_name, Qt::CaseInsensitive) < 0;
|
return StringUtils::naturalCompare(m_name, rhs.m_name, Qt::CaseInsensitive) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Meta::operator==(const Meta& rhs)
|
bool Metadata::operator==(const Metadata& rhs)
|
||||||
{
|
{
|
||||||
return version == rhs.version && m_name == rhs.m_name;
|
return version == rhs.version && m_name == rhs.m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Meta::operator>(const Meta& rhs)
|
bool Metadata::operator>(const Metadata& rhs)
|
||||||
{
|
{
|
||||||
return (!operator<(rhs)) && (!operator==(rhs));
|
return (!operator<(rhs)) && (!operator==(rhs));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Meta::operator<(BaseVersion& a)
|
bool Metadata::operator<(BaseVersion& a)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return operator<(dynamic_cast<Meta&>(a));
|
return operator<(dynamic_cast<Metadata&>(a));
|
||||||
} catch (const std::bad_cast& e) {
|
} catch (const std::bad_cast& e) {
|
||||||
return BaseVersion::operator<(a);
|
return BaseVersion::operator<(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Meta::operator>(BaseVersion& a)
|
bool Metadata::operator>(BaseVersion& a)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return operator>(dynamic_cast<Meta&>(a));
|
return operator>(dynamic_cast<Metadata&>(a));
|
||||||
} catch (const std::bad_cast& e) {
|
} catch (const std::bad_cast& e) {
|
||||||
return BaseVersion::operator>(a);
|
return BaseVersion::operator>(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace JavaRuntime
|
} // namespace Java
|
@ -26,11 +26,11 @@
|
|||||||
#include "BaseVersion.h"
|
#include "BaseVersion.h"
|
||||||
#include "java/JavaVersion.h"
|
#include "java/JavaVersion.h"
|
||||||
|
|
||||||
namespace JavaRuntime {
|
namespace Java {
|
||||||
|
|
||||||
enum class DownloadType { Manifest, Archive };
|
enum class DownloadType { Manifest, Archive };
|
||||||
|
|
||||||
class Meta : public BaseVersion {
|
class Metadata : public BaseVersion {
|
||||||
public:
|
public:
|
||||||
virtual QString descriptor() override { return version.toString(); }
|
virtual QString descriptor() override { return version.toString(); }
|
||||||
|
|
||||||
@ -40,9 +40,9 @@ class Meta : public BaseVersion {
|
|||||||
|
|
||||||
virtual bool operator<(BaseVersion& a) override;
|
virtual bool operator<(BaseVersion& a) override;
|
||||||
virtual bool operator>(BaseVersion& a) override;
|
virtual bool operator>(BaseVersion& a) override;
|
||||||
bool operator<(const Meta& rhs);
|
bool operator<(const Metadata& rhs);
|
||||||
bool operator==(const Meta& rhs);
|
bool operator==(const Metadata& rhs);
|
||||||
bool operator>(const Meta& rhs);
|
bool operator>(const Metadata& rhs);
|
||||||
|
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString vendor;
|
QString vendor;
|
||||||
@ -55,10 +55,10 @@ class Meta : public BaseVersion {
|
|||||||
QString packageType;
|
QString packageType;
|
||||||
JavaVersion version;
|
JavaVersion version;
|
||||||
};
|
};
|
||||||
using MetaPtr = std::shared_ptr<Meta>;
|
using MetadataPtr = std::shared_ptr<Metadata>;
|
||||||
|
|
||||||
DownloadType parseDownloadType(QString javaDownload);
|
DownloadType parseDownloadType(QString javaDownload);
|
||||||
QString downloadTypeToString(DownloadType javaDownload);
|
QString downloadTypeToString(DownloadType javaDownload);
|
||||||
MetaPtr parseJavaMeta(const QJsonObject& libObj);
|
MetadataPtr parseJavaMeta(const QJsonObject& libObj);
|
||||||
|
|
||||||
} // namespace JavaRuntime
|
} // namespace Java
|
@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "java/download/ArchiveJavaDownloader.h"
|
#include "java/download/ArchiveDownloadTask.h"
|
||||||
#include <quazip.h>
|
#include <quazip.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "MMCZip.h"
|
#include "MMCZip.h"
|
||||||
@ -25,11 +25,12 @@
|
|||||||
#include "net/NetJob.h"
|
#include "net/NetJob.h"
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
ArchiveJavaDownloader::ArchiveJavaDownloader(QUrl url, QString final_path, QString checksumType, QString checksumHash)
|
namespace Java {
|
||||||
|
ArchiveDownloadTask::ArchiveDownloadTask(QUrl url, QString final_path, QString checksumType, QString checksumHash)
|
||||||
: m_url(url), m_final_path(final_path), m_checksum_type(checksumType), m_checksum_hash(checksumHash)
|
: m_url(url), m_final_path(final_path), m_checksum_type(checksumType), m_checksum_hash(checksumHash)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void ArchiveJavaDownloader::executeTask()
|
void ArchiveDownloadTask::executeTask()
|
||||||
{
|
{
|
||||||
// JRE found ! download the zip
|
// JRE found ! download the zip
|
||||||
setStatus(tr("Downloading Java"));
|
setStatus(tr("Downloading Java"));
|
||||||
@ -49,8 +50,8 @@ void ArchiveJavaDownloader::executeTask()
|
|||||||
auto fullPath = entry->getFullPath();
|
auto fullPath = entry->getFullPath();
|
||||||
|
|
||||||
connect(download.get(), &NetJob::finished, [download, this] { disconnect(this, &Task::aborted, download.get(), &NetJob::abort); });
|
connect(download.get(), &NetJob::finished, [download, this] { disconnect(this, &Task::aborted, download.get(), &NetJob::abort); });
|
||||||
connect(download.get(), &NetJob::progress, this, &ArchiveJavaDownloader::progress);
|
connect(download.get(), &NetJob::progress, this, &ArchiveDownloadTask::progress);
|
||||||
connect(download.get(), &NetJob::failed, this, &ArchiveJavaDownloader::emitFailed);
|
connect(download.get(), &NetJob::failed, this, &ArchiveDownloadTask::emitFailed);
|
||||||
connect(this, &Task::aborted, download.get(), &NetJob::abort);
|
connect(this, &Task::aborted, download.get(), &NetJob::abort);
|
||||||
connect(download.get(), &NetJob::succeeded, [this, fullPath] {
|
connect(download.get(), &NetJob::succeeded, [this, fullPath] {
|
||||||
// This should do all of the extracting and creating folders
|
// This should do all of the extracting and creating folders
|
||||||
@ -59,7 +60,7 @@ void ArchiveJavaDownloader::executeTask()
|
|||||||
download->start();
|
download->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchiveJavaDownloader::extractJava(QString input)
|
void ArchiveDownloadTask::extractJava(QString input)
|
||||||
{
|
{
|
||||||
setStatus(tr("Extracting java"));
|
setStatus(tr("Extracting java"));
|
||||||
auto zip = std::make_shared<QuaZip>(input);
|
auto zip = std::make_shared<QuaZip>(input);
|
||||||
@ -79,14 +80,14 @@ void ArchiveJavaDownloader::extractJava(QString input)
|
|||||||
connect(this, &Task::aborted, zipTask.get(), &Task::abort);
|
connect(this, &Task::aborted, zipTask.get(), &Task::abort);
|
||||||
connect(zipTask.get(), &Task::finished, [zipTask, this] { disconnect(this, &Task::aborted, zipTask.get(), &Task::abort); });
|
connect(zipTask.get(), &Task::finished, [zipTask, this] { disconnect(this, &Task::aborted, zipTask.get(), &Task::abort); });
|
||||||
|
|
||||||
connect(zipTask.get(), &Task::succeeded, this, &ArchiveJavaDownloader::emitSucceeded);
|
connect(zipTask.get(), &Task::succeeded, this, &ArchiveDownloadTask::emitSucceeded);
|
||||||
connect(zipTask.get(), &Task::aborted, this, &ArchiveJavaDownloader::emitAborted);
|
connect(zipTask.get(), &Task::aborted, this, &ArchiveDownloadTask::emitAborted);
|
||||||
connect(zipTask.get(), &Task::failed, this, [this, progressStep](QString reason) {
|
connect(zipTask.get(), &Task::failed, this, [this, progressStep](QString reason) {
|
||||||
progressStep->state = TaskStepState::Failed;
|
progressStep->state = TaskStepState::Failed;
|
||||||
stepProgress(*progressStep);
|
stepProgress(*progressStep);
|
||||||
emitFailed(reason);
|
emitFailed(reason);
|
||||||
});
|
});
|
||||||
connect(zipTask.get(), &Task::stepProgress, this, &ArchiveJavaDownloader::propagateStepProgress);
|
connect(zipTask.get(), &Task::stepProgress, this, &ArchiveDownloadTask::propagateStepProgress);
|
||||||
|
|
||||||
connect(zipTask.get(), &Task::progress, this, [this, progressStep](qint64 current, qint64 total) {
|
connect(zipTask.get(), &Task::progress, this, [this, progressStep](qint64 current, qint64 total) {
|
||||||
progressStep->update(current, total);
|
progressStep->update(current, total);
|
||||||
@ -98,3 +99,4 @@ void ArchiveJavaDownloader::extractJava(QString input)
|
|||||||
});
|
});
|
||||||
zipTask->start();
|
zipTask->start();
|
||||||
}
|
}
|
||||||
|
} // namespace Java
|
@ -21,11 +21,12 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
class ArchiveJavaDownloader : public Task {
|
namespace Java {
|
||||||
|
class ArchiveDownloadTask : public Task {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ArchiveJavaDownloader(QUrl url, QString final_path, QString checksumType = "", QString checksumHash = "");
|
ArchiveDownloadTask(QUrl url, QString final_path, QString checksumType = "", QString checksumHash = "");
|
||||||
virtual ~ArchiveJavaDownloader() = default;
|
virtual ~ArchiveDownloadTask() = default;
|
||||||
|
|
||||||
[[nodiscard]] bool canAbort() const override { return true; }
|
[[nodiscard]] bool canAbort() const override { return true; }
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
@ -38,6 +39,5 @@ class ArchiveJavaDownloader : public Task {
|
|||||||
QString m_final_path;
|
QString m_final_path;
|
||||||
QString m_checksum_type;
|
QString m_checksum_type;
|
||||||
QString m_checksum_hash;
|
QString m_checksum_hash;
|
||||||
|
|
||||||
Task::Ptr m_current_task;
|
|
||||||
};
|
};
|
||||||
|
} // namespace Java
|
@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "java/download/ManifestJavaDownloader.h"
|
#include "java/download/ManifestDownloadTask.h"
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
@ -30,11 +30,12 @@ struct File {
|
|||||||
bool isExec;
|
bool isExec;
|
||||||
};
|
};
|
||||||
|
|
||||||
ManifestJavaDownloader::ManifestJavaDownloader(QUrl url, QString final_path, QString checksumType, QString checksumHash)
|
namespace Java {
|
||||||
|
ManifestDownloadTask::ManifestDownloadTask(QUrl url, QString final_path, QString checksumType, QString checksumHash)
|
||||||
: m_url(url), m_final_path(final_path), m_checksum_type(checksumType), m_checksum_hash(checksumHash)
|
: m_url(url), m_final_path(final_path), m_checksum_type(checksumType), m_checksum_hash(checksumHash)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void ManifestJavaDownloader::executeTask()
|
void ManifestDownloadTask::executeTask()
|
||||||
{
|
{
|
||||||
setStatus(tr("Downloading Java"));
|
setStatus(tr("Downloading Java"));
|
||||||
auto download = makeShared<NetJob>(QString("JRE::DownloadJava"), APPLICATION->network());
|
auto download = makeShared<NetJob>(QString("JRE::DownloadJava"), APPLICATION->network());
|
||||||
@ -51,8 +52,8 @@ void ManifestJavaDownloader::executeTask()
|
|||||||
download->addNetAction(action);
|
download->addNetAction(action);
|
||||||
|
|
||||||
connect(download.get(), &NetJob::finished, [download, this] { disconnect(this, &Task::aborted, download.get(), &NetJob::abort); });
|
connect(download.get(), &NetJob::finished, [download, this] { disconnect(this, &Task::aborted, download.get(), &NetJob::abort); });
|
||||||
connect(download.get(), &NetJob::progress, this, &ManifestJavaDownloader::progress);
|
connect(download.get(), &NetJob::progress, this, &ManifestDownloadTask::progress);
|
||||||
connect(download.get(), &NetJob::failed, this, &ManifestJavaDownloader::emitFailed);
|
connect(download.get(), &NetJob::failed, this, &ManifestDownloadTask::emitFailed);
|
||||||
connect(this, &Task::aborted, download.get(), &NetJob::abort);
|
connect(this, &Task::aborted, download.get(), &NetJob::abort);
|
||||||
|
|
||||||
connect(download.get(), &NetJob::succeeded, [files, this] {
|
connect(download.get(), &NetJob::succeeded, [files, this] {
|
||||||
@ -69,7 +70,7 @@ void ManifestJavaDownloader::executeTask()
|
|||||||
download->start();
|
download->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManifestJavaDownloader::downloadJava(const QJsonDocument& doc)
|
void ManifestDownloadTask::downloadJava(const QJsonDocument& doc)
|
||||||
{
|
{
|
||||||
// valid json doc, begin making jre spot
|
// valid json doc, begin making jre spot
|
||||||
FS::ensureFolderPathExists(m_final_path);
|
FS::ensureFolderPathExists(m_final_path);
|
||||||
@ -116,10 +117,11 @@ void ManifestJavaDownloader::downloadJava(const QJsonDocument& doc)
|
|||||||
disconnect(this, &Task::aborted, elementDownload, &NetJob::abort);
|
disconnect(this, &Task::aborted, elementDownload, &NetJob::abort);
|
||||||
elementDownload->deleteLater();
|
elementDownload->deleteLater();
|
||||||
});
|
});
|
||||||
connect(elementDownload, &NetJob::progress, this, &ManifestJavaDownloader::progress);
|
connect(elementDownload, &NetJob::progress, this, &ManifestDownloadTask::progress);
|
||||||
connect(elementDownload, &NetJob::failed, this, &ManifestJavaDownloader::emitFailed);
|
connect(elementDownload, &NetJob::failed, this, &ManifestDownloadTask::emitFailed);
|
||||||
|
|
||||||
connect(this, &Task::aborted, elementDownload, &NetJob::abort);
|
connect(this, &Task::aborted, elementDownload, &NetJob::abort);
|
||||||
connect(elementDownload, &NetJob::succeeded, [this] { emitSucceeded(); });
|
connect(elementDownload, &NetJob::succeeded, [this] { emitSucceeded(); });
|
||||||
elementDownload->start();
|
elementDownload->start();
|
||||||
}
|
}
|
||||||
|
} // namespace Java
|
@ -21,11 +21,13 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
class ManifestJavaDownloader : public Task {
|
namespace Java {
|
||||||
|
|
||||||
|
class ManifestDownloadTask : public Task {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ManifestJavaDownloader(QUrl url, QString final_path, QString checksumType = "", QString checksumHash = "");
|
ManifestDownloadTask(QUrl url, QString final_path, QString checksumType = "", QString checksumHash = "");
|
||||||
virtual ~ManifestJavaDownloader() = default;
|
virtual ~ManifestDownloadTask() = default;
|
||||||
|
|
||||||
[[nodiscard]] bool canAbort() const override { return true; }
|
[[nodiscard]] bool canAbort() const override { return true; }
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
@ -38,6 +40,5 @@ class ManifestJavaDownloader : public Task {
|
|||||||
QString m_final_path;
|
QString m_final_path;
|
||||||
QString m_checksum_type;
|
QString m_checksum_type;
|
||||||
QString m_checksum_hash;
|
QString m_checksum_hash;
|
||||||
|
|
||||||
Task::Ptr m_current_task;
|
|
||||||
};
|
};
|
||||||
|
} // namespace Java
|
@ -101,10 +101,14 @@ QVariant VersionList::data(const QModelIndex& index, int role) const
|
|||||||
|
|
||||||
BaseVersionList::RoleList VersionList::providesRoles() const
|
BaseVersionList::RoleList VersionList::providesRoles() const
|
||||||
{
|
{
|
||||||
return { VersionPointerRole, VersionRole, VersionIdRole, ParentVersionRole, TypeRole, UidRole,
|
return m_provided_roles;
|
||||||
TimeRole, RequiresRole, SortRole, RecommendedRole, LatestRole, VersionPtrRole };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VersionList::setProvidedRoles(RoleList roles)
|
||||||
|
{
|
||||||
|
m_provided_roles = roles;
|
||||||
|
};
|
||||||
|
|
||||||
QHash<int, QByteArray> VersionList::roleNames() const
|
QHash<int, QByteArray> VersionList::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles = BaseVersionList::roleNames();
|
QHash<int, QByteArray> roles = BaseVersionList::roleNames();
|
||||||
|
@ -47,6 +47,8 @@ class VersionList : public BaseVersionList, public BaseEntity {
|
|||||||
RoleList providesRoles() const override;
|
RoleList providesRoles() const override;
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
|
void setProvidedRoles(RoleList roles);
|
||||||
|
|
||||||
QString localFilename() const override;
|
QString localFilename() const override;
|
||||||
|
|
||||||
QString uid() const { return m_uid; }
|
QString uid() const { return m_uid; }
|
||||||
@ -79,6 +81,9 @@ class VersionList : public BaseVersionList, public BaseEntity {
|
|||||||
|
|
||||||
Version::Ptr m_recommended;
|
Version::Ptr m_recommended;
|
||||||
|
|
||||||
|
RoleList m_provided_roles = { VersionPointerRole, VersionRole, VersionIdRole, ParentVersionRole, TypeRole, UidRole,
|
||||||
|
TimeRole, RequiresRole, SortRole, RecommendedRole, LatestRole, VersionPtrRole };
|
||||||
|
|
||||||
void setupAddedVersion(int row, const Version::Ptr& version);
|
void setupAddedVersion(int row, const Version::Ptr& version);
|
||||||
};
|
};
|
||||||
} // namespace Meta
|
} // namespace Meta
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include <Json.h>
|
#include <Json.h>
|
||||||
#include <minecraft/MojangVersionFormat.h>
|
#include <minecraft/MojangVersionFormat.h>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "java/JavaRuntime.h"
|
#include "java/JavaMetadata.h"
|
||||||
#include "minecraft/Agent.h"
|
#include "minecraft/Agent.h"
|
||||||
#include "minecraft/ParseUtils.h"
|
#include "minecraft/ParseUtils.h"
|
||||||
|
|
||||||
@ -261,9 +261,9 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument& doc
|
|||||||
auto runtimes = requireObject(root, "runtimes");
|
auto runtimes = requireObject(root, "runtimes");
|
||||||
out->runtimes = {};
|
out->runtimes = {};
|
||||||
for (auto key : runtimes.keys()) {
|
for (auto key : runtimes.keys()) {
|
||||||
QList<JavaRuntime::MetaPtr> list;
|
QList<Java::MetadataPtr> list;
|
||||||
for (auto runtime : ensureArray(runtimes, key)) {
|
for (auto runtime : ensureArray(runtimes, key)) {
|
||||||
list.append(JavaRuntime::parseJavaMeta(ensureObject(runtime)));
|
list.append(Java::parseJavaMeta(ensureObject(runtime)));
|
||||||
}
|
}
|
||||||
out->runtimes[key] = list;
|
out->runtimes[key] = list;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
#include "Agent.h"
|
#include "Agent.h"
|
||||||
#include "Library.h"
|
#include "Library.h"
|
||||||
#include "ProblemProvider.h"
|
#include "ProblemProvider.h"
|
||||||
#include "java/JavaRuntime.h"
|
#include "java/JavaMetadata.h"
|
||||||
#include "minecraft/Rule.h"
|
#include "minecraft/Rule.h"
|
||||||
|
|
||||||
class PackProfile;
|
class PackProfile;
|
||||||
@ -155,7 +155,7 @@ class VersionFile : public ProblemContainer {
|
|||||||
/// is volatile -- may be removed as soon as it is no longer needed by something else
|
/// is volatile -- may be removed as soon as it is no longer needed by something else
|
||||||
bool m_volatile = false;
|
bool m_volatile = false;
|
||||||
|
|
||||||
QHash<QString, QList<JavaRuntime::MetaPtr>> runtimes;
|
QHash<QString, QList<Java::MetadataPtr>> runtimes;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Mojang: DEPRECATED list of 'downloads' - client jar, server jar, windows server exe, maybe more.
|
// Mojang: DEPRECATED list of 'downloads' - client jar, server jar, windows server exe, maybe more.
|
||||||
|
@ -1,90 +0,0 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
/*
|
|
||||||
* Prism Launcher - Minecraft Launcher
|
|
||||||
* Copyright (c) 2024 Trial97 <alexandru.tripon97@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "JavaDownload.h"
|
|
||||||
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "Application.h"
|
|
||||||
#include "FileSystem.h"
|
|
||||||
#include "QObjectPtr.h"
|
|
||||||
#include "SysInfo.h"
|
|
||||||
|
|
||||||
#include "java/JavaRuntime.h"
|
|
||||||
#include "java/download/ArchiveJavaDownloader.h"
|
|
||||||
#include "java/download/ManifestJavaDownloader.h"
|
|
||||||
|
|
||||||
#include "meta/Index.h"
|
|
||||||
#include "meta/Version.h"
|
|
||||||
|
|
||||||
#include "ui/dialogs/ProgressDialog.h"
|
|
||||||
#include "ui/java/ListModel.h"
|
|
||||||
#include "ui_JavaDownload.h"
|
|
||||||
|
|
||||||
JavaDownload::JavaDownload(QWidget* parent) : QDialog(parent), ui(new Ui::JavaDownload)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
ui->widget->initialize(new Java::JavaBaseVersionList("net.minecraft.java"));
|
|
||||||
ui->widget->selectCurrent();
|
|
||||||
connect(ui->widget, &VersionSelectWidget::selectedVersionChanged, this, &JavaDownload::setSelectedVersion);
|
|
||||||
auto reset = ui->buttonBox->button(QDialogButtonBox::Reset);
|
|
||||||
connect(reset, &QPushButton::clicked, this, &JavaDownload::refresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
JavaDownload::~JavaDownload()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void JavaDownload::setSelectedVersion(BaseVersion::Ptr version)
|
|
||||||
{
|
|
||||||
auto dcast = std::dynamic_pointer_cast<Meta::Version>(version);
|
|
||||||
if (!dcast) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ui->widget_2->initialize(new Java::InstallList(dcast, this));
|
|
||||||
ui->widget_2->selectCurrent();
|
|
||||||
}
|
|
||||||
|
|
||||||
void JavaDownload::accept()
|
|
||||||
{
|
|
||||||
auto meta = std::dynamic_pointer_cast<JavaRuntime::Meta>(ui->widget_2->selectedVersion());
|
|
||||||
if (!meta) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Task::Ptr task;
|
|
||||||
auto final_path = FS::PathCombine(APPLICATION->dataRoot(), "java", meta->m_name);
|
|
||||||
switch (meta->downloadType) {
|
|
||||||
case JavaRuntime::DownloadType::Manifest:
|
|
||||||
task = makeShared<ManifestJavaDownloader>(meta->url, final_path, meta->checksumType, meta->checksumHash);
|
|
||||||
break;
|
|
||||||
case JavaRuntime::DownloadType::Archive:
|
|
||||||
task = makeShared<ArchiveJavaDownloader>(meta->url, final_path, meta->checksumType, meta->checksumHash);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ProgressDialog pg(this);
|
|
||||||
pg.execWithTask(task.get());
|
|
||||||
QDialog::accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void JavaDownload::refresh()
|
|
||||||
{
|
|
||||||
ui->widget->loadList();
|
|
||||||
}
|
|
109
launcher/ui/java/JavaDownloader.cpp
Normal file
109
launcher/ui/java/JavaDownloader.cpp
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* Prism Launcher - Minecraft Launcher
|
||||||
|
* Copyright (c) 2024 Trial97 <alexandru.tripon97@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "JavaDownloader.h"
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
#include "BaseVersionList.h"
|
||||||
|
#include "FileSystem.h"
|
||||||
|
#include "QObjectPtr.h"
|
||||||
|
#include "SysInfo.h"
|
||||||
|
|
||||||
|
#include "java/JavaMetadata.h"
|
||||||
|
#include "java/download/ArchiveDownloadTask.h"
|
||||||
|
#include "java/download/ManifestDownloadTask.h"
|
||||||
|
|
||||||
|
#include "meta/Index.h"
|
||||||
|
#include "meta/Version.h"
|
||||||
|
|
||||||
|
#include "meta/VersionList.h"
|
||||||
|
#include "ui/dialogs/ProgressDialog.h"
|
||||||
|
#include "ui/java/VersionList.h"
|
||||||
|
#include "ui_JavaDownloader.h"
|
||||||
|
|
||||||
|
namespace Java {
|
||||||
|
|
||||||
|
Downloader::Downloader(QWidget* parent) : QDialog(parent), ui(new Ui::JavaDownloader)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
auto versionList = new Meta::VersionList("net.minecraft.java", this);
|
||||||
|
versionList->setProvidedRoles({ BaseVersionList::VersionRole, BaseVersionList::RecommendedRole, BaseVersionList::VersionPointerRole });
|
||||||
|
ui->majorVersionSelect->initialize(versionList);
|
||||||
|
ui->majorVersionSelect->selectCurrent();
|
||||||
|
ui->majorVersionSelect->setEmptyString(tr("No java versions are currently available in the meta"));
|
||||||
|
ui->majorVersionSelect->setEmptyErrorString(tr("Couldn't load or download the java version lists!"));
|
||||||
|
|
||||||
|
ui->javaVersionSelect->setEmptyString(tr("No java versions are currently available for your OS."));
|
||||||
|
ui->javaVersionSelect->setEmptyErrorString(tr("Couldn't load or download the java version lists!"));
|
||||||
|
|
||||||
|
ui->buttonBox->button(QDialogButtonBox::Retry)->setText(tr("Refresh"));
|
||||||
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Download"));
|
||||||
|
|
||||||
|
connect(ui->majorVersionSelect, &VersionSelectWidget::selectedVersionChanged, this, &Downloader::setSelectedVersion);
|
||||||
|
auto reset = ui->buttonBox->button(QDialogButtonBox::Reset);
|
||||||
|
connect(reset, &QPushButton::clicked, this, &Downloader::refresh);
|
||||||
|
}
|
||||||
|
|
||||||
|
Downloader::~Downloader()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Downloader::setSelectedVersion(BaseVersion::Ptr version)
|
||||||
|
{
|
||||||
|
auto dcast = std::dynamic_pointer_cast<Meta::Version>(version);
|
||||||
|
if (!dcast) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ui->javaVersionSelect->initialize(new Java::VersionList(dcast, this));
|
||||||
|
ui->javaVersionSelect->selectCurrent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Downloader::accept()
|
||||||
|
{
|
||||||
|
auto meta = std::dynamic_pointer_cast<Java::Metadata>(ui->javaVersionSelect->selectedVersion());
|
||||||
|
if (!meta) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Task::Ptr task;
|
||||||
|
auto final_path = FS::PathCombine(APPLICATION->dataRoot(), "java", meta->m_name);
|
||||||
|
switch (meta->downloadType) {
|
||||||
|
case Java::DownloadType::Manifest:
|
||||||
|
task = makeShared<ManifestDownloadTask>(meta->url, final_path, meta->checksumType, meta->checksumHash);
|
||||||
|
break;
|
||||||
|
case Java::DownloadType::Archive:
|
||||||
|
task = makeShared<ArchiveDownloadTask>(meta->url, final_path, meta->checksumType, meta->checksumHash);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
auto deletePath = [final_path] { FS::deletePath(final_path); };
|
||||||
|
connect(task.get(), &Task::failed, this, deletePath);
|
||||||
|
connect(task.get(), &Task::aborted, this, deletePath);
|
||||||
|
ProgressDialog pg(this);
|
||||||
|
pg.execWithTask(task.get());
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Downloader::refresh()
|
||||||
|
{
|
||||||
|
ui->majorVersionSelect->loadList();
|
||||||
|
}
|
||||||
|
} // namespace Java
|
@ -22,15 +22,17 @@
|
|||||||
#include "BaseVersion.h"
|
#include "BaseVersion.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class JavaDownload;
|
class JavaDownloader;
|
||||||
}
|
}
|
||||||
|
|
||||||
class JavaDownload : public QDialog {
|
namespace Java {
|
||||||
|
|
||||||
|
class Downloader : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit JavaDownload(QWidget* parent = 0);
|
explicit Downloader(QWidget* parent = 0);
|
||||||
~JavaDownload();
|
~Downloader();
|
||||||
|
|
||||||
void accept();
|
void accept();
|
||||||
|
|
||||||
@ -41,5 +43,6 @@ class JavaDownload : public QDialog {
|
|||||||
void setSelectedVersion(BaseVersion::Ptr version);
|
void setSelectedVersion(BaseVersion::Ptr version);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::JavaDownload* ui;
|
Ui::JavaDownloader* ui;
|
||||||
};
|
};
|
||||||
|
} // namespace Java
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>JavaDownload</class>
|
<class>JavaDownloader</class>
|
||||||
<widget class="QDialog" name="JavaDownload">
|
<widget class="QDialog" name="JavaDownloader">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
@ -23,7 +23,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="VersionSelectWidget" name="widget" native="true"/>
|
<widget class="VersionSelectWidget" name="majorVersionSelect" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@ -35,7 +35,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="VersionSelectWidget" name="widget_2" native="true"/>
|
<widget class="VersionSelectWidget" name="javaVersionSelect" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@ -67,7 +67,7 @@
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>accepted()</signal>
|
<signal>accepted()</signal>
|
||||||
<receiver>JavaDownload</receiver>
|
<receiver>JavaDownloader</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
@ -83,7 +83,7 @@
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>JavaDownload</receiver>
|
<receiver>JavaDownloader</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
@ -16,46 +16,46 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ListModel.h"
|
#include "VersionList.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "BaseVersionList.h"
|
#include "BaseVersionList.h"
|
||||||
#include "SysInfo.h"
|
#include "SysInfo.h"
|
||||||
#include "java/JavaRuntime.h"
|
#include "java/JavaMetadata.h"
|
||||||
|
|
||||||
namespace Java {
|
namespace Java {
|
||||||
|
|
||||||
InstallList::InstallList(Meta::Version::Ptr version, QObject* parent) : BaseVersionList(parent), m_version(version)
|
VersionList::VersionList(Meta::Version::Ptr version, QObject* parent) : BaseVersionList(parent), m_version(version)
|
||||||
{
|
{
|
||||||
if (version->isLoaded())
|
if (version->isLoaded())
|
||||||
sortVersions();
|
sortVersions();
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::Ptr InstallList::getLoadTask()
|
Task::Ptr VersionList::getLoadTask()
|
||||||
{
|
{
|
||||||
m_version->load(Net::Mode::Online);
|
m_version->load(Net::Mode::Online);
|
||||||
auto task = m_version->getCurrentTask();
|
auto task = m_version->getCurrentTask();
|
||||||
connect(task.get(), &Task::finished, this, &InstallList::sortVersions);
|
connect(task.get(), &Task::finished, this, &VersionList::sortVersions);
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BaseVersion::Ptr InstallList::at(int i) const
|
const BaseVersion::Ptr VersionList::at(int i) const
|
||||||
{
|
{
|
||||||
return m_vlist.at(i);
|
return m_vlist.at(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstallList::isLoaded()
|
bool VersionList::isLoaded()
|
||||||
{
|
{
|
||||||
return m_version->isLoaded();
|
return m_version->isLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
int InstallList::count() const
|
int VersionList::count() const
|
||||||
{
|
{
|
||||||
return m_vlist.count();
|
return m_vlist.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant InstallList::data(const QModelIndex& index, int role) const
|
QVariant VersionList::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -75,28 +75,28 @@ QVariant InstallList::data(const QModelIndex& index, int role) const
|
|||||||
return version->version.toString();
|
return version->version.toString();
|
||||||
case RecommendedRole:
|
case RecommendedRole:
|
||||||
return version->recommended;
|
return version->recommended;
|
||||||
case AliasRole:
|
case JavaNameRole:
|
||||||
return version->name();
|
return version->name();
|
||||||
case ArchitectureRole:
|
case CPUArchitectureRole:
|
||||||
return version->vendor;
|
return version->vendor;
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseVersionList::RoleList InstallList::providesRoles() const
|
BaseVersionList::RoleList VersionList::providesRoles() const
|
||||||
{
|
{
|
||||||
return { VersionPointerRole, VersionIdRole, VersionRole, RecommendedRole, AliasRole, ArchitectureRole };
|
return { VersionPointerRole, VersionIdRole, VersionRole, RecommendedRole, JavaNameRole, CPUArchitectureRole };
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sortJavas(BaseVersion::Ptr left, BaseVersion::Ptr right)
|
bool sortJavas(BaseVersion::Ptr left, BaseVersion::Ptr right)
|
||||||
{
|
{
|
||||||
auto rleft = std::dynamic_pointer_cast<JavaRuntime::Meta>(right);
|
auto rleft = std::dynamic_pointer_cast<Java::Metadata>(right);
|
||||||
auto rright = std::dynamic_pointer_cast<JavaRuntime::Meta>(left);
|
auto rright = std::dynamic_pointer_cast<Java::Metadata>(left);
|
||||||
return (*rleft) > (*rright);
|
return (*rleft) > (*rright);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallList::sortVersions()
|
void VersionList::sortVersions()
|
||||||
{
|
{
|
||||||
QString versionStr = SysInfo::getSupportedJavaArchitecture();
|
QString versionStr = SysInfo::getSupportedJavaArchitecture();
|
||||||
beginResetModel();
|
beginResetModel();
|
@ -18,23 +18,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "java/JavaRuntime.h"
|
#include "BaseVersionList.h"
|
||||||
#include "meta/VersionList.h"
|
#include "java/JavaMetadata.h"
|
||||||
|
#include "meta/Version.h"
|
||||||
|
|
||||||
namespace Java {
|
namespace Java {
|
||||||
|
|
||||||
class JavaBaseVersionList : public Meta::VersionList {
|
class VersionList : public BaseVersionList {
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit JavaBaseVersionList(const QString& uid, QObject* parent = nullptr) : VersionList(uid, parent) {}
|
|
||||||
BaseVersionList::RoleList providesRoles() const { return { VersionRole, RecommendedRole, VersionPointerRole }; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class InstallList : public BaseVersionList {
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit InstallList(Meta::Version::Ptr m_version, QObject* parent = 0);
|
explicit VersionList(Meta::Version::Ptr m_version, QObject* parent = 0);
|
||||||
|
|
||||||
Task::Ptr getLoadTask() override;
|
Task::Ptr getLoadTask() override;
|
||||||
bool isLoaded() override;
|
bool isLoaded() override;
|
||||||
@ -50,7 +44,7 @@ class InstallList : public BaseVersionList {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
Meta::Version::Ptr m_version;
|
Meta::Version::Ptr m_version;
|
||||||
QList<JavaRuntime::MetaPtr> m_vlist;
|
QList<Java::MetadataPtr> m_vlist;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Java
|
} // namespace Java
|
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include "JavaPage.h"
|
#include "JavaPage.h"
|
||||||
#include "JavaCommon.h"
|
#include "JavaCommon.h"
|
||||||
#include "ui/java/JavaDownload.h"
|
#include "ui/java/JavaDownloader.h"
|
||||||
#include "ui_JavaPage.h"
|
#include "ui_JavaPage.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@ -169,7 +169,7 @@ void JavaPage::on_javaTestBtn_clicked()
|
|||||||
|
|
||||||
void JavaPage::on_javaDownloadBtn_clicked()
|
void JavaPage::on_javaDownloadBtn_clicked()
|
||||||
{
|
{
|
||||||
auto jdialog = new JavaDownload(this);
|
auto jdialog = new Java::Downloader(this);
|
||||||
jdialog->exec();
|
jdialog->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "InstanceSettingsPage.h"
|
#include "InstanceSettingsPage.h"
|
||||||
#include "ui/java/JavaDownload.h"
|
#include "ui/java/JavaDownloader.h"
|
||||||
#include "ui_InstanceSettingsPage.h"
|
#include "ui_InstanceSettingsPage.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
@ -387,7 +387,7 @@ void InstanceSettingsPage::loadSettings()
|
|||||||
|
|
||||||
void InstanceSettingsPage::on_javaDownloadBtn_clicked()
|
void InstanceSettingsPage::on_javaDownloadBtn_clicked()
|
||||||
{
|
{
|
||||||
auto jdialog = new JavaDownload(this);
|
auto jdialog = new Java::Downloader(this);
|
||||||
jdialog->exec();
|
jdialog->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "java/JavaUtils.h"
|
#include "java/JavaUtils.h"
|
||||||
|
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
#include "ui/java/JavaDownload.h"
|
#include "ui/java/JavaDownloader.h"
|
||||||
#include "ui/widgets/VersionSelectWidget.h"
|
#include "ui/widgets/VersionSelectWidget.h"
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
@ -274,7 +274,7 @@ void JavaSettingsWidget::on_javaBrowseBtn_clicked()
|
|||||||
}
|
}
|
||||||
void JavaSettingsWidget::on_javaDownloadBtn_clicked()
|
void JavaSettingsWidget::on_javaDownloadBtn_clicked()
|
||||||
{
|
{
|
||||||
auto jdialog = new JavaDownload(this);
|
auto jdialog = new Java::Downloader(this);
|
||||||
jdialog->exec();
|
jdialog->exec();
|
||||||
}
|
}
|
||||||
void JavaSettingsWidget::on_javaStatusBtn_clicked()
|
void JavaSettingsWidget::on_javaStatusBtn_clicked()
|
||||||
|
Loading…
Reference in New Issue
Block a user