Use checkStateChanged(Qt::CheckState) with Qt >= 6.7

This commit is contained in:
Jonas Kvinge 2024-05-24 02:13:48 +02:00
parent 9f2e4ac312
commit c655963483
6 changed files with 34 additions and 1 deletions

View File

@ -41,7 +41,11 @@ AlbumCoverExport::AlbumCoverExport(QWidget *parent) : QDialog(parent), ui_(new U
ui_->setupUi(this);
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
QObject::connect(ui_->forceSize, &QCheckBox::checkStateChanged, this, &AlbumCoverExport::ForceSizeToggled);
#else
QObject::connect(ui_->forceSize, &QCheckBox::stateChanged, this, &AlbumCoverExport::ForceSizeToggled);
#endif
}
@ -99,7 +103,11 @@ AlbumCoverExport::DialogResult AlbumCoverExport::Exec() {
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
void AlbumCoverExport::ForceSizeToggled(Qt::CheckState state) {
#else
void AlbumCoverExport::ForceSizeToggled(int state) {
#endif
ui_->width->setEnabled(state == Qt::Checked);
ui_->height->setEnabled(state == Qt::Checked);
}

View File

@ -70,7 +70,11 @@ class AlbumCoverExport : public QDialog {
DialogResult Exec();
private slots:
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
void ForceSizeToggled(Qt::CheckState state);
#else
void ForceSizeToggled(int state);
#endif
private:
Ui_AlbumCoverExport *ui_;

View File

@ -172,7 +172,11 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent)
QObject::connect(spinbox, &SpinBox::Reset, this, &EditTagDialog::ResetField);
}
else if (CheckBox *checkbox = qobject_cast<CheckBox*>(widget)) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
QObject::connect(checkbox, &QCheckBox::checkStateChanged, this, &EditTagDialog::FieldValueEdited);
#else
QObject::connect(checkbox, &QCheckBox::stateChanged, this, &EditTagDialog::FieldValueEdited);
#endif
QObject::connect(checkbox, &CheckBox::Reset, this, &EditTagDialog::ResetField);
}
else if (RatingBox *ratingbox = qobject_cast<RatingBox*>(widget)) {

View File

@ -51,8 +51,13 @@ LastFMImportDialog::LastFMImportDialog(SharedPtr<LastFMImport> lastfm_import, QW
QObject::connect(ui_->button_go, &QPushButton::clicked, this, &LastFMImportDialog::Start);
QObject::connect(ui_->button_cancel, &QPushButton::clicked, this, &LastFMImportDialog::Cancel);
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
QObject::connect(ui_->checkbox_last_played, &QCheckBox::checkStateChanged, this, &LastFMImportDialog::UpdateGoButtonState);
QObject::connect(ui_->checkbox_playcounts, &QCheckBox::checkStateChanged, this, &LastFMImportDialog::UpdateGoButtonState);
#else
QObject::connect(ui_->checkbox_last_played, &QCheckBox::stateChanged, this, &LastFMImportDialog::UpdateGoButtonState);
QObject::connect(ui_->checkbox_playcounts, &QCheckBox::stateChanged, this, &LastFMImportDialog::UpdateGoButtonState);
#endif
}

View File

@ -97,7 +97,11 @@ CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog, QWidget *
QObject::connect(ui_->song_tracking, &QCheckBox::toggled, this, &CollectionSettingsPage::SongTrackingToggled);
#endif
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
QObject::connect(ui_->checkbox_disk_cache, &QCheckBox::checkStateChanged, this, &CollectionSettingsPage::DiskCacheEnable);
#else
QObject::connect(ui_->checkbox_disk_cache, &QCheckBox::stateChanged, this, &CollectionSettingsPage::DiskCacheEnable);
#endif
QObject::connect(ui_->button_clear_disk_cache, &QPushButton::clicked, dialog->app(), &Application::ClearPixmapDiskCache);
QObject::connect(ui_->button_clear_disk_cache, &QPushButton::clicked, this, &CollectionSettingsPage::ClearPixmapDiskCache);
@ -276,9 +280,13 @@ void CollectionSettingsPage::SongTrackingToggled() {
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
void CollectionSettingsPage::DiskCacheEnable(const Qt::CheckState state) {
#else
void CollectionSettingsPage::DiskCacheEnable(const int state) {
#endif
bool checked = state == Qt::Checked;
const bool checked = state == Qt::Checked;
ui_->label_disk_cache_size->setEnabled(checked);
ui_->spinbox_disk_cache_size->setEnabled(checked);
ui_->combobox_disk_cache_size->setEnabled(checked);

View File

@ -71,7 +71,11 @@ class CollectionSettingsPage : public SettingsPage {
void CurrentRowChanged(const QModelIndex &idx);
void SongTrackingToggled();
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
void DiskCacheEnable(const Qt::CheckState state);
#else
void DiskCacheEnable(const int state);
#endif
void ClearPixmapDiskCache();
void CacheSizeUnitChanged(int index);
void DiskCacheSizeUnitChanged(int index);