Small Refactor (move all related widgets to subfolder)

Signed-off-by: Tayou <tayou@gmx.net>
This commit is contained in:
Tayou
2023-05-19 20:36:49 +02:00
committed by Tayou
parent 3949f52f1d
commit 8a6c0e7314
25 changed files with 45 additions and 31 deletions

View File

@ -0,0 +1,42 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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>
#include <QStyledItemDelegate>
#include <QWidget>
#include <QPushButton>
#include "minecraft/gameoptions/GameOptions.h"
class GameOptionWidget : public QWidget {
public:
GameOptionWidget(QWidget* parent) : QWidget(parent){};
virtual void setEditorData(GameOptionItem optionItem) = 0;
virtual void saveEditorData(GameOptionItem optionItem) = 0;
void setSize(QRect size) {
setGeometry(size);
sizeHintData = QSize(size.height(), size.width());
}
QSize sizeHint() const override { return sizeHintData; }
protected:
QSize sizeHintData;
};

View File

@ -0,0 +1,46 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetCheckBox.h"
#include "ui_GameOptionWidgetCheckBox.h"
GameOptionWidgetCheckBox::GameOptionWidgetCheckBox(QWidget* parent, std::shared_ptr<GameOption> knownOption) : GameOptionWidget(parent), ui(new Ui::GameOptionWidgetCheckBox)
{
ui->setupUi(this);
if (knownOption == nullptr) {
ui->horizontalLayout->removeWidget(ui->resetButton);
delete ui->resetButton;
} else {
ui->resetButton->setMaximumWidth(ui->resetButton->height());
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultBool() ? "true" : "false"));
}
}
GameOptionWidgetCheckBox::~GameOptionWidgetCheckBox()
{
delete ui;
}
void GameOptionWidgetCheckBox::setEditorData(GameOptionItem optionItem) {
ui->checkBox->setText(optionItem.boolValue ? "true" : "false");
ui->checkBox->setChecked(optionItem.boolValue);
}
void GameOptionWidgetCheckBox::saveEditorData(GameOptionItem optionItem) {
optionItem.boolValue = ui->checkBox->isChecked();
}

View File

@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetCheckBox;
}
class GameOptionWidgetCheckBox : public GameOptionWidget {
public:
explicit GameOptionWidgetCheckBox(QWidget* parent, std::shared_ptr<GameOption> knownOption);
~GameOptionWidgetCheckBox() override;
void setEditorData(GameOptionItem optionItem) override;
void saveEditorData(GameOptionItem optionItem) override;
private:
Ui::GameOptionWidgetCheckBox* ui;
};

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetCheckBox</class>
<widget class="QWidget" name="GameOptionWidgetCheckBox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>42</height>
</rect>
</property>
<property name="windowTitle">
<string>GameOptionWidgetComboBox</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,43 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetComboBox.h"
#include "ui_GameOptionWidgetComboBox.h"
GameOptionWidgetComboBox::GameOptionWidgetComboBox(QWidget* parent, std::shared_ptr<GameOption> knownOption) : GameOptionWidget(parent), ui(new Ui::GameOptionWidgetComboBox)
{
ui->setupUi(this);
ui->resetButton->setMaximumWidth(ui->resetButton->height());
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultString()));
for (const auto& value : knownOption->validValues) {
ui->comboBox->addItem(value);
}
}
GameOptionWidgetComboBox::~GameOptionWidgetComboBox()
{
delete ui;
}
void GameOptionWidgetComboBox::setEditorData(GameOptionItem optionItem) {
ui->comboBox->setCurrentIndex(ui->comboBox->findText(optionItem.value));
}
void GameOptionWidgetComboBox::saveEditorData(GameOptionItem optionItem) {
optionItem.value = ui->comboBox->currentText();
}

View File

