Skip to content

Commit

Permalink
Remove Qt 5 support
Browse files Browse the repository at this point in the history
IB-8335

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Jan 8, 2025
1 parent c04bf62 commit cb4ea73
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 68 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install libraries
run: brew install qt@6
- name: Build
Expand All @@ -27,20 +25,14 @@ jobs:
container: ubuntu:${{ matrix.container }}
strategy:
matrix:
container: ['20.04', '22.04', '24.04']
container: ['22.04', '24.04', '24.10']
env:
DEBIAN_FRONTEND: noninteractive
steps:
- name: Install dependencies
if: matrix.container == '20.04'
run: apt update -qq && apt install --no-install-recommends -y git ca-certificates build-essential pkg-config cmake libpcsclite-dev libssl-dev qttools5-dev-tools qttools5-dev
- name: Install dependencies
if: matrix.container != '20.04'
run: apt update -qq && apt install --no-install-recommends -y git ca-certificates build-essential pkg-config cmake libpcsclite-dev libssl-dev libgl-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build packages
run: |
cmake -B build -S .
Expand All @@ -51,19 +43,17 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Prepare vcpkg
uses: lukka/run-vcpkg@v7
with:
vcpkgArguments: openssl
vcpkgGitCommitId: 18b028fe785e707265fa0e35590b7537ae1d12ea
vcpkgGitCommitId: e4644bd15436d406bba71928d086c809e5c9ca45
vcpkgTriplet: x64-windows
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: 6.7.1
arch: win64_msvc2019_64
version: 6.8.1
arch: win64_msvc2022_64
- name: Build
run: |
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo `
Expand Down
24 changes: 4 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,22 @@
cmake_minimum_required(VERSION 3.10)
project(qdigidoccommon VERSION 1.0.0)
if(NOT VERSION)
if(NOT DEFINED set_env)
macro(set_env)
set(${ARGN})
endmacro()
add_compile_definitions(
MAJOR_VER=${PROJECT_VERSION_MAJOR}
MINOR_VER=${PROJECT_VERSION_MINOR}
RELEASE_VER=${PROJECT_VERSION_PATCH}
BUILD_VER=$<IF:$<BOOL:$ENV{BUILD_NUMBER}>,$ENV{BUILD_NUMBER},0>
)
endif()
set_env( CONFIG_URL "https://id.eesti.ee/config.json" CACHE STRING "Set Config URL" )
find_package(OpenSSL 1.1.1 REQUIRED)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} 5.12.0 REQUIRED COMPONENTS Widgets Network LinguistTools)

if(${QT_VERSION} VERSION_LESS "5.15.0")
macro(qt_add_translation)
qt5_add_translation(${ARGN})
endmacro()
macro(qt_add_resources)
qt5_add_resources(${ARGN})
endmacro()
endif()
find_package(Qt6 6.2.0 REQUIRED COMPONENTS Widgets Network LinguistTools)

configure_file( translations/common_tr.qrc common_tr.qrc COPYONLY )
qt_add_translation(SOURCES translations/qtbase_et.ts translations/qtbase_ru.ts
translations/common_en.ts translations/common_et.ts translations/common_ru.ts)
qt_add_resources(SOURCES ${CMAKE_CURRENT_BINARY_DIR}/common_tr.qrc)
add_library(qdigidoccommon STATIC ${SOURCES} Common.cpp)
target_include_directories(qdigidoccommon PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(qdigidoccommon PUBLIC QT_DEPRECATED_WARNINGS_SINCE=051200)
target_link_libraries(qdigidoccommon PUBLIC Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Widgets OpenSSL::SSL)
target_compile_definitions(qdigidoccommon PUBLIC QT_DEPRECATED_WARNINGS_SINCE=060200)
target_link_libraries(qdigidoccommon PUBLIC Qt6::Network Qt6::Widgets OpenSSL::SSL)

if(WIN32)
target_compile_definitions(qdigidoccommon PUBLIC UNICODE WIN32_LEAN_AND_MEAN)
Expand Down
36 changes: 4 additions & 32 deletions Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ void Configuration::Private::setData(const QByteArray &_data, const QByteArray &
data = _data;
signature = _signature;
dataobject = toObject(data);
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
QSettings system(QSettings::SystemScope);
#else
QSettings system(QSettings::SystemScope, QCoreApplication::organizationName(), QCoreApplication::applicationName());
#endif
for(const QString &key: system.childKeys())
{
if(!dataobject.contains(key))
Expand Down Expand Up @@ -176,9 +172,7 @@ Configuration::Configuration(QObject *parent)
d->req.setRawHeader("User-Agent", QStringLiteral("%1/%2 (%3) Lang: %4 Devices: %5")
.arg(QCoreApplication::applicationName(), QCoreApplication::applicationVersion(),
Common::applicationOs(), QLocale().uiLanguages().first(), Common::drivers().join('/')).toUtf8());
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
d->req.setTransferTimeout();
#endif
d->net = new QNetworkAccessManager(this);
connect(d->net, &QNetworkAccessManager::sslErrors, this,
[](QNetworkReply *reply, const QList<QSslError> &errors){
Expand All @@ -203,7 +197,8 @@ Configuration::Configuration(QObject *parent)
return;
}
qDebug() << "Remote signature does not match, downloading new configuration";
sendRequest(d->url)->setProperty("signature", signature);
d->req.setUrl(d->url);
d->net->get(d->req)->setProperty("signature", signature);
}
else if(reply->url() == d->url)
{
Expand Down Expand Up @@ -311,33 +306,10 @@ QJsonObject Configuration::object() const
return d->dataobject;
}

QNetworkReply* Configuration::sendRequest(const QUrl &url)
{
d->req.setUrl(url);
QNetworkReply *reply = d->net->get(d->req);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
if(!reply->isRunning())
return reply;
QTimer *timer = new QTimer(this);
timer->setSingleShot(true);
connect(reply, &QNetworkReply::finished, timer, [=]{
timer->stop();
timer->deleteLater();
});
connect(timer, &QTimer::timeout, this, [=]{
timer->deleteLater();
reply->abort();
qDebug() << "Request timed out";
Q_EMIT finished(false, tr("Request timed out"));
});
timer->start(30*1000);
#endif
return reply;
}

void Configuration::update(bool force)
{
d->initCache(force);
sendRequest(d->rsaurl);
d->req.setUrl(d->rsaurl);
d->net->get(d->req);
QSettings().setValue(QStringLiteral("LastVersion"), QCoreApplication::applicationVersion());
}
2 changes: 0 additions & 2 deletions Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class Configuration final : public QObject
void finished(bool changed, const QString &error);

private:
QNetworkReply *sendRequest(const QUrl &url);

Q_DISABLE_COPY(Configuration)

class Private;
Expand Down

0 comments on commit cb4ea73

Please sign in to comment.