Remove unused code

GameOptions.{h,cpp}, GameOptionsPage.{h,cpp}, ThemeWizardPage.cpp

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad
2025-09-19 09:03:34 +01:00
parent 9f9aabcf97
commit 7789ba8608
7 changed files with 0 additions and 433 deletions

View File

@@ -252,9 +252,6 @@ set(MINECRAFT_SOURCES
minecraft/auth/steps/XboxUserStep.cpp
minecraft/auth/steps/XboxUserStep.h
minecraft/gameoptions/GameOptions.h
minecraft/gameoptions/GameOptions.cpp
minecraft/update/AssetUpdateTask.h
minecraft/update/AssetUpdateTask.cpp
minecraft/update/FMLLibrariesTask.cpp
@@ -915,8 +912,6 @@ SET(LAUNCHER_SOURCES
# GUI - instance pages
ui/pages/instance/ExternalResourcesPage.cpp
ui/pages/instance/ExternalResourcesPage.h
ui/pages/instance/GameOptionsPage.cpp
ui/pages/instance/GameOptionsPage.h
ui/pages/instance/VersionPage.cpp
ui/pages/instance/VersionPage.h
ui/pages/instance/ManagedPackPage.cpp
@@ -1210,7 +1205,6 @@ qt_wrap_ui(LAUNCHER_UI
ui/pages/instance/NotesPage.ui
ui/pages/instance/LogPage.ui
ui/pages/instance/ServersPage.ui
ui/pages/instance/GameOptionsPage.ui
ui/pages/instance/OtherLogsPage.ui
ui/pages/instance/VersionPage.ui
ui/pages/instance/ManagedPackPage.ui

View File

@@ -1,124 +0,0 @@
#include "GameOptions.h"
#include <QDebug>
#include <QSaveFile>
#include "FileSystem.h"
namespace {
bool load(const QString& path, std::vector<GameOptionItem>& contents, int& version)
{
contents.clear();
QFile file(path);
if (!file.open(QFile::ReadOnly)) {
qWarning() << "Failed to read options file.";
return false;
}
version = 0;
while (!file.atEnd()) {
auto line = file.readLine();
if (line.endsWith('\n')) {
line.chop(1);
}
auto separatorIndex = line.indexOf(':');
if (separatorIndex == -1) {
continue;
}
auto key = QString::fromUtf8(line.data(), separatorIndex);
auto value = QString::fromUtf8(line.data() + separatorIndex + 1, line.size() - 1 - separatorIndex);
qDebug() << "!!" << key << "!!";
if (key == "version") {
version = value.toInt();
continue;
}
contents.emplace_back(GameOptionItem{ key, value });
}
qDebug() << "Loaded" << path << "with version:" << version;
return true;
}
bool save(const QString& path, std::vector<GameOptionItem>& mapping, int version)
{
QSaveFile out(path);
if (!out.open(QIODevice::WriteOnly)) {
return false;
}
if (version != 0) {
QString versionLine = QString("version:%1\n").arg(version);
out.write(versionLine.toUtf8());
}
auto iter = mapping.begin();
while (iter != mapping.end()) {
out.write(iter->key.toUtf8());
out.write(":");
out.write(iter->value.toUtf8());
out.write("\n");
iter++;
}
return out.commit();
}
} // namespace
GameOptions::GameOptions(const QString& path) : path(path)
{
reload();
}
QVariant GameOptions::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role != Qt::DisplayRole) {
return QAbstractListModel::headerData(section, orientation, role);
}
switch (section) {
case 0:
return tr("Key");
case 1:
return tr("Value");
default:
return QVariant();
}
}
QVariant GameOptions::data(const QModelIndex& index, int role) const
{
if (!index.isValid())
return QVariant();
int row = index.row();
int column = index.column();
if (row < 0 || row >= int(contents.size()))
return QVariant();
if (role == Qt::DisplayRole) {
if (column == 0)
return contents[row].key;
return contents[row].value;
}
return QVariant();
}
int GameOptions::rowCount(const QModelIndex&) const
{
return static_cast<int>(contents.size());
}
int GameOptions::columnCount(const QModelIndex&) const
{
return 2;
}
bool GameOptions::isLoaded() const
{
return loaded;
}
bool GameOptions::reload()
{
beginResetModel();
loaded = load(path, contents, version);
endResetModel();
return loaded;
}
bool GameOptions::save()
{
return ::save(path, contents, version);
}

View File

@@ -1,32 +0,0 @@
#pragma once
#include <QAbstractListModel>
#include <QString>
#include <map>
struct GameOptionItem {
QString key;
QString value;
};
class GameOptions : public QAbstractListModel {
Q_OBJECT
public:
explicit GameOptions(const QString& path);
virtual ~GameOptions() = default;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
bool isLoaded() const;
bool reload();
bool save();
private:
std::vector<GameOptionItem> contents;
bool loaded = false;
QString path;
int version = 0;
};

View File

@@ -1,74 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.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
* 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/>.
*
* 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.
*/
#include "GameOptionsPage.h"
#include "minecraft/MinecraftInstance.h"
#include "minecraft/gameoptions/GameOptions.h"
#include "ui_GameOptionsPage.h"
GameOptionsPage::GameOptionsPage(MinecraftInstance* inst, QWidget* parent) : QWidget(parent), ui(new Ui::GameOptionsPage)
{
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
m_model = inst->gameOptionsModel();
ui->optionsView->setModel(m_model.get());
auto head = ui->optionsView->header();
if (head->count()) {
head->setSectionResizeMode(0, QHeaderView::ResizeToContents);
for (int i = 1; i < head->count(); i++) {
head->setSectionResizeMode(i, QHeaderView::Stretch);
}
}
}
GameOptionsPage::~GameOptionsPage()
{
// m_model->save();
}
void GameOptionsPage::openedImpl()
{
// m_model->observe();
}
void GameOptionsPage::closedImpl()
{
// m_model->unobserve();
}
void GameOptionsPage::retranslate()
{
ui->retranslateUi(this);
}

View File

@@ -1,70 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.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
* 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/>.
*
* 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
#include <QString>
#include <QWidget>
#include <Application.h>
#include "ui/pages/BasePage.h"
namespace Ui {
class GameOptionsPage;
}
class GameOptions;
class MinecraftInstance;
class GameOptionsPage : public QWidget, public BasePage {
Q_OBJECT
public:
explicit GameOptionsPage(MinecraftInstance* inst, QWidget* parent = 0);
virtual ~GameOptionsPage();
void openedImpl() override;
void closedImpl() override;
virtual QString displayName() const override { return tr("Game Options"); }
virtual QIcon icon() const override { return APPLICATION->getThemedIcon("settings"); }
virtual QString id() const override { return "gameoptions"; }
virtual QString helpPage() const override { return "Game-Options-management"; }
void retranslate() override;
private: // data
Ui::GameOptionsPage* ui = nullptr;
std::shared_ptr<GameOptions> m_model;
};

View File

@@ -1,88 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionsPage</class>
<widget class="QWidget" name="GameOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>706</width>
<height>575</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title">
<string notr="true">Tab 1</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="QTreeView" name="optionsView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<attribute name="headerStretchLastSection">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>optionsView</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@@ -1,39 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* 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
* 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 "ThemeWizardPage.h"
#include "ui_ThemeWizardPage.h"
#include "Application.h"
#include "ui/themes/ITheme.h"
#include "ui/themes/ThemeManager.h"
#include "ui/widgets/ThemeCustomizationWidget.h"
#include "ui_ThemeCustomizationWidget.h"
ThemeWizardPage::ThemeWizardPage(QWidget* parent) : BaseWizardPage(parent), ui(new Ui::ThemeWizardPage)
{
ui->setupUi(this);
connect(ui->themeCustomizationWidget, &ThemeCustomizationWidget::currentIconThemeChanged, this, &ThemeWizardPage::updateIcons);
connect(ui->themeCustomizationWidget, &ThemeCustomizationWidget::currentCatChanged, this, &ThemeWizardPage::updateCat);
updateIcons();
updateCat();
}
{
ui->retranslateUi(this);
}