Add "Select all" checkbox + ui revamp + code cleanup
Signed-off-by: Marcelo Hernandez <marcelohdez.inq@gmail.com>
This commit is contained in:
parent
e7e56eb1e3
commit
15593b5c09
@ -32,6 +32,7 @@ set(CORE_SOURCES
|
||||
InstanceCreationTask.h
|
||||
InstanceCreationTask.cpp
|
||||
InstanceCopyPrefs.h
|
||||
InstanceCopyPrefs.cpp
|
||||
InstanceCopyTask.h
|
||||
InstanceCopyTask.cpp
|
||||
InstanceImportTask.h
|
||||
|
15
launcher/InstanceCopyPrefs.cpp
Normal file
15
launcher/InstanceCopyPrefs.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
//
|
||||
// Created by marcelohdez on 10/22/22.
|
||||
//
|
||||
|
||||
#include "InstanceCopyPrefs.h"
|
||||
|
||||
InstanceCopyPrefs::InstanceCopyPrefs(bool setAll)
|
||||
: copySaves(setAll),
|
||||
keepPlaytime(setAll),
|
||||
copyGameOptions(setAll),
|
||||
copyResourcePacks(setAll),
|
||||
copyShaderPacks(setAll),
|
||||
copyServers(setAll),
|
||||
copyMods(setAll)
|
||||
{}
|
@ -6,6 +6,9 @@
|
||||
#define LAUNCHER_INSTANCECOPYPREFS_H
|
||||
|
||||
struct InstanceCopyPrefs {
|
||||
explicit InstanceCopyPrefs(bool setAll);
|
||||
~InstanceCopyPrefs() = default;
|
||||
|
||||
bool copySaves;
|
||||
bool keepPlaytime;
|
||||
bool copyGameOptions;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "pathmatcher/RegexpMatcher.h"
|
||||
#include <QtConcurrentRun>
|
||||
|
||||
InstanceCopyTask::InstanceCopyTask(InstancePtr origInstance, InstanceCopyPrefs prefs)
|
||||
InstanceCopyTask::InstanceCopyTask(InstancePtr origInstance, const InstanceCopyPrefs& prefs)
|
||||
{
|
||||
m_origInstance = origInstance;
|
||||
m_keepPlaytime = prefs.keepPlaytime;
|
||||
|
@ -15,7 +15,7 @@ class InstanceCopyTask : public InstanceTask
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InstanceCopyTask(InstancePtr origInstance, InstanceCopyPrefs prefs);
|
||||
explicit InstanceCopyTask(InstancePtr origInstance, const InstanceCopyPrefs& prefs);
|
||||
|
||||
protected:
|
||||
//! Entry point for tasks.
|
||||
|
@ -1616,17 +1616,7 @@ void MainWindow::on_actionCopyInstance_triggered()
|
||||
if (!copyInstDlg.exec())
|
||||
return;
|
||||
|
||||
auto copyTask = new InstanceCopyTask(
|
||||
m_selectedInstance,
|
||||
InstanceCopyPrefs {
|
||||
copyInstDlg.shouldCopySaves(),
|
||||
copyInstDlg.shouldKeepPlaytime(),
|
||||
copyInstDlg.shouldCopyGameOptions(),
|
||||
copyInstDlg.shouldCopyResourcePacks(),
|
||||
copyInstDlg.shouldCopyShaderPacks(),
|
||||
copyInstDlg.shouldCopyServers(),
|
||||
copyInstDlg.shouldCopyMods()
|
||||
});
|
||||
auto copyTask = new InstanceCopyTask(m_selectedInstance, copyInstDlg.getChosenOptions());
|
||||
copyTask->setName(copyInstDlg.instName());
|
||||
copyTask->setGroup(copyInstDlg.instGroup());
|
||||
copyTask->setIcon(copyInstDlg.iconKey());
|
||||
|
@ -78,13 +78,13 @@ CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent)
|
||||
}
|
||||
ui->groupBox->setCurrentIndex(index);
|
||||
ui->groupBox->lineEdit()->setPlaceholderText(tr("No group"));
|
||||
ui->copySavesCheckbox->setChecked(m_copySaves);
|
||||
ui->keepPlaytimeCheckbox->setChecked(m_keepPlaytime);
|
||||
ui->copyGameOptionsCheckbox->setChecked(m_copyGameOptions);
|
||||
ui->copyResPacksCheckbox->setChecked(m_copyResourcePacks);
|
||||
ui->copyShaderPacksCheckbox->setChecked(m_copyShaderPacks);
|
||||
ui->copyServersCheckbox->setChecked(m_copyServers);
|
||||
ui->copyModsCheckbox->setChecked(m_copyMods);
|
||||
ui->copySavesCheckbox->setChecked(m_selectedOptions.copySaves);
|
||||
ui->keepPlaytimeCheckbox->setChecked(m_selectedOptions.keepPlaytime);
|
||||
ui->copyGameOptionsCheckbox->setChecked(m_selectedOptions.copyGameOptions);
|
||||
ui->copyResPacksCheckbox->setChecked(m_selectedOptions.copyResourcePacks);
|
||||
ui->copyShaderPacksCheckbox->setChecked(m_selectedOptions.copyShaderPacks);
|
||||
ui->copyServersCheckbox->setChecked(m_selectedOptions.copyServers);
|
||||
ui->copyModsCheckbox->setChecked(m_selectedOptions.copyMods);
|
||||
}
|
||||
|
||||
CopyInstanceDialog::~CopyInstanceDialog()
|
||||
@ -139,122 +139,118 @@ void CopyInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1)
|
||||
updateDialogState();
|
||||
}
|
||||
|
||||
bool CopyInstanceDialog::shouldCopySaves() const
|
||||
const InstanceCopyPrefs& CopyInstanceDialog::getChosenOptions() const
|
||||
{
|
||||
return m_copySaves;
|
||||
return m_selectedOptions;
|
||||
}
|
||||
|
||||
void CopyInstanceDialog::on_selectAllCheckbox_stateChanged(int state)
|
||||
{
|
||||
bool checked;
|
||||
if(state == Qt::Unchecked)
|
||||
{
|
||||
checked = false;
|
||||
}
|
||||
else if(state == Qt::Checked)
|
||||
{
|
||||
checked = true;
|
||||
}
|
||||
|
||||
checkAllCheckboxes(checked);
|
||||
}
|
||||
|
||||
void CopyInstanceDialog::checkAllCheckboxes(bool b)
|
||||
{
|
||||
ui->keepPlaytimeCheckbox->setChecked(b);
|
||||
ui->copySavesCheckbox->setChecked(b);
|
||||
ui->copyGameOptionsCheckbox->setChecked(b);
|
||||
ui->copyResPacksCheckbox->setChecked(b);
|
||||
ui->copyShaderPacksCheckbox->setChecked(b);
|
||||
ui->copyServersCheckbox->setChecked(b);
|
||||
ui->copyModsCheckbox->setChecked(b);
|
||||
}
|
||||
|
||||
void CopyInstanceDialog::on_copySavesCheckbox_stateChanged(int state)
|
||||
{
|
||||
if(state == Qt::Unchecked)
|
||||
{
|
||||
m_copySaves = false;
|
||||
m_selectedOptions.copySaves = false;
|
||||
}
|
||||
else if(state == Qt::Checked)
|
||||
{
|
||||
m_copySaves = true;
|
||||
m_selectedOptions.copySaves = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CopyInstanceDialog::shouldKeepPlaytime() const
|
||||
{
|
||||
return m_keepPlaytime;
|
||||
}
|
||||
|
||||
|
||||
void CopyInstanceDialog::on_keepPlaytimeCheckbox_stateChanged(int state)
|
||||
{
|
||||
if(state == Qt::Unchecked)
|
||||
{
|
||||
m_keepPlaytime = false;
|
||||
m_selectedOptions.keepPlaytime = false;
|
||||
}
|
||||
else if(state == Qt::Checked)
|
||||
{
|
||||
m_keepPlaytime = true;
|
||||
m_selectedOptions.keepPlaytime = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CopyInstanceDialog::shouldCopyGameOptions() const
|
||||
{
|
||||
return m_copyGameOptions;
|
||||
}
|
||||
|
||||
void CopyInstanceDialog::on_copyGameOptionsCheckbox_stateChanged(int state)
|
||||
{
|
||||
if(state == Qt::Unchecked)
|
||||
{
|
||||
m_copyGameOptions = false;
|
||||
m_selectedOptions.copyGameOptions = false;
|
||||
}
|
||||
else if(state == Qt::Checked)
|
||||
{
|
||||
m_copyGameOptions = true;
|
||||
m_selectedOptions.copyGameOptions = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CopyInstanceDialog::shouldCopyResourcePacks() const
|
||||
{
|
||||
return m_copyResourcePacks;
|
||||
}
|
||||
|
||||
void CopyInstanceDialog::on_copyResPacksCheckbox_stateChanged(int state)
|
||||
{
|
||||
if(state == Qt::Unchecked)
|
||||
{
|
||||
m_copyResourcePacks = false;
|
||||
m_selectedOptions.copyResourcePacks = false;
|
||||
}
|
||||
else if(state == Qt::Checked)
|
||||
{
|
||||
m_copyResourcePacks = true;
|
||||
m_selectedOptions.copyResourcePacks = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CopyInstanceDialog::shouldCopyShaderPacks() const
|
||||
{
|
||||
return m_copyShaderPacks;
|
||||
}
|
||||
|
||||
void CopyInstanceDialog::on_copyShaderPacksCheckbox_stateChanged(int state)
|
||||
{
|
||||
if(state == Qt::Unchecked)
|
||||
{
|
||||
m_copyShaderPacks = false;
|
||||
m_selectedOptions.copyShaderPacks = false;
|
||||
}
|
||||
else if(state == Qt::Checked)
|
||||
{
|
||||
m_copyShaderPacks = true;
|
||||
m_selectedOptions.copyShaderPacks = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CopyInstanceDialog::shouldCopyServers() const
|
||||
{
|
||||
return m_copyServers;
|
||||
}
|
||||
|
||||
void CopyInstanceDialog::on_copyServersCheckbox_stateChanged(int state)
|
||||
{
|
||||
if(state == Qt::Unchecked)
|
||||
{
|
||||
m_copyServers = false;
|
||||
m_selectedOptions.copyServers = false;
|
||||
}
|
||||
else if(state == Qt::Checked)
|
||||
{
|
||||
m_copyServers = true;
|
||||
m_selectedOptions.copyServers = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CopyInstanceDialog::shouldCopyMods() const
|
||||
{
|
||||
return m_copyMods;
|
||||
}
|
||||
|
||||
void CopyInstanceDialog::on_copyModsCheckbox_stateChanged(int state)
|
||||
{
|
||||
if(state == Qt::Unchecked)
|
||||
{
|
||||
m_copyMods = false;
|
||||
m_selectedOptions.copyMods = false;
|
||||
}
|
||||
else if(state == Qt::Checked)
|
||||
{
|
||||
m_copyMods = true;
|
||||
m_selectedOptions.copyMods = true;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include "BaseVersion.h"
|
||||
#include <BaseInstance.h>
|
||||
#include "InstanceCopyPrefs.h"
|
||||
|
||||
class BaseInstance;
|
||||
|
||||
@ -39,18 +39,16 @@ public:
|
||||
QString instName() const;
|
||||
QString instGroup() const;
|
||||
QString iconKey() const;
|
||||
bool shouldCopySaves() const;
|
||||
bool shouldKeepPlaytime() const;
|
||||
bool shouldCopyGameOptions() const;
|
||||
bool shouldCopyResourcePacks() const;
|
||||
bool shouldCopyShaderPacks() const;
|
||||
bool shouldCopyServers() const;
|
||||
bool shouldCopyMods() const;
|
||||
const InstanceCopyPrefs& getChosenOptions() const;
|
||||
|
||||
private
|
||||
slots:
|
||||
void on_iconButton_clicked();
|
||||
void on_instNameTextBox_textChanged(const QString &arg1);
|
||||
|
||||
// Checkbox options:
|
||||
void checkAllCheckboxes(bool b);
|
||||
void on_selectAllCheckbox_stateChanged(int state);
|
||||
void on_copySavesCheckbox_stateChanged(int state);
|
||||
void on_keepPlaytimeCheckbox_stateChanged(int state);
|
||||
void on_copyGameOptionsCheckbox_stateChanged(int state);
|
||||
@ -63,11 +61,5 @@ private:
|
||||
Ui::CopyInstanceDialog *ui;
|
||||
QString InstIconKey;
|
||||
InstancePtr m_original;
|
||||
bool m_copySaves = true;
|
||||
bool m_keepPlaytime = true;
|
||||
bool m_copyGameOptions = true;
|
||||
bool m_copyResourcePacks = true;
|
||||
bool m_copyShaderPacks = true;
|
||||
bool m_copyServers = true;
|
||||
bool m_copyMods = true;
|
||||
InstanceCopyPrefs m_selectedOptions = InstanceCopyPrefs(true); // Default to all options as true
|
||||
};
|
||||
|
@ -9,8 +9,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>265</width>
|
||||
<height>425</height>
|
||||
<width>341</width>
|
||||
<height>385</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -60,7 +60,7 @@
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<width>60</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -83,7 +83,10 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<layout class="QGridLayout" name="groupDropdownLayout">
|
||||
<property name="verticalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelVersion_3">
|
||||
<property name="text">
|
||||
@ -110,30 +113,15 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="copyOptionsLayout">
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="copySavesCheckbox">
|
||||
<property name="text">
|
||||
<string>Copy saves</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="keepPlaytimeCheckbox">
|
||||
<property name="text">
|
||||
<string>Keep play time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="copyGameOptionsCheckbox">
|
||||
<property name="toolTip">
|
||||
<string>Copy the in-game options like FOV, max framerate, etc.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Copy game options</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="copyResPacksCheckbox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
@ -143,21 +131,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="copyShaderPacksCheckbox">
|
||||
<property name="text">
|
||||
<string>Copy shader packs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="copyServersCheckbox">
|
||||
<property name="text">
|
||||
<string>Copy servers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="copyModsCheckbox">
|
||||
<property name="toolTip">
|
||||
<string>Disabling this will still keep the mod loader (ex: Fabric, Quilt, etc.) but erase the mods folder and their configs.</string>
|
||||
@ -167,6 +141,46 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="copyGameOptionsCheckbox">
|
||||
<property name="toolTip">
|
||||
<string>Copy the in-game options like FOV, max framerate, etc.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Copy game options</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="copyServersCheckbox">
|
||||
<property name="text">
|
||||
<string>Copy servers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="keepPlaytimeCheckbox">
|
||||
<property name="text">
|
||||
<string>Keep play time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="copyShaderPacksCheckbox">
|
||||
<property name="text">
|
||||
<string>Copy shader packs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="selectAllCheckbox">
|
||||
<property name="text">
|
||||
<string>Select all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
@ -183,8 +197,6 @@
|
||||
<tabstop>iconButton</tabstop>
|
||||
<tabstop>instNameTextBox</tabstop>
|
||||
<tabstop>groupBox</tabstop>
|
||||
<tabstop>copySavesCheckbox</tabstop>
|
||||
<tabstop>keepPlaytimeCheckbox</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../../graphics.qrc"/>
|
||||
|
Loading…
Reference in New Issue
Block a user