@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetComboBox;
}
class GameOptionWidgetComboBox : public GameOptionWidget {
public:
explicit GameOptionWidgetComboBox(QWidget* parent, std::shared_ptr<GameOption> knownOption);
~GameOptionWidgetComboBox() override;
void setEditorData(GameOptionItem optionItem) override;
void saveEditorData(GameOptionItem optionItem) override;
private:
Ui::GameOptionWidgetComboBox* ui;
};

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetComboBox</class>
<widget class="QWidget" name="GameOptionWidgetComboBox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>45</height>
</rect>
</property>
<property name="windowTitle">
<string>GameOptionWidgetComboBox</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="comboBox"/>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,61 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetKeyBind.h"
#include "ui_GameOptionWidgetKeyBind.h"
GameOptionWidgetKeyBind::GameOptionWidgetKeyBind(QWidget* parent, std::shared_ptr<GameOption> knownOption) : GameOptionWidget(parent), ui(new Ui::GameOptionWidgetKeyBind)
{
ui->setupUi(this);
if (knownOption == nullptr) {
ui->horizontalLayout->removeWidget(ui->resetButton);
delete ui->resetButton;
} else {
ui->resetButton->setMaximumWidth(ui->resetButton->height());
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultString()));
}
}
GameOptionWidgetKeyBind::~GameOptionWidgetKeyBind()
{
delete ui;
}
void GameOptionWidgetKeyBind::setEditorData(GameOptionItem optionItem) {
/*for (auto& keyBinding : *keybindingOptions) {
// this could become a std::find_if eventually, if someone wants to bother making it that.
if (keyBinding->minecraftKeyCode == contents[row].knownOption->getDefaultString()) {
return keyBinding->displayName; // + " (" + contents[row].knownOption->getDefaultString() + ")";
}
}
return contents[row].knownOption->getDefaultString();*/
ui->keySequenceEdit->setKeySequence(optionItem.value);
}
void GameOptionWidgetKeyBind::saveEditorData(GameOptionItem optionItem) {
QString minecraftKeyCode;
/*for (auto& keyBinding : *keybindingOptions) {
// this could become a std::find_if eventually, if someone wants to bother making it that.
if (keyBinding->qtKeyCode.keyboardKey == ui->keySequenceEdit->keySequence()[0].key() ||
keyBinding->qtKeyCode.mouseButton == ui->keySequenceEdit->keySequence()[0].key()) {
minecraftKeyCode = keyBinding->minecraftKeyCode;
}
}*/
optionItem.value = minecraftKeyCode;
}

View File

