remove checkBool function, add updateSelectAllCheckbox function

Signed-off-by: Marcelo Hernandez <marcelohdez.inq@gmail.com>
This commit is contained in:
Marcelo Hernandez 2022-10-24 20:49:40 -04:00
parent a89df42561
commit 385c452ddf
No known key found for this signature in database
GPG Key ID: 1405A0E7C9C4D61D
2 changed files with 21 additions and 18 deletions

View File

@ -138,12 +138,9 @@ void CopyInstanceDialog::checkAllCheckboxes(const bool& b)
ui->copyModsCheckbox->setChecked(b); ui->copyModsCheckbox->setChecked(b);
} }
// Sets b to true if state is a checked checkbox // Check the "Select all" checkbox checked if all options are already checked:
void CopyInstanceDialog::checkBool(bool& b, const int& state) void CopyInstanceDialog::updateSelectAllCheckbox()
{ {
b = (state == Qt::Checked);
// Have "Select all" checkbox checked if all options are already checked:
ui->selectAllCheckbox->blockSignals(true); ui->selectAllCheckbox->blockSignals(true);
ui->selectAllCheckbox->setChecked(m_selectedOptions.allTrue()); ui->selectAllCheckbox->setChecked(m_selectedOptions.allTrue());
ui->selectAllCheckbox->blockSignals(false); ui->selectAllCheckbox->blockSignals(false);
@ -170,42 +167,49 @@ void CopyInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1)
void CopyInstanceDialog::on_selectAllCheckbox_stateChanged(int state) void CopyInstanceDialog::on_selectAllCheckbox_stateChanged(int state)
{ {
bool checked; bool checked;
checkBool(checked, state); checked = (state == Qt::Checked);
checkAllCheckboxes(checked); checkAllCheckboxes(checked);
} }
void CopyInstanceDialog::on_copySavesCheckbox_stateChanged(int state) void CopyInstanceDialog::on_copySavesCheckbox_stateChanged(int state)
{ {
checkBool(m_selectedOptions.copySaves, state); m_selectedOptions.copySaves = (state == Qt::Checked);
updateSelectAllCheckbox();
} }
void CopyInstanceDialog::on_keepPlaytimeCheckbox_stateChanged(int state) void CopyInstanceDialog::on_keepPlaytimeCheckbox_stateChanged(int state)
{ {
checkBool(m_selectedOptions.keepPlaytime, state); m_selectedOptions.keepPlaytime = (state == Qt::Checked);
updateSelectAllCheckbox();
} }
void CopyInstanceDialog::on_copyGameOptionsCheckbox_stateChanged(int state) void CopyInstanceDialog::on_copyGameOptionsCheckbox_stateChanged(int state)
{ {
checkBool(m_selectedOptions.copyGameOptions, state); m_selectedOptions.copyGameOptions = (state == Qt::Checked);
updateSelectAllCheckbox();
} }
void CopyInstanceDialog::on_copyResPacksCheckbox_stateChanged(int state) void CopyInstanceDialog::on_copyResPacksCheckbox_stateChanged(int state)
{ {
checkBool(m_selectedOptions.copyResourcePacks, state); m_selectedOptions.copyResourcePacks = (state == Qt::Checked);
updateSelectAllCheckbox();
} }
void CopyInstanceDialog::on_copyShaderPacksCheckbox_stateChanged(int state) void CopyInstanceDialog::on_copyShaderPacksCheckbox_stateChanged(int state)
{ {
checkBool(m_selectedOptions.copyShaderPacks, state); m_selectedOptions.copyShaderPacks = (state == Qt::Checked);
updateSelectAllCheckbox();
} }
void CopyInstanceDialog::on_copyServersCheckbox_stateChanged(int state) void CopyInstanceDialog::on_copyServersCheckbox_stateChanged(int state)
{ {
checkBool(m_selectedOptions.copyServers, state); m_selectedOptions.copyServers = (state == Qt::Checked);
updateSelectAllCheckbox();
} }
void CopyInstanceDialog::on_copyModsCheckbox_stateChanged(int state) void CopyInstanceDialog::on_copyModsCheckbox_stateChanged(int state)
{ {
checkBool(m_selectedOptions.copyMods, state); m_selectedOptions.copyMods = (state == Qt::Checked);
updateSelectAllCheckbox();
} }

View File

@ -45,11 +45,7 @@ private
slots: slots:
void on_iconButton_clicked(); void on_iconButton_clicked();
void on_instNameTextBox_textChanged(const QString &arg1); void on_instNameTextBox_textChanged(const QString &arg1);
// Checkboxes
// Checkbox options:
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);
@ -60,6 +56,9 @@ slots:
void on_copyModsCheckbox_stateChanged(int state); void on_copyModsCheckbox_stateChanged(int state);
private: private:
void checkAllCheckboxes(const bool& b);
void updateSelectAllCheckbox();
/* data */
Ui::CopyInstanceDialog *ui; Ui::CopyInstanceDialog *ui;
QString InstIconKey; QString InstIconKey;
InstancePtr m_original; InstancePtr m_original;