build: raise minimum Qt version to 6.8 and drop pre-6.8 fallbacks

This commit is contained in:
yyc12345 committed 2026-10-19 21:30:00 +08:00
1 parent 124c69bf8b
commit ceb240d01a
6 files changed
+9 -48

No files matched your search

+1 -1
View File
@@ -20,7 +20,7 @@ set (CMAKE_AUTOUIC ON)
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core) find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core)
set (QT_MINIMUM_VERSION "6.5") set (QT_MINIMUM_VERSION "6.8")
find_package(Qt${QT_VERSION_MAJOR} ${QT_MINIMUM_VERSION} REQUIRED find_package(Qt${QT_VERSION_MAJOR} ${QT_MINIMUM_VERSION} REQUIRED
COMPONENTS Widgets Svg SvgWidgets LinguistTools COMPONENTS Widgets Svg SvgWidgets LinguistTools
+1 -8
View File
@@ -21,17 +21,12 @@
static const QColor& ColorSchemaToTextForeground(Qt::ColorScheme colorScheme) { static const QColor& ColorSchemaToTextForeground(Qt::ColorScheme colorScheme) {
// YYC MARK: // YYC MARK:
// If we are using Windows 10 and lower system or Qt which do not support "Windows 11" // If we are using Windows 10 and lower system, we should only support light mode.
// theme (lower than Qt 6.7), we should only support light mode.
// Because Qt's dark-mode-aware "Windows 11" theme is only well-supported on Windows 11. // Because Qt's dark-mode-aware "Windows 11" theme is only well-supported on Windows 11.
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
colorScheme = Qt::ColorScheme::Light;
#else
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows11) { if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows11) {
colorScheme = Qt::ColorScheme::Light; colorScheme = Qt::ColorScheme::Light;
} }
#endif // QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
#endif // defined(Q_OS_WIN) #endif // defined(Q_OS_WIN)
switch (colorScheme) { switch (colorScheme) {
@@ -164,11 +159,9 @@ void GraphicsScene::showSvg(const QString &filepath)
this->clear(); this->clear();
QGraphicsSvgItem * svgItem = new QGraphicsSvgItem(); QGraphicsSvgItem * svgItem = new QGraphicsSvgItem();
QSvgRenderer * render = new QSvgRenderer(svgItem); QSvgRenderer * render = new QSvgRenderer(svgItem);
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
if (Settings::instance()->svgTiny12Only()) { if (Settings::instance()->svgTiny12Only()) {
render->setOptions(QtSvg::Tiny12FeaturesOnly); render->setOptions(QtSvg::Tiny12FeaturesOnly);
} }
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
render->load(filepath); render->load(filepath);
svgItem->setSharedRenderer(render); svgItem->setSharedRenderer(render);
this->addItem(svgItem); this->addItem(svgItem);
+1 -16
View File
@@ -57,7 +57,6 @@ void GraphicsView::showFileFromPath(const QString &filePath)
} else if (!imageReader.canRead()) { } else if (!imageReader.canRead()) {
showText(tr("Image data is invalid or currently unsupported")); showText(tr("Image data is invalid or currently unsupported"));
} else { } else {
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
QImage && img = imageReader.read(); QImage && img = imageReader.read();
if (img.isNull()) { if (img.isNull()) {
showText(tr("Image data is invalid or currently unsupported")); showText(tr("Image data is invalid or currently unsupported"));
@@ -68,15 +67,6 @@ void GraphicsView::showFileFromPath(const QString &filePath)
img.setDevicePixelRatio(devicePixelRatioF()); img.setDevicePixelRatio(devicePixelRatioF());
showImage(img); showImage(img);
} }
#else
QPixmap && pixmap = QPixmap::fromImageReader(&imageReader);
if (pixmap.isNull()) {
showText(tr("Image data is invalid or currently unsupported"));
} else {
pixmap.setDevicePixelRatio(devicePixelRatioF());
showImage(pixmap);
}
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
} }
} }
} }
@@ -366,17 +356,12 @@ QTransform GraphicsView::resetScale(const QTransform & orig)
void GraphicsView::updateStyle(Qt::ColorScheme colorScheme) { void GraphicsView::updateStyle(Qt::ColorScheme colorScheme) {
// YYC MARK: // YYC MARK:
// If we are using Windows 10 and lower system or Qt which do not support "Windows 11" // If we are using Windows 10 and lower system, we should only support light mode.
// theme (lower than Qt 6.7), we should only support light mode.
// Because Qt's dark-mode-aware "Windows 11" theme is only well-supported on Windows 11. // Because Qt's dark-mode-aware "Windows 11" theme is only well-supported on Windows 11.
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
colorScheme = Qt::ColorScheme::Light;
#else
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows11) { if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows11) {
colorScheme = Qt::ColorScheme::Light; colorScheme = Qt::ColorScheme::Light;
} }
#endif // QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
#endif // defined(Q_OS_WIN) #endif // defined(Q_OS_WIN)
switch (colorScheme) { switch (colorScheme) {
+1 -5
View File
@@ -257,11 +257,7 @@ void MainWindow::galleryCurrent(bool fromFileWatcher)
QStringList MainWindow::supportedImageFormats() QStringList MainWindow::supportedImageFormats()
{ {
QStringList formatFilters { QStringList formatFilters;
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
QStringLiteral("*.jfif")
#endif // QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
};
for (const QByteArray &item : QImageReader::supportedImageFormats()) { for (const QByteArray &item : QImageReader::supportedImageFormats()) {
formatFilters.append(QStringLiteral("*.") % QString::fromLocal8Bit(item)); formatFilters.append(QStringLiteral("*.") % QString::fromLocal8Bit(item));
} }
+1 -6
View File
@@ -43,17 +43,12 @@ void NavigatorView::updateMainViewportRegion()
void NavigatorView::updateStyle(Qt::ColorScheme colorScheme) { void NavigatorView::updateStyle(Qt::ColorScheme colorScheme) {
// YYC MARK: // YYC MARK:
// If we are using Windows 10 and lower system or Qt which do not support "Windows 11" // If we are using Windows 10 and lower system, we should only support light mode.
// theme (lower than Qt 6.7), we should only support light mode.
// Because Qt's dark-mode-aware "Windows 11" theme is only well-supported on Windows 11. // Because Qt's dark-mode-aware "Windows 11" theme is only well-supported on Windows 11.
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
colorScheme = Qt::ColorScheme::Light;
#else
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows11) { if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows11) {
colorScheme = Qt::ColorScheme::Light; colorScheme = Qt::ColorScheme::Light;
} }
#endif // QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
#endif // defined(Q_OS_WIN) #endif // defined(Q_OS_WIN)
switch (colorScheme) { switch (colorScheme) {
+4 -12
View File
@@ -98,27 +98,19 @@ SettingsDialog::SettingsDialog(QWidget *parent)
Qt::HighDpiScaleFactorRoundingPolicy hidpi = settings->hiDpiScaleFactorBehavior(); Qt::HighDpiScaleFactorRoundingPolicy hidpi = settings->hiDpiScaleFactorBehavior();
ui->m_hiDpiRoundingPolicyBehavior->setCurrentIndex(HIDPI_OPTIONS.to_index(hidpi)); ui->m_hiDpiRoundingPolicyBehavior->setCurrentIndex(HIDPI_OPTIONS.to_index(hidpi));
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) connect(ui->m_showNavigatorView, &QCheckBox::checkStateChanged, this, [ = ](Qt::CheckState state){
# define QCHECKBOX_CHECKSTATECHANGED QCheckBox::checkStateChanged
# define QT_CHECKSTATE Qt::CheckState
#else
# define QCHECKBOX_CHECKSTATECHANGED QCheckBox::stateChanged
# define QT_CHECKSTATE int
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
connect(ui->m_showNavigatorView, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){
Settings::instance()->setShowNavigatorView(state == Qt::Checked); Settings::instance()->setShowNavigatorView(state == Qt::Checked);
}); });
connect(ui->m_useLightCheckerboard, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){ connect(ui->m_useLightCheckerboard, &QCheckBox::checkStateChanged, this, [ = ](Qt::CheckState state){
Settings::instance()->setUseLightCheckerboard(state == Qt::Checked); Settings::instance()->setUseLightCheckerboard(state == Qt::Checked);
}); });
connect(ui->m_loopGallery, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){ connect(ui->m_loopGallery, &QCheckBox::checkStateChanged, this, [ = ](Qt::CheckState state){
Settings::instance()->setLoopGallery(state == Qt::Checked); Settings::instance()->setLoopGallery(state == Qt::Checked);
}); });
connect(ui->m_svgTiny12Only, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){ connect(ui->m_svgTiny12Only, &QCheckBox::checkStateChanged, this, [ = ](Qt::CheckState state){
Settings::instance()->setSvgTiny12Only(state == Qt::Checked); Settings::instance()->setSvgTiny12Only(state == Qt::Checked);
}); });