Merge branch 'develop' into env-vars

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad
2023-08-26 23:12:02 +01:00
committed by GitHub
258 changed files with 4136 additions and 2335 deletions

View File

@ -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;
}

View File

@ -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
@ -185,12 +186,20 @@ QString JavaSettingsWidget::javaPath() const
int JavaSettingsWidget::maxHeapSize() const
{
return m_maxMemSpinBox->value();
auto min = m_minMemSpinBox->value();
auto max = m_maxMemSpinBox->value();
if (max < min)
max = min;
return max;
}
int JavaSettingsWidget::minHeapSize() const
{
return m_minMemSpinBox->value();
auto min = m_minMemSpinBox->value();
auto max = m_maxMemSpinBox->value();
if (min > max)
min = max;
return min;
}
bool JavaSettingsWidget::permGenEnabled() const
@ -213,17 +222,9 @@ void JavaSettingsWidget::memoryValueChanged(int)
if (obj == m_minMemSpinBox && min != observedMinMemory) {
observedMinMemory = min;
actuallyChanged = true;
if (min > max) {
observedMaxMemory = min;
m_maxMemSpinBox->setValue(min);
}
} else if (obj == m_maxMemSpinBox && max != observedMaxMemory) {
observedMaxMemory = max;
actuallyChanged = true;
if (min > max) {
observedMinMemory = max;
m_minMemSpinBox->setValue(max);
}
} else if (obj == m_permGenSpinBox && permgen != observedPermGenMemory) {
observedPermGenMemory = permgen;
actuallyChanged = true;
@ -360,8 +361,8 @@ void JavaSettingsWidget::checkJavaPath(const QString& path)
setJavaStatus(JavaStatus::Pending);
m_checker.reset(new JavaChecker());
m_checker->m_path = path;
m_checker->m_minMem = m_minMemSpinBox->value();
m_checker->m_maxMem = m_maxMemSpinBox->value();
m_checker->m_minMem = minHeapSize();
m_checker->m_maxMem = maxHeapSize();
if (m_permGenSpinBox->isVisible()) {
m_checker->m_permGen = m_permGenSpinBox->value();
}
@ -414,6 +415,9 @@ void JavaSettingsWidget::updateThresholds()
} else if (observedMaxMemory > (m_availableMemory * 0.9)) {
iconName = "status-yellow";
m_labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity."));
} else if (observedMaxMemory < observedMinMemory) {
iconName = "status-yellow";
m_labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation is smaller than the minimum value"));
} else {
iconName = "status-good";
m_labelMaxMemIcon->setToolTip("");

View File

@ -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();
}

View File

@ -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; };

View File

@ -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

View File

@ -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);
}

View File

@ -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()) {

View File

@ -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") } };
};

View File

@ -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>&amp;Colors</string>
<string>&amp;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">

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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())