Skip to content

Commit

Permalink
src/gui/widgets/settings: ifdef deprecated statechanged signals
Browse files Browse the repository at this point in the history
Replaced stateChanged() with checkStateChanged() signals on Qt 6.7.0 and
greater.
  • Loading branch information
ripose-jp committed Oct 28, 2024
1 parent b060a0e commit d4fe784
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
29 changes: 25 additions & 4 deletions src/gui/widgets/settings/ankisettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,14 @@ AnkiSettings::AnkiSettings(QWidget *parent)
initIcons();

connect(
m_ui->checkBoxEnabled, &QCheckBox::stateChanged,
this, &AnkiSettings::enabledStateChanged
m_ui->checkBoxEnabled,
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
&QCheckBox::stateChanged,
#else
&QCheckBox::checkStateChanged,
#endif
this,
&AnkiSettings::enabledStateChanged
);
connect(
m_ui->comboBoxProfile, &QComboBox::currentTextChanged,
Expand All @@ -124,8 +130,19 @@ AnkiSettings::AnkiSettings(QWidget *parent)
this, [=] { connectToClient(true); }
);
connect(
m_ui->checkboxAdvanced, &QCheckBox::stateChanged, this,
[=] (int state) {
m_ui->checkboxAdvanced,
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
&QCheckBox::stateChanged,
#else
&QCheckBox::checkStateChanged,
#endif
this,
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
[=] (int state)
#else
[=] (Qt::CheckState state)
#endif
{
m_ui->frameAdvanced->setVisible(state == Qt::Checked);
}
);
Expand Down Expand Up @@ -425,7 +442,11 @@ void AnkiSettings::updateModelFields(CardBuilder *cb, const QString &model)
/* End AnkiConnect Actions */
/* Begin UI Management */

#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
void AnkiSettings::enabledStateChanged(int state)
#else
void AnkiSettings::enabledStateChanged(Qt::CheckState state)
#endif
{
bool enabled = state == Qt::CheckState::Checked;
m_ui->frameContent->setEnabled(enabled);
Expand Down
6 changes: 5 additions & 1 deletion src/gui/widgets/settings/ankisettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ private Q_SLOTS:
/**
* Called when the Anki Integration Enabled checkbox is changed.
* Enables/Disables widgets on the front end.
* @param state The checkbox state (Qt::CheckState).
* @param state The checkbox state.
*/
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
void enabledStateChanged(int state);
#else
void enabledStateChanged(Qt::CheckState state);
#endif

/**
* Connects to AnkiConnect and updates the decks, models, and fields.
Expand Down
16 changes: 14 additions & 2 deletions src/gui/widgets/settings/interfacesettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,20 @@ InterfaceSettings::InterfaceSettings(QWidget *parent)
[=] { askButtonColor(m_ui->buttonSubStroke, m_strokeColor); }
);

connect(m_ui->checkStyleSheets, &QCheckBox::stateChanged, this,
[=] (const int state) {
connect(
m_ui->checkStyleSheets,
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
&QCheckBox::stateChanged,
#else
&QCheckBox::checkStateChanged,
#endif
this,
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
[=] (int state)
#else
[=] (Qt::CheckState state)
#endif
{
m_ui->frameStyleSheets->setEnabled(
state == Qt::CheckState::Checked
);
Expand Down

0 comments on commit d4fe784

Please sign in to comment.