Skip to content

Commit

Permalink
Qt 6 support (open-eid#991)
Browse files Browse the repository at this point in the history
IB-7156

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored May 20, 2022
1 parent a706087 commit 0975701
Show file tree
Hide file tree
Showing 53 changed files with 647 additions and 330 deletions.
25 changes: 19 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: |
QT_DIR=$(ls -d /Library/Developer/Qt-*-OpenSSL | tail -n 1)
cmake \
-DQt5_DIR=${QT_DIR}/lib/cmake/Qt5 \
-DCMAKE_PREFIX_PATH=${QT_DIR} \
-DOPENSSL_ROOT_DIR=/Library/Developer/OpenSSL \
-DLDAP_ROOT=/Library/Developer/OpenLDAP \
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -B build -S .
Expand Down Expand Up @@ -133,10 +133,9 @@ jobs:
strategy:
matrix:
vcver: [141, 142, 143]
arch: [x86, x64]
arch: [x64]
qtver: [5.12.12]
include:
- arch: x86
qt: win32_msvc2017
- arch: x64
qt: win64_msvc2017_64
- vcver: 141
Expand All @@ -147,7 +146,20 @@ jobs:
toolset: 14.29
- vcver: 143
image: windows-2022
toolset: 14.31
toolset: 14.32
- vcver: 142
arch: x86
qtver: 5.12.12
qt: win32_msvc2017
image: windows-2019
toolset: 14.29
- vcver: 142
arch: x64
qtver: 6.3.0
qtmodules: qt5compat
qt: win64_msvc2019_64
image: windows-2019
toolset: 14.29
env:
VER_SUFFIX: .VS${{ matrix.vcver }}
steps:
Expand Down Expand Up @@ -176,8 +188,9 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: '5.12.12'
version: ${{ matrix.qtver }}
arch: ${{ matrix.qt }}
modules: ${{ matrix.qtmodules }}
- name: Setup dev env
uses: ilammy/msvc-dev-cmd@v1
with:
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if(POLICY CMP0074)
endif()
project(qdigidoc4 VERSION 4.2.12)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

Expand All @@ -14,7 +14,8 @@ include( VersionInfo )
find_package( PKCS11 )
find_package( LibDigiDocpp 3.14.8 REQUIRED )
find_package( LDAP REQUIRED )
find_package( Qt5 5.9.0 REQUIRED COMPONENTS Core Widgets Network PrintSupport Svg LinguistTools )
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} 5.9.0 REQUIRED COMPONENTS Core Widgets Network PrintSupport Svg LinguistTools)

set_env( TSL_URL "https://ec.europa.eu/tools/lotl/eu-lotl.xml" CACHE STRING "TSL trust list primary URL" )
set_env( TSL_INCLUDE "EE" CACHE STRING "TSL list include in binary" )
Expand Down
35 changes: 18 additions & 17 deletions client/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ class MacMenuBar {};

#include <qtsingleapplication/src/qtlocalpeer.h>

#include <QAction>
#include <QtCore/QFileInfo>
#include <QtCore/QJsonArray>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject>
#include <QtCore/QProcess>
#include <QtCore/QSettings>
#include <QtCore/QStandardPaths>
#include <QtCore/QTimer>
#include <QtCore/QTranslator>
#include <QtCore/QUrl>
Expand All @@ -61,7 +63,6 @@ class MacMenuBar {};
#include <QtNetwork/QNetworkProxy>
#include <QtNetwork/QSslCertificate>
#include <QtNetwork/QSslConfiguration>
#include <QtWidgets/QAction>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QProgressBar>
#include <QtWidgets/QProgressDialog>
Expand Down Expand Up @@ -163,7 +164,7 @@ class DigidocConf: public digidoc::XmlConfCurrent
bool PKCS12Disable() const override
{ return s.value(QStringLiteral("PKCS12Disable"), digidoc::XmlConfCurrent::PKCS12Disable()).toBool(); }
std::string TSLCache() const override
{ return QStandardPaths::writableLocation(QStandardPaths::DataLocation).toStdString(); }
{ return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation).toStdString(); }
bool TSLOnlineDigest() const override
{ return s.value(QStringLiteral("TSLOnlineDigest"), digidoc::XmlConfCurrent::TSLOnlineDigest()).toBool(); }

Expand Down Expand Up @@ -645,13 +646,13 @@ void Application::loadTranslation( const QString &lang )
return;
QSettings().setValue(QStringLiteral("Language"), d->lang = lang);