@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetKeyBind;
}
class GameOptionWidgetKeyBind : public GameOptionWidget {
public:
explicit GameOptionWidgetKeyBind(QWidget* parent, std::shared_ptr<GameOption> knownOption);
~GameOptionWidgetKeyBind() override;
void setEditorData(GameOptionItem optionItem) override;
void saveEditorData(GameOptionItem optionItem) override;
private:
Ui::GameOptionWidgetKeyBind* ui;
};

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetKeyBind</class>
<widget class="QWidget" name="GameOptionWidgetKeyBind">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>63</height>
</rect>
</property>
<property name="windowTitle">
<string>GameOptionWidgetComboBox</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QKeySequenceEdit" name="keySequenceEdit"/>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Bind Mouse Button</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,99 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetSlider.h"
#include "Application.h"
#include "minecraft/gameoptions/GameOptions.h"
#include "ui_GameOptionWidgetSlider.h"
#include <QString>
#include <QStyledItemDelegate>
#include <QWidget>
GameOptionWidgetSlider::GameOptionWidgetSlider(QWidget* parent, std::shared_ptr<GameOption> knownOption)
: GameOptionWidget(parent), ui(new Ui::GameOptionWidgetSlider)
{
ui->setupUi(this);
ui->resetButton->setMaximumWidth(ui->resetButton->height());
if (knownOption->type == OptionType::Float) {
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultFloat()));
ui->slider->setMinimum(knownOption->getFloatRange().min * 100);
ui->slider->setMaximum(knownOption->getFloatRange().max * 100);
// QLocale((QString)APPLICATION->settings()->get("Language"))
ui->maxLabel->setText(QString("%1").arg(knownOption->getFloatRange().max));
ui->minLabel->setText(QString("%1").arg(knownOption->getFloatRange().min));
connect(ui->slider, QOverload<int>::of(&QSlider::valueChanged), this, [&](int value) { ui->spinBox->setValue(value); });
connect(ui->spinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, [&](int value) { ui->slider->setValue(value); });
} else { // Int slider
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultInt()));
ui->slider->setMinimum(knownOption->getIntRange().min);
ui->slider->setMaximum(knownOption->getIntRange().max);
ui->maxLabel->setText(QString("%1").arg(knownOption->getIntRange().max));
ui->minLabel->setText(QString("%1").arg(knownOption->getIntRange().min));
connect(ui->slider, QOverload<int>::of(&QSlider::valueChanged), this, [&](int value) { ui->spinBox->setValue(value / 100.0f); });
connect(ui->spinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, [&](int value) { ui->slider->setValue(value * 100.0f); });
}
}
void GameOptionWidgetSlider::setEditorData(GameOptionItem optionItem) {
switch (optionItem.type) {
case OptionType::Int: {
ui->slider->setValue(optionItem.intValue);
break;
}
case OptionType::Float: {
ui->slider->setValue(optionItem.floatValue * 100);
break;
}
default:
break;
}
}
GameOptionWidgetSlider::~GameOptionWidgetSlider() {
destroy(ui);
}
void GameOptionWidgetSlider::saveEditorData(GameOptionItem optionItem) {
switch (optionItem.type) {
case OptionType::Int: {
optionItem.intValue = ui->slider->value();
break;
}
case OptionType::Float: {
optionItem.floatValue = ui->slider->value() / 100.0f;
break;
}
default:
break;
}
}
QSize GameOptionWidgetSlider::sizeHint() const
{
QSize size = GameOptionWidget::sizeHint();
size.setHeight(size.height() * 2);
return size;
}

View File

@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetSlider;
}
class GameOptionWidgetSlider : public GameOptionWidget {
public:
GameOptionWidgetSlider(QWidget* parent, std::shared_ptr<GameOption> knownOption);
~GameOptionWidgetSlider() override;
void setEditorData(GameOptionItem optionItem);
void saveEditorData(GameOptionItem optionItem) override;
QSize sizeHint() const override;
private:
Ui::GameOptionWidgetSlider* ui;
};

View File

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetSlider</class>
<widget class="QWidget" name="GameOptionWidgetSlider">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>60</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSlider" name="slider">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="minLabel">
<property name="text">
<string>[min]</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="maxLabel">
<property name="text">
<string>[max]</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,45 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetSpinnerFloat.h"
#include "ui_GameOptionWidgetSpinnerFloat.h"
GameOptionWidgetSpinnerFloat::GameOptionWidgetSpinnerFloat(QWidget* parent, std::shared_ptr<GameOption> knownOption) : GameOptionWidget(parent), ui(new Ui::GameOptionWidgetSpinnerFloat)
{
ui->setupUi(this);
if (knownOption == nullptr) {
ui->horizontalLayout->removeWidget(ui->resetButton);
delete ui->resetButton;
} else {
ui->resetButton->setMaximumWidth(ui->resetButton->height());
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultFloat()));
}
}
GameOptionWidgetSpinnerFloat::~GameOptionWidgetSpinnerFloat()
{
delete ui;
}
void GameOptionWidgetSpinnerFloat::setEditorData(GameOptionItem optionItem) {
ui->doubleSpinBox->setValue(optionItem.floatValue);
}
void GameOptionWidgetSpinnerFloat::saveEditorData(GameOptionItem optionItem) {
optionItem.floatValue = ui->doubleSpinBox->value();
}

View File

