create getters and setters for InstanceCopyPrefs

+ use pragma once like other .h files in this directory

Signed-off-by: Marcelo Hernandez <marcelohdez.inq@gmail.com>
This commit is contained in:
Marcelo Hernandez 2022-10-29 00:55:33 -04:00
parent 63b6c6685c
commit c00f96c7ca
No known key found for this signature in database
GPG Key ID: 1405A0E7C9C4D61D
4 changed files with 109 additions and 22 deletions

View File

@ -47,3 +47,75 @@ QString InstanceCopyPrefs::getSelectedFiltersAsRegex() const
return {};
}
// ======= Getters =======
bool InstanceCopyPrefs::isCopySavesEnabled() const
{
return copySaves;
}
bool InstanceCopyPrefs::isKeepPlaytimeEnabled() const
{
return keepPlaytime;
}
bool InstanceCopyPrefs::isCopyGameOptionsEnabled() const
{
return copyGameOptions;
}
bool InstanceCopyPrefs::isCopyResourcePacksEnabled() const
{
return copyResourcePacks;
}
bool InstanceCopyPrefs::isCopyShaderPacksEnabled() const
{
return copyShaderPacks;
}
bool InstanceCopyPrefs::isCopyServersEnabled() const
{
return copyServers;
}
bool InstanceCopyPrefs::isCopyModsEnabled() const
{
return copyMods;
}
// ======= Setters =======
void InstanceCopyPrefs::enableCopySaves(bool b)
{
copySaves = b;
}
void InstanceCopyPrefs::enableKeepPlaytime(bool b)
{
keepPlaytime = b;
}
void InstanceCopyPrefs::enableCopyGameOptions(bool b)
{
copyGameOptions = b;
}
void InstanceCopyPrefs::enableCopyResourcePacks(bool b)
{
copyResourcePacks = b;
}
void InstanceCopyPrefs::enableCopyShaderPacks(bool b)
{
copyShaderPacks = b;
}
void InstanceCopyPrefs::enableCopyServers(bool b)
{
copyServers = b;
}
void InstanceCopyPrefs::enableCopyMods(bool b)
{
copyMods = b;
}

View File

@ -2,12 +2,32 @@
// Created by marcelohdez on 10/22/22.
//
#ifndef LAUNCHER_INSTANCECOPYPREFS_H
#define LAUNCHER_INSTANCECOPYPREFS_H
#pragma once
#include <QStringList>
struct InstanceCopyPrefs {
public:
[[nodiscard]] bool allTrue() const;
[[nodiscard]] QString getSelectedFiltersAsRegex() const;
// Getters
[[nodiscard]] bool isCopySavesEnabled() const;
[[nodiscard]] bool isKeepPlaytimeEnabled() const;
[[nodiscard]] bool isCopyGameOptionsEnabled() const;
[[nodiscard]] bool isCopyResourcePacksEnabled() const;
[[nodiscard]] bool isCopyShaderPacksEnabled() const;
[[nodiscard]] bool isCopyServersEnabled() const;
[[nodiscard]] bool isCopyModsEnabled() const;
// Setters
void enableCopySaves(bool b);
void enableKeepPlaytime(bool b);
void enableCopyGameOptions(bool b);
void enableCopyResourcePacks(bool b);
void enableCopyShaderPacks(bool b);
void enableCopyServers(bool b);
void enableCopyMods(bool b);
protected: // data
bool copySaves = true;
bool keepPlaytime = true;
bool copyGameOptions = true;
@ -15,9 +35,4 @@ struct InstanceCopyPrefs {
bool copyShaderPacks = true;
bool copyServers = true;
bool copyMods = true;
[[nodiscard]] bool allTrue() const;
[[nodiscard]] QString getSelectedFiltersAsRegex() const;
};
#endif // LAUNCHER_INSTANCECOPYPREFS_H

View File

@ -8,7 +8,7 @@
InstanceCopyTask::InstanceCopyTask(InstancePtr origInstance, const InstanceCopyPrefs& prefs)
{
m_origInstance = origInstance;
m_keepPlaytime = prefs.keepPlaytime;
m_keepPlaytime = prefs.isKeepPlaytimeEnabled();
QString filters = prefs.getSelectedFiltersAsRegex();
if (!filters.isEmpty())

View File

@ -77,13 +77,13 @@ CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent)
}
ui->groupBox->setCurrentIndex(index);
ui->groupBox->lineEdit()->setPlaceholderText(tr("No group"));
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);
ui->copySavesCheckbox->setChecked(m_selectedOptions.isCopySavesEnabled());
ui->keepPlaytimeCheckbox->setChecked(m_selectedOptions.isKeepPlaytimeEnabled());
ui->copyGameOptionsCheckbox->setChecked(m_selectedOptions.isCopyGameOptionsEnabled());
ui->copyResPacksCheckbox->setChecked(m_selectedOptions.isCopyResourcePacksEnabled());
ui->copyShaderPacksCheckbox->setChecked(m_selectedOptions.isCopyShaderPacksEnabled());
ui->copyServersCheckbox->setChecked(m_selectedOptions.isCopyServersEnabled());
ui->copyModsCheckbox->setChecked(m_selectedOptions.isCopyModsEnabled());
}
CopyInstanceDialog::~CopyInstanceDialog()
@ -172,43 +172,43 @@ void CopyInstanceDialog::on_selectAllCheckbox_stateChanged(int state)
void CopyInstanceDialog::on_copySavesCheckbox_stateChanged(int state)
{
m_selectedOptions.copySaves = (state == Qt::Checked);
m_selectedOptions.enableCopySaves(state == Qt::Checked);
updateSelectAllCheckbox();
}
void CopyInstanceDialog::on_keepPlaytimeCheckbox_stateChanged(int state)
{
m_selectedOptions.keepPlaytime = (state == Qt::Checked);
m_selectedOptions.enableKeepPlaytime(state == Qt::Checked);
updateSelectAllCheckbox();
}
void CopyInstanceDialog::on_copyGameOptionsCheckbox_stateChanged(int state)
{
m_selectedOptions.copyGameOptions = (state == Qt::Checked);
m_selectedOptions.enableCopyGameOptions(state == Qt::Checked);
updateSelectAllCheckbox();
}
void CopyInstanceDialog::on_copyResPacksCheckbox_stateChanged(int state)
{
m_selectedOptions.copyResourcePacks = (state == Qt::Checked);
m_selectedOptions.enableCopyResourcePacks(state == Qt::Checked);
updateSelectAllCheckbox();
}
void CopyInstanceDialog::on_copyShaderPacksCheckbox_stateChanged(int state)
{
m_selectedOptions.copyShaderPacks = (state == Qt::Checked);
m_selectedOptions.enableCopyShaderPacks(state == Qt::Checked);
updateSelectAllCheckbox();
}
void CopyInstanceDialog::on_copyServersCheckbox_stateChanged(int state)
{
m_selectedOptions.copyServers = (state == Qt::Checked);
m_selectedOptions.enableCopyServers(state == Qt::Checked);
updateSelectAllCheckbox();
}
void CopyInstanceDialog::on_copyModsCheckbox_stateChanged(int state)
{
m_selectedOptions.copyMods = (state == Qt::Checked);
m_selectedOptions.enableCopyMods(state == Qt::Checked);
updateSelectAllCheckbox();
}