Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Qt 5 support #1315

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
container: ubuntu:${{ matrix.container }}
strategy:
matrix:
container: ['20.04', '22.04', '24.04', '24.10']
container: ['22.04', '24.04', '24.10']
env:
DEBIAN_FRONTEND: noninteractive
DEBFULLNAME: github-actions
Expand All @@ -71,10 +71,6 @@ jobs:
path: libdigidocpp-pkg
repo: open-eid/libdigidocpp
- name: Install dependencies
if: matrix.container == '20.04'
run: apt update -qq && apt install --no-install-recommends -y git lsb-release build-essential devscripts debhelper pkg-config lintian ./libdigidocpp-pkg/*.deb cmake libldap2-dev gettext libpcsclite-dev libssl-dev libqt5svg5-dev qttools5-dev-tools qttools5-dev libflatbuffers-dev zlib1g-dev
- name: Install dependencies
if: matrix.container != '20.04'
run: apt update -qq && apt install --no-install-recommends -y git lsb-release build-essential devscripts debhelper pkg-config lintian ${UBUNTU_DEPS}
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -137,10 +133,12 @@ jobs:
runs-on: ${{ matrix.image }}
strategy:
matrix:
vcver: [143]
vcver: [143, 142]
include:
- vcver: 143
image: windows-2022
- vcver: 142
image: windows-2019
env:
VER_SUFFIX: .VS${{ matrix.vcver }}
steps:
Expand All @@ -164,7 +162,7 @@ jobs:
uses: lukka/run-vcpkg@v7
with:
vcpkgArguments: openssl zlib flatbuffers
vcpkgGitCommitId: 18b028fe785e707265fa0e35590b7537ae1d12ea
vcpkgGitCommitId: e4644bd15436d406bba71928d086c809e5c9ca45
vcpkgTriplet: x64-windows
- name: Install Qt
uses: jurplel/install-qt-action@v4
Expand Down
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.22)
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/cmake/modules/VersionInfo.cmake)
message(FATAL_ERROR "cmake submodule directory empty, did you 'git clone --recursive'?")
endif()
Expand All @@ -14,8 +14,7 @@ include( VersionInfo )
find_package(libdigidocpp 4.2.0 REQUIRED HINTS /Library)
message("-- Found libdigidocpp: ${libdigidocpp_DIR} (found version \"${libdigidocpp_VERSION}\")")
find_package( LDAP REQUIRED )
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} 5.12.0 REQUIRED COMPONENTS Core Widgets Network PrintSupport Svg LinguistTools)
find_package(Qt6 6.2.0 REQUIRED COMPONENTS Core Widgets Network PrintSupport SvgWidgets LinguistTools)
find_package(FlatBuffers CONFIG REQUIRED NAMES FlatBuffers Flatbuffers)
find_package(ZLIB REQUIRED)

Expand Down
15 changes: 5 additions & 10 deletions client/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class DigidocConf final: public digidoc::XmlConfCurrent
{
std::vector<digidoc::X509Cert> list = toCerts(QLatin1String("CERT-BUNDLE"));
if(digidoc::X509Cert cert = toCert(fromBase64(Settings::TSA_CERT)))
list.push_back(cert);
list.push_back(std::move(cert));
list.emplace_back(); // Make sure that TSA cert pinning is enabled
return list;
}
Expand All @@ -181,7 +181,7 @@ class DigidocConf final: public digidoc::XmlConfCurrent
{
std::vector<digidoc::X509Cert> list = toCerts(QLatin1String("CERT-BUNDLE"));
if(digidoc::X509Cert cert = verifyServiceCert())
list.push_back(cert);
list.push_back(std::move(cert));
list.emplace_back(); // Make sure that TSA cert pinning is enabled
return list;
}
Expand Down Expand Up @@ -312,7 +312,6 @@ Application::Application( int &argc, char **argv )
if(QFile::exists(QStringLiteral("%1/%2.log").arg(QDir::tempPath(), applicationName())))
qInstallMessageHandler(msgHandler);

Q_INIT_RESOURCE(common_tr);
#if defined(Q_OS_WIN)
AllowSetForegroundWindow( ASFW_ANY );
#ifdef NDEBUG
Expand Down Expand Up @@ -658,9 +657,9 @@ void Application::loadTranslation( const QString &lang )
else if(lang == QLatin1String("ru")) QLocale::setDefault(QLocale( QLocale::Russian, QLocale::RussianFederation));
else QLocale::setDefault(QLocale(QLocale::Estonian, QLocale::Estonia));

void(d->appTranslator.load(QStringLiteral(":/translations/") + lang));
void(d->commonTranslator.load(QStringLiteral(":/translations/common_") + lang));
void(d->qtTranslator.load(QStringLiteral(":/translations/qt_") + lang));
void(d->appTranslator.load(QLatin1String(":/translations/%1.qm").arg(lang)));
void(d->commonTranslator.load(QLatin1String(":/translations/common_%1.qm").arg(lang)));
void(d->qtTranslator.load(QLatin1String(":/translations/qt_%1.qm").arg(lang)));
if( d->closeAction ) d->closeAction->setText( tr("Close Window") );
if( d->newClientAction ) d->newClientAction->setText( tr("New Window") );
if(d->helpAction) d->helpAction->setText(tr("DigiDoc4 Client Help"));
Expand Down Expand Up @@ -822,11 +821,7 @@ void Application::openHelp()
void Application::parseArgs( const QString &msg )
{
QStringList params;
#if QT_VERSION > QT_VERSION_CHECK(5, 14, 0)
for(const QString &param: msg.split(QStringLiteral("\", \""), Qt::SkipEmptyParts))
#else
for(const QString &param: msg.split(QStringLiteral("\", \""), QString::SkipEmptyParts))
#endif
{
QUrl url( param, QUrl::StrictMode );
params.append(param != QLatin1String("-crypto") && !url.toLocalFile().isEmpty() ? url.toLocalFile() : param);
Expand Down
47 changes: 26 additions & 21 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
get_target_property(qtCore_install_prefix Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
get_target_property(qtCore_install_prefix Qt6::qmake IMPORTED_LOCATION)
get_filename_component(qtCore_install_prefix ${qtCore_install_prefix} DIRECTORY)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/TSL.qrc)
set(TSL_QRC ${CMAKE_CURRENT_SOURCE_DIR}/TSL.qrc)
get_filename_component(TSL_FILENAME ${TSL_URL} NAME_WLE)
set(TSL_LIST ${TSL_FILENAME} ${TSL_INCLUDE})
list(TRANSFORM TSL_LIST APPEND .xml)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TSL_FILENAME}.xml)
set(TSL_DIR ${CMAKE_CURRENT_SOURCE_DIR})
list(TRANSFORM TSL_LIST PREPEND ${TSL_DIR}/)
else()
set(TSL_DIR ${CMAKE_CURRENT_BINARY_DIR})
list(TRANSFORM TSL_LIST PREPEND ${TSL_DIR}/)
add_executable(TSLDownload TSLDownload.cpp)
target_link_libraries(TSLDownload Qt${QT_VERSION_MAJOR}::Network)
target_link_libraries(TSLDownload Qt6::Network)
set_target_properties(TSLDownload PROPERTIES AUTOMOC OFF)
add_custom_command(
OUTPUT TSL.qrc
OUTPUT ${TSL_LIST}
DEPENDS TSLDownload
COMMAND $<TARGET_FILE:TSLDownload> "${CMAKE_CURRENT_BINARY_DIR}" ${TSL_URL} ${TSL_INCLUDE}
COMMAND $<TARGET_FILE:TSLDownload> ${CMAKE_CURRENT_BINARY_DIR} ${TSL_URL} ${TSL_INCLUDE}
WORKING_DIRECTORY ${qtCore_install_prefix}
)
set(TSL_QRC ${CMAKE_CURRENT_BINARY_DIR}/TSL.qrc)
endif()

configure_file( translations/tr.qrc tr.qrc COPYONLY )
qt_add_translation(SOURCES translations/en.ts translations/et.ts translations/ru.ts)

file(GLOB WIDGETS CONFIGURE_DEPENDS
"dialogs/*.cpp" "dialogs/*.h" "dialogs/*.ui"
"effects/*.cpp" "effects/*.h" "effects/*.ui"
Expand All @@ -33,8 +35,6 @@ add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE
${WIDGETS}
images/images.qrc
fonts/fonts.qrc
${CMAKE_CURRENT_BINARY_DIR}/tr.qrc
${TSL_QRC}
common_enums.h
main.cpp
Application.cpp
Expand Down Expand Up @@ -69,8 +69,6 @@ add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE
MainWindow.ui
PrintSheet.cpp
PrintSheet.h
QCardLock.cpp
QCardLock.h
QCryptoBackend.cpp
QCryptoBackend.h
QPCSC.cpp
Expand All @@ -93,11 +91,23 @@ add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE
TokenData.h
Utils.h
)
qt_add_translations(${PROJECT_NAME} TS_FILES
translations/en.ts
translations/et.ts
translations/ru.ts
../common/translations/common_en.ts
../common/translations/common_et.ts
../common/translations/common_ru.ts
../common/translations/qtbase_et.ts
../common/translations/qtbase_ru.ts
RESOURCE_PREFIX /translations
)
qt_add_resources(${PROJECT_NAME} tsl BASE ${TSL_DIR} PREFIX /TSL FILES ${TSL_LIST})

target_link_libraries(${PROJECT_NAME}
qdigidoccommon
Qt${QT_VERSION_MAJOR}::PrintSupport
Qt${QT_VERSION_MAJOR}::Svg
Qt6::PrintSupport
Qt6::SvgWidgets
digidocpp::digidocpp
${LDAP_LIBRARIES}
$<TARGET_NAME_IF_EXISTS:flatbuffers::flatbuffers>
Expand All @@ -109,11 +119,6 @@ if(NOT BUILD_DATE)
string(TIMESTAMP BUILD_DATE "%d.%m.%Y")
endif()

if(${QT_VERSION_MAJOR} STREQUAL "6")
find_package(Qt6 COMPONENTS SvgWidgets REQUIRED)
target_link_libraries(${PROJECT_NAME} Qt6::SvgWidgets)
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES
AUTOUIC ON
AUTORCC ON
Expand Down
9 changes: 1 addition & 8 deletions client/Crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
#include <QtNetwork/QSslKey>

#include <openssl/aes.h>
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
#include <openssl/core_names.h>
#endif
#include <openssl/ec.h>
#include <openssl/err.h>
#include <openssl/evp.h>
Expand Down Expand Up @@ -168,19 +166,14 @@ QByteArray Crypto::concatKDF(QCryptographicHash::Algorithm hashAlg, const QByteA
QByteArray Crypto::curve_oid(EVP_PKEY *key)
{
QByteArray buf(50, 0);
#if OPENSSL_VERSION_NUMBER < 0x30000000L
int nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(key)));
#else
std::array<char, 64> group{};
size_t size = group.size();
if(EVP_PKEY_get_utf8_string_param(key, OSSL_PKEY_PARAM_GROUP_NAME, group.data(), group.size(), &size) != 1)
{
buf.clear();
return buf;
}
int nid = OBJ_sn2nid(group.data());
#endif
ASN1_OBJECT *obj = OBJ_nid2obj(nid);
ASN1_OBJECT *obj = OBJ_nid2obj(OBJ_sn2nid(group.data()));
if(int size = OBJ_obj2txt(buf.data(), buf.size(), obj, 1); size != NID_undef)
buf.resize(size);
else
Expand Down
6 changes: 0 additions & 6 deletions client/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
#include <QtCore/QTextStream>
#include <QtNetwork/QSslCertificate>

#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
namespace Qt {
using ::hex;
}
#endif

void Diagnostics::generalInfo(QTextStream &s)
{
s << "<b>" << tr("Arguments:") << "</b> " << Application::arguments().join(' ') << "<br />"
Expand Down
22 changes: 7 additions & 15 deletions client/IKValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,12 @@
#include <QtCore/QDate>
#include <QtCore/QStringList>

inline int toInt(QStringView str) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return QLocale::system().toInt(str); // QLocale, workaround for Qt 5
#else
return str.toInt();
#endif
}

QDate IKValidator::birthDate(QStringView ik)
{
if(ik.size() != 11) return {};

quint16 year = 0;
switch(toInt(ik.left(1)))
switch(ik.left(1).toInt())
{
case 1: case 2: year = 1800; break;
case 3: case 4: year = 1900; break;
Expand All @@ -45,9 +37,9 @@ QDate IKValidator::birthDate(QStringView ik)
}

QDate date(
toInt(ik.mid(1, 2)) + year,
toInt(ik.mid(3, 2)),
toInt(ik.mid(5, 2)));
ik.mid(1, 2).toInt() + year,
ik.mid(3, 2).toInt(),
ik.mid(5, 2).toInt());
return date.isValid() ? date : QDate();
}

Expand Down Expand Up @@ -80,8 +72,8 @@ bool IKValidator::isValid(QStringView ik)
int sum1 = 0, sum2 = 0;
for(int i = 0, pos1 = 1, pos2 = 3; i < 10; ++i)
{
sum1 += toInt(ik.mid(i, 1)) * pos1;
sum2 += toInt(ik.mid(i, 1)) * pos2;
sum1 += ik.mid(i, 1).toInt() * pos1;
sum2 += ik.mid(i, 1).toInt() * pos2;
pos1 = pos1 == 9 ? 1 : pos1 + 1;
pos2 = pos2 == 9 ? 1 : pos2 + 1;
}
Expand All @@ -91,7 +83,7 @@ bool IKValidator::isValid(QStringView ik)
(result = sum2 % 11) >= 10)
result = 0;

return toInt(ik.right(1)) == result;
return ik.right(1).toInt() == result;
}


Expand Down
5 changes: 0 additions & 5 deletions client/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,7 @@ MainWindow::MainWindow( QWidget *parent )
ui->pageButtonGroup->setId(ui->myEid, Pages::MyEid);

connect(ui->pageButtonGroup, QOverload<QAbstractButton *, bool>::of(&QButtonGroup::buttonToggled), this, &MainWindow::clearPopups);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
connect(ui->pageButtonGroup, &QButtonGroup::idToggled, this, &MainWindow::pageSelected);
#else
connect(ui->pageButtonGroup, QOverload<QAbstractButton *, bool>::of(&QButtonGroup::buttonToggled), this,
[=](QAbstractButton *button, bool checked){ pageSelected(ui->pageButtonGroup->id(button), checked); });
#endif
ui->help->installEventFilter(new ButtonHoverFilter(QStringLiteral(":/images/icon_Abi.svg"), QStringLiteral(":/images/icon_Abi_hover.svg"), this));
ui->settings->installEventFilter(new ButtonHoverFilter(QStringLiteral(":/images/icon_Seaded.svg"), QStringLiteral(":/images/icon_Seaded_hover.svg"), this));
connect(ui->help, &QToolButton::clicked, qApp, &Application::openHelp);
Expand Down
73 changes: 0 additions & 73 deletions client/QCardLock.cpp

This file was deleted.

Loading
Loading