Add backwards support Qt6.7's checkStateChanged on QCheckBoxes (#5137)

This commit is contained in:
Zach H 2024-10-20 23:35:34 -04:00 committed by GitHub
parent b041f4ace2
commit 8d5421d9da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 251 additions and 176 deletions

View file

@ -11,6 +11,7 @@
#include <QIcon>
#include <QStringList>
#include <QTime>
#include <QTimeZone>
enum GameListColumn
{
@ -93,7 +94,11 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
case CREATED: {
switch (role) {
case Qt::DisplayRole: {
QDateTime then = QDateTime::fromSecsSinceEpoch(gameentry.start_time(), Qt::UTC);
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
auto then = QDateTime::fromSecsSinceEpoch(gameentry.start_time(), QTimeZone::UTC);
#else
auto then = QDateTime::fromSecsSinceEpoch(gameentry.start_time(), Qt::UTC);
#endif
int secs = then.secsTo(QDateTime::currentDateTimeUtc());
return getGameCreatedString(secs);
}
@ -487,7 +492,9 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sour
bool GamesProxyModel::filterAcceptsRow(int sourceRow) const
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
static const QDate epochDate = QDateTime::fromSecsSinceEpoch(0, QTimeZone::UTC).date();
#elif (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
static const QDate epochDate = QDateTime::fromSecsSinceEpoch(0, Qt::UTC).date();
#else
static const QDate epochDate = QDateTime::fromTime_t(0, Qt::UTC).date();

View file

@ -96,9 +96,12 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
// numberCard is the num of cards we want to reveal from an area. Ex: scry the top 3 cards.
// If the number is < 0 then it means that we can make the area sorted and we dont care about the order.
if (numberCards < 0) {
connect(&sortByNameCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSortByName(int)));
connect(&sortByTypeCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSortByType(int)));
connect(&pileViewCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSetPileView(int)));
connect(&sortByNameCheckBox, SIGNAL(QT_STATE_CHANGED(QT_STATE_CHANGED_T)), this,
SLOT(processSortByName(QT_STATE_CHANGED_T)));
connect(&sortByTypeCheckBox, SIGNAL(QT_STATE_CHANGED(QT_STATE_CHANGED_T)), this,
SLOT(processSortByType(QT_STATE_CHANGED_T)));
connect(&pileViewCheckBox, SIGNAL(QT_STATE_CHANGED(QT_STATE_CHANGED_T)), this,
SLOT(processSetPileView(QT_STATE_CHANGED_T)));
sortByNameCheckBox.setChecked(SettingsCache::instance().getZoneViewSortByName());
sortByTypeCheckBox.setChecked(SettingsCache::instance().getZoneViewSortByType());
pileViewCheckBox.setChecked(SettingsCache::instance().getZoneViewPileView());
@ -114,7 +117,7 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
zone->initializeCards(cardList);
}
void ZoneViewWidget::processSortByType(int value)
void ZoneViewWidget::processSortByType(QT_STATE_CHANGED_T value)
{
pileViewCheckBox.setEnabled(value);
SettingsCache::instance().setZoneViewSortByType(value);
@ -122,13 +125,13 @@ void ZoneViewWidget::processSortByType(int value)
zone->setSortByType(value);
}
void ZoneViewWidget::processSortByName(int value)
void ZoneViewWidget::processSortByName(QT_STATE_CHANGED_T value)
{
SettingsCache::instance().setZoneViewSortByName(value);
zone->setSortByName(value);
}
void ZoneViewWidget::processSetPileView(int value)
void ZoneViewWidget::processSetPileView(QT_STATE_CHANGED_T value)
{
SettingsCache::instance().setZoneViewPileView(value);
zone->setPileView(value);

View file

@ -1,6 +1,8 @@
#ifndef ZONEVIEWWIDGET_H
#define ZONEVIEWWIDGET_H
#include "../../utility/macros.h"
#include <QCheckBox>
#include <QGraphicsProxyWidget>
#include <QGraphicsWidget>
@ -50,9 +52,9 @@ private:
signals:
void closePressed(ZoneViewWidget *zv);
private slots:
void processSortByType(int value);
void processSortByName(int value);
void processSetPileView(int value);
void processSortByType(QT_STATE_CHANGED_T value);
void processSortByName(QT_STATE_CHANGED_T value);
void processSetPileView(QT_STATE_CHANGED_T value);
void resizeToZoneContents();
void handleScrollBarChange(int value);
void zoneDeleted();