aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-07-19 12:26:12 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-07-19 12:26:12 +0300
commitf046bd7d500c16f530db48f9da5b0809a02b7519 (patch)
treee87c08a1042566236b64cebed8dde9728f49046f /launcher/ui
parentec32618e1158beba1cf5b4c91c3835a233eceeeb (diff)
parent593f45298614843c14acb11994320f90a474c750 (diff)
downloadPrismLauncher-f046bd7d500c16f530db48f9da5b0809a02b7519.tar.gz
PrismLauncher-f046bd7d500c16f530db48f9da5b0809a02b7519.tar.bz2
PrismLauncher-f046bd7d500c16f530db48f9da5b0809a02b7519.zip
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into catpacks
Diffstat (limited to 'launcher/ui')
-rw-r--r--launcher/ui/dialogs/ExportInstanceDialog.cpp99
-rw-r--r--launcher/ui/dialogs/ExportInstanceDialog.h25
-rw-r--r--launcher/ui/instanceview/VisualGroup.cpp232
-rw-r--r--launcher/ui/instanceview/VisualGroup.h48
-rw-r--r--launcher/ui/pages/global/AccountListPage.cpp13
-rw-r--r--launcher/ui/pages/global/LauncherPage.cpp2
-rw-r--r--launcher/ui/pages/global/MinecraftPage.cpp6
-rw-r--r--launcher/ui/pages/global/MinecraftPage.ui19
-rw-r--r--launcher/ui/pages/instance/InstanceSettingsPage.cpp15
-rw-r--r--launcher/ui/pages/instance/InstanceSettingsPage.ui25
-rw-r--r--launcher/ui/setupwizard/ThemeWizardPage.cpp2
-rw-r--r--launcher/ui/setupwizard/ThemeWizardPage.h2
-rw-r--r--launcher/ui/themes/CustomTheme.cpp2
-rw-r--r--launcher/ui/themes/CustomTheme.h2
-rw-r--r--launcher/ui/themes/ITheme.cpp2
-rw-r--r--launcher/ui/themes/ITheme.h2
-rw-r--r--launcher/ui/themes/SystemTheme.cpp2
-rw-r--r--launcher/ui/themes/SystemTheme.h2
-rw-r--r--launcher/ui/themes/ThemeManager.cpp2
-rw-r--r--launcher/ui/themes/ThemeManager.h2
-rw-r--r--launcher/ui/widgets/ThemeCustomizationWidget.cpp2
-rw-r--r--launcher/ui/widgets/ThemeCustomizationWidget.h2
22 files changed, 234 insertions, 274 deletions
diff --git a/launcher/ui/dialogs/ExportInstanceDialog.cpp b/launcher/ui/dialogs/ExportInstanceDialog.cpp
index cc41c394..d1a69b93 100644
--- a/launcher/ui/dialogs/ExportInstanceDialog.cpp
+++ b/launcher/ui/dialogs/ExportInstanceDialog.cpp
@@ -3,6 +3,7 @@
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -41,6 +42,9 @@
#include <QFileSystemModel>
#include <QMessageBox>
#include "FileIgnoreProxy.h"
+#include "QObjectPtr.h"
+#include "ui/dialogs/CustomMessageBox.h"
+#include "ui/dialogs/ProgressDialog.h"
#include "ui_ExportInstanceDialog.h"
#include <FileSystem.h>
@@ -72,7 +76,7 @@ ExportInstanceDialog::ExportInstanceDialog(InstancePtr instance, QWidget* parent
ui->treeView->setRootIndex(proxyModel->mapFromSource(model->index(root)));
ui->treeView->sortByColumn(0, Qt::AscendingOrder);
- connect(proxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(rowsInserted(QModelIndex,int,int)));
+ connect(proxyModel, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(rowsInserted(QModelIndex, int, int)));
model->setFilter(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Hidden);
model->setRootPath(root);
@@ -92,32 +96,26 @@ void SaveIcon(InstancePtr m_instance)
auto iconKey = m_instance->iconKey();
auto iconList = APPLICATION->icons();
auto mmcIcon = iconList->icon(iconKey);
- if(!mmcIcon || mmcIcon->isBuiltIn()) {
+ if (!mmcIcon || mmcIcon->isBuiltIn()) {
return;
}
auto path = mmcIcon->getFilePath();
- if(!path.isNull()) {
- QFileInfo inInfo (path);
- FS::copy(path, FS::PathCombine(m_instance->instanceRoot(), inInfo.fileName())) ();
+ if (!path.isNull()) {
+ QFileInfo inInfo(path);
+ FS::copy(path, FS::PathCombine(m_instance->instanceRoot(), inInfo.fileName()))();
return;
}
- auto & image = mmcIcon->m_images[mmcIcon->type()];
- auto & icon = image.icon;
+ auto& image = mmcIcon->m_images[mmcIcon->type()];
+ auto& icon = image.icon;
auto sizes = icon.availableSizes();
- if(sizes.size() == 0)
- {
+ if (sizes.size() == 0) {
return;
}
- auto areaOf = [](QSize size)
- {
- return size.width() * size.height();
- };
+ auto areaOf = [](QSize size) { return size.width() * size.height(); };
QSize largest = sizes[0];
// find variant with largest area
- for(auto size: sizes)
- {
- if(areaOf(largest) < areaOf(size))
- {
+ for (auto size : sizes) {
+ if (areaOf(largest) < areaOf(size)) {
largest = size;
}
}
@@ -125,16 +123,15 @@ void SaveIcon(InstancePtr m_instance)
pixmap.save(FS::PathCombine(m_instance->instanceRoot(), iconKey + ".png"));
}
-bool ExportInstanceDialog::doExport()
+void ExportInstanceDialog::doExport()
{
auto name = FS::RemoveInvalidFilenameChars(m_instance->name());
- const QString output = QFileDialog::getSaveFileName(
- this, tr("Export %1").arg(m_instance->name()),
- FS::PathCombine(QDir::homePath(), name + ".zip"), "Zip (*.zip)", nullptr);
- if (output.isEmpty())
- {
- return false;
+ const QString output = QFileDialog::getSaveFileName(this, tr("Export %1").arg(m_instance->name()),
+ FS::PathCombine(QDir::homePath(), name + ".zip"), "Zip (*.zip)", nullptr);
+ if (output.isEmpty()) {
+ QDialog::done(QDialog::Rejected);
+ return;
}
SaveIcon(m_instance);
@@ -143,46 +140,40 @@ bool ExportInstanceDialog::doExport()
if (!MMCZip::collectFileListRecursively(m_instance->instanceRoot(), nullptr, &files,
std::bind(&FileIgnoreProxy::filterFile, proxyModel, std::placeholders::_1))) {
QMessageBox::warning(this, tr("Error"), tr("Unable to export instance"));
- return false;
+ QDialog::done(QDialog::Rejected);
+ return;
}
- if (!MMCZip::compressDirFiles(output, m_instance->instanceRoot(), files, true))
- {
- QMessageBox::warning(this, tr("Error"), tr("Unable to export instance"));
- return false;
- }
- return true;
+ auto task = makeShared<MMCZip::ExportToZipTask>(output, m_instance->instanceRoot(), files, "", true);
+
+ connect(task.get(), &Task::failed, this,
+ [this, output](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); });
+ connect(task.get(), &Task::finished, this, [task] { task->deleteLater(); });
+
+ ProgressDialog progress(this);
+ progress.setSkipButton(true, tr("Abort"));
+ auto result = progress.execWithTask(task.get());
+ QDialog::done(result);
}
void ExportInstanceDialog::done(int result)
{
savePackIgnore();
- if (result == QDialog::Accepted)
- {
- if (doExport())
- {
- QDialog::done(QDialog::Accepted);
- return;
- }
- else
- {
- return;
- }
+ if (result == QDialog::Accepted) {
+ doExport();
+ return;
}
QDialog::done(result);
}
void ExportInstanceDialog::rowsInserted(QModelIndex parent, int top, int bottom)
{
- //WARNING: possible off-by-one?
- for(int i = top; i < bottom; i++)
- {
+ // WARNING: possible off-by-one?
+ for (int i = top; i < bottom; i++) {
auto node = proxyModel->index(i, 0, parent);
- if(proxyModel->shouldExpand(node))
- {
+ if (proxyModel->shouldExpand(node)) {
auto expNode = node.parent();
- if(!expNode.isValid())
- {
+ if (!expNode.isValid()) {
continue;
}
ui->treeView->expand(node);
@@ -199,8 +190,7 @@ void ExportInstanceDialog::loadPackIgnore()
{
auto filename = ignoreFileName();
QFile ignoreFile(filename);
- if(!ignoreFile.open(QIODevice::ReadOnly))
- {
+ if (!ignoreFile.open(QIODevice::ReadOnly)) {
return;
}
auto data = ignoreFile.readAll();
@@ -216,12 +206,9 @@ void ExportInstanceDialog::savePackIgnore()
{
auto data = proxyModel->blockedPaths().toStringList().join('\n').toUtf8();
auto filename = ignoreFileName();
- try
- {
+ try {
FS::write(filename, data);
- }
- catch (const Exception &e)
- {
+ } catch (const Exception& e) {
qWarning() << e.cause();
}
}
diff --git a/launcher/ui/dialogs/ExportInstanceDialog.h b/launcher/ui/dialogs/ExportInstanceDialog.h
index 5e801875..02f38f63 100644
--- a/launcher/ui/dialogs/ExportInstanceDialog.h
+++ b/launcher/ui/dialogs/ExportInstanceDialog.h
@@ -2,6 +2,7 @@
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,39 +39,37 @@
#include <QDialog>
#include <QModelIndex>
#include <memory>
-#include "FileIgnoreProxy.h"
#include "FastFileIconProvider.h"
+#include "FileIgnoreProxy.h"
class BaseInstance;
typedef std::shared_ptr<BaseInstance> InstancePtr;
-namespace Ui
-{
+namespace Ui {
class ExportInstanceDialog;
}
-class ExportInstanceDialog : public QDialog
-{
+class ExportInstanceDialog : public QDialog {
Q_OBJECT
-public:
- explicit ExportInstanceDialog(InstancePtr instance, QWidget *parent = 0);
+ public:
+ explicit ExportInstanceDialog(InstancePtr instance, QWidget* parent = 0);
~ExportInstanceDialog();
virtual void done(int result);
-private:
- bool doExport();
+ private:
+ void doExport();
void loadPackIgnore();
void savePackIgnore();
QString ignoreFileName();
-private:
- Ui::ExportInstanceDialog *ui;
+ private:
+ Ui::ExportInstanceDialog* ui;
InstancePtr m_instance;
- FileIgnoreProxy * proxyModel;
+ FileIgnoreProxy* proxyModel;
FastFileIconProvider icons;
-private slots:
+ private slots:
void rowsInserted(QModelIndex parent, int top, int bottom);
};
diff --git a/launcher/ui/instanceview/VisualGroup.cpp b/launcher/ui/instanceview/VisualGroup.cpp
index e6bca17d..aaf31941 100644
--- a/launcher/ui/instanceview/VisualGroup.cpp
+++ b/launcher/ui/instanceview/VisualGroup.cpp
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ * Copyright (C) 2023 Tayou <git@tayou.org>
*
* 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
@@ -35,22 +36,18 @@
#include "VisualGroup.h"
+#include <QApplication>
+#include <QDebug>
#include <QModelIndex>
#include <QPainter>
#include <QtMath>
-#include <QApplication>
-#include <QDebug>
+#include <utility>
#include "InstanceView.h"
-VisualGroup::VisualGroup(const QString &text, InstanceView *view) : view(view), text(text), collapsed(false)
-{
-}
+VisualGroup::VisualGroup(QString text, InstanceView* view) : view(view), text(std::move(text)), collapsed(false) {}
-VisualGroup::VisualGroup(const VisualGroup *other)
- : view(other->view), text(other->text), collapsed(other->collapsed)
-{
-}
+VisualGroup::VisualGroup(const VisualGroup* other) : view(other->view), text(other->text), collapsed(other->collapsed) {}
void VisualGroup::update()
{
@@ -64,13 +61,11 @@ void VisualGroup::update()
int positionInRow = 0;
int currentRow = 0;
int offsetFromTop = 0;
- for (auto item: temp_items)
- {
- if(positionInRow == itemsPerRow)
- {
+ for (auto item : temp_items) {
+ if (positionInRow == itemsPerRow) {
rows[currentRow].height = maxRowHeight;
rows[currentRow].top = offsetFromTop;
- currentRow ++;
+ currentRow++;
offsetFromTop += maxRowHeight + 5;
positionInRow = 0;
maxRowHeight = 0;
@@ -83,8 +78,7 @@ void VisualGroup::update()
#endif
auto itemHeight = view->itemDelegate()->sizeHint(viewItemOption, item).height();
- if(itemHeight > maxRowHeight)
- {
+ if (itemHeight > maxRowHeight) {
maxRowHeight = itemHeight;
}
rows[currentRow].items.append(item);
@@ -94,16 +88,13 @@ void VisualGroup::update()
rows[currentRow].top = offsetFromTop;
}
-QPair<int, int> VisualGroup::positionOf(const QModelIndex &index) const
+QPair<int, int> VisualGroup::positionOf(const QModelIndex& index) const
{
int y = 0;
- for (auto & row: rows)
- {
- for(auto x = 0; x < row.items.size(); x++)
- {
- if(row.items[x] == index)
- {
- return qMakePair(x,y);
+ for (auto& row : rows) {
+ for (auto x = 0; x < row.items.size(); x++) {
+ if (row.items[x] == index) {
+ return qMakePair(x, y);
}
}
y++;
@@ -112,193 +103,109 @@ QPair<int, int> VisualGroup::positionOf(const QModelIndex &index) const
return qMakePair(0, 0);
}
-int VisualGroup::rowTopOf(const QModelIndex &index) const
+int VisualGroup::rowTopOf(const QModelIndex& index) const
{
auto position = positionOf(index);
return rows[position.second].top;
}
-int VisualGroup::rowHeightOf(const QModelIndex &index) const
+int VisualGroup::rowHeightOf(const QModelIndex& index) const
{
auto position = positionOf(index);
return rows[position.second].height;
}
-VisualGroup::HitResults VisualGroup::hitScan(const QPoint &pos) const
+VisualGroup::HitResults VisualGroup::hitScan(const QPoint& pos) const
{
VisualGroup::HitResults results = VisualGroup::NoHit;
int y_start = verticalPosition();
int body_start = y_start + headerHeight();
- int body_end = body_start + contentHeight() + 5; // FIXME: wtf is this 5?
+ int body_end = body_start + contentHeight();
int y = pos.y();
// int x = pos.x();
- if (y < y_start)
- {
+ if (y < y_start) {
results = VisualGroup::NoHit;
- }
- else if (y < body_start)
- {
+ } else if (y < body_start) {
results = VisualGroup::HeaderHit;
int collapseSize = headerHeight() - 4;
// the icon
- QRect iconRect = QRect(view->m_leftMargin + 2, 2 + y_start, collapseSize, collapseSize);
- if (iconRect.contains(pos))
- {
+ QRect iconRect = QRect(view->m_leftMargin + 2, 2 + y_start, view->width() - 4, collapseSize);
+ if (iconRect.contains(pos)) {
results |= VisualGroup::CheckboxHit;
}
- }
- else if (y < body_end)
- {
+ } else if (y < body_end) {
results |= VisualGroup::BodyHit;
}
return results;
}
-void VisualGroup::drawHeader(QPainter *painter, const QStyleOptionViewItem &option)
+void VisualGroup::drawHeader(QPainter* painter, const QStyleOptionViewItem& option) const
{
- painter->setRenderHint(QPainter::Antialiasing);
-
- const QRect optRect = option.rect;
+ QRect optRect = option.rect;
+ optRect.setTop(optRect.top() + 7);
QFont font(QApplication::font());
font.setBold(true);
const QFontMetrics fontMetrics = QFontMetrics(font);
+ painter->setFont(font);
+
+ QPen pen;
+ pen.setWidth(2);
+ QColor penColor = option.palette.text().color();
+ penColor.setAlphaF(0.6);
+ pen.setColor(penColor);
+ painter->setPen(pen);
+ painter->setRenderHint(QPainter::Antialiasing);
- QColor outlineColor = option.palette.text().color();
- outlineColor.setAlphaF(0.35);
-
- //BEGIN: top left corner
- {
- painter->save();
- painter->setPen(outlineColor);
- const QPointF topLeft(optRect.topLeft());
- QRectF arc(topLeft, QSizeF(4, 4));
- arc.translate(0.5, 0.5);
- painter->drawArc(arc, 1440, 1440);
- painter->restore();
- }
- //END: top left corner
-
- //BEGIN: left vertical line
- {
- QPoint start(optRect.topLeft());
- start.ry() += 3;
- QPoint verticalGradBottom(optRect.topLeft());
- verticalGradBottom.ry() += fontMetrics.height() + 5;
- QLinearGradient gradient(start, verticalGradBottom);
- gradient.setColorAt(0, outlineColor);
- gradient.setColorAt(1, Qt::transparent);
- painter->fillRect(QRect(start, QSize(1, fontMetrics.height() + 5)), gradient);
- }
- //END: left vertical line
-
- //BEGIN: horizontal line
- {
- QPoint start(optRect.topLeft());
- start.rx() += 3;
- QPoint horizontalGradTop(optRect.topLeft());
- horizontalGradTop.rx() += optRect.width() - 6;
- painter->fillRect(QRect(start, QSize(optRect.width() - 6, 1)), outlineColor);
- }
- //END: horizontal line
-
- //BEGIN: top right corner
- {
- painter->save();
- painter->setPen(outlineColor);
- QPointF topRight(optRect.topRight());
- topRight.rx() -= 4;
- QRectF arc(topRight, QSizeF(4, 4));
- arc.translate(0.5, 0.5);
- painter->drawArc(arc, 0, 1440);
- painter->restore();
- }
- //END: top right corner
-
- //BEGIN: right vertical line
- {
- QPoint start(optRect.topRight());
- start.ry() += 3;
- QPoint verticalGradBottom(optRect.topRight());
- verticalGradBottom.ry() += fontMetrics.height() + 5;
- QLinearGradient gradient(start, verticalGradBottom);
- gradient.setColorAt(0, outlineColor);
- gradient.setColorAt(1, Qt::transparent);
- painter->fillRect(QRect(start, QSize(1, fontMetrics.height() + 5)), gradient);
- }
- //END: right vertical line
+ // sizes and offsets, to keep things consistent below
+ int arrowOffsetLeft = fontMetrics.height() / 2 + 7;
+ int textOffsetLeft = arrowOffsetLeft * 2;
+ int arrowSize = 6;
+ int centerHeight = optRect.top() + fontMetrics.height() / 2;
- //BEGIN: checkboxy thing
+ // BEGIN: arrow
{
- painter->save();
- painter->setRenderHint(QPainter::Antialiasing, false);
- painter->setFont(font);
- QColor penColor(option.palette.text().color());
- penColor.setAlphaF(0.6);
- painter->setPen(penColor);
- QRect iconSubRect(option.rect);
- iconSubRect.setTop(iconSubRect.top() + 7);
- iconSubRect.setLeft(iconSubRect.left() + 7);
-
- int sizing = fontMetrics.height();
- int even = ( (sizing - 1) % 2 );
-
- iconSubRect.setHeight(sizing - even);
- iconSubRect.setWidth(sizing - even);
- painter->drawRect(iconSubRect);
-
-
- /*
- if(collapsed)
- painter->drawText(iconSubRect, Qt::AlignHCenter | Qt::AlignVCenter, "+");
- else
- painter->drawText(iconSubRect, Qt::AlignHCenter | Qt::AlignVCenter, "-");
- */
- painter->setBrush(option.palette.text());
- painter->fillRect(iconSubRect.x(), iconSubRect.y() + iconSubRect.height() / 2,
- iconSubRect.width(), 2, penColor);
- if (collapsed)
- {
- painter->fillRect(iconSubRect.x() + iconSubRect.width() / 2, iconSubRect.y(), 2,
- iconSubRect.height(), penColor);
+ QPolygon arrowPolygon;
+ if (collapsed) {
+ arrowPolygon << QPoint(arrowOffsetLeft - arrowSize / 2, centerHeight - arrowSize)
+ << QPoint(arrowOffsetLeft + arrowSize / 2, centerHeight)
+ << QPoint(arrowOffsetLeft - arrowSize / 2, centerHeight + arrowSize);
+ painter->drawPolyline(arrowPolygon);
+ } else {
+ arrowPolygon << QPoint(arrowOffsetLeft - arrowSize, centerHeight - arrowSize / 2)
+ << QPoint(arrowOffsetLeft, centerHeight + arrowSize / 2)
+ << QPoint(arrowOffsetLeft + arrowSize, centerHeight - arrowSize / 2);
+ painter->drawPolyline(arrowPolygon);
}
-
- painter->restore();
}
- //END: checkboxy thing
+ // END: arrow
- //BEGIN: text
+ // BEGIN: text
{
- QRect textRect(option.rect);
- textRect.setTop(textRect.top() + 7);
- textRect.setLeft(textRect.left() + 7 + fontMetrics.height() + 7);
+ QRect textRect(optRect);
+ textRect.setTop(textRect.top());
+ textRect.setLeft(textOffsetLeft);
textRect.setHeight(fontMetrics.height());
textRect.setRight(textRect.right() - 7);
- painter->save();
- painter->setFont(font);
- QColor penColor(option.palette.text().color());
- penColor.setAlphaF(0.6);
- painter->setPen(penColor);
- painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, text);
- painter->restore();
+ painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, !text.isEmpty() ? text : QObject::tr("Ungrouped"));
}
- //END: text
+ // END: text
}
int VisualGroup::totalHeight() const
{
- return headerHeight() + 5 + contentHeight(); // FIXME: wtf is that '5'?
+ return headerHeight() + contentHeight();
}
-int VisualGroup::headerHeight() const
+int VisualGroup::headerHeight()
{
QFont font(QApplication::font());
font.setBold(true);
QFontMetrics fontMetrics(font);
const int height = fontMetrics.height() + 1 /* 1 pixel-width gradient */
- + 11 /* top and bottom separation */;
+ + 11 /* top and bottom separation */;
return height;
/*
int raw = view->viewport()->fontMetrics().height() + 4;
@@ -311,8 +218,7 @@ int VisualGroup::headerHeight() const
int VisualGroup::contentHeight() const
{
- if (collapsed)
- {
+ if (collapsed) {
return 0;
}
auto last = rows[numRows() - 1];
@@ -321,7 +227,7 @@ int VisualGroup::contentHeight() const
int VisualGroup::numRows() const
{
- return rows.size();
+ return (int)rows.size();
}
int VisualGroup::verticalPosition() const
@@ -332,11 +238,9 @@ int VisualGroup::verticalPosition() const
QList<QModelIndex> VisualGroup::items() const
{
QList<QModelIndex> indices;
- for (int i = 0; i < view->model()->rowCount(); ++i)
- {
+ for (int i = 0; i < view->model()->rowCount(); ++i) {
const QModelIndex index = view->model()->index(i, 0);
- if (index.data(InstanceViewRoles::GroupRole).toString() == text)
- {
+ if (index.data(InstanceViewRoles::GroupRole).toString() == text) {
indices.append(index);
}
}
diff --git a/launcher/ui/instanceview/VisualGroup.h b/launcher/ui/instanceview/VisualGroup.h
index 5a743aa1..697298c2 100644
--- a/launcher/ui/instanceview/VisualGroup.h
+++ b/launcher/ui/instanceview/VisualGroup.h
@@ -1,16 +1,36 @@
-/* Copyright 2013-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2023 Tayou <git@tayou.org>
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#pragma once
@@ -42,8 +62,8 @@ struct VisualRow
struct VisualGroup
{
/* constructors */
- VisualGroup(const QString &text, InstanceView *view);
- VisualGroup(const VisualGroup *other);
+ VisualGroup(QString text, InstanceView *view);
+ explicit VisualGroup(const VisualGroup *other);
/* data */
InstanceView *view = nullptr;
@@ -58,13 +78,13 @@ struct VisualGroup
void update();
/// draw the header at y-position.
- void drawHeader(QPainter *painter, const QStyleOptionViewItem &option);
+ void drawHeader(QPainter *painter, const QStyleOptionViewItem &option) const;
/// height of the group, in total. includes a small bit of padding.
int totalHeight() const;
/// height of the group header, in pixels
- int headerHeight() const;
+ static int headerHeight() ;
/// height of the group content, in pixels
int contentHeight() const;
diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp
index 278f45c4..fced5ff4 100644
--- a/launcher/ui/pages/global/AccountListPage.cpp
+++ b/launcher/ui/pages/global/AccountListPage.cpp
@@ -159,19 +159,6 @@ void AccountListPage::on_actionAddMojang_triggered()
void AccountListPage::on_actionAddMicrosoft_triggered()
{
- if(BuildConfig.BUILD_PLATFORM == "osx64") {
- CustomMessageBox::selectable(
- this,
- tr("Microsoft Accounts not available"),
- //: %1 refers to the launcher itself
- tr(
- "Microsoft accounts are only usable on macOS 10.13 or newer, with fully updated %1.\n\n"
- "Please update both your operating system and %1."
- ).arg(BuildConfig.LAUNCHER_DISPLAYNAME),
- QMessageBox::Warning
- )->exec();
- return;
- }
MinecraftAccountPtr account = MSALoginDialog::newAccount(
this,
tr("Please enter your Mojang account email and password to add your account.")
diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp
index 816dde72..2080b56f 100644
--- a/launcher/ui/pages/global/LauncherPage.cpp
+++ b/launcher/ui/pages/global/LauncherPage.cpp
@@ -3,7 +3,7 @@
* Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (c) 2022 dada513 <dada513@protonmail.com>
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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
diff --git a/launcher/ui/pages/global/MinecraftPage.cpp b/launcher/ui/pages/global/MinecraftPage.cpp
index eca3e865..95482356 100644
--- a/launcher/ui/pages/global/MinecraftPage.cpp
+++ b/launcher/ui/pages/global/MinecraftPage.cpp
@@ -2,6 +2,7 @@
/*
* PolyMC - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
+ * Copyright (C) 2023 seth <getchoo at tuta dot io>
*
* 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
@@ -99,6 +100,9 @@ void MinecraftPage::applySettings()
// Miscellaneous
s->set("CloseAfterLaunch", ui->closeAfterLaunchCheck->isChecked());
s->set("QuitAfterGameStop", ui->quitAfterGameStopCheck->isChecked());
+
+ // Mod loader settings
+ s->set("DisableQuiltBeacon", ui->disableQuiltBeaconCheckBox->isChecked());
}
void MinecraftPage::loadSettings()
@@ -137,6 +141,8 @@ void MinecraftPage::loadSettings()
ui->closeAfterLaunchCheck->setChecked(s->get("CloseAfterLaunch").toBool());
ui->quitAfterGameStopCheck->setChecked(s->get("QuitAfterGameStop").toBool());
+
+ ui->disableQuiltBeaconCheckBox->setChecked(s->get("DisableQuiltBeacon").toBool());
}
void MinecraftPage::retranslate()
diff --git a/launcher/ui/pages/global/MinecraftPage.ui b/launcher/ui/pages/global/MinecraftPage.ui
index 8f5de725..a3188dcc 100644
--- a/launcher/ui/pages/global/MinecraftPage.ui
+++ b/launcher/ui/pages/global/MinecraftPage.ui
@@ -191,6 +191,25 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
+ <widget class="QGroupBox" name="modLoaderSettingsGroupBox">
+ <property name="title">
+ <string>Mod loader settings</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_13">
+ <item>
+ <widget class="QCheckBox" name="disableQuiltBeaconCheckBox">
+ <property name="text">
+ <string>Disable Quilt Loader Beacon</string>
+ </property>
+ <property name="toolTip">
+ <string>Disable Quilt loader's beacon for counting monthly active users</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="nativeLibWorkaroundGroupBox">
<property name="title">
<string>Native library workarounds</string>
diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp
index 943ff17f..25cc1a0d 100644
--- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp
+++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp
@@ -3,6 +3,7 @@
* PolyMC - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ * Copyright (C) 2023 seth <getchoo at tuta dot io>
*
* 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
@@ -50,9 +51,9 @@
#include "Application.h"
#include "minecraft/auth/AccountList.h"
+#include "FileSystem.h"
#include "java/JavaInstallList.h"
#include "java/JavaUtils.h"
-#include "FileSystem.h"
InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
: QWidget(parent), ui(new Ui::InstanceSettingsPage), m_instance(inst)
@@ -280,6 +281,14 @@ void InstanceSettingsPage::applySettings()
m_settings->reset("InstanceAccountId");
}
+ bool overrideModLoaderSettings = ui->modLoaderSettingsGroupBox->isChecked();
+ m_settings->set("OverrideModLoaderSettings", overrideModLoaderSettings);
+ if (overrideModLoaderSettings) {
+ m_settings->set("DisableQuiltBeacon", ui->disableQuiltBeaconCheckBox->isChecked());
+ } else {
+ m_settings->reset("DisableQuiltBeacon");
+ }
+
// FIXME: This should probably be called by a signal instead
m_instance->updateRuntimeContext();
}
@@ -380,6 +389,10 @@ void InstanceSettingsPage::loadSettings()
ui->instanceAccountGroupBox->setChecked(m_settings->get("UseAccountForInstance").toBool());
updateAccountsMenu();
+
+ // Mod loader specific settings
+ ui->modLoaderSettingsGroupBox->setChecked(m_settings->get("OverrideModLoaderSettings").toBool());
+ ui->disableQuiltBeaconCheckBox->setChecked(m_settings->get("DisableQuiltBeacon").toBool());
}
void InstanceSettingsPage::on_javaDetectBtn_clicked()
diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.ui b/launcher/ui/pages/instance/InstanceSettingsPage.ui
index 8427965d..323890b9 100644
--- a/launcher/ui/pages/instance/InstanceSettingsPage.ui
+++ b/launcher/ui/pages/instance/InstanceSettingsPage.ui
@@ -542,6 +542,31 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
+ <widget class="QGroupBox" name="modLoaderSettingsGroupBox">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="title">
+ <string>Mod loader settings</string>
+ </property>
+ <layout class="QVBoxLayout" name="VerticalLayout_16">
+ <item>
+ <widget class="QCheckBox" name="disableQuiltBeaconCheckBox">
+ <property name="text">
+ <string>Disable Quilt Loader Beacon</string>
+ </property>
+ <property name="toolTip">
+ <string>Disable Quilt loader's beacon for counting monthly active users</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="gameTimeGroupBox">
<property name="enabled">
<bool>true</bool>
diff --git a/launcher/ui/setupwizard/ThemeWizardPage.cpp b/launcher/ui/setupwizard/ThemeWizardPage.cpp
index 282a01ac..1c336921 100644
--- a/launcher/ui/setupwizard/ThemeWizardPage.cpp
+++ b/launcher/ui/setupwizard/ThemeWizardPage.cpp
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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
diff --git a/launcher/ui/setupwizard/ThemeWizardPage.h b/launcher/ui/setupwizard/ThemeWizardPage.h
index 61a3d0c0..f3d40b6d 100644
--- a/launcher/ui/setupwizard/ThemeWizardPage.h
+++ b/launcher/ui/setupwizard/ThemeWizardPage.h
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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
diff --git a/launcher/ui/themes/CustomTheme.cpp b/launcher/ui/themes/CustomTheme.cpp
index 198e76ba..177edefa 100644
--- a/launcher/ui/themes/CustomTheme.cpp
+++ b/launcher/ui/themes/CustomTheme.cpp
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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
diff --git a/launcher/ui/themes/CustomTheme.h b/launcher/ui/themes/CustomTheme.h
index f2b1b06e..3ec4cafa 100644
--- a/launcher/ui/themes/CustomTheme.h
+++ b/launcher/ui/themes/CustomTheme.h
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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
diff --git a/launcher/ui/themes/ITheme.cpp b/launcher/ui/themes/ITheme.cpp
index 8f0757e1..42d63b11 100644
--- a/launcher/ui/themes/ITheme.cpp
+++ b/launcher/ui/themes/ITheme.cpp
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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
diff --git a/launcher/ui/themes/ITheme.h b/launcher/ui/themes/ITheme.h
index a0a638bd..d85e7f98 100644
--- a/launcher/ui/themes/ITheme.h
+++ b/launcher/ui/themes/ITheme.h
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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
diff --git a/launcher/ui/themes/SystemTheme.cpp b/launcher/ui/themes/SystemTheme.cpp
index 3a746d02..3b8cb24a 100644
--- a/launcher/ui/themes/SystemTheme.cpp
+++ b/launcher/ui/themes/SystemTheme.cpp
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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
diff --git a/launcher/ui/themes/SystemTheme.h b/launcher/ui/themes/SystemTheme.h
index 05f31233..4f7d83e5 100644
--- a/launcher/ui/themes/SystemTheme.h
+++ b/launcher/ui/themes/SystemTheme.h
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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
diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp
index 683642d7..9ed8e129 100644
--- a/launcher/ui/themes/ThemeManager.cpp
+++ b/launcher/ui/themes/ThemeManager.cpp
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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
diff --git a/launcher/ui/themes/ThemeManager.h b/launcher/ui/themes/ThemeManager.h
index bc0d31cd..1ce8c6f4 100644
--- a/launcher/ui/themes/ThemeManager.h
+++ b/launcher/ui/themes/ThemeManager.h
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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
diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.cpp b/launcher/ui/widgets/ThemeCustomizationWidget.cpp
index e2c5ce3d..291f8ed9 100644
--- a/launcher/ui/widgets/ThemeCustomizationWidget.cpp
+++ b/launcher/ui/widgets/ThemeCustomizationWidget.cpp
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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
diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.h b/launcher/ui/widgets/ThemeCustomizationWidget.h
index be204e57..af47c788 100644
--- a/launcher/ui/widgets/ThemeCustomizationWidget.h
+++ b/launcher/ui/widgets/ThemeCustomizationWidget.h
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
- * Copyright (C) 2022 Tayou <tayou@gmx.net>
+ * Copyright (C) 2022 Tayou <git@tayou.org>
*
* 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