Check "Select all" checkbox if all options are already selected
+ code cleanup Signed-off-by: Marcelo Hernandez <marcelohdez.inq@gmail.com>
This commit is contained in:
parent
15593b5c09
commit
4caf06bc99
@ -4,12 +4,13 @@
|
|||||||
|
|
||||||
#include "InstanceCopyPrefs.h"
|
#include "InstanceCopyPrefs.h"
|
||||||
|
|
||||||
InstanceCopyPrefs::InstanceCopyPrefs(bool setAll)
|
bool InstanceCopyPrefs::allTrue() const
|
||||||
: copySaves(setAll),
|
{
|
||||||
keepPlaytime(setAll),
|
return copySaves &&
|
||||||
copyGameOptions(setAll),
|
keepPlaytime &&
|
||||||
copyResourcePacks(setAll),
|
copyGameOptions &&
|
||||||
copyShaderPacks(setAll),
|
copyResourcePacks &&
|
||||||
copyServers(setAll),
|
copyShaderPacks &&
|
||||||
copyMods(setAll)
|
copyServers &&
|
||||||
{}
|
copyMods;
|
||||||
|
}
|
||||||
|
@ -6,16 +6,15 @@
|
|||||||
#define LAUNCHER_INSTANCECOPYPREFS_H
|
#define LAUNCHER_INSTANCECOPYPREFS_H
|
||||||
|
|
||||||
struct InstanceCopyPrefs {
|
struct InstanceCopyPrefs {
|
||||||
explicit InstanceCopyPrefs(bool setAll);
|
bool copySaves = true;
|
||||||
~InstanceCopyPrefs() = default;
|
bool keepPlaytime = true;
|
||||||
|
bool copyGameOptions = true;
|
||||||
|
bool copyResourcePacks = true;
|
||||||
|
bool copyShaderPacks = true;
|
||||||
|
bool copyServers = true;
|
||||||
|
bool copyMods = true;
|
||||||
|
|
||||||
bool copySaves;
|
bool allTrue() const;
|
||||||
bool keepPlaytime;
|
|
||||||
bool copyGameOptions;
|
|
||||||
bool copyResourcePacks;
|
|
||||||
bool copyShaderPacks;
|
|
||||||
bool copyServers;
|
|
||||||
bool copyMods;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LAUNCHER_INSTANCECOPYPREFS_H
|
#endif // LAUNCHER_INSTANCECOPYPREFS_H
|
||||||
|
@ -122,6 +122,40 @@ QString CopyInstanceDialog::instGroup() const
|
|||||||
return ui->groupBox->currentText();
|
return ui->groupBox->currentText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const InstanceCopyPrefs& CopyInstanceDialog::getChosenOptions() const
|
||||||
|
{
|
||||||
|
return m_selectedOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CopyInstanceDialog::checkAllCheckboxes(const 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets b to true if state is a checked checkbox
|
||||||
|
void CopyInstanceDialog::checkBool(bool& b, const int& state)
|
||||||
|
{
|
||||||
|
if(state == Qt::Unchecked)
|
||||||
|
{
|
||||||
|
b = false;
|
||||||
|
}
|
||||||
|
else if(state == Qt::Checked)
|
||||||
|
{
|
||||||
|
b = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Have "Select all" checkbox checked if all options are already checked:
|
||||||
|
ui->selectAllCheckbox->blockSignals(true);
|
||||||
|
ui->selectAllCheckbox->setChecked(m_selectedOptions.allTrue());
|
||||||
|
ui->selectAllCheckbox->blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
void CopyInstanceDialog::on_iconButton_clicked()
|
void CopyInstanceDialog::on_iconButton_clicked()
|
||||||
{
|
{
|
||||||
IconPickerDialog dlg(this);
|
IconPickerDialog dlg(this);
|
||||||
@ -134,123 +168,51 @@ void CopyInstanceDialog::on_iconButton_clicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CopyInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1)
|
void CopyInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
updateDialogState();
|
updateDialogState();
|
||||||
}
|
}
|
||||||
|
|
||||||
const InstanceCopyPrefs& CopyInstanceDialog::getChosenOptions() const
|
|
||||||
{
|
|
||||||
return m_selectedOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CopyInstanceDialog::on_selectAllCheckbox_stateChanged(int state)
|
void CopyInstanceDialog::on_selectAllCheckbox_stateChanged(int state)
|
||||||
{
|
{
|
||||||
bool checked;
|
bool checked;
|
||||||
if(state == Qt::Unchecked)
|
checkBool(checked, state);
|
||||||
{
|
|
||||||
checked = false;
|
|
||||||
}
|
|
||||||
else if(state == Qt::Checked)
|
|
||||||
{
|
|
||||||
checked = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
checkAllCheckboxes(checked);
|
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)
|
void CopyInstanceDialog::on_copySavesCheckbox_stateChanged(int state)
|
||||||
{
|
{
|
||||||
if(state == Qt::Unchecked)
|
checkBool(m_selectedOptions.copySaves, state);
|
||||||
{
|
|
||||||
m_selectedOptions.copySaves = false;
|
|
||||||
}
|
|
||||||
else if(state == Qt::Checked)
|
|
||||||
{
|
|
||||||
m_selectedOptions.copySaves = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CopyInstanceDialog::on_keepPlaytimeCheckbox_stateChanged(int state)
|
void CopyInstanceDialog::on_keepPlaytimeCheckbox_stateChanged(int state)
|
||||||
{
|
{
|
||||||
if(state == Qt::Unchecked)
|
checkBool(m_selectedOptions.keepPlaytime, state);
|
||||||
{
|
|
||||||
m_selectedOptions.keepPlaytime = false;
|
|
||||||
}
|
|
||||||
else if(state == Qt::Checked)
|
|
||||||
{
|
|
||||||
m_selectedOptions.keepPlaytime = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyInstanceDialog::on_copyGameOptionsCheckbox_stateChanged(int state)
|
void CopyInstanceDialog::on_copyGameOptionsCheckbox_stateChanged(int state)
|
||||||
{
|
{
|
||||||
if(state == Qt::Unchecked)
|
checkBool(m_selectedOptions.copyGameOptions, state);
|
||||||
{
|
|
||||||
m_selectedOptions.copyGameOptions = false;
|
|
||||||
}
|
|
||||||
else if(state == Qt::Checked)
|
|
||||||
{
|
|
||||||
m_selectedOptions.copyGameOptions = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyInstanceDialog::on_copyResPacksCheckbox_stateChanged(int state)
|
void CopyInstanceDialog::on_copyResPacksCheckbox_stateChanged(int state)
|
||||||
{
|
{
|
||||||
if(state == Qt::Unchecked)
|
checkBool(m_selectedOptions.copyResourcePacks, state);
|
||||||
{
|
|
||||||
m_selectedOptions.copyResourcePacks = false;
|
|
||||||
}
|
|
||||||
else if(state == Qt::Checked)
|
|
||||||
{
|
|
||||||
m_selectedOptions.copyResourcePacks = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyInstanceDialog::on_copyShaderPacksCheckbox_stateChanged(int state)
|
void CopyInstanceDialog::on_copyShaderPacksCheckbox_stateChanged(int state)
|
||||||
{
|
{
|
||||||
if(state == Qt::Unchecked)
|
checkBool(m_selectedOptions.copyShaderPacks, state);
|
||||||
{
|
|
||||||
m_selectedOptions.copyShaderPacks = false;
|
|
||||||
}
|
|
||||||
else if(state == Qt::Checked)
|
|
||||||
{
|
|
||||||
m_selectedOptions.copyShaderPacks = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyInstanceDialog::on_copyServersCheckbox_stateChanged(int state)
|
void CopyInstanceDialog::on_copyServersCheckbox_stateChanged(int state)
|
||||||
{
|
{
|
||||||
if(state == Qt::Unchecked)
|
checkBool(m_selectedOptions.copyServers, state);
|
||||||
{
|
|
||||||
m_selectedOptions.copyServers = false;
|
|
||||||
}
|
|
||||||
else if(state == Qt::Checked)
|
|
||||||
{
|
|
||||||
m_selectedOptions.copyServers = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyInstanceDialog::on_copyModsCheckbox_stateChanged(int state)
|
void CopyInstanceDialog::on_copyModsCheckbox_stateChanged(int state)
|
||||||
{
|
{
|
||||||
if(state == Qt::Unchecked)
|
checkBool(m_selectedOptions.copyMods, state);
|
||||||
{
|
|
||||||
m_selectedOptions.copyMods = false;
|
|
||||||
}
|
|
||||||
else if(state == Qt::Checked)
|
|
||||||
{
|
|
||||||
m_selectedOptions.copyMods = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,9 @@ slots:
|
|||||||
void on_instNameTextBox_textChanged(const QString &arg1);
|
void on_instNameTextBox_textChanged(const QString &arg1);
|
||||||
|
|
||||||
// Checkbox options:
|
// Checkbox options:
|
||||||
void checkAllCheckboxes(bool b);
|
void checkAllCheckboxes(const bool& b);
|
||||||
|
void checkBool(bool& b, const int& state);
|
||||||
|
|
||||||
void on_selectAllCheckbox_stateChanged(int state);
|
void on_selectAllCheckbox_stateChanged(int state);
|
||||||
void on_copySavesCheckbox_stateChanged(int state);
|
void on_copySavesCheckbox_stateChanged(int state);
|
||||||
void on_keepPlaytimeCheckbox_stateChanged(int state);
|
void on_keepPlaytimeCheckbox_stateChanged(int state);
|
||||||
@ -61,5 +63,5 @@ private:
|
|||||||
Ui::CopyInstanceDialog *ui;
|
Ui::CopyInstanceDialog *ui;
|
||||||
QString InstIconKey;
|
QString InstIconKey;
|
||||||
InstancePtr m_original;
|
InstancePtr m_original;
|
||||||
InstanceCopyPrefs m_selectedOptions = InstanceCopyPrefs(true); // Default to all options as true
|
InstanceCopyPrefs m_selectedOptions;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user