chore: drop Qt 5 support

The required exiv2 version is now 0.28.x as well since it was
keeped for Qt 5 build.

Due to exiv2ConfigVersion.cmake doesn't allow us write something
like find_package(exiv2 "0.28") to require version >= 0.28.0,
we simply don't put the required version number here for now.
This commit is contained in:
Gary Wang 2025-05-23 00:06:43 +08:00
parent 369aa13be3
commit 24a0b581f3
No known key found for this signature in database
GPG Key ID: 5D30A4F15EA78760
10 changed files with 17 additions and 102 deletions

View File

@ -3,30 +3,6 @@ name: Ubuntu CI
on: [push, pull_request]
jobs:
ubuntu-22-04-build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Get build dept.
run: |
sudo apt update
sudo apt install cmake qtbase5-dev libqt5svg5-dev qttools5-dev libexiv2-dev
- name: Build it
run: |
mkdir build
cd build
cmake ../ -DPREFER_QT_5=ON
make
cpack -G DEB
- name: Try install it
run: |
cd build
sudo apt install ./*.deb
- uses: actions/upload-artifact@v4
with:
name: ubuntu-22.04-deb-package
path: build/*.deb
ubuntu-24-04-build:
runs-on: ubuntu-24.04
steps:

View File

@ -10,7 +10,6 @@ include(GNUInstallDirs)
include(FeatureSummary)
option (EXIV2_METADATA_SUPPORT "Better image metadata support via libexiv2" ON)
option (PREFER_QT_5 "Prefer to use Qt 5" OFF)
option (TRANSLATION_RESOURCE_EMBEDDING "Embedding .qm translation files inside resource" OFF)
set (CMAKE_CXX_STANDARD 17)
@ -18,27 +17,15 @@ set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_AUTOMOC ON)
set (CMAKE_AUTORCC ON)
if (PREFER_QT_5)
find_package(QT NAMES Qt5 REQUIRED COMPONENTS Core)
else ()
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core)
endif ()
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core)
if (${QT_VERSION_MAJOR} EQUAL "5")
set (QT_MINIMUM_VERSION "5.15.2")
else ()
set (QT_MINIMUM_VERSION "6.4")
endif ()
set (QT_MINIMUM_VERSION "6.4")
find_package(Qt${QT_VERSION_MAJOR} ${QT_MINIMUM_VERSION} REQUIRED
COMPONENTS Widgets Svg LinguistTools
COMPONENTS Widgets Svg SvgWidgets LinguistTools
OPTIONAL_COMPONENTS DBus
)
if (${QT_VERSION_MAJOR} EQUAL "6")
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} ${QT_MINIMUM_VERSION} CONFIG REQUIRED SvgWidgets)
endif ()
if (EXIV2_METADATA_SUPPORT)
find_package(exiv2)
set_package_properties(exiv2 PROPERTIES
@ -117,34 +104,23 @@ add_executable (${EXE_NAME}
${PPIC_RC_FILES}
)
if (${QT_VERSION_MAJOR} EQUAL "6")
set(ADD_TRANSLATIONS_ADDITIONAL_ARGS)
set(ADD_TRANSLATIONS_ADDITIONAL_ARGS)
if (Qt6_VERSION VERSION_GREATER_EQUAL "6.9.0")
if (Qt6_VERSION VERSION_GREATER_EQUAL "6.9.0")
set(ADD_TRANSLATIONS_ADDITIONAL_ARGS MERGE_QT_TRANSLATIONS)
endif()
endif()
if (TRANSLATION_RESOURCE_EMBEDDING)
if (TRANSLATION_RESOURCE_EMBEDDING)
qt_add_translations(${EXE_NAME} ${ADD_TRANSLATIONS_ADDITIONAL_ARGS} TS_FILES ${PPIC_TS_FILES})
else()
qt_add_translations(${EXE_NAME} ${ADD_TRANSLATIONS_ADDITIONAL_ARGS} TS_FILES ${PPIC_TS_FILES} QM_FILES_OUTPUT_VARIABLE PPIC_QM_FILES)
endif()
else()
qt_create_translation(PPIC_QM_FILES ${PPIC_CPP_FILES_FOR_I18N} ${PPIC_TS_FILES})
qt_add_translations(${EXE_NAME} ${ADD_TRANSLATIONS_ADDITIONAL_ARGS} TS_FILES ${PPIC_TS_FILES} QM_FILES_OUTPUT_VARIABLE PPIC_QM_FILES)
endif()
target_sources(${EXE_NAME} PRIVATE ${PPIC_QM_FILES})
target_link_libraries (${EXE_NAME} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Svg)
if (${QT_VERSION_MAJOR} EQUAL "6")
target_link_libraries (${EXE_NAME} Qt::SvgWidgets)
endif ()
target_link_libraries (${EXE_NAME} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::SvgWidgets)
if (exiv2_FOUND)
if(NOT TARGET Exiv2::exiv2lib AND TARGET exiv2lib)
# for exiv2 0.27.x
add_library(Exiv2::exiv2lib ALIAS exiv2lib)
endif()
target_link_libraries (${EXE_NAME}
Exiv2::exiv2lib
)
@ -153,7 +129,7 @@ if (exiv2_FOUND)
)
endif ()
if (TARGET Qt5::DBus OR TARGET Qt6::DBus)
if (TARGET Qt6::DBus)
target_link_libraries (${EXE_NAME}
Qt${QT_VERSION_MAJOR}::DBus
)

View File

@ -17,14 +17,7 @@ FramelessWindow::FramelessWindow(QWidget *parent)
, m_oldCursorShape(Qt::ArrowCursor)
, m_oldEdges()
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint);
#else
// There is a bug in Qt 5 that will make pressing Meta+Up cause the app
// fullscreen under Windows, see QTBUG-91226 to learn more.
// The bug seems no longer exists in Qt 6 (I only tested it under Qt 6.3.0).
this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
this->setMouseTracking(true);
this->setAttribute(Qt::WA_Hover, true);
this->installEventFilter(this);
@ -97,11 +90,7 @@ bool FramelessWindow::mousePress(QMouseEvent* event)
{
if (event->buttons() & Qt::LeftButton && !isMaximized() && !isFullScreen()) {
QWindow* win = window()->windowHandle();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Qt::Edges edges = this->getEdgesByPos(event->globalPosition().toPoint(), win->frameGeometry());
#else
Qt::Edges edges = this->getEdgesByPos(event->globalPos(), win->frameGeometry());
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (edges) {
win->startSystemResize(edges);
return true;

View File

@ -41,9 +41,7 @@ void GraphicsView::showFileFromPath(const QString &filePath)
QImageReader imageReader(filePath);
imageReader.setAutoTransform(true);
imageReader.setDecideFormatFromContent(true);
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
imageReader.setAllocationLimit(0);
#endif //QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
// Since if the image format / plugin does not support this feature, imageFormat() will returns an invalid format.
// So we cannot use imageFormat() and check if it returns QImage::Format_Invalid to detect if we support the file.

View File

@ -24,9 +24,6 @@ int main(int argc, char *argv[])
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Settings::instance()->hiDpiScaleFactorBehavior());
QApplication a(argc, argv);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
a.setAttribute(Qt::ApplicationAttribute::AA_UseHighDpiPixmaps);
#endif
QTranslator translator;
#if defined(TRANSLATION_RESOURCE_EMBEDDING)

View File

@ -304,7 +304,7 @@ void MainWindow::showEvent(QShowEvent *event)
return FramelessWindow::showEvent(event);
}
void MainWindow::enterEvent(QT_ENTER_EVENT *event)
void MainWindow::enterEvent(QEnterEvent *event)
{
m_bottomButtonGroup->setOpacity(1);
m_gv->setOpacity(1);
@ -345,11 +345,7 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event)
{
if (event->buttons() & Qt::LeftButton && m_clickedOnWindow && !isMaximized() && !isFullScreen()) {
if (!window()->windowHandle()->startSystemMove()) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
move(event->globalPosition().toPoint() - m_oldMousePos);
#else
move(event->globalPos() - m_oldMousePos);
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
}
event->accept();
}

View File

@ -11,12 +11,6 @@
#include <QPropertyAnimation>
#include <QPushButton>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
typedef QEnterEvent QT_ENTER_EVENT;
#else
typedef QEvent QT_ENTER_EVENT;
#endif // QT_VERSION_CHECK(6, 0, 0)
QT_BEGIN_NAMESPACE
class QGraphicsOpacityEffect;
class QGraphicsView;
@ -51,7 +45,7 @@ public:
protected slots:
void showEvent(QShowEvent *event) override;
void enterEvent(QT_ENTER_EVENT *event) override;
void enterEvent(QEnterEvent *event) override;
void leaveEvent(QEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;

View File

@ -63,9 +63,7 @@ void ShortcutEditor::reloadShortcuts()
shortcuts.append(QKeySequence());
for (const QKeySequence & shortcut : shortcuts) {
QKeySequenceEdit * keyseqEdit = new QKeySequenceEdit(this);
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
keyseqEdit->setClearButtonEnabled(true);
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
keyseqEdit->setMaximumSequenceLength(1);
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)

View File

@ -12,18 +12,10 @@ environment:
QTDIR: C:\Qt\6.8\mingw_64
MINGW64: C:\Qt\Tools\mingw1310_64
KF_BRANCH: master
EXIV2_VERSION: "0.28.3"
EXIV2_VERSION: "0.28.5"
EXIV2_CMAKE_OPTIONS: "-DEXIV2_ENABLE_BROTLI=OFF -DEXIV2_ENABLE_INIH=OFF -DEXIV2_BUILD_EXIV2_COMMAND=OFF"
PPIC_CMAKE_OPTIONS: "-DPREFER_QT_5=OFF"
WINDEPLOYQT_ARGS: "--verbose=2 --no-quick-import --no-translations --no-opengl-sw --no-system-d3d-compiler --skip-plugin-types tls,networkinformation"
- job_name: mingw81_64_qt5_15_2
QTDIR: C:\Qt\5.15.2\mingw81_64
MINGW64: C:\Qt\Tools\mingw810_64
KF_BRANCH: kf5
EXIV2_VERSION: "0.27.7"
EXIV2_CMAKE_OPTIONS: "-DEXIV2_BUILD_SAMPLES=OFF -DEXIV2_ENABLE_WIN_UNICODE=ON -DEXIV2_BUILD_EXIV2_COMMAND=OFF"
PPIC_CMAKE_OPTIONS: "-DPREFER_QT_5=ON"
WINDEPLOYQT_ARGS: "--verbose=2 --no-quick-import --no-translations --no-opengl-sw --no-angle --no-system-d3d-compiler"
install:
- mkdir %CMAKE_INSTALL_PREFIX%

View File

@ -1,9 +1,8 @@
# SPDX-FileCopyrightText: 2024 Gary Wang <git@blumia.net>
# SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
#
# SPDX-License-Identifier: MIT
QT += core widgets gui svg
greaterThan(QT_MAJOR_VERSION, 5): QT += svgwidgets
QT += core widgets gui svg svgwidgets
TARGET = ppic
TEMPLATE = app