Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into download_threads
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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
|
||||
@ -251,6 +252,11 @@ bool InstanceWindow::selectPage(QString pageId)
|
||||
return m_container->selectPage(pageId);
|
||||
}
|
||||
|
||||
BasePage* InstanceWindow::selectedPage() const
|
||||
{
|
||||
return m_container->selectedPage();
|
||||
}
|
||||
|
||||
void InstanceWindow::refreshContainer()
|
||||
{
|
||||
m_container->refreshContainer();
|
||||
|
@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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
|
||||
@ -55,6 +56,7 @@ class InstanceWindow : public QMainWindow, public BasePageContainer {
|
||||
virtual ~InstanceWindow();
|
||||
|
||||
bool selectPage(QString pageId) override;
|
||||
BasePage* selectedPage() const override;
|
||||
void refreshContainer() override;
|
||||
|
||||
QString instanceId();
|
||||
|
@ -515,9 +515,9 @@ void MainWindow::showInstanceContextMenu(const QPoint& pos)
|
||||
QAction* actionCreateInstance = new QAction(tr("Create instance"), this);
|
||||
actionCreateInstance->setToolTip(ui->actionAddInstance->toolTip());
|
||||
if (!group.isNull()) {
|
||||
QVariantMap data;
|
||||
data["group"] = group;
|
||||
actionCreateInstance->setData(data);
|
||||
QVariantMap instance_action_data;
|
||||
instance_action_data["group"] = group;
|
||||
actionCreateInstance->setData(instance_action_data);
|
||||
}
|
||||
|
||||
connect(actionCreateInstance, SIGNAL(triggered(bool)), SLOT(on_actionAddInstance_triggered()));
|
||||
@ -527,9 +527,9 @@ void MainWindow::showInstanceContextMenu(const QPoint& pos)
|
||||
actions.append(actionCreateInstance);
|
||||
if (!group.isNull()) {
|
||||
QAction* actionDeleteGroup = new QAction(tr("Delete group '%1'").arg(group), this);
|
||||
QVariantMap data;
|
||||
data["group"] = group;
|
||||
actionDeleteGroup->setData(data);
|
||||
QVariantMap delete_group_action_data;
|
||||
delete_group_action_data["group"] = group;
|
||||
actionDeleteGroup->setData(delete_group_action_data);
|
||||
connect(actionDeleteGroup, SIGNAL(triggered(bool)), SLOT(deleteGroup()));
|
||||
actions.append(actionDeleteGroup);
|
||||
}
|
||||
@ -627,7 +627,7 @@ void MainWindow::updateThemeMenu()
|
||||
themeMenu = new QMenu(this);
|
||||
}
|
||||
|
||||
auto themes = APPLICATION->getValidApplicationThemes();
|
||||
auto themes = APPLICATION->themeManager()->getValidApplicationThemes();
|
||||
|
||||
QActionGroup* themesGroup = new QActionGroup(this);
|
||||
|
||||
@ -641,7 +641,7 @@ void MainWindow::updateThemeMenu()
|
||||
themeAction->setActionGroup(themesGroup);
|
||||
|
||||
connect(themeAction, &QAction::triggered, [theme]() {
|
||||
APPLICATION->setApplicationTheme(theme->id());
|
||||
APPLICATION->themeManager()->setApplicationTheme(theme->id());
|
||||
APPLICATION->settings()->set("ApplicationTheme", theme->id());
|
||||
});
|
||||
}
|
||||
@ -744,9 +744,9 @@ void MainWindow::changeActiveAccount()
|
||||
if (sAction->data().type() != QVariant::Type::Int)
|
||||
return;
|
||||
|
||||
QVariant data = sAction->data();
|
||||
QVariant action_data = sAction->data();
|
||||
bool valid = false;
|
||||
int index = data.toInt(&valid);
|
||||
int index = action_data.toInt(&valid);
|
||||
if (!valid) {
|
||||
index = -1;
|
||||
}
|
||||
@ -1061,9 +1061,9 @@ void MainWindow::on_actionChangeInstIcon_triggered()
|
||||
void MainWindow::iconUpdated(QString icon)
|
||||
{
|
||||
if (icon == m_currentInstIcon) {
|
||||
auto icon = APPLICATION->icons()->getIcon(m_currentInstIcon);
|
||||
ui->actionChangeInstIcon->setIcon(icon);
|
||||
changeIconButton->setIcon(icon);
|
||||
auto new_icon = APPLICATION->icons()->getIcon(m_currentInstIcon);
|
||||
ui->actionChangeInstIcon->setIcon(new_icon);
|
||||
changeIconButton->setIcon(new_icon);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1134,16 +1134,35 @@ void MainWindow::undoTrashInstance()
|
||||
ui->actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething());
|
||||
}
|
||||
|
||||
void MainWindow::on_actionViewLauncherRootFolder_triggered()
|
||||
{
|
||||
DesktopServices::openDirectory(".");
|
||||
}
|
||||
|
||||
void MainWindow::on_actionViewInstanceFolder_triggered()
|
||||
{
|
||||
QString str = APPLICATION->settings()->get("InstanceDir").toString();
|
||||
DesktopServices::openDirectory(str);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionViewLauncherRootFolder_triggered()
|
||||
void MainWindow::on_actionViewCentralModsFolder_triggered()
|
||||
{
|
||||
const QString dataPath = QDir::currentPath();
|
||||
DesktopServices::openDirectory(dataPath);
|
||||
DesktopServices::openDirectory(APPLICATION->settings()->get("CentralModsDir").toString(), true);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionViewIconThemeFolder_triggered()
|
||||
{
|
||||
DesktopServices::openDirectory(APPLICATION->themeManager()->getIconThemesFolder().path());
|
||||
}
|
||||
|
||||
void MainWindow::on_actionViewWidgetThemeFolder_triggered()
|
||||
{
|
||||
DesktopServices::openDirectory(APPLICATION->themeManager()->getApplicationThemesFolder().path());
|
||||
}
|
||||
|
||||
void MainWindow::on_actionViewCatPackFolder_triggered()
|
||||
{
|
||||
DesktopServices::openDirectory(APPLICATION->themeManager()->getCatPacksFolder().path());
|
||||
}
|
||||
|
||||
void MainWindow::refreshInstances()
|
||||
@ -1151,11 +1170,6 @@ void MainWindow::refreshInstances()
|
||||
APPLICATION->instances()->loadList();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionViewCentralModsFolder_triggered()
|
||||
{
|
||||
DesktopServices::openDirectory(APPLICATION->settings()->get("CentralModsDir").toString(), true);
|
||||
}
|
||||
|
||||
void MainWindow::checkForUpdates()
|
||||
{
|
||||
if (BuildConfig.UPDATER_ENABLED) {
|
||||
@ -1590,7 +1604,7 @@ void MainWindow::startTask(Task* task)
|
||||
task->start();
|
||||
}
|
||||
|
||||
void MainWindow::instanceChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
void MainWindow::instanceChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
if (!current.isValid()) {
|
||||
APPLICATION->settings()->set("SelectedInstance", QString());
|
||||
@ -1725,7 +1739,7 @@ void MainWindow::setInstanceActionsEnabled(bool enabled)
|
||||
ui->actionCreateInstanceShortcut->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void MainWindow::refreshCurrentInstance(bool running)
|
||||
void MainWindow::refreshCurrentInstance([[maybe_unused]] bool running)
|
||||
{
|
||||
auto current = view->selectionModel()->currentIndex();
|
||||
instanceChanged(current, current);
|
||||
|
@ -109,16 +109,19 @@ class MainWindow : public QMainWindow {
|
||||
|
||||
void on_actionChangeInstIcon_triggered();
|
||||
|
||||
void on_actionViewInstanceFolder_triggered();
|
||||
|
||||
void on_actionViewLauncherRootFolder_triggered();
|
||||
|
||||
void on_actionViewInstanceFolder_triggered();
|
||||
void on_actionViewCentralModsFolder_triggered();
|
||||
|
||||
void on_actionViewIconThemeFolder_triggered();
|
||||
void on_actionViewWidgetThemeFolder_triggered();
|
||||
void on_actionViewCatPackFolder_triggered();
|
||||
|
||||
void on_actionViewSelectedInstFolder_triggered();
|
||||
|
||||
void refreshInstances();
|
||||
|
||||
void on_actionViewCentralModsFolder_triggered();
|
||||
|
||||
void checkForUpdates();
|
||||
|
||||
void on_actionSettings_triggered();
|
||||
|
@ -186,9 +186,14 @@
|
||||
<property name="toolTipsVisible">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<addaction name="actionViewInstanceFolder"/>
|
||||
<addaction name="actionViewLauncherRootFolder"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionViewInstanceFolder"/>
|
||||
<addaction name="actionViewCentralModsFolder"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionViewIconThemeFolder"/>
|
||||
<addaction name="actionViewWidgetThemeFolder"/>
|
||||
<addaction name="actionViewCatPackFolder"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="accountsMenu">
|
||||
<property name="title">
|
||||
@ -465,7 +470,8 @@
|
||||
</action>
|
||||
<action name="actionExportInstanceZip">
|
||||
<property name="icon">
|
||||
<iconset theme="launcher"/>
|
||||
<iconset theme="launcher">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Prism Launcher (zip)</string>
|
||||
@ -473,7 +479,8 @@
|
||||
</action>
|
||||
<action name="actionExportInstanceMrPack">
|
||||
<property name="icon">
|
||||
<iconset theme="modrinth"/>
|
||||
<iconset theme="modrinth">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Modrinth (mrpack)</string>
|
||||
@ -481,15 +488,17 @@
|
||||
</action>
|
||||
<action name="actionExportInstanceFlamePack">
|
||||
<property name="icon">
|
||||
<iconset theme="flame"/>
|
||||
<iconset theme="flame">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>CurseForge (zip)</string>
|
||||
<string>CurseForge (zip)</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExportInstanceToModList">
|
||||
<property name="icon">
|
||||
<iconset theme="new"/>
|
||||
<iconset theme="new">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mod List</string>
|
||||
@ -552,7 +561,7 @@
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&View Instance Folder</string>
|
||||
<string>View &Instance Folder</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Open the instance folder in a file browser.</string>
|
||||
@ -564,7 +573,7 @@
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&View Launcher Root Folder</string>
|
||||
<string>View Launcher &Root Folder</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Open the launcher's root folder in a file browser.</string>
|
||||
@ -719,6 +728,38 @@
|
||||
<string>Open the %1 wiki</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewWidgetThemeFolder">
|
||||
<property name="icon">
|
||||
<iconset theme="viewfolder">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>View &Widget Themes Folder</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>View Widget Theme Folder</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewIconThemeFolder">
|
||||
<property name="icon">
|
||||
<iconset theme="viewfolder">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>View I&con Theme Folder</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>View Icon Theme Folder</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewCatPackFolder">
|
||||
<property name="icon">
|
||||
<iconset theme="viewfolder"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>View Cat Packs Folder</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -220,7 +220,7 @@ void CopyInstanceDialog::on_iconButton_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void CopyInstanceDialog::on_instNameTextBox_textChanged(const QString& arg1)
|
||||
void CopyInstanceDialog::on_instNameTextBox_textChanged([[maybe_unused]] const QString& arg1)
|
||||
{
|
||||
updateDialogState();
|
||||
}
|
||||
|
@ -195,8 +195,8 @@ void ExportInstanceDialog::loadPackIgnore()
|
||||
if (!ignoreFile.open(QIODevice::ReadOnly)) {
|
||||
return;
|
||||
}
|
||||
auto data = ignoreFile.readAll();
|
||||
auto string = QString::fromUtf8(data);
|
||||
auto ignoreData = ignoreFile.readAll();
|
||||
auto string = QString::fromUtf8(ignoreData);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
proxyModel->setBlockedPaths(string.split('\n', Qt::SkipEmptyParts));
|
||||
#else
|
||||
@ -206,10 +206,10 @@ void ExportInstanceDialog::loadPackIgnore()
|
||||
|
||||
void ExportInstanceDialog::savePackIgnore()
|
||||
{
|
||||
auto data = proxyModel->blockedPaths().toStringList().join('\n').toUtf8();
|
||||
auto ignoreData = proxyModel->blockedPaths().toStringList().join('\n').toUtf8();
|
||||
auto filename = ignoreFileName();
|
||||
try {
|
||||
FS::write(filename, data);
|
||||
FS::write(filename, ignoreData);
|
||||
} catch (const Exception& e) {
|
||||
qWarning() << e.cause();
|
||||
}
|
||||
|
164
launcher/ui/dialogs/InstallLoaderDialog.cpp
Normal file
164
launcher/ui/dialogs/InstallLoaderDialog.cpp
Normal file
@ -0,0 +1,164 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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 "InstallLoaderDialog.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include "Application.h"
|
||||
#include "BuildConfig.h"
|
||||
#include "DesktopServices.h"
|
||||
#include "meta/Index.h"
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include "minecraft/PackProfile.h"
|
||||
#include "ui/widgets/PageContainer.h"
|
||||
#include "ui/widgets/VersionSelectWidget.h"
|
||||
|
||||
class InstallLoaderPage : public VersionSelectWidget, public BasePage {
|
||||
public:
|
||||
InstallLoaderPage(const QString& id,
|
||||
const QString& iconName,
|
||||
const QString& name,
|
||||
const Version& oldestVersion,
|
||||
const std::shared_ptr<PackProfile> profile)
|
||||
: VersionSelectWidget(nullptr), uid(id), iconName(iconName), name(name)
|
||||
{
|
||||
const QString minecraftVersion = profile->getComponentVersion("net.minecraft");
|
||||
setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion));
|
||||
setExactIfPresentFilter(BaseVersionList::ParentVersionRole, minecraftVersion);
|
||||
|
||||
if (oldestVersion != Version() && Version(minecraftVersion) < oldestVersion)
|
||||
setExactFilter(BaseVersionList::ParentVersionRole, "AAA");
|
||||
|
||||
if (const QString currentVersion = profile->getComponentVersion(id); !currentVersion.isNull())
|
||||
setCurrentVersion(currentVersion);
|
||||
}
|
||||
|
||||
QString id() const override { return uid; }
|
||||
QString displayName() const override { return name; }
|
||||
QIcon icon() const override { return APPLICATION->getThemedIcon(iconName); }
|
||||
|
||||
void openedImpl() override
|
||||
{
|
||||
if (loaded)
|
||||
return;
|
||||
|
||||
const auto versions = APPLICATION->metadataIndex()->get(uid);
|
||||
if (!versions)
|
||||
return;
|
||||
|
||||
initialize(versions.get());
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
void setParentContainer(BasePageContainer* container) override
|
||||
{
|
||||
auto dialog = dynamic_cast<QDialog*>(dynamic_cast<PageContainer*>(container)->parent());
|
||||
connect(view(), &QAbstractItemView::doubleClicked, dialog, &QDialog::accept);
|
||||
}
|
||||
|
||||
private:
|
||||
const QString uid;
|
||||
const QString iconName;
|
||||
const QString name;
|
||||
bool loaded = false;
|
||||
};
|
||||
|
||||
static InstallLoaderPage* pageCast(BasePage* page)
|
||||
{
|
||||
auto result = dynamic_cast<InstallLoaderPage*>(page);
|
||||
Q_ASSERT(result != nullptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr<PackProfile> profile, const QString& uid, QWidget* parent)
|
||||
: QDialog(parent), profile(std::move(profile)), container(new PageContainer(this, QString(), this)), buttons(new QDialogButtonBox(this))
|
||||
{
|
||||
auto layout = new QVBoxLayout(this);
|
||||
|
||||
container->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
layout->addWidget(container);
|
||||
|
||||
auto buttonLayout = new QHBoxLayout(this);
|
||||
|
||||
auto refreshButton = new QPushButton(tr("&Refresh"), this);
|
||||
connect(refreshButton, &QPushButton::clicked, this, [this] { pageCast(container->selectedPage())->loadList(); });
|
||||
buttonLayout->addWidget(refreshButton);
|
||||
|
||||
buttons->setOrientation(Qt::Horizontal);
|
||||
buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
|
||||
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
buttonLayout->addWidget(buttons);
|
||||
|
||||
layout->addLayout(buttonLayout);
|
||||
|
||||
setWindowTitle(dialogTitle());
|
||||
setWindowModality(Qt::WindowModal);
|
||||
resize(520, 347);
|
||||
|
||||
for (BasePage* page : container->getPages()) {
|
||||
if (page->id() == uid)
|
||||
container->selectPage(page->id());
|
||||
|
||||
connect(pageCast(page), &VersionSelectWidget::selectedVersionChanged, this, [this, page] {
|
||||
if (page->id() == container->selectedPage()->id())
|
||||
validate(container->selectedPage());
|
||||
});
|
||||
}
|
||||
connect(container, &PageContainer::selectedPageChanged, this, [this](BasePage* previous, BasePage* current) { validate(current); });
|
||||
pageCast(container->selectedPage())->selectSearch();
|
||||
validate(container->selectedPage());
|
||||
}
|
||||
|
||||
QList<BasePage*> InstallLoaderDialog::getPages()
|
||||
{
|
||||
return { // Forge
|
||||
new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), {}, profile),
|
||||
// Fabric
|
||||
new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc", tr("Fabric"), Version("1.14"), profile),
|
||||
// Quilt
|
||||
new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), Version("1.14"), profile),
|
||||
// LiteLoader
|
||||
new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), {}, profile)
|
||||
};
|
||||
}
|
||||
|
||||
QString InstallLoaderDialog::dialogTitle()
|
||||
{
|
||||
return tr("Install Loader");
|
||||
}
|
||||
|
||||
void InstallLoaderDialog::validate(BasePage* page)
|
||||
{
|
||||
buttons->button(QDialogButtonBox::Ok)->setEnabled(pageCast(page)->selectedVersion() != nullptr);
|
||||
}
|
||||
|
||||
void InstallLoaderDialog::done(int result)
|
||||
{
|
||||
if (result == Accepted) {
|
||||
auto* page = pageCast(container->selectedPage());
|
||||
if (page->selectedVersion()) {
|
||||
profile->setComponentVersion(page->id(), page->selectedVersion()->descriptor());
|
||||
profile->resolve(Net::Mode::Online);
|
||||
}
|
||||
}
|
||||
|
||||
QDialog::done(result);
|
||||
}
|
45
launcher/ui/dialogs/InstallLoaderDialog.h
Normal file
45
launcher/ui/dialogs/InstallLoaderDialog.h
Normal file
@ -0,0 +1,45 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui/pages/BasePageProvider.h"
|
||||
|
||||
class MinecraftInstance;
|
||||
class PageContainer;
|
||||
class PackProfile;
|
||||
class QDialogButtonBox;
|
||||
|
||||
class InstallLoaderDialog final : public QDialog, protected BasePageProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InstallLoaderDialog(std::shared_ptr<PackProfile> instance, const QString& uid = QString(), QWidget* parent = nullptr);
|
||||
|
||||
QList<BasePage*> getPages() override;
|
||||
QString dialogTitle() override;
|
||||
|
||||
void validate(BasePage* page);
|
||||
void done(int result) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<PackProfile> profile;
|
||||
PageContainer* container;
|
||||
QDialogButtonBox* buttons;
|
||||
};
|
@ -290,7 +290,7 @@ void NewInstanceDialog::on_iconButton_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void NewInstanceDialog::on_instNameTextBox_textChanged(const QString& arg1)
|
||||
void NewInstanceDialog::on_instNameTextBox_textChanged([[maybe_unused]] const QString& arg1)
|
||||
{
|
||||
updateDialogState();
|
||||
}
|
||||
@ -299,7 +299,7 @@ void NewInstanceDialog::importIconNow()
|
||||
{
|
||||
if (importIcon) {
|
||||
APPLICATION->icons()->installIcon(importIconPath, importIconName);
|
||||
InstIconKey = importIconName;
|
||||
InstIconKey = importIconName.mid(0, importIconName.lastIndexOf('.'));
|
||||
importIcon = false;
|
||||
}
|
||||
APPLICATION->settings()->set("NewInstanceGeometry", saveGeometry().toBase64());
|
||||
|
@ -163,13 +163,15 @@ void ProfileSetupDialog::checkName(const QString& name)
|
||||
requestor->get(request);
|
||||
}
|
||||
|
||||
void ProfileSetupDialog::checkFinished(QNetworkReply::NetworkError error, QByteArray data, QList<QNetworkReply::RawHeaderPair> headers)
|
||||
void ProfileSetupDialog::checkFinished(QNetworkReply::NetworkError error,
|
||||
QByteArray profileData,
|
||||
[[maybe_unused]] QList<QNetworkReply::RawHeaderPair> headers)
|
||||
{
|
||||
auto requestor = qobject_cast<AuthRequest*>(QObject::sender());
|
||||
requestor->deleteLater();
|
||||
|
||||
if (error == QNetworkReply::NoError) {
|
||||
auto doc = QJsonDocument::fromJson(data);
|
||||
auto doc = QJsonDocument::fromJson(profileData);
|
||||
auto root = doc.object();
|
||||
auto statusValue = root.value("status").toString("INVALID");
|
||||
if (statusValue == "AVAILABLE") {
|
||||
@ -202,11 +204,11 @@ void ProfileSetupDialog::setupProfile(const QString& profileName)
|
||||
request.setRawHeader("Authorization", QString("Bearer %1").arg(token).toUtf8());
|
||||
|
||||
QString payloadTemplate("{\"profileName\":\"%1\"}");
|
||||
auto data = payloadTemplate.arg(profileName).toUtf8();
|
||||
auto profileData = payloadTemplate.arg(profileName).toUtf8();
|
||||
|
||||
AuthRequest* requestor = new AuthRequest(this);
|
||||
connect(requestor, &AuthRequest::finished, this, &ProfileSetupDialog::setupProfileFinished);
|
||||
requestor->post(request, data);
|
||||
requestor->post(request, profileData);
|
||||
isWorking = true;
|
||||
|
||||
auto button = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
||||
@ -243,8 +245,8 @@ struct MojangError {
|
||||
} // namespace
|
||||
|
||||
void ProfileSetupDialog::setupProfileFinished(QNetworkReply::NetworkError error,
|
||||
QByteArray data,
|
||||
QList<QNetworkReply::RawHeaderPair> headers)
|
||||
QByteArray errorData,
|
||||
[[maybe_unused]] QList<QNetworkReply::RawHeaderPair> headers)
|
||||
{
|
||||
auto requestor = qobject_cast<AuthRequest*>(QObject::sender());
|
||||
requestor->deleteLater();
|
||||
@ -257,7 +259,7 @@ void ProfileSetupDialog::setupProfileFinished(QNetworkReply::NetworkError error,
|
||||
*/
|
||||
accept();
|
||||
} else {
|
||||
auto parsedError = MojangError::fromJSON(data);
|
||||
auto parsedError = MojangError::fromJSON(errorData);
|
||||
ui->errorLabel->setVisible(true);
|
||||
ui->errorLabel->setText(tr("The server returned the following error:") + "\n\n" + parsedError.errorMessage);
|
||||
qDebug() << parsedError.rawError;
|
||||
|
@ -85,7 +85,7 @@ void ProgressDialog::on_skipButton_clicked(bool checked)
|
||||
{
|
||||
Q_UNUSED(checked);
|
||||
if (ui->skipButton->isEnabled()) // prevent other triggers from aborting
|
||||
task->abort();
|
||||
m_task->abort();
|
||||
}
|
||||
|
||||
ProgressDialog::~ProgressDialog()
|
||||
@ -127,7 +127,7 @@ void ProgressDialog::updateSize(bool recenterParent)
|
||||
|
||||
int ProgressDialog::execWithTask(Task* task)
|
||||
{
|
||||
this->task = task;
|
||||
this->m_task = task;
|
||||
|
||||
if (!task) {
|
||||
qDebug() << "Programmer error: Progress dialog created with null task.";
|
||||
@ -179,8 +179,8 @@ int ProgressDialog::execWithTask(std::unique_ptr<Task>& task)
|
||||
|
||||
bool ProgressDialog::handleImmediateResult(QDialog::DialogCode& result)
|
||||
{
|
||||
if (task->isFinished()) {
|
||||
if (task->wasSuccessful()) {
|
||||
if (m_task->isFinished()) {
|
||||
if (m_task->wasSuccessful()) {
|
||||
result = QDialog::Accepted;
|
||||
} else {
|
||||
result = QDialog::Rejected;
|
||||
@ -192,12 +192,12 @@ bool ProgressDialog::handleImmediateResult(QDialog::DialogCode& result)
|
||||
|
||||
Task* ProgressDialog::getTask()
|
||||
{
|
||||
return task;
|
||||
return m_task;
|
||||
}
|
||||
|
||||
void ProgressDialog::onTaskStarted() {}
|
||||
|
||||
void ProgressDialog::onTaskFailed(QString failure)
|
||||
void ProgressDialog::onTaskFailed([[maybe_unused]] QString failure)
|
||||
{
|
||||
reject();
|
||||
hide();
|
||||
@ -209,11 +209,11 @@ void ProgressDialog::onTaskSucceeded()
|
||||
hide();
|
||||
}
|
||||
|
||||
void ProgressDialog::changeStatus(const QString& status)
|
||||
void ProgressDialog::changeStatus([[maybe_unused]] const QString& status)
|
||||
{
|
||||
ui->globalStatusLabel->setText(task->getStatus());
|
||||
ui->globalStatusLabel->setText(m_task->getStatus());
|
||||
ui->globalStatusLabel->adjustSize();
|
||||
ui->globalStatusDetailsLabel->setText(task->getDetails());
|
||||
ui->globalStatusDetailsLabel->setText(m_task->getDetails());
|
||||
ui->globalStatusDetailsLabel->adjustSize();
|
||||
|
||||
updateSize();
|
||||
@ -279,7 +279,7 @@ void ProgressDialog::keyPressEvent(QKeyEvent* e)
|
||||
|
||||
void ProgressDialog::closeEvent(QCloseEvent* e)
|
||||
{
|
||||
if (task && task->isRunning()) {
|
||||
if (m_task && m_task->isRunning()) {
|
||||
e->ignore();
|
||||
} else {
|
||||
QDialog::closeEvent(e);
|
||||
|
@ -92,7 +92,7 @@ class ProgressDialog : public QDialog {
|
||||
private:
|
||||
Ui::ProgressDialog* ui;
|
||||
|
||||
Task* task;
|
||||
Task* m_task;
|
||||
|
||||
bool m_is_multi_step = false;
|
||||
QHash<QUuid, SubTaskProgressBar*> taskProgress;
|
||||
|
@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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
|
||||
@ -209,15 +209,17 @@ bool ResourceDownloadDialog::selectPage(QString pageId)
|
||||
return m_container->selectPage(pageId);
|
||||
}
|
||||
|
||||
ResourcePage* ResourceDownloadDialog::getSelectedPage()
|
||||
ResourcePage* ResourceDownloadDialog::selectedPage()
|
||||
{
|
||||
return m_selectedPage;
|
||||
ResourcePage* result = dynamic_cast<ResourcePage*>(m_container->selectedPage());
|
||||
Q_ASSERT(result != nullptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
void ResourceDownloadDialog::addResource(ModPlatform::IndexedPack::Ptr pack, ModPlatform::IndexedVersion& ver)
|
||||
{
|
||||
removeResource(pack->name);
|
||||
m_selectedPage->addResourceToPage(pack, ver, getBaseModel());
|
||||
selectedPage()->addResourceToPage(pack, ver, getBaseModel());
|
||||
setButtonStatus();
|
||||
}
|
||||
|
||||
@ -257,14 +259,8 @@ void ResourceDownloadDialog::selectedPageChanged(BasePage* previous, BasePage* s
|
||||
return;
|
||||
}
|
||||
|
||||
m_selectedPage = dynamic_cast<ResourcePage*>(selected);
|
||||
if (!m_selectedPage) {
|
||||
qCritical() << "Page '" << selected->displayName() << "' in ResourceDownloadDialog is not a ResourcePage!";
|
||||
return;
|
||||
}
|
||||
|
||||
// Same effect as having a global search bar
|
||||
m_selectedPage->setSearchTerm(prev_page->getSearchTerm());
|
||||
selectedPage()->setSearchTerm(prev_page->getSearchTerm());
|
||||
}
|
||||
|
||||
ModDownloadDialog::ModDownloadDialog(QWidget* parent, const std::shared_ptr<ModFolderModel>& mods, BaseInstance* instance)
|
||||
@ -290,8 +286,6 @@ QList<BasePage*> ModDownloadDialog::getPages()
|
||||
if (APPLICATION->capabilities() & Application::SupportsFlame && FlameAPI::validateModLoaders(loaders))
|
||||
pages.append(FlameModPage::create(this, *m_instance));
|
||||
|
||||
m_selectedPage = dynamic_cast<ModPage*>(pages[0]);
|
||||
|
||||
return pages;
|
||||
}
|
||||
|
||||
@ -306,7 +300,7 @@ GetModDependenciesTask::Ptr ModDownloadDialog::getModDependenciesTask()
|
||||
return makeShared<GetModDependenciesTask>(this, m_instance, model, selectedVers);
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
ResourcePackDownloadDialog::ResourcePackDownloadDialog(QWidget* parent,
|
||||
const std::shared_ptr<ResourcePackFolderModel>& resource_packs,
|
||||
@ -330,8 +324,6 @@ QList<BasePage*> ResourcePackDownloadDialog::getPages()
|
||||
if (APPLICATION->capabilities() & Application::SupportsFlame)
|
||||
pages.append(FlameResourcePackPage::create(this, *m_instance));
|
||||
|
||||
m_selectedPage = dynamic_cast<ResourcePackResourcePage*>(pages[0]);
|
||||
|
||||
return pages;
|
||||
}
|
||||
|
||||
@ -357,8 +349,6 @@ QList<BasePage*> TexturePackDownloadDialog::getPages()
|
||||
if (APPLICATION->capabilities() & Application::SupportsFlame)
|
||||
pages.append(FlameTexturePackPage::create(this, *m_instance));
|
||||
|
||||
m_selectedPage = dynamic_cast<TexturePackResourcePage*>(pages[0]);
|
||||
|
||||
return pages;
|
||||
}
|
||||
|
||||
@ -379,11 +369,7 @@ ShaderPackDownloadDialog::ShaderPackDownloadDialog(QWidget* parent,
|
||||
QList<BasePage*> ShaderPackDownloadDialog::getPages()
|
||||
{
|
||||
QList<BasePage*> pages;
|
||||
|
||||
pages.append(ModrinthShaderPackPage::create(this, *m_instance));
|
||||
|
||||
m_selectedPage = dynamic_cast<ShaderPackResourcePage*>(pages[0]);
|
||||
|
||||
return pages;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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
|
||||
@ -61,7 +61,7 @@ class ResourceDownloadDialog : public QDialog, public BasePageProvider {
|
||||
QString dialogTitle() override { return tr("Download %1").arg(resourcesString()); };
|
||||
|
||||
bool selectPage(QString pageId);
|
||||
ResourcePage* getSelectedPage();
|
||||
ResourcePage* selectedPage();
|
||||
|
||||
void addResource(ModPlatform::IndexedPack::Ptr, ModPlatform::IndexedVersion&);
|
||||
void removeResource(const QString&);
|
||||
@ -88,7 +88,6 @@ class ResourceDownloadDialog : public QDialog, public BasePageProvider {
|
||||
const std::shared_ptr<ResourceFolderModel> m_base_model;
|
||||
|
||||
PageContainer* m_container = nullptr;
|
||||
ResourcePage* m_selectedPage = nullptr;
|
||||
|
||||
QDialogButtonBox m_buttons;
|
||||
QVBoxLayout m_vertical_layout;
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
ReviewMessageBox::ReviewMessageBox(QWidget* parent, QString const& title, QString const& icon)
|
||||
ReviewMessageBox::ReviewMessageBox(QWidget* parent, [[maybe_unused]] QString const& title, [[maybe_unused]] QString const& icon)
|
||||
: QDialog(parent), ui(new Ui::ReviewMessageBox)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -133,15 +133,15 @@ SkinUploadDialog::SkinUploadDialog(MinecraftAccountPtr acct, QWidget* parent) :
|
||||
ui->setupUi(this);
|
||||
|
||||
// FIXME: add a model for this, download/refresh the capes on demand
|
||||
auto& data = *acct->accountData();
|
||||
auto& accountData = *acct->accountData();
|
||||
int index = 0;
|
||||
ui->capeCombo->addItem(tr("No Cape"), QVariant());
|
||||
auto currentCape = data.minecraftProfile.currentCape;
|
||||
auto currentCape = accountData.minecraftProfile.currentCape;
|
||||
if (currentCape.isEmpty()) {
|
||||
ui->capeCombo->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
for (auto& cape : data.minecraftProfile.capes) {
|
||||
for (auto& cape : accountData.minecraftProfile.capes) {
|
||||
index++;
|
||||
if (cape.data.size()) {
|
||||
QPixmap capeImage;
|
||||
|
@ -42,7 +42,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -54,7 +54,7 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList* vlist, QString title,
|
||||
m_verticalLayout = new QVBoxLayout(this);
|
||||
m_verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
|
||||
|
||||
m_versionWidget = new VersionSelectWidget(true, parent);
|
||||
m_versionWidget = new VersionSelectWidget(parent);
|
||||
m_verticalLayout->addWidget(m_versionWidget);
|
||||
|
||||
m_horizontalLayout = new QHBoxLayout();
|
||||
@ -74,8 +74,9 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList* vlist, QString title,
|
||||
|
||||
retranslate();
|
||||
|
||||
QObject::connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(m_versionWidget->view(), &QAbstractItemView::doubleClicked, this, &QDialog::accept);
|
||||
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
setWindowModality(Qt::WindowModal);
|
||||
@ -121,6 +122,7 @@ int VersionSelectDialog::exec()
|
||||
{
|
||||
QDialog::open();
|
||||
m_versionWidget->initialize(m_vlist);
|
||||
m_versionWidget->selectSearch();
|
||||
if (resizeOnColumn != -1) {
|
||||
m_versionWidget->setResizeOn(resizeOnColumn);
|
||||
}
|
||||
@ -147,6 +149,11 @@ void VersionSelectDialog::setExactFilter(BaseVersionList::ModelRoles role, QStri
|
||||
m_versionWidget->setExactFilter(role, filter);
|
||||
}
|
||||
|
||||
void VersionSelectDialog::setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter)
|
||||
{
|
||||
m_versionWidget->setExactIfPresentFilter(role, filter);
|
||||
}
|
||||
|
||||
void VersionSelectDialog::setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter)
|
||||
{
|
||||
m_versionWidget->setFuzzyFilter(role, filter);
|
||||
|
@ -46,6 +46,7 @@ class VersionSelectDialog : public QDialog {
|
||||
void setCurrentVersion(const QString& version);
|
||||
void setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter);
|
||||
void setExactFilter(BaseVersionList::ModelRoles role, QString filter);
|
||||
void setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter);
|
||||
void setEmptyString(QString emptyString);
|
||||
void setEmptyErrorString(QString emptyErrorString);
|
||||
void setResizeOn(int column);
|
||||
|
@ -367,7 +367,9 @@ class NoReturnTextEdit : public QTextEdit {
|
||||
void editingDone();
|
||||
};
|
||||
|
||||
void ListViewDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
void ListViewDelegate::updateEditorGeometry(QWidget* editor,
|
||||
const QStyleOptionViewItem& option,
|
||||
[[maybe_unused]] const QModelIndex& index) const
|
||||
{
|
||||
const int iconSize = 48;
|
||||
QRect textRect = option.rect;
|
||||
@ -379,17 +381,17 @@ void ListViewDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionV
|
||||
void ListViewDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
|
||||
{
|
||||
auto text = index.data(Qt::EditRole).toString();
|
||||
QTextEdit* realeditor = qobject_cast<NoReturnTextEdit*>(editor);
|
||||
realeditor->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
||||
realeditor->append(text);
|
||||
realeditor->selectAll();
|
||||
realeditor->document()->clearUndoRedoStacks();
|
||||
QTextEdit* realEditor = qobject_cast<NoReturnTextEdit*>(editor);
|
||||
realEditor->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
||||
realEditor->append(text);
|
||||
realEditor->selectAll();
|
||||
realEditor->document()->clearUndoRedoStacks();
|
||||
}
|
||||
|
||||
void ListViewDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
|
||||
{
|
||||
QTextEdit* realeditor = qobject_cast<NoReturnTextEdit*>(editor);
|
||||
QString text = realeditor->toPlainText();
|
||||
QTextEdit* realEditor = qobject_cast<NoReturnTextEdit*>(editor);
|
||||
QString text = realEditor->toPlainText();
|
||||
text.replace(QChar('\n'), QChar(' '));
|
||||
text = text.trimmed();
|
||||
// Prevent instance names longer than 128 chars
|
||||
@ -399,7 +401,9 @@ void ListViewDelegate::setModelData(QWidget* editor, QAbstractItemModel* model,
|
||||
}
|
||||
}
|
||||
|
||||
QWidget* ListViewDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
QWidget* ListViewDelegate::createEditor(QWidget* parent,
|
||||
[[maybe_unused]] const QStyleOptionViewItem& option,
|
||||
[[maybe_unused]] const QModelIndex& index) const
|
||||
{
|
||||
auto editor = new NoReturnTextEdit(parent);
|
||||
connect(editor, &NoReturnTextEdit::editingDone, this, &ListViewDelegate::editingDone);
|
||||
|
@ -47,8 +47,8 @@
|
||||
#include <QScrollBar>
|
||||
#include <QtMath>
|
||||
|
||||
#include <QDebug>
|
||||
#include "VisualGroup.h"
|
||||
#include "ui/themes/ThemeManager.h"
|
||||
|
||||
#include <Application.h>
|
||||
#include <InstanceList.h>
|
||||
@ -86,16 +86,18 @@ void InstanceView::setModel(QAbstractItemModel* model)
|
||||
connect(model, &QAbstractItemModel::rowsRemoved, this, &InstanceView::rowsRemoved);
|
||||
}
|
||||
|
||||
void InstanceView::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles)
|
||||
void InstanceView::dataChanged([[maybe_unused]] const QModelIndex& topLeft,
|
||||
[[maybe_unused]] const QModelIndex& bottomRight,
|
||||
[[maybe_unused]] const QVector<int>& roles)
|
||||
{
|
||||
scheduleDelayedItemsLayout();
|
||||
}
|
||||
void InstanceView::rowsInserted(const QModelIndex& parent, int start, int end)
|
||||
void InstanceView::rowsInserted([[maybe_unused]] const QModelIndex& parent, [[maybe_unused]] int start, [[maybe_unused]] int end)
|
||||
{
|
||||
scheduleDelayedItemsLayout();
|
||||
}
|
||||
|
||||
void InstanceView::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end)
|
||||
void InstanceView::rowsAboutToBeRemoved([[maybe_unused]] const QModelIndex& parent, [[maybe_unused]] int start, [[maybe_unused]] int end)
|
||||
{
|
||||
scheduleDelayedItemsLayout();
|
||||
}
|
||||
@ -239,9 +241,9 @@ QString InstanceView::groupNameAt(const QPoint& point)
|
||||
{
|
||||
executeDelayedItemsLayout();
|
||||
|
||||
VisualGroup::HitResults hitresult;
|
||||
auto group = categoryAt(point + offset(), hitresult);
|
||||
if (group && (hitresult & (VisualGroup::HeaderHit | VisualGroup::BodyHit))) {
|
||||
VisualGroup::HitResults hitResult;
|
||||
auto group = categoryAt(point + offset(), hitResult);
|
||||
if (group && (hitResult & (VisualGroup::HeaderHit | VisualGroup::BodyHit))) {
|
||||
return group->text;
|
||||
}
|
||||
return QString();
|
||||
@ -275,9 +277,9 @@ void InstanceView::mousePressEvent(QMouseEvent* event)
|
||||
m_pressedAlreadySelected = selectionModel()->isSelected(m_pressedIndex);
|
||||
m_pressedPosition = geometryPos;
|
||||
|
||||
VisualGroup::HitResults hitresult;
|
||||
m_pressedCategory = categoryAt(geometryPos, hitresult);
|
||||
if (m_pressedCategory && hitresult & VisualGroup::CheckboxHit) {
|
||||
VisualGroup::HitResults hitResult;
|
||||
m_pressedCategory = categoryAt(geometryPos, hitResult);
|
||||
if (m_pressedCategory && hitResult & VisualGroup::CheckboxHit) {
|
||||
setState(m_pressedCategory->collapsed ? ExpandingState : CollapsingState);
|
||||
event->accept();
|
||||
return;
|
||||
@ -361,10 +363,10 @@ void InstanceView::mouseReleaseEvent(QMouseEvent* event)
|
||||
QPoint geometryPos = event->pos() + offset();
|
||||
QPersistentModelIndex index = indexAt(visualPos);
|
||||
|
||||
VisualGroup::HitResults hitresult;
|
||||
VisualGroup::HitResults hitResult;
|
||||
|
||||
bool click =
|
||||
(index == m_pressedIndex && index.isValid()) || (m_pressedCategory && m_pressedCategory == categoryAt(geometryPos, hitresult));
|
||||
(index == m_pressedIndex && index.isValid()) || (m_pressedCategory && m_pressedCategory == categoryAt(geometryPos, hitResult));
|
||||
|
||||
if (click && m_pressedCategory) {
|
||||
if (state() == ExpandingState) {
|
||||
@ -444,12 +446,12 @@ void InstanceView::setPaintCat(bool visible)
|
||||
{
|
||||
m_catVisible = visible;
|
||||
if (visible)
|
||||
m_catPixmap.load(APPLICATION->getCatPack());
|
||||
m_catPixmap.load(APPLICATION->themeManager()->getCatPack());
|
||||
else
|
||||
m_catPixmap = QPixmap();
|
||||
}
|
||||
|
||||
void InstanceView::paintEvent(QPaintEvent* event)
|
||||
void InstanceView::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
{
|
||||
executeDelayedItemsLayout();
|
||||
|
||||
@ -545,7 +547,7 @@ void InstanceView::paintEvent(QPaintEvent* event)
|
||||
#endif
|
||||
}
|
||||
|
||||
void InstanceView::resizeEvent(QResizeEvent* event)
|
||||
void InstanceView::resizeEvent([[maybe_unused]] QResizeEvent* event)
|
||||
{
|
||||
int newItemsPerRow = calculateItemsPerRow();
|
||||
if (newItemsPerRow != m_currentItemsPerRow) {
|
||||
@ -581,7 +583,7 @@ void InstanceView::dragMoveEvent(QDragMoveEvent* event)
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void InstanceView::dragLeaveEvent(QDragLeaveEvent* event)
|
||||
void InstanceView::dragLeaveEvent([[maybe_unused]] QDragLeaveEvent* event)
|
||||
{
|
||||
executeDelayedItemsLayout();
|
||||
|
||||
@ -604,9 +606,9 @@ void InstanceView::dropEvent(QDropEvent* event)
|
||||
if (event->possibleActions() & Qt::MoveAction) {
|
||||
std::pair<VisualGroup*, VisualGroup::HitResults> dropPos = rowDropPos(event->pos());
|
||||
const VisualGroup* group = dropPos.first;
|
||||
auto hitresult = dropPos.second;
|
||||
auto hitResult = dropPos.second;
|
||||
|
||||
if (hitresult == VisualGroup::HitResult::NoHit) {
|
||||
if (hitResult == VisualGroup::HitResult::NoHit) {
|
||||
viewport()->update();
|
||||
return;
|
||||
}
|
||||
@ -643,15 +645,15 @@ void InstanceView::startDrag(Qt::DropActions supportedActions)
|
||||
if (indexes.count() == 0)
|
||||
return;
|
||||
|
||||
QMimeData* data = model()->mimeData(indexes);
|
||||
if (!data) {
|
||||
QMimeData* mimeData = model()->mimeData(indexes);
|
||||
if (!mimeData) {
|
||||
return;
|
||||
}
|
||||
QRect rect;
|
||||
QPixmap pixmap = renderToPixmap(indexes, &rect);
|
||||
QDrag* drag = new QDrag(this);
|
||||
drag->setPixmap(pixmap);
|
||||
drag->setMimeData(data);
|
||||
drag->setMimeData(mimeData);
|
||||
drag->setHotSpot(m_pressedPosition - rect.topLeft());
|
||||
Qt::DropAction defaultDropAction = Qt::IgnoreAction;
|
||||
if (this->defaultDropAction() != Qt::IgnoreAction && (supportedActions & this->defaultDropAction())) {
|
||||
@ -767,16 +769,16 @@ QList<std::pair<QRect, QModelIndex>> InstanceView::draggablePaintPairs(const QMo
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool InstanceView::isDragEventAccepted(QDropEvent* event)
|
||||
bool InstanceView::isDragEventAccepted([[maybe_unused]] QDropEvent* event)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::pair<VisualGroup*, VisualGroup::HitResults> InstanceView::rowDropPos(const QPoint& pos)
|
||||
{
|
||||
VisualGroup::HitResults hitresult;
|
||||
auto group = categoryAt(pos + offset(), hitresult);
|
||||
return std::make_pair(group, hitresult);
|
||||
VisualGroup::HitResults hitResult;
|
||||
auto group = categoryAt(pos + offset(), hitResult);
|
||||
return std::make_pair(group, hitResult);
|
||||
}
|
||||
|
||||
QPoint InstanceView::offset() const
|
||||
@ -802,7 +804,7 @@ QRegion InstanceView::visualRegionForSelection(const QItemSelection& selection)
|
||||
return region;
|
||||
}
|
||||
|
||||
QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
|
||||
QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorAction, [[maybe_unused]] Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
auto current = currentIndex();
|
||||
if (!current.isValid()) {
|
||||
@ -822,20 +824,20 @@ QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorActio
|
||||
switch (cursorAction) {
|
||||
case MoveUp: {
|
||||
if (row == 0) {
|
||||
int prevgroupindex = group_index - 1;
|
||||
while (prevgroupindex >= 0) {
|
||||
auto prevgroup = m_groups[prevgroupindex];
|
||||
if (prevgroup->collapsed) {
|
||||
prevgroupindex--;
|
||||
int prevGroupIndex = group_index - 1;
|
||||
while (prevGroupIndex >= 0) {
|
||||
auto prevGroup = m_groups[prevGroupIndex];
|
||||
if (prevGroup->collapsed) {
|
||||
prevGroupIndex--;
|
||||
continue;
|
||||
}
|
||||
int newRow = prevgroup->numRows() - 1;
|
||||
int newRowSize = prevgroup->rows[newRow].size();
|
||||
int newRow = prevGroup->numRows() - 1;
|
||||
int newRowSize = prevGroup->rows[newRow].size();
|
||||
int newColumn = m_currentCursorColumn;
|
||||
if (m_currentCursorColumn >= newRowSize) {
|
||||
newColumn = newRowSize - 1;
|
||||
}
|
||||
return prevgroup->rows[newRow][newColumn];
|
||||
return prevGroup->rows[newRow][newColumn];
|
||||
}
|
||||
} else {
|
||||
int newRow = row - 1;
|
||||
@ -850,19 +852,19 @@ QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorActio
|
||||
}
|
||||
case MoveDown: {
|
||||
if (row == cat->rows.size() - 1) {
|
||||
int nextgroupindex = group_index + 1;
|
||||
while (nextgroupindex < m_groups.size()) {
|
||||
auto nextgroup = m_groups[nextgroupindex];
|
||||
if (nextgroup->collapsed) {
|
||||
nextgroupindex++;
|
||||
int nextGroupIndex = group_index + 1;
|
||||
while (nextGroupIndex < m_groups.size()) {
|
||||
auto nextGroup = m_groups[nextGroupIndex];
|
||||
if (nextGroup->collapsed) {
|
||||
nextGroupIndex++;
|
||||
continue;
|
||||
}
|
||||
int newRowSize = nextgroup->rows[0].size();
|
||||
int newRowSize = nextGroup->rows[0].size();
|
||||
int newColumn = m_currentCursorColumn;
|
||||
if (m_currentCursorColumn >= newRowSize) {
|
||||
newColumn = newRowSize - 1;
|
||||
}
|
||||
return nextgroup->rows[0][newColumn];
|
||||
return nextGroup->rows[0][newColumn];
|
||||
}
|
||||
} else {
|
||||
int newRow = row + 1;
|
||||
@ -936,7 +938,7 @@ void InstanceView::scrollTo(const QModelIndex& index, ScrollHint hint)
|
||||
verticalScrollBar()->setValue(verticalScrollToValue(index, rect, hint));
|
||||
}
|
||||
|
||||
int InstanceView::verticalScrollToValue(const QModelIndex& index, const QRect& rect, QListView::ScrollHint hint) const
|
||||
int InstanceView::verticalScrollToValue([[maybe_unused]] const QModelIndex& index, const QRect& rect, QListView::ScrollHint hint) const
|
||||
{
|
||||
const QRect area = viewport()->rect();
|
||||
const bool above = (hint == QListView::EnsureVisible && rect.top() < area.top());
|
||||
|
@ -6,6 +6,7 @@ class BasePageContainer {
|
||||
public:
|
||||
virtual ~BasePageContainer(){};
|
||||
virtual bool selectPage(QString pageId) = 0;
|
||||
virtual BasePage* selectedPage() const = 0;
|
||||
virtual BasePage* getPage(QString pageId) { return nullptr; };
|
||||
virtual void refreshContainer() = 0;
|
||||
virtual bool requestClose() = 0;
|
||||
|
@ -83,7 +83,7 @@ AccountListPage::AccountListPage(QWidget* parent) : QMainWindow(parent), ui(new
|
||||
QItemSelectionModel* selectionModel = ui->listView->selectionModel();
|
||||
|
||||
connect(selectionModel, &QItemSelectionModel::selectionChanged,
|
||||
[this](const QItemSelection& sel, const QItemSelection& dsel) { updateButtonStates(); });
|
||||
[this]([[maybe_unused]] const QItemSelection& sel, [[maybe_unused]] const QItemSelection& dsel) { updateButtonStates(); });
|
||||
connect(ui->listView, &VersionListView::customContextMenuRequested, this, &AccountListPage::ShowContextMenu);
|
||||
|
||||
connect(m_accounts.get(), &AccountList::listChanged, this, &AccountListPage::listChanged);
|
||||
|
@ -47,7 +47,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="jprofilerPathBtn">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -84,7 +84,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="jvisualvmPathBtn">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -121,7 +121,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="mceditPathBtn">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -166,7 +166,7 @@
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="jsonEditorBrowseBtn">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -166,7 +166,7 @@ void JavaPage::on_javaTestBtn_clicked()
|
||||
checker->run();
|
||||
}
|
||||
|
||||
void JavaPage::on_maxMemSpinBox_valueChanged(int i)
|
||||
void JavaPage::on_maxMemSpinBox_valueChanged([[maybe_unused]] int i)
|
||||
{
|
||||
updateThresholds();
|
||||
}
|
||||
|
@ -160,117 +160,7 @@
|
||||
<string>Java Runtime</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="javaDetectBtn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Auto-detect...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelJVMArgs">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>JVM arguments:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelJavaPath">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Java path:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>javaPathTextBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="javaTestBtn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Test</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="javaPathTextBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="javaBrowseBtn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="skipCompatibilityCheckbox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>If enabled, the launcher will not check if an instance is compatible with the selected Java version.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Skip Java compatibility checks</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="skipJavaWizardCheckbox">
|
||||
<property name="toolTip">
|
||||
<string>If enabled, the launcher will not prompt you to choose a Java version if one isn't found.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Skip Java &Wizard</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<item row="7" column="0" colspan="3">
|
||||
<widget class="QPlainTextEdit" name="jvmArgsTextBox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
@ -289,6 +179,114 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="skipCompatibilityCheckbox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>If enabled, the launcher will not check if an instance is compatible with the selected Java version.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Skip Java compatibility checks</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="javaDetectBtn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Auto-detect...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="javaTestBtn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Test</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="labelJVMArgs">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>JVM arguments:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelJavaPath">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Java path:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>javaPathTextBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="javaPathTextBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="javaBrowseBtn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="skipJavaWizardCheckbox">
|
||||
<property name="toolTip">
|
||||
<string>If enabled, the launcher will not prompt you to choose a Java version if one isn't found.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Skip Java &Wizard</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -317,8 +315,6 @@
|
||||
<tabstop>permGenSpinBox</tabstop>
|
||||
<tabstop>javaBrowseBtn</tabstop>
|
||||
<tabstop>javaPathTextBox</tabstop>
|
||||
<tabstop>javaDetectBtn</tabstop>
|
||||
<tabstop>javaTestBtn</tabstop>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
|
@ -99,7 +99,7 @@
|
||||
<item row="3" column="2">
|
||||
<widget class="QToolButton" name="downloadsDirBrowseBtn">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -109,7 +109,7 @@
|
||||
<item row="1" column="2">
|
||||
<widget class="QToolButton" name="modsDirBrowseBtn">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -126,14 +126,14 @@
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="instDirBrowseBtn">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QToolButton" name="iconsDirBrowseBtn">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -71,7 +71,7 @@ void ProxyPage::updateCheckboxStuff()
|
||||
ui->proxyAuthBox->setEnabled(enableEditing);
|
||||
}
|
||||
|
||||
void ProxyPage::proxyGroupChanged(QAbstractButton* button)
|
||||
void ProxyPage::proxyGroupChanged([[maybe_unused]] QAbstractButton* button)
|
||||
{
|
||||
updateCheckboxStuff();
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ bool ExternalResourcesPage::current(const QModelIndex& current, const QModelInde
|
||||
return onSelectionChanged(current, previous);
|
||||
}
|
||||
|
||||
bool ExternalResourcesPage::onSelectionChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
bool ExternalResourcesPage::onSelectionChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
auto sourceCurrent = m_filterModel->mapToSource(current);
|
||||
int row = sourceCurrent.row();
|
||||
|
@ -440,7 +440,7 @@ void InstanceSettingsPage::changeInstanceAccount(int index)
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceSettingsPage::on_maxMemSpinBox_valueChanged(int i)
|
||||
void InstanceSettingsPage::on_maxMemSpinBox_valueChanged([[maybe_unused]] int i)
|
||||
{
|
||||
updateThresholds();
|
||||
}
|
||||
|
@ -61,31 +61,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QLineEdit" name="javaPathTextBox"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="javaDetectBtn">
|
||||
<property name="text">
|
||||
<string>Auto-detect...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="javaBrowseBtn">
|
||||
<property name="text">
|
||||
<string>Browse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="javaTestBtn">
|
||||
<property name="text">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="skipCompatibilityCheckbox">
|
||||
<property name="toolTip">
|
||||
<string>If enabled, the launcher will not check if an instance is compatible with the selected Java version.</string>
|
||||
@ -95,6 +71,38 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="javaPathTextBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="javaBrowseBtn">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="javaDetectBtn">
|
||||
<property name="text">
|
||||
<string>Auto-detect...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="javaTestBtn">
|
||||
<property name="text">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -699,10 +707,6 @@
|
||||
<tabstop>openGlobalJavaSettingsButton</tabstop>
|
||||
<tabstop>settingsTabs</tabstop>
|
||||
<tabstop>javaSettingsGroupBox</tabstop>
|
||||
<tabstop>javaPathTextBox</tabstop>
|
||||
<tabstop>javaDetectBtn</tabstop>
|
||||
<tabstop>javaBrowseBtn</tabstop>
|
||||
<tabstop>javaTestBtn</tabstop>
|
||||
<tabstop>memoryGroupBox</tabstop>
|
||||
<tabstop>minMemSpinBox</tabstop>
|
||||
<tabstop>maxMemSpinBox</tabstop>
|
||||
|
@ -3,6 +3,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include "ManagedPackPage.h"
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QUrlQuery>
|
||||
#include "ui_ManagedPackPage.h"
|
||||
|
||||
#include <QListView>
|
||||
@ -23,6 +26,8 @@
|
||||
#include "ui/dialogs/CustomMessageBox.h"
|
||||
#include "ui/dialogs/ProgressDialog.h"
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
|
||||
/** This is just to override the combo box popup behavior so that the combo box doesn't take the whole screen.
|
||||
* ... thanks Qt.
|
||||
*/
|
||||
@ -103,6 +108,19 @@ ManagedPackPage::ManagedPackPage(BaseInstance* inst, InstanceWindow* instance_wi
|
||||
// Pretend we're opening the page again
|
||||
openedImpl();
|
||||
});
|
||||
|
||||
connect(ui->changelogTextBrowser, &QTextBrowser::anchorClicked, this, [](const QUrl url) {
|
||||
if (url.scheme().isEmpty()) {
|
||||
auto querry =
|
||||
QUrlQuery(url.query()).queryItemValue("remoteUrl", QUrl::FullyDecoded); // curseforge workaround for linkout?remoteUrl=
|
||||
auto decoded = QUrl::fromPercentEncoding(querry.toUtf8());
|
||||
auto newUrl = QUrl(decoded);
|
||||
if (newUrl.isValid() && (newUrl.scheme() == "http" || newUrl.scheme() == "https"))
|
||||
QDesktopServices ::openUrl(newUrl);
|
||||
return;
|
||||
}
|
||||
QDesktopServices::openUrl(url);
|
||||
});
|
||||
}
|
||||
|
||||
ManagedPackPage::~ManagedPackPage()
|
||||
@ -226,7 +244,7 @@ void ModrinthManagedPackPage::parseManagedPack()
|
||||
QString id = m_inst->getManagedPackID();
|
||||
|
||||
m_fetch_job->addNetAction(
|
||||
Net::Download::makeByteArray(QString("%1/project/%2/version").arg(BuildConfig.MODRINTH_PROD_URL, id), response));
|
||||
Net::ApiDownload::makeByteArray(QString("%1/project/%2/version").arg(BuildConfig.MODRINTH_PROD_URL, id), response));
|
||||
|
||||
QObject::connect(m_fetch_job.get(), &NetJob::succeeded, this, [this, response, id] {
|
||||
QJsonParseError parse_error{};
|
||||
@ -376,7 +394,7 @@ void FlameManagedPackPage::parseManagedPack()
|
||||
|
||||
QString id = m_inst->getManagedPackID();
|
||||
|
||||
m_fetch_job->addNetAction(Net::Download::makeByteArray(QString("%1/mods/%2/files").arg(BuildConfig.FLAME_BASE_URL, id), response));
|
||||
m_fetch_job->addNetAction(Net::ApiDownload::makeByteArray(QString("%1/mods/%2/files").arg(BuildConfig.FLAME_BASE_URL, id), response));
|
||||
|
||||
QObject::connect(m_fetch_job.get(), &NetJob::succeeded, this, [this, response, id] {
|
||||
QJsonParseError parse_error{};
|
||||
|
@ -168,10 +168,13 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="changelogTextBrowser">
|
||||
<widget class="ProjectDescriptionPage" name="changelogTextBrowser">
|
||||
<property name="placeholderText">
|
||||
<string>No changelog available for this version!</string>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -188,6 +191,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ProjectDescriptionPage</class>
|
||||
<extends>QTextBrowser</extends>
|
||||
<header>ui/widgets/ProjectDescriptionPage.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -127,7 +127,7 @@ bool ModFolderPage::shouldDisplay() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ModFolderPage::onSelectionChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
bool ModFolderPage::onSelectionChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
auto sourceCurrent = m_filterModel->mapToSource(current);
|
||||
int row = sourceCurrent.row();
|
||||
|
@ -246,20 +246,20 @@ void OtherLogsPage::on_btnClean_clicked()
|
||||
}
|
||||
}
|
||||
if (!failed.empty()) {
|
||||
QMessageBox* messageBox = new QMessageBox(this);
|
||||
messageBox->setWindowTitle(tr("Error"));
|
||||
QMessageBox* messageBoxFailure = new QMessageBox(this);
|
||||
messageBoxFailure->setWindowTitle(tr("Error"));
|
||||
if (failed.size() > 5) {
|
||||
messageBox->setText(tr("Couldn't delete some files!"));
|
||||
messageBox->setDetailedText(failed.join('\n'));
|
||||
messageBoxFailure->setText(tr("Couldn't delete some files!"));
|
||||
messageBoxFailure->setDetailedText(failed.join('\n'));
|
||||
} else {
|
||||
messageBox->setText(tr("Couldn't delete some files:\n%1").arg(failed.join('\n')));
|
||||
messageBoxFailure->setText(tr("Couldn't delete some files:\n%1").arg(failed.join('\n')));
|
||||
}
|
||||
messageBox->setStandardButtons(QMessageBox::Ok);
|
||||
messageBox->setDefaultButton(QMessageBox::Ok);
|
||||
messageBox->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
messageBox->setIcon(QMessageBox::Critical);
|
||||
messageBox->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
messageBox->exec();
|
||||
messageBoxFailure->setStandardButtons(QMessageBox::Ok);
|
||||
messageBoxFailure->setDefaultButton(QMessageBox::Ok);
|
||||
messageBoxFailure->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
messageBoxFailure->setIcon(QMessageBox::Critical);
|
||||
messageBoxFailure->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
messageBoxFailure->exec();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ ResourcePackPage::ResourcePackPage(MinecraftInstance* instance, std::shared_ptr<
|
||||
ui->actionViewConfigs->setVisible(false);
|
||||
}
|
||||
|
||||
bool ResourcePackPage::onSelectionChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
bool ResourcePackPage::onSelectionChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
auto sourceCurrent = m_filterModel->mapToSource(current);
|
||||
int row = sourceCurrent.row();
|
||||
|
@ -607,7 +607,7 @@ void ServersPage::runningStateChanged(bool running)
|
||||
updateState();
|
||||
}
|
||||
|
||||
void ServersPage::currentChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
void ServersPage::currentChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
int nextServer = -1;
|
||||
if (!current.isValid()) {
|
||||
@ -620,7 +620,7 @@ void ServersPage::currentChanged(const QModelIndex& current, const QModelIndex&
|
||||
}
|
||||
|
||||
// WARNING: this is here because currentChanged is not accurate when removing rows. the current item needs to be fixed up after removal.
|
||||
void ServersPage::rowsRemoved(const QModelIndex& parent, int first, int last)
|
||||
void ServersPage::rowsRemoved([[maybe_unused]] const QModelIndex& parent, int first, int last)
|
||||
{
|
||||
if (currentServer < first) {
|
||||
// current was before the removal
|
||||
|
@ -57,7 +57,7 @@ TexturePackPage::TexturePackPage(MinecraftInstance* instance, std::shared_ptr<Te
|
||||
ui->actionViewConfigs->setVisible(false);
|
||||
}
|
||||
|
||||
bool TexturePackPage::onSelectionChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
bool TexturePackPage::onSelectionChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
auto sourceCurrent = m_filterModel->mapToSource(current);
|
||||
int row = sourceCurrent.row();
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright (C) 2022-2023 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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
|
||||
@ -51,6 +51,7 @@
|
||||
#include <QUrl>
|
||||
|
||||
#include "VersionPage.h"
|
||||
#include "ui/dialogs/InstallLoaderDialog.h"
|
||||
#include "ui_VersionPage.h"
|
||||
|
||||
#include "ui/dialogs/CustomMessageBox.h"
|
||||
@ -188,7 +189,7 @@ void VersionPage::showContextMenu(const QPoint& pos)
|
||||
delete menu;
|
||||
}
|
||||
|
||||
void VersionPage::packageCurrent(const QModelIndex& current, const QModelIndex& previous)
|
||||
void VersionPage::packageCurrent(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
if (!current.isValid()) {
|
||||
ui->frame->clear();
|
||||
@ -226,18 +227,6 @@ void VersionPage::packageCurrent(const QModelIndex& current, const QModelIndex&
|
||||
|
||||
void VersionPage::updateVersionControls()
|
||||
{
|
||||
// FIXME: this is a dirty hack
|
||||
auto minecraftVersion = Version(m_profile->getComponentVersion("net.minecraft"));
|
||||
|
||||
bool supportsFabric = minecraftVersion >= Version("1.14");
|
||||
ui->actionInstall_Fabric->setEnabled(supportsFabric);
|
||||
|
||||
bool supportsQuilt = minecraftVersion >= Version("1.14");
|
||||
ui->actionInstall_Quilt->setEnabled(supportsQuilt);
|
||||
|
||||
bool supportsLiteLoader = minecraftVersion <= Version("1.12.2");
|
||||
ui->actionInstall_LiteLoader->setEnabled(supportsLiteLoader);
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
@ -389,20 +378,14 @@ void VersionPage::on_actionChange_version_triggered()
|
||||
return;
|
||||
}
|
||||
auto uid = list->uid();
|
||||
// FIXME: this is a horrible HACK. Get version filtering information from the actual metadata...
|
||||
if (uid == "net.minecraftforge") {
|
||||
on_actionInstall_Forge_triggered();
|
||||
return;
|
||||
} else if (uid == "com.mumfrey.liteloader") {
|
||||
on_actionInstall_LiteLoader_triggered();
|
||||
return;
|
||||
}
|
||||
|
||||
VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this);
|
||||
if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed") {
|
||||
vselect.setEmptyString(tr("No intermediary mappings versions are currently available."));
|
||||
vselect.setEmptyErrorString(tr("Couldn't load or download the intermediary mappings version lists!"));
|
||||
vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
|
||||
}
|
||||
vselect.setExactIfPresentFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
|
||||
|
||||
auto currentVersion = patch->getVersion();
|
||||
if (!currentVersion.isEmpty()) {
|
||||
vselect.setCurrentVersion(currentVersion);
|
||||
@ -443,79 +426,11 @@ void VersionPage::on_actionDownload_All_triggered()
|
||||
m_container->refreshContainer();
|
||||
}
|
||||
|
||||
void VersionPage::on_actionInstall_Forge_triggered()
|
||||
void VersionPage::on_actionInstall_Loader_triggered()
|
||||
{
|
||||
auto vlist = APPLICATION->metadataIndex()->get("net.minecraftforge");
|
||||
if (!vlist) {
|
||||
return;
|
||||
}
|
||||
VersionSelectDialog vselect(vlist.get(), tr("Select Forge version"), this);
|
||||
vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
|
||||
vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") +
|
||||
m_profile->getComponentVersion("net.minecraft"));
|
||||
vselect.setEmptyErrorString(tr("Couldn't load or download the Forge version lists!"));
|
||||
|
||||
auto currentVersion = m_profile->getComponentVersion("net.minecraftforge");
|
||||
if (!currentVersion.isEmpty()) {
|
||||
vselect.setCurrentVersion(currentVersion);
|
||||
}
|
||||
|
||||
if (vselect.exec() && vselect.selectedVersion()) {
|
||||
auto vsn = vselect.selectedVersion();
|
||||
m_profile->setComponentVersion("net.minecraftforge", vsn->descriptor());
|
||||
m_profile->resolve(Net::Mode::Online);
|
||||
// m_profile->installVersion();
|
||||
preselect(m_profile->rowCount(QModelIndex()) - 1);
|
||||
m_container->refreshContainer();
|
||||
}
|
||||
}
|
||||
|
||||
void VersionPage::on_actionInstall_Fabric_triggered()
|
||||
{
|
||||
auto vlist = APPLICATION->metadataIndex()->get("net.fabricmc.fabric-loader");
|
||||
if (!vlist) {
|
||||
return;
|
||||
}
|
||||
VersionSelectDialog vselect(vlist.get(), tr("Select Fabric Loader version"), this);
|
||||
vselect.setEmptyString(tr("No Fabric Loader versions are currently available."));
|
||||
vselect.setEmptyErrorString(tr("Couldn't load or download the Fabric Loader version lists!"));
|
||||
|
||||
auto currentVersion = m_profile->getComponentVersion("net.fabricmc.fabric-loader");
|
||||
if (!currentVersion.isEmpty()) {
|
||||
vselect.setCurrentVersion(currentVersion);
|
||||
}
|
||||
|
||||
if (vselect.exec() && vselect.selectedVersion()) {
|
||||
auto vsn = vselect.selectedVersion();
|
||||
m_profile->setComponentVersion("net.fabricmc.fabric-loader", vsn->descriptor());
|
||||
m_profile->resolve(Net::Mode::Online);
|
||||
preselect(m_profile->rowCount(QModelIndex()) - 1);
|
||||
m_container->refreshContainer();
|
||||
}
|
||||
}
|
||||
|
||||
void VersionPage::on_actionInstall_Quilt_triggered()
|
||||
{
|
||||
auto vlist = APPLICATION->metadataIndex()->get("org.quiltmc.quilt-loader");
|
||||
if (!vlist) {
|
||||
return;
|
||||
}
|
||||
VersionSelectDialog vselect(vlist.get(), tr("Select Quilt Loader version"), this);
|
||||
vselect.setEmptyString(tr("No Quilt Loader versions are currently available."));
|
||||
vselect.setEmptyErrorString(tr("Couldn't load or download the Quilt Loader version lists!"));
|
||||
|
||||
auto currentVersion = m_profile->getComponentVersion("org.quiltmc.quilt-loader");
|
||||
if (!currentVersion.isEmpty()) {
|
||||
vselect.setCurrentVersion(currentVersion);
|
||||
}
|
||||
|
||||
if (vselect.exec() && vselect.selectedVersion()) {
|
||||
auto vsn = vselect.selectedVersion();
|
||||
m_profile->setComponentVersion("org.quiltmc.quilt-loader", vsn->descriptor());
|
||||
m_profile->resolve(Net::Mode::Online);
|
||||
preselect(m_profile->rowCount(QModelIndex()) - 1);
|
||||
m_container->refreshContainer();
|
||||
}
|
||||
InstallLoaderDialog dialog(m_inst->getPackProfile(), QString(), this);
|
||||
dialog.exec();
|
||||
m_container->refreshContainer();
|
||||
}
|
||||
|
||||
void VersionPage::on_actionAdd_Empty_triggered()
|
||||
@ -534,33 +449,6 @@ void VersionPage::on_actionAdd_Empty_triggered()
|
||||
}
|
||||
}
|
||||
|
||||
void VersionPage::on_actionInstall_LiteLoader_triggered()
|
||||
{
|
||||
auto vlist = APPLICATION->metadataIndex()->get("com.mumfrey.liteloader");
|
||||
if (!vlist) {
|
||||
return;
|
||||
}
|
||||
VersionSelectDialog vselect(vlist.get(), tr("Select LiteLoader version"), this);
|
||||
vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
|
||||
vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") +
|
||||
m_profile->getComponentVersion("net.minecraft"));
|
||||
vselect.setEmptyErrorString(tr("Couldn't load or download the LiteLoader version lists!"));
|
||||
|
||||
auto currentVersion = m_profile->getComponentVersion("com.mumfrey.liteloader");
|
||||
if (!currentVersion.isEmpty()) {
|
||||
vselect.setCurrentVersion(currentVersion);
|
||||
}
|
||||
|
||||
if (vselect.exec() && vselect.selectedVersion()) {
|
||||
auto vsn = vselect.selectedVersion();
|
||||
m_profile->setComponentVersion("com.mumfrey.liteloader", vsn->descriptor());
|
||||
m_profile->resolve(Net::Mode::Online);
|
||||
// m_profile->installVersion(vselect.selectedVersion());
|
||||
preselect(m_profile->rowCount(QModelIndex()) - 1);
|
||||
m_container->refreshContainer();
|
||||
}
|
||||
}
|
||||
|
||||
void VersionPage::on_actionLibrariesFolder_triggered()
|
||||
{
|
||||
DesktopServices::openDirectory(m_inst->getLocalLibraryPath(), true);
|
||||
@ -571,7 +459,7 @@ void VersionPage::on_actionMinecraftFolder_triggered()
|
||||
DesktopServices::openDirectory(m_inst->gameRoot(), true);
|
||||
}
|
||||
|
||||
void VersionPage::versionCurrent(const QModelIndex& current, const QModelIndex& previous)
|
||||
void VersionPage::versionCurrent(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
currentIdx = current.row();
|
||||
updateButtons(currentIdx);
|
||||
|
@ -68,11 +68,8 @@ class VersionPage : public QMainWindow, public BasePage {
|
||||
|
||||
private slots:
|
||||
void on_actionChange_version_triggered();
|
||||
void on_actionInstall_Forge_triggered();
|
||||
void on_actionInstall_Fabric_triggered();
|
||||
void on_actionInstall_Quilt_triggered();
|
||||
void on_actionInstall_Loader_triggered();
|
||||
void on_actionAdd_Empty_triggered();
|
||||
void on_actionInstall_LiteLoader_triggered();
|
||||
void on_actionReload_triggered();
|
||||
void on_actionRemove_triggered();
|
||||
void on_actionMove_up_triggered();
|
||||
|
@ -98,11 +98,7 @@
|
||||
<addaction name="actionEdit"/>
|
||||
<addaction name="actionRevert"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionInstall_Forge"/>
|
||||
<addaction name="actionInstall_Fabric"/>
|
||||
<addaction name="actionInstall_Quilt"/>
|
||||
<addaction name="actionInstall_LiteLoader"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionInstall_Loader"/>
|
||||
<addaction name="actionAdd_to_Minecraft_jar"/>
|
||||
<addaction name="actionReplace_Minecraft_jar"/>
|
||||
<addaction name="actionAdd_Agents"/>
|
||||
@ -116,26 +112,26 @@
|
||||
</widget>
|
||||
<action name="actionChange_version">
|
||||
<property name="text">
|
||||
<string>Change version</string>
|
||||
<string>Change Version</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Change version of the selected package.</string>
|
||||
<string>Change version of the selected component.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMove_up">
|
||||
<property name="text">
|
||||
<string>Move up</string>
|
||||
<string>Move Up</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Make the selected package apply sooner.</string>
|
||||
<string>Make the selected component apply sooner.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMove_down">
|
||||
<property name="text">
|
||||
<string>Move down</string>
|
||||
<string>Move Down</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Make the selected package apply later.</string>
|
||||
<string>Make the selected component apply later.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRemove">
|
||||
@ -143,7 +139,7 @@
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove selected package from the instance.</string>
|
||||
<string>Remove selected component from the instance.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCustomize">
|
||||
@ -151,7 +147,7 @@
|
||||
<string>Customize</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Customize selected package.</string>
|
||||
<string>Customize selected component.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEdit">
|
||||
@ -159,7 +155,7 @@
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Edit selected package.</string>
|
||||
<string>Edit selected component.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRevert">
|
||||
@ -167,39 +163,15 @@
|
||||
<string>Revert</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Revert the selected package to default.</string>
|
||||
<string>Revert the selected component to default.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInstall_Forge">
|
||||
<action name="actionInstall_Loader">
|
||||
<property name="text">
|
||||
<string>Install Forge</string>
|
||||
<string>Install Loader</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Install the Minecraft Forge package.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInstall_Fabric">
|
||||
<property name="text">
|
||||
<string>Install Fabric</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Install the Fabric Loader package.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInstall_Quilt">
|
||||
<property name="text">
|
||||
<string>Install Quilt</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Install the Quilt Loader package.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInstall_LiteLoader">
|
||||
<property name="text">
|
||||
<string>Install LiteLoader</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Install the LiteLoader package.</string>
|
||||
<string>Install a mod loader.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAdd_to_Minecraft_jar">
|
||||
@ -228,7 +200,7 @@
|
||||
<string>Add Empty</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add an empty custom package.</string>
|
||||
<string>Add an empty custom component.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionReload">
|
||||
@ -236,12 +208,12 @@
|
||||
<string>Reload</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reload all packages.</string>
|
||||
<string>Reload all components.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDownload_All">
|
||||
<property name="text">
|
||||
<string>Download All</string>
|
||||
<string>Download all</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Download the files needed to launch the instance now.</string>
|
||||
|
@ -327,7 +327,7 @@ void WorldListPage::mceditState(LoggedProcess::State state)
|
||||
}
|
||||
}
|
||||
|
||||
void WorldListPage::worldChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
void WorldListPage::worldChanged([[maybe_unused]] const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
QModelIndex index = getSelectedWorld();
|
||||
bool enable = index.isValid();
|
||||
|
@ -48,7 +48,7 @@ class UrlValidator : public QValidator {
|
||||
public:
|
||||
using QValidator::QValidator;
|
||||
|
||||
State validate(QString& in, int& pos) const
|
||||
State validate(QString& in, [[maybe_unused]] int& pos) const
|
||||
{
|
||||
const QUrl url(in);
|
||||
if (url.isValid() && !url.isRelative() && !url.isEmpty()) {
|
||||
@ -106,8 +106,8 @@ void ImportPage::updateState()
|
||||
bool isMRPack = fi.suffix() == "mrpack";
|
||||
|
||||
if (fi.exists() && (isZip || isMRPack)) {
|
||||
QFileInfo fi(url.fileName());
|
||||
dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url, this));
|
||||
QFileInfo file_info(url.fileName());
|
||||
dialog->setSuggestedPack(file_info.completeBaseName(), new InstanceImportTask(url, this));
|
||||
dialog->setSuggestedIcon("default");
|
||||
}
|
||||
} else {
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "BuildConfig.h"
|
||||
#include "Json.h"
|
||||
|
||||
#include "net/Download.h"
|
||||
#include "net/ApiDownload.h"
|
||||
#include "net/NetJob.h"
|
||||
|
||||
#include "modplatform/ModIndex.h"
|
||||
@ -105,7 +105,7 @@ QHash<int, QByteArray> ResourceModel::roleNames() const
|
||||
return roles;
|
||||
}
|
||||
|
||||
bool ResourceModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
bool ResourceModel::setData(const QModelIndex& index, const QVariant& value, [[maybe_unused]] int role)
|
||||
{
|
||||
int pos = index.row();
|
||||
if (pos >= m_packs.size() || pos < 0 || !index.isValid())
|
||||
@ -284,7 +284,7 @@ std::optional<QIcon> ResourceModel::getIcon(QModelIndex& index, const QUrl& url)
|
||||
auto cache_entry = APPLICATION->metacache()->resolveEntry(
|
||||
metaEntryBase(),
|
||||
QString("logos/%1").arg(QString(QCryptographicHash::hash(url.toEncoded(), QCryptographicHash::Algorithm::Sha1).toHex())));
|
||||
auto icon_fetch_action = Net::Download::makeCached(url, cache_entry);
|
||||
auto icon_fetch_action = Net::ApiDownload::makeCached(url, cache_entry);
|
||||
|
||||
auto full_file_path = cache_entry->getFullPath();
|
||||
connect(icon_fetch_action.get(), &NetAction::succeeded, this, [=] {
|
||||
@ -313,7 +313,7 @@ std::optional<QIcon> ResourceModel::getIcon(QModelIndex& index, const QUrl& url)
|
||||
#define NEED_FOR_CALLBACK_ASSERT(name) \
|
||||
Q_ASSERT_X(0 != 0, #name, "You NEED to re-implement this if you intend on using the default callbacks.")
|
||||
|
||||
QJsonArray ResourceModel::documentToArray(QJsonDocument& doc) const
|
||||
QJsonArray ResourceModel::documentToArray([[maybe_unused]] QJsonDocument& doc) const
|
||||
{
|
||||
NEED_FOR_CALLBACK_ASSERT("documentToArray");
|
||||
return {};
|
||||
@ -375,7 +375,7 @@ void ResourceModel::searchRequestSucceeded(QJsonDocument& doc)
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void ResourceModel::searchRequestFailed(QString reason, int network_error_code)
|
||||
void ResourceModel::searchRequestFailed([[maybe_unused]] QString reason, int network_error_code)
|
||||
{
|
||||
switch (network_error_code) {
|
||||
default:
|
||||
|
@ -42,7 +42,10 @@ class ResourceModel : public QAbstractListModel {
|
||||
[[nodiscard]] virtual auto debugName() const -> QString;
|
||||
[[nodiscard]] virtual auto metaEntryBase() const -> QString = 0;
|
||||
|
||||
[[nodiscard]] inline int rowCount(const QModelIndex& parent) const override { return parent.isValid() ? 0 : m_packs.size(); }
|
||||
[[nodiscard]] inline int rowCount(const QModelIndex& parent) const override
|
||||
{
|
||||
return parent.isValid() ? 0 : static_cast<int>(m_packs.size());
|
||||
}
|
||||
[[nodiscard]] inline int columnCount(const QModelIndex& parent) const override { return parent.isValid() ? 0 : 1; }
|
||||
[[nodiscard]] inline auto flags(const QModelIndex& index) const -> Qt::ItemFlags override { return QAbstractListModel::flags(index); }
|
||||
|
||||
|
@ -9,7 +9,8 @@
|
||||
namespace ResourceDownload {
|
||||
|
||||
ResourcePackResourceModel::ResourcePackResourceModel(BaseInstance const& base_inst, ResourceAPI* api)
|
||||
: ResourceModel(api), m_base_instance(base_inst){};
|
||||
: ResourceModel(api), m_base_instance(base_inst)
|
||||
{}
|
||||
|
||||
/******** Make data requests ********/
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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
|
||||
@ -280,7 +280,7 @@ void ResourcePage::updateVersionList()
|
||||
updateSelectionButton();
|
||||
}
|
||||
|
||||
void ResourcePage::onSelectionChanged(QModelIndex curr, QModelIndex prev)
|
||||
void ResourcePage::onSelectionChanged(QModelIndex curr, [[maybe_unused]] QModelIndex prev)
|
||||
{
|
||||
if (!curr.isValid()) {
|
||||
return;
|
||||
@ -307,9 +307,9 @@ void ResourcePage::onSelectionChanged(QModelIndex curr, QModelIndex prev)
|
||||
updateUi();
|
||||
}
|
||||
|
||||
void ResourcePage::onVersionSelectionChanged(QString data)
|
||||
void ResourcePage::onVersionSelectionChanged(QString versionData)
|
||||
{
|
||||
if (data.isNull() || data.isEmpty()) {
|
||||
if (versionData.isNull() || versionData.isEmpty()) {
|
||||
m_selected_version_index = -1;
|
||||
return;
|
||||
}
|
||||
@ -395,7 +395,7 @@ void ResourcePage::openUrl(const QUrl& url)
|
||||
if (auto current_pack = getCurrentPack(); current_pack && slug != current_pack->slug) {
|
||||
m_parent_dialog->selectPage(page);
|
||||
|
||||
auto newPage = m_parent_dialog->getSelectedPage();
|
||||
auto newPage = m_parent_dialog->selectedPage();
|
||||
|
||||
QLineEdit* searchEdit = newPage->m_ui->searchEdit;
|
||||
auto model = newPage->m_model;
|
||||
|
@ -97,7 +97,11 @@ class ResourcePage : public QWidget, public BasePage {
|
||||
virtual void openUrl(const QUrl&);
|
||||
|
||||
/** Whether the version is opted out or not. Currently only makes sense in CF. */
|
||||
virtual bool optedOut(ModPlatform::IndexedVersion& ver) const { return false; };
|
||||
virtual bool optedOut(ModPlatform::IndexedVersion& ver) const
|
||||
{
|
||||
Q_UNUSED(ver);
|
||||
return false;
|
||||
};
|
||||
|
||||
public:
|
||||
BaseInstance& m_base_instance;
|
||||
|
@ -9,7 +9,8 @@
|
||||
namespace ResourceDownload {
|
||||
|
||||
ShaderPackResourceModel::ShaderPackResourceModel(BaseInstance const& base_inst, ResourceAPI* api)
|
||||
: ResourceModel(api), m_base_instance(base_inst){};
|
||||
: ResourceModel(api), m_base_instance(base_inst)
|
||||
{}
|
||||
|
||||
/******** Make data requests ********/
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <BuildConfig.h>
|
||||
#include <Json.h>
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
|
||||
namespace Atl {
|
||||
|
||||
ListModel::ListModel(QObject* parent) : QAbstractListModel(parent) {}
|
||||
@ -75,7 +77,7 @@ void ListModel::request()
|
||||
|
||||
auto netJob = makeShared<NetJob>("Atl::Request", APPLICATION->network());
|
||||
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/json/packsnew.json");
|
||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(url), response));
|
||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(url), response));
|
||||
jobPtr = netJob;
|
||||
jobPtr->start();
|
||||
|
||||
@ -137,8 +139,7 @@ void ListModel::requestFailed(QString reason)
|
||||
void ListModel::getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback)
|
||||
{
|
||||
if (m_logoMap.contains(logo)) {
|
||||
callback(
|
||||
APPLICATION->metacache()->resolveEntry("ATLauncherPacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
|
||||
callback(APPLICATION->metacache()->resolveEntry("ATLauncherPacks", QString("logos/%1").arg(logo))->getFullPath());
|
||||
} else {
|
||||
requestLogo(logo, logoUrl);
|
||||
}
|
||||
@ -168,9 +169,9 @@ void ListModel::requestLogo(QString file, QString url)
|
||||
return;
|
||||
}
|
||||
|
||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("ATLauncherPacks", QString("logos/%1").arg(file.section(".", 0, 0)));
|
||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("ATLauncherPacks", QString("logos/%1").arg(file));
|
||||
auto job = new NetJob(QString("ATLauncher Icon Download %1").arg(file), APPLICATION->network());
|
||||
job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
|
||||
job->addNetAction(Net::ApiDownload::makeCached(QUrl(url), entry));
|
||||
|
||||
auto fullPath = entry->getFullPath();
|
||||
QObject::connect(job, &NetJob::succeeded, this, [this, file, fullPath, job] {
|
||||
|
@ -43,6 +43,8 @@
|
||||
#include "Json.h"
|
||||
#include "modplatform/atlauncher/ATLShareCode.h"
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
|
||||
AtlOptionalModListModel::AtlOptionalModListModel(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
|
||||
: QAbstractListModel(parent), m_version(version), m_mods(mods)
|
||||
{
|
||||
@ -113,7 +115,7 @@ QVariant AtlOptionalModListModel::data(const QModelIndex& index, int role) const
|
||||
return {};
|
||||
}
|
||||
|
||||
bool AtlOptionalModListModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
bool AtlOptionalModListModel::setData(const QModelIndex& index, [[maybe_unused]] const QVariant& value, int role)
|
||||
{
|
||||
if (role == Qt::CheckStateRole) {
|
||||
auto row = index.row();
|
||||
@ -155,7 +157,7 @@ void AtlOptionalModListModel::useShareCode(const QString& code)
|
||||
{
|
||||
m_jobPtr.reset(new NetJob("Atl::Request", APPLICATION->network()));
|
||||
auto url = QString(BuildConfig.ATL_API_BASE_URL + "share-codes/" + code);
|
||||
m_jobPtr->addNetAction(Net::Download::makeByteArray(QUrl(url), m_response));
|
||||
m_jobPtr->addNetAction(Net::ApiDownload::makeByteArray(QUrl(url), m_response));
|
||||
|
||||
connect(m_jobPtr.get(), &NetJob::succeeded, this, &AtlOptionalModListModel::shareCodeSuccess);
|
||||
connect(m_jobPtr.get(), &NetJob::failed, this, &AtlOptionalModListModel::shareCodeFailure);
|
||||
@ -206,7 +208,7 @@ void AtlOptionalModListModel::shareCodeSuccess()
|
||||
emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn), AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
|
||||
}
|
||||
|
||||
void AtlOptionalModListModel::shareCodeFailure(const QString& reason)
|
||||
void AtlOptionalModListModel::shareCodeFailure([[maybe_unused]] const QString& reason)
|
||||
{
|
||||
m_jobPtr.reset();
|
||||
|
||||
@ -281,15 +283,15 @@ void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool
|
||||
// if the dependency is 'effectively hidden', then track which mods
|
||||
// depend on it - so we can efficiently disable it when no more dependents
|
||||
// depend on it.
|
||||
auto dependants = m_dependants[dependencyName];
|
||||
auto dependents = m_dependents[dependencyName];
|
||||
|
||||
if (enable) {
|
||||
dependants.append(mod.name);
|
||||
dependents.append(mod.name);
|
||||
} else {
|
||||
dependants.removeAll(mod.name);
|
||||
dependents.removeAll(mod.name);
|
||||
|
||||
// if there are no longer any dependents, let's disable the mod
|
||||
if (dependencyMod.effectively_hidden && dependants.isEmpty()) {
|
||||
if (dependencyMod.effectively_hidden && dependents.isEmpty()) {
|
||||
setMod(dependencyMod, dependencyIndex, false, shouldEmit);
|
||||
}
|
||||
}
|
||||
@ -297,8 +299,8 @@ void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool
|
||||
|
||||
// disable mods that depend on this one, if disabling
|
||||
if (!enable) {
|
||||
auto dependants = m_dependants[mod.name];
|
||||
for (const auto& dependencyName : dependants) {
|
||||
auto dependents = m_dependents[mod.name];
|
||||
for (const auto& dependencyName : dependents) {
|
||||
auto dependencyIndex = m_index[dependencyName];
|
||||
auto dependencyMod = m_mods.at(dependencyIndex);
|
||||
|
||||
|
@ -90,7 +90,7 @@ class AtlOptionalModListModel : public QAbstractListModel {
|
||||
|
||||
QMap<QString, bool> m_selection;
|
||||
QMap<QString, int> m_index;
|
||||
QMap<QString, QVector<QString>> m_dependants;
|
||||
QMap<QString, QVector<QString>> m_dependents;
|
||||
};
|
||||
|
||||
class AtlOptionalModDialog : public QDialog {
|
||||
|
@ -123,13 +123,13 @@ void AtlPage::triggerSearch()
|
||||
filterModel->setSearchTerm(ui->searchEdit->text());
|
||||
}
|
||||
|
||||
void AtlPage::onSortingSelectionChanged(QString data)
|
||||
void AtlPage::onSortingSelectionChanged(QString sort)
|
||||
{
|
||||
auto toSet = filterModel->getAvailableSortings().value(data);
|
||||
auto toSet = filterModel->getAvailableSortings().value(sort);
|
||||
filterModel->setSorting(toSet);
|
||||
}
|
||||
|
||||
void AtlPage::onSelectionChanged(QModelIndex first, QModelIndex second)
|
||||
void AtlPage::onSelectionChanged(QModelIndex first, [[maybe_unused]] QModelIndex second)
|
||||
{
|
||||
ui->versionSelectionBox->clear();
|
||||
|
||||
@ -151,13 +151,13 @@ void AtlPage::onSelectionChanged(QModelIndex first, QModelIndex second)
|
||||
suggestCurrent();
|
||||
}
|
||||
|
||||
void AtlPage::onVersionSelectionChanged(QString data)
|
||||
void AtlPage::onVersionSelectionChanged(QString version)
|
||||
{
|
||||
if (data.isNull() || data.isEmpty()) {
|
||||
if (version.isNull() || version.isEmpty()) {
|
||||
selectedVersion = "";
|
||||
return;
|
||||
}
|
||||
|
||||
selectedVersion = data;
|
||||
selectedVersion = version;
|
||||
suggestCurrent();
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "Application.h"
|
||||
#include "ui/widgets/ProjectItem.h"
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
|
||||
#include <Version.h>
|
||||
|
||||
#include <QtMath>
|
||||
@ -70,7 +72,7 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool ListModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
bool ListModel::setData(const QModelIndex& index, const QVariant& value, [[maybe_unused]] int role)
|
||||
{
|
||||
int pos = index.row();
|
||||
if (pos >= modpacks.size() || pos < 0 || !index.isValid())
|
||||
@ -104,9 +106,9 @@ void ListModel::requestLogo(QString logo, QString url)
|
||||
return;
|
||||
}
|
||||
|
||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo.section(".", 0, 0)));
|
||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo));
|
||||
auto job = new NetJob(QString("Flame Icon Download %1").arg(logo), APPLICATION->network());
|
||||
job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
|
||||
job->addNetAction(Net::ApiDownload::makeCached(QUrl(url), entry));
|
||||
|
||||
auto fullPath = entry->getFullPath();
|
||||
QObject::connect(job, &NetJob::succeeded, this, [this, logo, fullPath, job] {
|
||||
@ -130,7 +132,7 @@ void ListModel::requestLogo(QString logo, QString url)
|
||||
void ListModel::getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback)
|
||||
{
|
||||
if (m_logoMap.contains(logo)) {
|
||||
callback(APPLICATION->metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
|
||||
callback(APPLICATION->metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo))->getFullPath());
|
||||
} else {
|
||||
requestLogo(logo, logoUrl);
|
||||
}
|
||||
@ -141,7 +143,7 @@ Qt::ItemFlags ListModel::flags(const QModelIndex& index) const
|
||||
return QAbstractListModel::flags(index);
|
||||
}
|
||||
|
||||
bool ListModel::canFetchMore(const QModelIndex& parent) const
|
||||
bool ListModel::canFetchMore([[maybe_unused]] const QModelIndex& parent) const
|
||||
{
|
||||
return searchState == CanPossiblyFetchMore;
|
||||
}
|
||||
@ -173,7 +175,7 @@ void ListModel::performPaginatedSearch()
|
||||
.arg(currentSearchTerm)
|
||||
.arg(currentSort + 1);
|
||||
|
||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), response));
|
||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(searchUrl), response));
|
||||
jobPtr = netJob;
|
||||
jobPtr->start();
|
||||
QObject::connect(netJob.get(), &NetJob::succeeded, this, &ListModel::searchRequestFinished);
|
||||
|
@ -46,6 +46,8 @@
|
||||
#include "ui/dialogs/NewInstanceDialog.h"
|
||||
#include "ui/widgets/ProjectItem.h"
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
|
||||
static FlameAPI api;
|
||||
|
||||
FlamePage::FlamePage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), ui(new Ui::FlamePage), dialog(dialog)
|
||||
@ -114,7 +116,7 @@ void FlamePage::triggerSearch()
|
||||
listModel->searchWithTerm(ui->searchEdit->text(), ui->sortByBox->currentIndex());
|
||||
}
|
||||
|
||||
void FlamePage::onSelectionChanged(QModelIndex curr, QModelIndex prev)
|
||||
void FlamePage::onSelectionChanged(QModelIndex curr, [[maybe_unused]] QModelIndex prev)
|
||||
{
|
||||
ui->versionSelectionBox->clear();
|
||||
|
||||
@ -132,7 +134,8 @@ void FlamePage::onSelectionChanged(QModelIndex curr, QModelIndex prev)
|
||||
auto netJob = new NetJob(QString("Flame::PackVersions(%1)").arg(current.name), APPLICATION->network());
|
||||
auto response = std::make_shared<QByteArray>();
|
||||
int addonId = current.addonId;
|
||||
netJob->addNetAction(Net::Download::makeByteArray(QString("https://api.curseforge.com/v1/mods/%1/files").arg(addonId), response));
|
||||
netJob->addNetAction(
|
||||
Net::ApiDownload::makeByteArray(QString("https://api.curseforge.com/v1/mods/%1/files").arg(addonId), response));
|
||||
|
||||
QObject::connect(netJob, &NetJob::succeeded, this, [this, response, addonId, curr] {
|
||||
if (addonId != current.addonId) {
|
||||
@ -207,17 +210,17 @@ void FlamePage::suggestCurrent()
|
||||
|
||||
dialog->setSuggestedPack(current.name, new InstanceImportTask(version.downloadUrl, this, std::move(extra_info)));
|
||||
QString editedLogoName;
|
||||
editedLogoName = "curseforge_" + current.logoName.section(".", 0, 0);
|
||||
editedLogoName = "curseforge_" + current.logoName;
|
||||
listModel->getLogo(current.logoName, current.logoUrl,
|
||||
[this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
|
||||
}
|
||||
|
||||
void FlamePage::onVersionSelectionChanged(QString data)
|
||||
void FlamePage::onVersionSelectionChanged(QString version)
|
||||
{
|
||||
bool is_blocked = false;
|
||||
ui->versionSelectionBox->currentData().toInt(&is_blocked);
|
||||
|
||||
if (data.isNull() || data.isEmpty() || is_blocked) {
|
||||
if (version.isNull() || version.isEmpty() || is_blocked) {
|
||||
m_selected_version_index = -1;
|
||||
return;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ void FlameModModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonAr
|
||||
auto FlameModModel::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) -> ModPlatform::IndexedVersion
|
||||
{
|
||||
return FlameMod::loadDependencyVersions(m, arr);
|
||||
};
|
||||
}
|
||||
|
||||
auto FlameModModel::documentToArray(QJsonDocument& obj) const -> QJsonArray
|
||||
{
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include "ListModel.h"
|
||||
#include "Application.h"
|
||||
#include "net/ApiDownload.h"
|
||||
#include "net/HttpMetaCache.h"
|
||||
#include "net/NetJob.h"
|
||||
|
||||
@ -76,7 +77,7 @@ bool FilterModel::lessThan(const QModelIndex& left, const QModelIndex& right) co
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FilterModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
|
||||
bool FilterModel::filterAcceptsRow([[maybe_unused]] int sourceRow, [[maybe_unused]] const QModelIndex& sourceParent) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -173,10 +174,10 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void ListModel::fill(ModpackList modpacks)
|
||||
void ListModel::fill(ModpackList modpacks_)
|
||||
{
|
||||
beginResetModel();
|
||||
this->modpacks = modpacks;
|
||||
this->modpacks = modpacks_;
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
@ -229,9 +230,9 @@ void ListModel::requestLogo(QString file)
|
||||
return;
|
||||
}
|
||||
|
||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(file.section(".", 0, 0)));
|
||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(file));
|
||||
NetJob* job = new NetJob(QString("FTB Icon Download for %1").arg(file), APPLICATION->network());
|
||||
job->addNetAction(Net::Download::makeCached(QUrl(QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/%1").arg(file)), entry));
|
||||
job->addNetAction(Net::ApiDownload::makeCached(QUrl(QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/%1").arg(file)), entry));
|
||||
|
||||
auto fullPath = entry->getFullPath();
|
||||
QObject::connect(job, &NetJob::finished, this, [this, file, fullPath, job] {
|
||||
@ -255,7 +256,7 @@ void ListModel::requestLogo(QString file)
|
||||
void ListModel::getLogo(const QString& logo, LogoCallback callback)
|
||||
{
|
||||
if (m_logoMap.contains(logo)) {
|
||||
callback(APPLICATION->metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
|
||||
callback(APPLICATION->metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(logo))->getFullPath());
|
||||
} else {
|
||||
requestLogo(logo);
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ void Page::ftbPrivatePackDataDownloadSuccessfully(Modpack pack)
|
||||
privateListModel->addPack(pack);
|
||||
}
|
||||
|
||||
void Page::ftbPrivatePackDataDownloadFailed(QString reason, QString packCode)
|
||||
void Page::ftbPrivatePackDataDownloadFailed([[maybe_unused]] QString reason, QString packCode)
|
||||
{
|
||||
auto reply = QMessageBox::question(this, tr("FTB private packs"),
|
||||
tr("Failed to download pack information for code %1.\nShould it be removed now?").arg(packCode));
|
||||
@ -224,7 +224,7 @@ void Page::ftbPrivatePackDataDownloadFailed(QString reason, QString packCode)
|
||||
}
|
||||
}
|
||||
|
||||
void Page::onPublicPackSelectionChanged(QModelIndex now, QModelIndex prev)
|
||||
void Page::onPublicPackSelectionChanged(QModelIndex now, [[maybe_unused]] QModelIndex prev)
|
||||
{
|
||||
if (!now.isValid()) {
|
||||
onPackSelectionChanged();
|
||||
@ -234,7 +234,7 @@ void Page::onPublicPackSelectionChanged(QModelIndex now, QModelIndex prev)
|
||||
onPackSelectionChanged(&selectedPack);
|
||||
}
|
||||
|
||||
void Page::onThirdPartyPackSelectionChanged(QModelIndex now, QModelIndex prev)
|
||||
void Page::onThirdPartyPackSelectionChanged(QModelIndex now, [[maybe_unused]] QModelIndex prev)
|
||||
{
|
||||
if (!now.isValid()) {
|
||||
onPackSelectionChanged();
|
||||
@ -244,7 +244,7 @@ void Page::onThirdPartyPackSelectionChanged(QModelIndex now, QModelIndex prev)
|
||||
onPackSelectionChanged(&selectedPack);
|
||||
}
|
||||
|
||||
void Page::onPrivatePackSelectionChanged(QModelIndex now, QModelIndex prev)
|
||||
void Page::onPrivatePackSelectionChanged(QModelIndex now, [[maybe_unused]] QModelIndex prev)
|
||||
{
|
||||
if (!now.isValid()) {
|
||||
onPackSelectionChanged();
|
||||
@ -284,20 +284,20 @@ void Page::onPackSelectionChanged(Modpack* pack)
|
||||
suggestCurrent();
|
||||
}
|
||||
|
||||
void Page::onVersionSelectionItemChanged(QString data)
|
||||
void Page::onVersionSelectionItemChanged(QString version)
|
||||
{
|
||||
if (data.isNull() || data.isEmpty()) {
|
||||
if (version.isNull() || version.isEmpty()) {
|
||||
selectedVersion = "";
|
||||
return;
|
||||
}
|
||||
|
||||
selectedVersion = data;
|
||||
selectedVersion = version;
|
||||
suggestCurrent();
|
||||
}
|
||||
|
||||
void Page::onSortingSelectionChanged(QString data)
|
||||
void Page::onSortingSelectionChanged(QString sort)
|
||||
{
|
||||
FilterModel::Sorting toSet = publicFilterModel->getAvailableSortings().value(data);
|
||||
FilterModel::Sorting toSet = publicFilterModel->getAvailableSortings().value(sort);
|
||||
publicFilterModel->setSorting(toSet);
|
||||
thirdPartyFilterModel->setSorting(toSet);
|
||||
privateFilterModel->setSorting(toSet);
|
||||
|
@ -42,6 +42,8 @@
|
||||
#include "minecraft/PackProfile.h"
|
||||
#include "ui/widgets/ProjectItem.h"
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace Modrinth {
|
||||
@ -115,7 +117,7 @@ auto ModpackListModel::data(const QModelIndex& index, int role) const -> QVarian
|
||||
return {};
|
||||
}
|
||||
|
||||
bool ModpackListModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
bool ModpackListModel::setData(const QModelIndex& index, const QVariant& value, [[maybe_unused]] int role)
|
||||
{
|
||||
int pos = index.row();
|
||||
if (pos >= modpacks.size() || pos < 0 || !index.isValid())
|
||||
@ -142,7 +144,7 @@ void ModpackListModel::performPaginatedSearch()
|
||||
.arg(currentSearchTerm)
|
||||
.arg(currentSort);
|
||||
|
||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchAllUrl), m_all_response));
|
||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(searchAllUrl), m_all_response));
|
||||
|
||||
QObject::connect(netJob.get(), &NetJob::succeeded, this, [this] {
|
||||
QJsonParseError parse_error_all{};
|
||||
@ -194,8 +196,6 @@ static auto sortFromIndex(int index) -> QString
|
||||
case 4:
|
||||
return "updated";
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void ModpackListModel::searchWithTerm(const QString& term, const int sort)
|
||||
@ -218,9 +218,7 @@ void ModpackListModel::searchWithTerm(const QString& term, const int sort)
|
||||
void ModpackListModel::getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback)
|
||||
{
|
||||
if (m_logoMap.contains(logo)) {
|
||||
callback(APPLICATION->metacache()
|
||||
->resolveEntry(m_parent->metaEntryBase(), QString("logos/%1").arg(logo.section(".", 0, 0)))
|
||||
->getFullPath());
|
||||
callback(APPLICATION->metacache()->resolveEntry(m_parent->metaEntryBase(), QString("logos/%1").arg(logo))->getFullPath());
|
||||
} else {
|
||||
requestLogo(logo, logoUrl);
|
||||
}
|
||||
@ -232,10 +230,9 @@ void ModpackListModel::requestLogo(QString logo, QString url)
|
||||
return;
|
||||
}
|
||||
|
||||
MetaEntryPtr entry =
|
||||
APPLICATION->metacache()->resolveEntry(m_parent->metaEntryBase(), QString("logos/%1").arg(logo.section(".", 0, 0)));
|
||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry(m_parent->metaEntryBase(), QString("logos/%1").arg(logo));
|
||||
auto job = new NetJob(QString("%1 Icon Download %2").arg(m_parent->debugName()).arg(logo), APPLICATION->network());
|
||||
job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
|
||||
job->addNetAction(Net::ApiDownload::makeCached(QUrl(url), entry));
|
||||
|
||||
auto fullPath = entry->getFullPath();
|
||||
QObject::connect(job, &NetJob::succeeded, this, [this, logo, fullPath, job] {
|
||||
|
@ -46,6 +46,8 @@
|
||||
|
||||
#include "ui/widgets/ProjectItem.h"
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QKeyEvent>
|
||||
#include <QPushButton>
|
||||
@ -105,7 +107,7 @@ bool ModrinthPage::eventFilter(QObject* watched, QEvent* event)
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void ModrinthPage::onSelectionChanged(QModelIndex curr, QModelIndex prev)
|
||||
void ModrinthPage::onSelectionChanged(QModelIndex curr, [[maybe_unused]] QModelIndex prev)
|
||||
{
|
||||
ui->versionSelectionBox->clear();
|
||||
|
||||
@ -127,7 +129,7 @@ void ModrinthPage::onSelectionChanged(QModelIndex curr, QModelIndex prev)
|
||||
|
||||
QString id = current.id;
|
||||
|
||||
netJob->addNetAction(Net::Download::makeByteArray(QString("%1/project/%2").arg(BuildConfig.MODRINTH_PROD_URL, id), response));
|
||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QString("%1/project/%2").arg(BuildConfig.MODRINTH_PROD_URL, id), response));
|
||||
|
||||
QObject::connect(netJob, &NetJob::succeeded, this, [this, response, id, curr] {
|
||||
if (id != current.id) {
|
||||
@ -176,7 +178,7 @@ void ModrinthPage::onSelectionChanged(QModelIndex curr, QModelIndex prev)
|
||||
QString id = current.id;
|
||||
|
||||
netJob->addNetAction(
|
||||
Net::Download::makeByteArray(QString("%1/project/%2/version").arg(BuildConfig.MODRINTH_PROD_URL, id), response));
|
||||
Net::ApiDownload::makeByteArray(QString("%1/project/%2/version").arg(BuildConfig.MODRINTH_PROD_URL, id), response));
|
||||
|
||||
QObject::connect(netJob, &NetJob::succeeded, this, [this, response, id, curr] {
|
||||
if (id != current.id) {
|
||||
@ -309,9 +311,9 @@ void ModrinthPage::triggerSearch()
|
||||
m_model->searchWithTerm(ui->searchEdit->text(), ui->sortByBox->currentIndex());
|
||||
}
|
||||
|
||||
void ModrinthPage::onVersionSelectionChanged(QString data)
|
||||
void ModrinthPage::onVersionSelectionChanged(QString version)
|
||||
{
|
||||
if (data.isNull() || data.isEmpty()) {
|
||||
if (version.isNull() || version.isEmpty()) {
|
||||
selectedVersion = "";
|
||||
return;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ void ModrinthModModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJso
|
||||
auto ModrinthModModel::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) -> ModPlatform::IndexedVersion
|
||||
{
|
||||
return ::Modrinth::loadDependencyVersions(m, arr);
|
||||
};
|
||||
}
|
||||
|
||||
auto ModrinthModModel::documentToArray(QJsonDocument& obj) const -> QJsonArray
|
||||
{
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "BuildConfig.h"
|
||||
#include "Json.h"
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
Technic::ListModel::ListModel(QObject* parent) : QAbstractListModel(parent) {}
|
||||
@ -116,7 +118,7 @@ void Technic::ListModel::performSearch()
|
||||
QString("%1search?build=%2&q=%3").arg(BuildConfig.TECHNIC_API_BASE_URL, BuildConfig.TECHNIC_API_BUILD, currentSearchTerm);
|
||||
searchMode = List;
|
||||
}
|
||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), response));
|
||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(searchUrl), response));
|
||||
jobPtr = netJob;
|
||||
jobPtr->start();
|
||||
QObject::connect(netJob.get(), &NetJob::succeeded, this, &ListModel::searchRequestFinished);
|
||||
@ -157,7 +159,7 @@ void Technic::ListModel::searchRequestFinished()
|
||||
pack.logoName = "null";
|
||||
} else {
|
||||
pack.logoUrl = rawURL;
|
||||
pack.logoName = rawURL.section(QLatin1Char('/'), -1).section(QLatin1Char('.'), 0, 0);
|
||||
pack.logoName = rawURL.section(QLatin1Char('/'), -1);
|
||||
}
|
||||
pack.broken = false;
|
||||
newList.append(pack);
|
||||
@ -179,7 +181,7 @@ void Technic::ListModel::searchRequestFinished()
|
||||
auto iconUrl = Json::requireString(iconObj, "url");
|
||||
|
||||
pack.logoUrl = iconUrl;
|
||||
pack.logoName = iconUrl.section(QLatin1Char('/'), -1).section(QLatin1Char('.'), 0, 0);
|
||||
pack.logoName = iconUrl.section(QLatin1Char('/'), -1);
|
||||
} else {
|
||||
pack.logoUrl = "null";
|
||||
pack.logoName = "null";
|
||||
@ -254,7 +256,7 @@ void Technic::ListModel::requestLogo(QString logo, QString url)
|
||||
|
||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("TechnicPacks", QString("logos/%1").arg(logo));
|
||||
auto job = new NetJob(QString("Technic Icon Download %1").arg(logo), APPLICATION->network());
|
||||
job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
|
||||
job->addNetAction(Net::ApiDownload::makeCached(QUrl(url), entry));
|
||||
|
||||
auto fullPath = entry->getFullPath();
|
||||
|
||||
|
@ -49,6 +49,8 @@
|
||||
#include "Application.h"
|
||||
#include "modplatform/technic/SolderPackManifest.h"
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
|
||||
TechnicPage::TechnicPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), ui(new Ui::TechnicPage), dialog(dialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -100,7 +102,7 @@ void TechnicPage::triggerSearch()
|
||||
model->searchWithTerm(ui->searchEdit->text());
|
||||
}
|
||||
|
||||
void TechnicPage::onSelectionChanged(QModelIndex first, QModelIndex second)
|
||||
void TechnicPage::onSelectionChanged(QModelIndex first, [[maybe_unused]] QModelIndex second)
|
||||
{
|
||||
ui->versionSelectionBox->clear();
|
||||
|
||||
@ -125,7 +127,7 @@ void TechnicPage::suggestCurrent()
|
||||
return;
|
||||
}
|
||||
|
||||
QString editedLogoName = "technic_" + current.logoName.section(".", 0, 0);
|
||||
QString editedLogoName = "technic_" + current.logoName;
|
||||
model->getLogo(current.logoName, current.logoUrl,
|
||||
[this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
|
||||
|
||||
@ -136,7 +138,7 @@ void TechnicPage::suggestCurrent()
|
||||
|
||||
auto netJob = makeShared<NetJob>(QString("Technic::PackMeta(%1)").arg(current.name), APPLICATION->network());
|
||||
QString slug = current.slug;
|
||||
netJob->addNetAction(Net::Download::makeByteArray(
|
||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(
|
||||
QString("%1modpack/%2?build=%3").arg(BuildConfig.TECHNIC_API_BASE_URL, slug, BuildConfig.TECHNIC_API_BUILD), response));
|
||||
QObject::connect(netJob.get(), &NetJob::succeeded, this, [this, slug] {
|
||||
jobPtr.reset();
|
||||
@ -232,7 +234,7 @@ void TechnicPage::metadataLoaded()
|
||||
|
||||
auto netJob = makeShared<NetJob>(QString("Technic::SolderMeta(%1)").arg(current.name), APPLICATION->network());
|
||||
auto url = QString("%1/modpack/%2").arg(current.url, current.slug);
|
||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(url), response));
|
||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(url), response));
|
||||
|
||||
QObject::connect(netJob.get(), &NetJob::succeeded, this, &TechnicPage::onSolderLoaded);
|
||||
|
||||
@ -304,13 +306,13 @@ void TechnicPage::onSolderLoaded()
|
||||
metadataLoaded();
|
||||
}
|
||||
|
||||
void TechnicPage::onVersionSelectionChanged(QString data)
|
||||
void TechnicPage::onVersionSelectionChanged(QString version)
|
||||
{
|
||||
if (data.isNull() || data.isEmpty()) {
|
||||
if (version.isNull() || version.isEmpty()) {
|
||||
selectedVersion = "";
|
||||
return;
|
||||
}
|
||||
|
||||
selectedVersion = data;
|
||||
selectedVersion = version;
|
||||
selectVersion();
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ void ThemeWizardPage::updateIcons()
|
||||
void ThemeWizardPage::updateCat()
|
||||
{
|
||||
qDebug() << "Setting Cat";
|
||||
ui->catImagePreviewButton->setIcon(QIcon(QString(R"(%1)").arg(APPLICATION->getCatPack())));
|
||||
ui->catImagePreviewButton->setIcon(QIcon(QString(R"(%1)").arg(APPLICATION->themeManager()->getCatPack())));
|
||||
}
|
||||
|
||||
void ThemeWizardPage::retranslate()
|
||||
|
@ -52,8 +52,8 @@ class BasicCatPack : public CatPack {
|
||||
public:
|
||||
BasicCatPack(QString id, QString name) : m_id(id), m_name(name) {}
|
||||
BasicCatPack(QString id) : BasicCatPack(id, id) {}
|
||||
virtual QString id() { return m_id; };
|
||||
virtual QString name() { return m_name; };
|
||||
virtual QString id() { return m_id; }
|
||||
virtual QString name() { return m_name; }
|
||||
virtual QString path();
|
||||
|
||||
protected:
|
||||
|
@ -148,7 +148,7 @@ static bool writeThemeJson(const QString& path,
|
||||
try {
|
||||
Json::write(rootObj, path);
|
||||
return true;
|
||||
} catch (const Exception& e) {
|
||||
} catch ([[maybe_unused]] const Exception& e) {
|
||||
themeWarningLog() << "Failed to write theme json to" << path;
|
||||
return false;
|
||||
}
|
||||
|
53
launcher/ui/themes/IconTheme.cpp
Normal file
53
launcher/ui/themes/IconTheme.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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 "IconTheme.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QSettings>
|
||||
|
||||
IconTheme::IconTheme(const QString& id, const QString& path) : m_id(id), m_path(path) {}
|
||||
|
||||
bool IconTheme::load()
|
||||
{
|
||||
const QString path = m_path + "/index.theme";
|
||||
|
||||
if (!QFile::exists(path))
|
||||
return false;
|
||||
|
||||
QSettings settings(path, QSettings::IniFormat);
|
||||
settings.beginGroup("Icon Theme");
|
||||
m_name = settings.value("Name").toString();
|
||||
settings.endGroup();
|
||||
return !m_name.isNull();
|
||||
}
|
||||
|
||||
QString IconTheme::id()
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QString IconTheme::path()
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
QString IconTheme::name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
37
launcher/ui/themes/IconTheme.h
Normal file
37
launcher/ui/themes/IconTheme.h
Normal file
@ -0,0 +1,37 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
class IconTheme {
|
||||
public:
|
||||
IconTheme(const QString& id, const QString& path);
|
||||
IconTheme() = default;
|
||||
|
||||
bool load();
|
||||
QString id();
|
||||
QString path();
|
||||
QString name();
|
||||
|
||||
private:
|
||||
QString m_id;
|
||||
QString m_path;
|
||||
QString m_name;
|
||||
};
|
@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2022 Tayou <git@tayou.org>
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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
|
||||
@ -31,9 +32,8 @@
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
ThemeManager::ThemeManager(MainWindow* mainWindow)
|
||||
ThemeManager::ThemeManager()
|
||||
{
|
||||
m_mainWindow = mainWindow;
|
||||
initializeThemes();
|
||||
initializeCatPacks();
|
||||
}
|
||||
@ -59,53 +59,110 @@ ITheme* ThemeManager::getTheme(QString themeId)
|
||||
return m_themes[themeId].get();
|
||||
}
|
||||
|
||||
QString ThemeManager::addIconTheme(IconTheme theme)
|
||||
{
|
||||
QString id = theme.id();
|
||||
if (m_icons.find(id) == m_icons.end())
|
||||
m_icons.emplace(id, std::move(theme));
|
||||
else
|
||||
themeWarningLog() << "IconTheme(" << id << ") not added to prevent id duplication";
|
||||
return id;
|
||||
}
|
||||
|
||||
void ThemeManager::initializeThemes()
|
||||
{
|
||||
// Icon themes
|
||||
{
|
||||
// TODO: icon themes and instance icons do not mesh well together. Rearrange and fix discrepancies!
|
||||
// set icon theme search path!
|
||||
auto searchPaths = QIcon::themeSearchPaths();
|
||||
searchPaths.append("iconthemes");
|
||||
QIcon::setThemeSearchPaths(searchPaths);
|
||||
themeDebugLog() << "<> Icon themes initialized.";
|
||||
}
|
||||
initializeIcons();
|
||||
|
||||
// Initialize widget themes
|
||||
{
|
||||
themeDebugLog() << "<> Initializing Widget Themes";
|
||||
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<SystemTheme>());
|
||||
auto darkThemeId = addTheme(std::make_unique<DarkTheme>());
|
||||
themeDebugLog() << "Loading Built-in Theme:" << darkThemeId;
|
||||
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<BrightTheme>());
|
||||
initializeWidgets();
|
||||
}
|
||||
|
||||
// TODO: need some way to differentiate same name themes in different subdirectories (maybe smaller grey text next to theme name in
|
||||
// dropdown?)
|
||||
QString themeFolder = QDir("./themes/").absoluteFilePath("");
|
||||
themeDebugLog() << "Theme Folder Path: " << themeFolder;
|
||||
void ThemeManager::initializeIcons()
|
||||
{
|
||||
// TODO: icon themes and instance icons do not mesh well together. Rearrange and fix discrepancies!
|
||||
// set icon theme search path!
|
||||
themeDebugLog() << "<> Initializing Icon Themes";
|
||||
|
||||
QDirIterator directoryIterator(themeFolder, QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
while (directoryIterator.hasNext()) {
|
||||
QDir dir(directoryIterator.next());
|
||||
QFileInfo themeJson(dir.absoluteFilePath("theme.json"));
|
||||
if (themeJson.exists()) {
|
||||
// Load "theme.json" based themes
|
||||
themeDebugLog() << "Loading JSON Theme from:" << themeJson.absoluteFilePath();
|
||||
addTheme(std::make_unique<CustomTheme>(getTheme(darkThemeId), themeJson, true));
|
||||
} else {
|
||||
// Load pure QSS Themes
|
||||
QDirIterator stylesheetFileIterator(dir.absoluteFilePath(""), { "*.qss", "*.css" }, QDir::Files);
|
||||
while (stylesheetFileIterator.hasNext()) {
|
||||
QFile customThemeFile(stylesheetFileIterator.next());
|
||||
QFileInfo customThemeFileInfo(customThemeFile);
|
||||
themeDebugLog() << "Loading QSS Theme from:" << customThemeFileInfo.absoluteFilePath();
|
||||
addTheme(std::make_unique<CustomTheme>(getTheme(darkThemeId), customThemeFileInfo, false));
|
||||
}
|
||||
}
|
||||
auto searchPaths = QIcon::themeSearchPaths();
|
||||
searchPaths.append(m_iconThemeFolder.path());
|
||||
QIcon::setThemeSearchPaths(searchPaths);
|
||||
|
||||
for (const QString& id : builtinIcons) {
|
||||
IconTheme theme(id, QString(":/icons/%1").arg(id));
|
||||
if (!theme.load()) {
|
||||
themeWarningLog() << "Couldn't load built-in icon theme" << id;
|
||||
continue;
|
||||
}
|
||||
|
||||
themeDebugLog() << "<> Widget themes initialized.";
|
||||
addIconTheme(std::move(theme));
|
||||
themeDebugLog() << "Loaded Built-In Icon Theme" << id;
|
||||
}
|
||||
|
||||
if (!m_iconThemeFolder.mkpath("."))
|
||||
themeWarningLog() << "Couldn't create icon theme folder";
|
||||
themeDebugLog() << "Icon Theme Folder Path: " << m_iconThemeFolder.absolutePath();
|
||||
|
||||
QDirIterator directoryIterator(m_iconThemeFolder.path(), QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
while (directoryIterator.hasNext()) {
|
||||
QDir dir(directoryIterator.next());
|
||||
IconTheme theme(dir.dirName(), dir.path());
|
||||
if (!theme.load())
|
||||
continue;
|
||||
|
||||
addIconTheme(std::move(theme));
|
||||
themeDebugLog() << "Loaded Custom Icon Theme from" << dir.path();
|
||||
}
|
||||
|
||||
themeDebugLog() << "<> Icon themes initialized.";
|
||||
}
|
||||
|
||||
void ThemeManager::initializeWidgets()
|
||||
{
|
||||
themeDebugLog() << "<> Initializing Widget Themes";
|
||||
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<SystemTheme>());
|
||||
auto darkThemeId = addTheme(std::make_unique<DarkTheme>());
|
||||
themeDebugLog() << "Loading Built-in Theme:" << darkThemeId;
|
||||
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<BrightTheme>());
|
||||
|
||||
// TODO: need some way to differentiate same name themes in different subdirectories (maybe smaller grey text next to theme name in
|
||||
// dropdown?)
|
||||
|
||||
if (!m_applicationThemeFolder.mkpath("."))
|
||||
themeWarningLog() << "Couldn't create theme folder";
|
||||
themeDebugLog() << "Theme Folder Path: " << m_applicationThemeFolder.absolutePath();
|
||||
|
||||
QDirIterator directoryIterator(m_applicationThemeFolder.path(), QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
while (directoryIterator.hasNext()) {
|
||||
QDir dir(directoryIterator.next());
|
||||
QFileInfo themeJson(dir.absoluteFilePath("theme.json"));
|
||||
if (themeJson.exists()) {
|
||||
// Load "theme.json" based themes
|
||||
themeDebugLog() << "Loading JSON Theme from:" << themeJson.absoluteFilePath();
|
||||
addTheme(std::make_unique<CustomTheme>(getTheme(darkThemeId), themeJson, true));
|
||||
} else {
|
||||
// Load pure QSS Themes
|
||||
QDirIterator stylesheetFileIterator(dir.absoluteFilePath(""), { "*.qss", "*.css" }, QDir::Files);
|
||||
while (stylesheetFileIterator.hasNext()) {
|
||||
QFile customThemeFile(stylesheetFileIterator.next());
|
||||
QFileInfo customThemeFileInfo(customThemeFile);
|
||||
themeDebugLog() << "Loading QSS Theme from:" << customThemeFileInfo.absoluteFilePath();
|
||||
addTheme(std::make_unique<CustomTheme>(getTheme(darkThemeId), customThemeFileInfo, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
themeDebugLog() << "<> Widget themes initialized.";
|
||||
}
|
||||
|
||||
QList<IconTheme*> ThemeManager::getValidIconThemes()
|
||||
{
|
||||
QList<IconTheme*> ret;
|
||||
ret.reserve(m_icons.size());
|
||||
for (auto&& [id, theme] : m_icons) {
|
||||
ret.append(&theme);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QList<ITheme*> ThemeManager::getValidApplicationThemes()
|
||||
@ -128,17 +185,39 @@ QList<CatPack*> ThemeManager::getValidCatPacks()
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ThemeManager::setIconTheme(const QString& name)
|
||||
bool ThemeManager::isValidIconTheme(const QString& id)
|
||||
{
|
||||
QIcon::setThemeName(name);
|
||||
return !id.isEmpty() && m_icons.find(id) != m_icons.end();
|
||||
}
|
||||
|
||||
void ThemeManager::applyCurrentlySelectedTheme(bool initial)
|
||||
bool ThemeManager::isValidApplicationTheme(const QString& id)
|
||||
{
|
||||
setIconTheme(APPLICATION->settings()->get("IconTheme").toString());
|
||||
themeDebugLog() << "<> Icon theme set.";
|
||||
setApplicationTheme(APPLICATION->settings()->get("ApplicationTheme").toString(), initial);
|
||||
themeDebugLog() << "<> Application theme set.";
|
||||
return !id.isEmpty() && m_themes.find(id) != m_themes.end();
|
||||
}
|
||||
|
||||
QDir ThemeManager::getIconThemesFolder()
|
||||
{
|
||||
return m_iconThemeFolder;
|
||||
}
|
||||
|
||||
QDir ThemeManager::getApplicationThemesFolder()
|
||||
{
|
||||
return m_applicationThemeFolder;
|
||||
}
|
||||
|
||||
QDir ThemeManager::getCatPacksFolder()
|
||||
{
|
||||
return m_catPacksFolder;
|
||||
}
|
||||
|
||||
void ThemeManager::setIconTheme(const QString& name)
|
||||
{
|
||||
if (m_icons.find(name) == m_icons.end()) {
|
||||
themeWarningLog() << "Tried to set invalid icon theme:" << name;
|
||||
return;
|
||||
}
|
||||
|
||||
QIcon::setThemeName(name);
|
||||
}
|
||||
|
||||
void ThemeManager::setApplicationTheme(const QString& name, bool initial)
|
||||
@ -154,6 +233,15 @@ void ThemeManager::setApplicationTheme(const QString& name, bool initial)
|
||||
}
|
||||
}
|
||||
|
||||
void ThemeManager::applyCurrentlySelectedTheme(bool initial)
|
||||
{
|
||||
auto settings = APPLICATION->settings();
|
||||
setIconTheme(settings->get("IconTheme").toString());
|
||||
themeDebugLog() << "<> Icon theme set.";
|
||||
setApplicationTheme(settings->get("ApplicationTheme").toString(), initial);
|
||||
themeDebugLog() << "<> Application theme set.";
|
||||
}
|
||||
|
||||
QString ThemeManager::getCatPack(QString catName)
|
||||
{
|
||||
auto catIter = m_catPacks.find(!catName.isEmpty() ? catName : APPLICATION->settings()->get("BackgroundCat").toString());
|
||||
@ -187,9 +275,9 @@ void ThemeManager::initializeCatPacks()
|
||||
for (auto [id, name] : defaultCats) {
|
||||
addCatPack(std::unique_ptr<CatPack>(new BasicCatPack(id, name)));
|
||||
}
|
||||
QDir catpacksDir("catpacks");
|
||||
QString catpacksFolder = catpacksDir.absoluteFilePath("");
|
||||
themeDebugLog() << "CatPacks Folder Path:" << catpacksFolder;
|
||||
if (!m_catPacksFolder.mkpath("."))
|
||||
themeWarningLog() << "Couldn't create catpacks folder";
|
||||
themeDebugLog() << "CatPacks Folder Path:" << m_catPacksFolder.absolutePath();
|
||||
|
||||
QStringList supportedImageFormats;
|
||||
for (auto format : QImageReader::supportedImageFormats()) {
|
||||
@ -206,9 +294,9 @@ void ThemeManager::initializeCatPacks()
|
||||
}
|
||||
};
|
||||
|
||||
loadFiles(catpacksDir);
|
||||
loadFiles(m_catPacksFolder);
|
||||
|
||||
QDirIterator directoryIterator(catpacksFolder, QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
QDirIterator directoryIterator(m_catPacksFolder.path(), QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
while (directoryIterator.hasNext()) {
|
||||
QDir dir(directoryIterator.next());
|
||||
QFileInfo manifest(dir.absoluteFilePath("catpack.json"));
|
||||
|
@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2022 Tayou <git@tayou.org>
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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
|
||||
@ -19,6 +20,7 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "IconTheme.h"
|
||||
#include "ui/MainWindow.h"
|
||||
#include "ui/themes/CatPack.h"
|
||||
#include "ui/themes/ITheme.h"
|
||||
@ -34,11 +36,17 @@ inline auto themeWarningLog()
|
||||
|
||||
class ThemeManager {
|
||||
public:
|
||||
ThemeManager(MainWindow* mainWindow);
|
||||
ThemeManager();
|
||||
|
||||
QList<IconTheme*> getValidIconThemes();
|
||||
QList<ITheme*> getValidApplicationThemes();
|
||||
void setIconTheme(const QString& name);
|
||||
bool isValidIconTheme(const QString& id);
|
||||
bool isValidApplicationTheme(const QString& id);
|
||||
QDir getIconThemesFolder();
|
||||
QDir getApplicationThemesFolder();
|
||||
QDir getCatPacksFolder();
|
||||
void applyCurrentlySelectedTheme(bool initial = false);
|
||||
void setIconTheme(const QString& name);
|
||||
void setApplicationTheme(const QString& name, bool initial = false);
|
||||
|
||||
/// @brief Returns the background based on selected and with events (Birthday, XMas, etc.)
|
||||
@ -49,12 +57,21 @@ class ThemeManager {
|
||||
|
||||
private:
|
||||
std::map<QString, std::unique_ptr<ITheme>> m_themes;
|
||||
std::map<QString, IconTheme> m_icons;
|
||||
QDir m_iconThemeFolder{ "iconthemes" };
|
||||
QDir m_applicationThemeFolder{ "themes" };
|
||||
QDir m_catPacksFolder{ "catpacks" };
|
||||
std::map<QString, std::unique_ptr<CatPack>> m_catPacks;
|
||||
MainWindow* m_mainWindow;
|
||||
|
||||
void initializeThemes();
|
||||
void initializeCatPacks();
|
||||
QString addTheme(std::unique_ptr<ITheme> theme);
|
||||
ITheme* getTheme(QString themeId);
|
||||
QString addIconTheme(IconTheme theme);
|
||||
QString addCatPack(std::unique_ptr<CatPack> catPack);
|
||||
void initializeIcons();
|
||||
void initializeWidgets();
|
||||
|
||||
const QStringList builtinIcons{ "pe_colored", "pe_light", "pe_dark", "pe_blue", "breeze_light", "breeze_dark",
|
||||
"OSX", "iOS", "flat", "flat_white", "multimc" };
|
||||
};
|
||||
|
@ -348,7 +348,7 @@ void InfoFrame::setImage(QPixmap img)
|
||||
}
|
||||
}
|
||||
|
||||
void InfoFrame::descriptionEllipsisHandler(QString link)
|
||||
void InfoFrame::descriptionEllipsisHandler([[maybe_unused]] QString link)
|
||||
{
|
||||
if (!m_current_box) {
|
||||
m_current_box = CustomMessageBox::selectable(this, "", m_description);
|
||||
@ -359,7 +359,7 @@ void InfoFrame::descriptionEllipsisHandler(QString link)
|
||||
}
|
||||
}
|
||||
|
||||
void InfoFrame::licenseEllipsisHandler(QString link)
|
||||
void InfoFrame::licenseEllipsisHandler([[maybe_unused]] QString link)
|
||||
{
|
||||
if (!m_current_box) {
|
||||
m_current_box = CustomMessageBox::selectable(this, "", m_license);
|
||||
@ -370,7 +370,7 @@ void InfoFrame::licenseEllipsisHandler(QString link)
|
||||
}
|
||||
}
|
||||
|
||||
void InfoFrame::boxClosed(int result)
|
||||
void InfoFrame::boxClosed([[maybe_unused]] int result)
|
||||
{
|
||||
m_current_box = nullptr;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ void JavaSettingsWidget::setupUi()
|
||||
m_verticalLayout = new QVBoxLayout(this);
|
||||
m_verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
|
||||
|
||||
m_versionWidget = new VersionSelectWidget(true, this);
|
||||
m_versionWidget = new VersionSelectWidget(this);
|
||||
m_verticalLayout->addWidget(m_versionWidget);
|
||||
|
||||
m_horizontalLayout = new QHBoxLayout();
|
||||
@ -126,6 +126,7 @@ void JavaSettingsWidget::setupUi()
|
||||
void JavaSettingsWidget::initialize()
|
||||
{
|
||||
m_versionWidget->initialize(APPLICATION->javalist().get());
|
||||
m_versionWidget->selectSearch();
|
||||
m_versionWidget->setResizeOn(2);
|
||||
auto s = APPLICATION->settings();
|
||||
// Memory
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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
|
||||
@ -131,7 +132,12 @@ BasePage* PageContainer::getPage(QString pageId)
|
||||
return m_model->findPageEntryById(pageId);
|
||||
}
|
||||
|
||||
const QList<BasePage*> PageContainer::getPages() const
|
||||
BasePage* PageContainer::selectedPage() const
|
||||
{
|
||||
return m_currentPage;
|
||||
}
|
||||
|
||||
const QList<BasePage*>& PageContainer::getPages() const
|
||||
{
|
||||
return m_model->pages();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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
|
||||
@ -75,9 +76,10 @@ class PageContainer : public QWidget, public BasePageContainer {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool selectPage(QString pageId) override;
|
||||
bool selectPage(QString pageId) override;
|
||||
BasePage* selectedPage() const override;
|
||||
BasePage* getPage(QString pageId) override;
|
||||
const QList<BasePage*> getPages() const;
|
||||
const QList<BasePage*>& getPages() const;
|
||||
|
||||
void refreshContainer() override;
|
||||
virtual void setParentContainer(BasePageContainer* container) { m_container = container; };
|
||||
|
@ -89,6 +89,8 @@ class PageView : public QListView {
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
|
||||
setItemDelegate(new PageViewDelegate(this));
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
// Adjust margins when using Breeze theme
|
||||
setProperty("_kde_side_panel_view", true);
|
||||
}
|
||||
|
||||
virtual QSize sizeHint() const
|
||||
|
@ -26,7 +26,7 @@ unique_qobject_ptr<SubTaskProgressBar> SubTaskProgressBar::create(QWidget* paren
|
||||
return unique_qobject_ptr<SubTaskProgressBar>(progress_bar);
|
||||
}
|
||||
|
||||
SubTaskProgressBar::SubTaskProgressBar(QWidget* parent) : ui(new Ui::SubTaskProgressBar)
|
||||
SubTaskProgressBar::SubTaskProgressBar(QWidget* parent) : QWidget(parent), ui(new Ui::SubTaskProgressBar)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "ui_ThemeCustomizationWidget.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "DesktopServices.h"
|
||||
#include "ui/themes/ITheme.h"
|
||||
#include "ui/themes/ThemeManager.h"
|
||||
|
||||
@ -31,6 +32,13 @@ ThemeCustomizationWidget::ThemeCustomizationWidget(QWidget* parent) : QWidget(pa
|
||||
connect(ui->widgetStyleComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
&ThemeCustomizationWidget::applyWidgetTheme);
|
||||
connect(ui->backgroundCatComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyCatTheme);
|
||||
|
||||
connect(ui->iconsFolder, &QPushButton::clicked, this,
|
||||
[] { DesktopServices::openDirectory(APPLICATION->themeManager()->getIconThemesFolder().path()); });
|
||||
connect(ui->widgetStyleFolder, &QPushButton::clicked, this,
|
||||
[] { DesktopServices::openDirectory(APPLICATION->themeManager()->getApplicationThemesFolder().path()); });
|
||||
connect(ui->catPackFolder, &QPushButton::clicked, this,
|
||||
[] { DesktopServices::openDirectory(APPLICATION->themeManager()->getCatPacksFolder().path()); });
|
||||
}
|
||||
|
||||
ThemeCustomizationWidget::~ThemeCustomizationWidget()
|
||||
@ -67,7 +75,7 @@ void ThemeCustomizationWidget::showFeatures(ThemeFields features)
|
||||
ui->iconsComboBox->setEnabled(features & ThemeFields::ICONS);
|
||||
ui->iconsLabel->setEnabled(features & ThemeFields::ICONS);
|
||||
ui->widgetStyleComboBox->setEnabled(features & ThemeFields::WIDGETS);
|
||||
ui->widgetThemeLabel->setEnabled(features & ThemeFields::WIDGETS);
|
||||
ui->widgetStyleLabel->setEnabled(features & ThemeFields::WIDGETS);
|
||||
ui->backgroundCatComboBox->setEnabled(features & ThemeFields::CAT);
|
||||
ui->backgroundCatLabel->setEnabled(features & ThemeFields::CAT);
|
||||
}
|
||||
@ -76,11 +84,10 @@ void ThemeCustomizationWidget::applyIconTheme(int index)
|
||||
{
|
||||
auto settings = APPLICATION->settings();
|
||||
auto originalIconTheme = settings->get("IconTheme").toString();
|
||||
auto& newIconTheme = m_iconThemeOptions[index].first;
|
||||
settings->set("IconTheme", newIconTheme);
|
||||
|
||||
auto newIconTheme = ui->iconsComboBox->currentData().toString();
|
||||
if (originalIconTheme != newIconTheme) {
|
||||
APPLICATION->applyCurrentlySelectedTheme();
|
||||
settings->set("IconTheme", newIconTheme);
|
||||
APPLICATION->themeManager()->applyCurrentlySelectedTheme();
|
||||
}
|
||||
|
||||
emit currentIconThemeChanged(index);
|
||||
@ -93,7 +100,7 @@ void ThemeCustomizationWidget::applyWidgetTheme(int index)
|
||||
auto newAppTheme = ui->widgetStyleComboBox->currentData().toString();
|
||||
if (originalAppTheme != newAppTheme) {
|
||||
settings->set("ApplicationTheme", newAppTheme);
|
||||
APPLICATION->applyCurrentlySelectedTheme();
|
||||
APPLICATION->themeManager()->applyCurrentlySelectedTheme();
|
||||
}
|
||||
|
||||
emit currentWidgetThemeChanged(index);
|
||||
@ -121,18 +128,23 @@ void ThemeCustomizationWidget::loadSettings()
|
||||
{
|
||||
auto settings = APPLICATION->settings();
|
||||
|
||||
auto iconTheme = settings->get("IconTheme").toString();
|
||||
for (auto& iconThemeFromList : m_iconThemeOptions) {
|
||||
QIcon iconForComboBox = QIcon(QString(":/icons/%1/scalable/settings").arg(iconThemeFromList.first));
|
||||
ui->iconsComboBox->addItem(iconForComboBox, iconThemeFromList.second);
|
||||
if (iconTheme == iconThemeFromList.first) {
|
||||
ui->iconsComboBox->setCurrentIndex(ui->iconsComboBox->count() - 1);
|
||||
{
|
||||
auto currentIconTheme = settings->get("IconTheme").toString();
|
||||
auto iconThemes = APPLICATION->themeManager()->getValidIconThemes();
|
||||
int idx = 0;
|
||||
for (auto iconTheme : iconThemes) {
|
||||
QIcon iconForComboBox = QIcon(iconTheme->path() + "/scalable/settings");
|
||||
ui->iconsComboBox->addItem(iconForComboBox, iconTheme->name(), iconTheme->id());
|
||||
if (currentIconTheme == iconTheme->id()) {
|
||||
ui->iconsComboBox->setCurrentIndex(idx);
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto currentTheme = settings->get("ApplicationTheme").toString();
|
||||
auto themes = APPLICATION->getValidApplicationThemes();
|
||||
auto themes = APPLICATION->themeManager()->getValidApplicationThemes();
|
||||
int idx = 0;
|
||||
for (auto& theme : themes) {
|
||||
ui->widgetStyleComboBox->addItem(theme->name(), theme->id());
|
||||
@ -144,7 +156,7 @@ void ThemeCustomizationWidget::loadSettings()
|
||||
}
|
||||
|
||||
auto cat = settings->get("BackgroundCat").toString();
|
||||
for (auto& catFromList : APPLICATION->getValidCatPacks()) {
|
||||
for (auto& catFromList : APPLICATION->themeManager()->getValidCatPacks()) {
|
||||
QIcon catIcon = QIcon(QString("%1").arg(catFromList->path()));
|
||||
ui->backgroundCatComboBox->addItem(catIcon, catFromList->name(), catFromList->id());
|
||||
if (cat == catFromList->id()) {
|
||||
|
@ -31,7 +31,7 @@ class ThemeCustomizationWidget : public QWidget {
|
||||
|
||||
public:
|
||||
explicit ThemeCustomizationWidget(QWidget* parent = nullptr);
|
||||
~ThemeCustomizationWidget();
|
||||
~ThemeCustomizationWidget() override;
|
||||
|
||||
void showFeatures(ThemeFields features);
|
||||
|
||||
@ -52,18 +52,4 @@ class ThemeCustomizationWidget : public QWidget {
|
||||
|
||||
private:
|
||||
Ui::ThemeCustomizationWidget* ui;
|
||||
|
||||
// TODO finish implementing
|
||||
QList<std::pair<QString, QString>> m_iconThemeOptions{ { "pe_colored", QObject::tr("Simple (Colored Icons)") },
|
||||
{ "pe_light", QObject::tr("Simple (Light Icons)") },
|
||||
{ "pe_dark", QObject::tr("Simple (Dark Icons)") },
|
||||
{ "pe_blue", QObject::tr("Simple (Blue Icons)") },
|
||||
{ "breeze_light", QObject::tr("Breeze Light") },
|
||||
{ "breeze_dark", QObject::tr("Breeze Dark") },
|
||||
{ "OSX", QObject::tr("OSX") },
|
||||
{ "iOS", QObject::tr("iOS") },
|
||||
{ "flat", QObject::tr("Flat") },
|
||||
{ "flat_white", QObject::tr("Flat (White)") },
|
||||
{ "multimc", QObject::tr("Legacy") },
|
||||
{ "custom", QObject::tr("Custom") } };
|
||||
};
|
||||
|
@ -40,22 +40,43 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="iconsComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="iconsLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="iconsComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="iconsFolder">
|
||||
<property name="toolTip">
|
||||
<string>View icon themes folder.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="viewfolder">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="widgetThemeLabel">
|
||||
<widget class="QLabel" name="widgetStyleLabel">
|
||||
<property name="text">
|
||||
<string>&Colors</string>
|
||||
<string>&Widgets</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>widgetStyleComboBox</cstring>
|
||||
@ -63,17 +84,38 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="widgetStyleComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="widgetStyleLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="widgetStyleComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="widgetStyleFolder">
|
||||
<property name="toolTip">
|
||||
<string>View widget themes folder.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="viewfolder">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="backgroundCatLabel">
|
||||
@ -89,7 +131,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QHBoxLayout" name="catLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="backgroundCatComboBox">
|
||||
<property name="sizePolicy">
|
||||
@ -107,15 +149,15 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="catInfoLabel">
|
||||
<widget class="QPushButton" name="catPackFolder">
|
||||
<property name="toolTip">
|
||||
<string>The cat appears in the background and is not shown by default. It is only made visible when pressing the Cat button in the Toolbar.</string>
|
||||
<string>View cat packs folder.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="about">
|
||||
<iconset theme="viewfolder">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
#include "net/NetJob.h"
|
||||
|
||||
enum FormatProperties { ImageData = QTextFormat::UserProperty + 1 };
|
||||
@ -97,7 +98,7 @@ void VariableSizedImageObject::loadImage(QTextDocument* doc, const QUrl& source,
|
||||
QString("images/%1").arg(QString(QCryptographicHash::hash(source.toEncoded(), QCryptographicHash::Algorithm::Sha1).toHex())));
|
||||
|
||||
auto job = new NetJob(QString("Load Image: %1").arg(source.fileName()), APPLICATION->network());
|
||||
job->addNetAction(Net::Download::makeCached(source, entry));
|
||||
job->addNetAction(Net::ApiDownload::makeCached(source, entry));
|
||||
|
||||
auto full_entry_path = entry->getFullPath();
|
||||
auto source_url = source;
|
||||
|
@ -11,9 +11,7 @@
|
||||
|
||||
#include "ui/dialogs/CustomMessageBox.h"
|
||||
|
||||
VersionSelectWidget::VersionSelectWidget(QWidget* parent) : VersionSelectWidget(false, parent) {}
|
||||
|
||||
VersionSelectWidget::VersionSelectWidget(bool focusSearch, QWidget* parent) : QWidget(parent), focusSearch(focusSearch)
|
||||
VersionSelectWidget::VersionSelectWidget(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
setObjectName(QStringLiteral("VersionSelectWidget"));
|
||||
verticalLayout = new QVBoxLayout(this);
|
||||
@ -114,9 +112,6 @@ void VersionSelectWidget::initialize(BaseVersionList* vlist)
|
||||
listView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
listView->header()->setSectionResizeMode(resizeOnColumn, QHeaderView::Stretch);
|
||||
|
||||
if (focusSearch)
|
||||
search->setFocus();
|
||||
|
||||
if (!m_vlist->isLoaded()) {
|
||||
loadList();
|
||||
} else {
|
||||
@ -199,6 +194,16 @@ void VersionSelectWidget::selectCurrent()
|
||||
}
|
||||
}
|
||||
|
||||
void VersionSelectWidget::selectSearch()
|
||||
{
|
||||
search->setFocus();
|
||||
}
|
||||
|
||||
VersionListView* VersionSelectWidget::view()
|
||||
{
|
||||
return listView;
|
||||
}
|
||||
|
||||
void VersionSelectWidget::selectRecommended()
|
||||
{
|
||||
auto idx = m_proxyModel->getRecommended();
|
||||
@ -221,14 +226,19 @@ BaseVersion::Ptr VersionSelectWidget::selectedVersion() const
|
||||
return variant.value<BaseVersion::Ptr>();
|
||||
}
|
||||
|
||||
void VersionSelectWidget::setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter)
|
||||
{
|
||||
m_proxyModel->setFilter(role, new ContainsFilter(filter));
|
||||
}
|
||||
|
||||
void VersionSelectWidget::setExactFilter(BaseVersionList::ModelRoles role, QString filter)
|
||||
{
|
||||
m_proxyModel->setFilter(role, new ExactFilter(filter));
|
||||
}
|
||||
|
||||
void VersionSelectWidget::setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter)
|
||||
void VersionSelectWidget::setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter)
|
||||
{
|
||||
m_proxyModel->setFilter(role, new ContainsFilter(filter));
|
||||
m_proxyModel->setFilter(role, new ExactIfPresentFilter(filter));
|
||||
}
|
||||
|
||||
void VersionSelectWidget::setFilter(BaseVersionList::ModelRoles role, Filter* filter)
|
||||
|
@ -51,7 +51,6 @@ class VersionSelectWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VersionSelectWidget(QWidget* parent);
|
||||
explicit VersionSelectWidget(bool focusSearch = false, QWidget* parent = 0);
|
||||
~VersionSelectWidget();
|
||||
|
||||
//! loads the list if needed.
|
||||
@ -64,15 +63,19 @@ class VersionSelectWidget : public QWidget {
|
||||
BaseVersion::Ptr selectedVersion() const;
|
||||
void selectRecommended();
|
||||
void selectCurrent();
|
||||
void selectSearch();
|
||||
VersionListView* view();
|
||||
|
||||
void setCurrentVersion(const QString& version);
|
||||
void setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter);
|
||||
void setExactFilter(BaseVersionList::ModelRoles role, QString filter);
|
||||
void setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter);
|
||||
void setFilter(BaseVersionList::ModelRoles role, Filter* filter);
|
||||
void setEmptyString(QString emptyString);
|
||||
void setEmptyErrorString(QString emptyErrorString);
|
||||
void setEmptyMode(VersionListView::EmptyMode mode);
|
||||
void setResizeOn(int column);
|
||||
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
|
||||
signals:
|
||||
@ -97,7 +100,6 @@ class VersionSelectWidget : public QWidget {
|
||||
int resizeOnColumn = 0;
|
||||
Task* loadTask;
|
||||
bool preselectedAlready = false;
|
||||
bool focusSearch;
|
||||
|
||||
QVBoxLayout* verticalLayout = nullptr;
|
||||
VersionListView* listView = nullptr;
|
||||
|
@ -204,8 +204,10 @@ static void copyAction(QAction* from, QAction* to)
|
||||
|
||||
void WideBar::showVisibilityMenu(QPoint const& position)
|
||||
{
|
||||
if (!m_bar_menu)
|
||||
if (!m_bar_menu) {
|
||||
m_bar_menu = std::make_unique<QMenu>(this);
|
||||
m_bar_menu->setTearOffEnabled(true);
|
||||
}
|
||||
|
||||
if (m_menu_state == MenuState::Dirty) {
|
||||
for (auto* old_action : m_bar_menu->actions())
|
||||
|
Reference in New Issue
Block a user