@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetSpinnerFloat;
}
class GameOptionWidgetSpinnerFloat : public GameOptionWidget {
public:
explicit GameOptionWidgetSpinnerFloat(QWidget* parent, std::shared_ptr<GameOption> knownOption);
~GameOptionWidgetSpinnerFloat() override;
void setEditorData(GameOptionItem optionItem) override;
private:
Ui::GameOptionWidgetSpinnerFloat* ui;
public:
void saveEditorData(GameOptionItem optionItem) override;
};

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetSpinnerFloat</class>
<widget class="QWidget" name="GameOptionWidgetSpinnerFloat">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>GameOptionWidgetComboBox</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox"/>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,45 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetSpinnerInt.h"
#include "ui_GameOptionWidgetSpinnerInt.h"
GameOptionWidgetSpinnerInt::GameOptionWidgetSpinnerInt(QWidget* parent, std::shared_ptr<GameOption> knownOption) : GameOptionWidget(parent), ui(new Ui::GameOptionWidgetSpinnerInt)
{
ui->setupUi(this);
if (knownOption == nullptr) {
ui->horizontalLayout->removeWidget(ui->resetButton);
delete ui->resetButton;
} else {
ui->resetButton->setMaximumWidth(ui->resetButton->height());
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultInt()));
}
}
GameOptionWidgetSpinnerInt::~GameOptionWidgetSpinnerInt()
{
delete ui;
}
void GameOptionWidgetSpinnerInt::setEditorData(GameOptionItem optionItem) {
ui->spinBox->setValue(optionItem.intValue);
}
void GameOptionWidgetSpinnerInt::saveEditorData(GameOptionItem optionItem) {
optionItem.intValue = ui->spinBox->value();
}

View File

@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetSpinnerInt;
}
class GameOptionWidgetSpinnerInt : public GameOptionWidget {
public:
explicit GameOptionWidgetSpinnerInt(QWidget* parent, std::shared_ptr<GameOption> knownOption);
~GameOptionWidgetSpinnerInt() override;
void setEditorData(GameOptionItem optionItem) override;
private:
Ui::GameOptionWidgetSpinnerInt* ui;
public:
void saveEditorData(GameOptionItem optionItem) override;
};

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetSpinnerInt</class>
<widget class="QWidget" name="GameOptionWidgetSpinnerInt">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>GameOptionWidgetComboBox</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSpinBox" name="spinBox"/>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,45 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetText.h"
#include "ui_GameOptionWidgetText.h"
GameOptionWidgetText::GameOptionWidgetText(QWidget* parent, const std::shared_ptr<GameOption>& knownOption) : GameOptionWidget(parent), ui(new Ui::GameOptionWidgetText)
{
ui->setupUi(this);
if (knownOption == nullptr) {
ui->horizontalLayout->removeWidget(ui->resetButton);
delete ui->resetButton;
} else {
ui->resetButton->setMaximumWidth(ui->resetButton->height());
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultString()));
}
}
GameOptionWidgetText::~GameOptionWidgetText()
{
delete ui;
}
void GameOptionWidgetText::setEditorData(GameOptionItem optionItem) {
ui->lineEdit->setText(optionItem.value);
}
void GameOptionWidgetText::saveEditorData(GameOptionItem optionItem) {
optionItem.value = ui->lineEdit->text();
}

View File

@ -0,0 +1,40 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetText;
}
class GameOptionWidgetText : public GameOptionWidget {
public:
void saveEditorData(GameOptionItem optionItem) override;
public:
explicit GameOptionWidgetText(QWidget* parent, const std::shared_ptr<GameOption>& knownOption);
~GameOptionWidgetText() override;
void setEditorData(GameOptionItem optionItem) override;
private:
Ui::GameOptionWidgetText* ui;
};

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetText</class>
<widget class="QWidget" name="GameOptionWidgetText">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>55</height>
</rect>
</property>
<property name="windowTitle">
<string>GameOptionWidgetComboBox</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>