if(lang == QStringLiteral("en")) QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom));
else if(lang == QStringLiteral("ru")) QLocale::setDefault(QLocale( QLocale::Russian, QLocale::RussianFederation));
if(lang == QLatin1String("en")) QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom));
else if(lang == QLatin1String("ru")) QLocale::setDefault(QLocale( QLocale::Russian, QLocale::RussianFederation));
else QLocale::setDefault(QLocale(QLocale::Estonian, QLocale::Estonia));

d->appTranslator.load(QStringLiteral(":/translations/") + lang);
d->commonTranslator.load(QStringLiteral(":/translations/common_") + lang);
d->qtTranslator.load(QStringLiteral(":/translations/qt_") + lang);
void(d->appTranslator.load(QStringLiteral(":/translations/") + lang));
void(d->commonTranslator.load(QStringLiteral(":/translations/common_") + lang));
void(d->qtTranslator.load(QStringLiteral(":/translations/qt_") + lang));
if( d->closeAction ) d->closeAction->setText( tr("Close Window") );
if( d->newClientAction ) d->newClientAction->setText( tr("New Window") );
if( d->newCryptoAction ) d->newCryptoAction->setText( tr("New Crypto window") );
Expand All @@ -676,7 +677,7 @@ void Application::mailTo( const QUrl &url )
doc.lpszFileName = PWSTR(fileName.utf16());
MapiMessageW message = {};
message.lpszSubject = PWSTR(subject.utf16());
message.lpszNoteText = L"";
message.lpszNoteText = PWSTR(L"");
message.nFileCount = 1;
message.lpFiles = lpMapiFileDescW(&doc);
switch( mapi( NULL, 0, &message, MAPI_LOGON_UI|MAPI_DIALOG, 0 ) )
Expand All @@ -699,7 +700,7 @@ void Application::mailTo( const QUrl &url )
doc.lpszFileName = LPSTR(fileName.constData());
MapiMessage message = {};
message.lpszSubject = LPSTR(subject.constData());
message.lpszNoteText = "";
message.lpszNoteText = LPSTR("");
message.nFileCount = 1;
message.lpFiles = lpMapiFileDesc(&doc);
switch( mapi( NULL, 0, &message, MAPI_LOGON_UI|MAPI_DIALOG, 0 ) )
Expand Down Expand Up @@ -953,8 +954,8 @@ void Application::openHelp()
{
QString lang = language();
QUrl u(QStringLiteral("https://www.id.ee/id-abikeskus/"));
if(lang == QStringLiteral("en")) u = QStringLiteral("https://www.id.ee/en/id-help/");
if(lang == QStringLiteral("ru")) u = QStringLiteral("https://www.id.ee/ru/id-pomoshh/");
if(lang == QLatin1String("en")) u = QStringLiteral("https://www.id.ee/en/id-help/");
if(lang == QLatin1String("ru")) u = QStringLiteral("https://www.id.ee/ru/id-pomoshh/");
QDesktopServices::openUrl(u);
}

Expand All @@ -970,16 +971,16 @@ void Application::parseArgs( const QString &msg )
#endif
{
QUrl url( param, QUrl::StrictMode );
params << (param != QStringLiteral("-crypto") && !url.toLocalFile().isEmpty() ? url.toLocalFile() : param);
params << (param != QLatin1String("-crypto") && !url.toLocalFile().isEmpty() ? url.toLocalFile() : param);
}
parseArgs( params );
}

void Application::parseArgs( const QStringList &args )
{
bool crypto = args.contains(QStringLiteral("-crypto"));
bool sign = args.contains(QStringLiteral("-sign"));
bool newWindow = args.contains(QStringLiteral("-newWindow"));
bool crypto = args.contains(QLatin1String("-crypto"));
bool sign = args.contains(QLatin1String("-sign"));
bool newWindow = args.contains(QLatin1String("-newWindow"));
QStringList params = args;
params.removeAll(QStringLiteral("-sign"));
params.removeAll(QStringLiteral("-crypto"));
Expand All @@ -989,7 +990,7 @@ void Application::parseArgs( const QStringList &args )
params.removeAll(QStringLiteral("-pkcs11"));

QString suffix = params.size() == 1 ? QFileInfo(params.value(0)).suffix() : QString();
showClient(params, crypto || (suffix.compare(QStringLiteral("cdoc"), Qt::CaseInsensitive) == 0), sign, newWindow);
showClient(params, crypto || (suffix.compare(QLatin1String("cdoc"), Qt::CaseInsensitive) == 0), sign, newWindow);
}

uint Application::readTSLVersion(const QString &path)
Expand All @@ -1000,7 +1001,7 @@ uint Application::readTSLVersion(const QString &path)
QXmlStreamReader r(&f);
while(!r.atEnd())
{
if(r.readNextStartElement() && r.name() == "TSLSequenceNumber")
if(r.readNextStartElement() && r.name() == QLatin1String("TSLSequenceNumber"))
{
r.readNext();
return r.text().toUInt();
Expand Down
42 changes: 28 additions & 14 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
set_app_name( PROGNAME qdigidoc4 )

add_executable( TSLDownload TSLDownload.cpp )
target_link_libraries( TSLDownload Qt5::Network )
target_link_libraries(TSLDownload Qt${QT_VERSION_MAJOR}::Network)
get_target_property(qtCore_install_prefix Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
get_filename_component(qtCore_install_prefix ${qtCore_install_prefix} DIRECTORY)
add_custom_command(
OUTPUT TSL.qrc
DEPENDS TSLDownload
COMMAND $<TARGET_FILE:TSLDownload> "${CMAKE_CURRENT_BINARY_DIR}" ${TSL_URL} ${TSL_INCLUDE}
WORKING_DIRECTORY ${_qt5Core_install_prefix}/bin
WORKING_DIRECTORY ${qtCore_install_prefix}
)

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

add_executable( ${PROGNAME} WIN32 MACOSX_BUNDLE
${PROGNAME}.rc
Expand All @@ -28,6 +30,7 @@ add_executable( ${PROGNAME} WIN32 MACOSX_BUNDLE
Diagnostics.cpp
DiagnosticsTask.cpp
DocumentModel.cpp
IKValidator.cpp
MainWindow.ui
MainWindow.cpp
MainWindow_MyEID.cpp
Expand Down Expand Up @@ -102,6 +105,7 @@ add_executable( ${PROGNAME} WIN32 MACOSX_BUNDLE
widgets/InfoStack.ui
widgets/InfoStack.cpp
widgets/LabelButton.cpp
widgets/LineEdit.cpp
widgets/MainAction.ui
widgets/MainAction.cpp
widgets/NoCardInfo.ui
Expand All @@ -123,11 +127,21 @@ add_executable( ${PROGNAME} WIN32 MACOSX_BUNDLE

target_link_libraries( ${PROGNAME}
qdigidoccommon
Qt5::PrintSupport
Qt5::Svg
Qt${QT_VERSION_MAJOR}::PrintSupport
Qt${QT_VERSION_MAJOR}::Svg
${LIBDIGIDOCPP_LIBRARY}
${LDAP_LIBRARIES}
)

if(${QT_VERSION_MAJOR} STREQUAL "6")
find_package(Qt6 COMPONENTS Core5Compat SvgWidgets REQUIRED)
target_link_libraries(${PROGNAME} Qt6::Core5Compat Qt6::SvgWidgets)
elseif(WIN32)
find_package(Qt5 COMPONENTS WinExtras)
target_compile_definitions(${PROGNAME} PRIVATE QT_WIN_EXTRAS)
target_link_libraries(${PROGNAME} Qt5::WinExtras)
endif()

set_target_properties(${PROGNAME} PROPERTIES
AUTOUIC ON
AUTORCC ON
Expand Down Expand Up @@ -156,7 +170,7 @@ if( APPLE )
COMMAND cp -a $<TARGET_BUNDLE_DIR:DigiDocQL> $<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/Library/QuickLook
)
add_custom_target( macdeployqt DEPENDS ${PROGNAME}
COMMAND ${_qt5Core_install_prefix}/bin/macdeployqt $<TARGET_BUNDLE_DIR:${PROGNAME}>
COMMAND ${qtCore_install_prefix}/macdeployqt $<TARGET_BUNDLE_DIR:${PROGNAME}>
COMMAND rm -rf $<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/PlugIns/bearer
COMMAND cp -a /Library/Frameworks/digidocpp.framework $<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/Frameworks
COMMAND rm $<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/Frameworks/digidocpp.framework/Resources/digidoc-tool
Expand Down Expand Up @@ -197,8 +211,7 @@ elseif(WIN32)
target_sources( ${PROGNAME} PRIVATE QCSP.cpp QCNG.cpp QWin.cpp CertStore.cpp Diagnostics_win.cpp)
target_compile_options(${PROGNAME} PRIVATE "/guard:cf")
target_link_options(${PROGNAME} PRIVATE "/guard:cf" $<$<BOOL:${CROSSSIGNCERT}>:/INTEGRITYCHECK>)
find_package( Qt5 COMPONENTS WinExtras )
target_link_libraries( ${PROGNAME} Qt5::WinExtras NCrypt Crypt32 Cryptui )
target_link_libraries(${PROGNAME} NCrypt Crypt32 Cryptui)
get_filename_component(LIBS_PATH ${LIBDIGIDOCPP_LIBRARIES} DIRECTORY)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PLATFORM x64)
Expand All @@ -210,19 +223,20 @@ elseif(WIN32)
set(MSI_FILE "Digidoc4_Client-${VERSION}$ENV{VER_SUFFIX}.${PLATFORM}")
list(APPEND CANDLE_CMD "$ENV{WIX}bin\\candle.exe" -nologo -arch ${PLATFORM} -dMSI_VERSION=${VERSION} -dPlatform=${PLATFORM}
-dlibs_path="${LIBS_PATH}" -dclient_path=$<TARGET_FILE:${PROGNAME}> -dico_path=${CMAKE_CURRENT_SOURCE_DIR}/images/digidoc.ico
-dqtconf=${CMAKE_SOURCE_DIR}/qt.conf -dschemasLocation=${LIBS_PATH}/schema SchemasFragment.wxs ${CMAKE_SOURCE_DIR}/qdigidoc4.wxs
${CMAKE_MODULE_PATH}/WelcomeDlg2.wxs ${CMAKE_MODULE_PATH}/WixUI_Minimal2.wxs)
-dqtconf=${CMAKE_SOURCE_DIR}/qt.conf -dschemasLocation=${LIBS_PATH}/schema SchemasFragment.wxs
-dqt_ver_major=${QT_VERSION_MAJOR} -dqt_suffix=$<$<CONFIG:Debug>:d> ${CMAKE_SOURCE_DIR}/qdigidoc4.wxs
${CMAKE_SOURCE_DIR}/cmake/modules/WelcomeDlg2.wxs ${CMAKE_SOURCE_DIR}/cmake/modules/WixUI_Minimal2.wxs)
list(APPEND LIGHT_CMD "$ENV{WIX}bin\\light.exe" -nologo -ext WixUIExtension
qdigidoc4.wixobj SchemasFragment.wixobj WelcomeDlg2.wixobj WixUI_Minimal2.wixobj
-dWixUIDialogBmp=${CMAKE_MODULE_PATH}/dlgbmp.bmp
-dWixUIBannerBmp=${CMAKE_MODULE_PATH}/banner.bmp)
-dWixUIDialogBmp=${CMAKE_SOURCE_DIR}/cmake/modules/dlgbmp.bmp
-dWixUIBannerBmp=${CMAKE_SOURCE_DIR}/cmake/modules/banner.bmp)
add_custom_target(msi DEPENDS ${PROGNAME}
COMMAND "$ENV{WIX}bin\\heat.exe" dir ${LIBS_PATH}/schema -nologo -cg Schemas -gg -scom -sreg -sfrag -srd -dr SchemaFolder -var var.schemasLocation -out SchemasFragment.wxs
COMMAND ${CANDLE_CMD}
COMMAND ${LIGHT_CMD} -loc ${CMAKE_SOURCE_DIR}/qdigidoc4.en-US.wxl -cultures:en-US -o "${MSI_FILE}.en-US.msi"
COMMAND ${LIGHT_CMD} -loc ${CMAKE_SOURCE_DIR}/qdigidoc4.et-EE.wxl -cultures:et-EE -o "${MSI_FILE}.et-EE.msi"
#Build MSI with QT
COMMAND ${CANDLE_CMD} -dqt_path=${_qt5Core_install_prefix}
COMMAND ${CANDLE_CMD} -dqt_path=${qtCore_install_prefix}
COMMAND ${LIGHT_CMD} -loc ${CMAKE_SOURCE_DIR}/qdigidoc4.en-US.wxl -cultures:en-US -o "${MSI_FILE}.en-US.qt.msi"
COMMAND ${LIGHT_CMD} -loc ${CMAKE_SOURCE_DIR}/qdigidoc4.et-EE.wxl -cultures:et-EE -o "${MSI_FILE}.et-EE.qt.msi"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
Expand Down Expand Up @@ -259,7 +273,7 @@ elseif(WIN32)
COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/digidocpp.conf appx
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Assets appx/Assets
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBS_PATH}/schema appx/schema
COMMAND ${_qt5Core_install_prefix}/bin/windeployqt --no-translations --no-compiler-runtime --no-patchqt appx
COMMAND ${qtCore_install_prefix}/windeployqt --no-translations --no-compiler-runtime --no-patchqt appx
COMMAND ${CMAKE_COMMAND} -E remove_directory appx/bearer
COMMAND makeappx.exe pack -d appx -p ${MSI_FILE}.appx
# https://msdn.microsoft.com/en-us/library/windows/desktop/jj835832(v=vs.85).aspx
Expand Down
Loading

0 comments on commit 0975701

Please sign in to comment.