Skip to content

Commit

Permalink
Set minimum supported Qt 5.12 (open-eid#1147)
Browse files Browse the repository at this point in the history
IB-7398

Signed-off-by: Raul Metsma <[email protected]>

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored Jan 12, 2023
1 parent 1be23ae commit eb0d0ba
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 57 deletions.
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
cmake_minimum_required(VERSION 3.10)
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
cmake_minimum_required(VERSION 3.16)
project(qdigidoc4 VERSION 4.3.0)

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
Expand All @@ -15,7 +12,7 @@ find_package( PKCS11 )
find_package(LibDigiDocpp 3.14.11 REQUIRED)
find_package( LDAP REQUIRED )
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)
find_package(Qt${QT_VERSION_MAJOR} 5.12.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
29 changes: 7 additions & 22 deletions client/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class DigidocConf final: public digidoc::XmlConfCurrent
s.remove(QStringLiteral("TSA-URL")); // Cleanup user conf if it is default url
QList<QSslCertificate> list;
for(const QJsonValue &cert: obj.value(QStringLiteral("CERT-BUNDLE")).toArray())
list << QSslCertificate(QByteArray::fromBase64(cert.toString().toLatin1()), QSsl::Der);
list.append(QSslCertificate(QByteArray::fromBase64(cert.toString().toLatin1()), QSsl::Der));
QSslConfiguration ssl = QSslConfiguration::defaultConfiguration();
ssl.setCaCertificates(list);
QSslConfiguration::setDefaultConfiguration(ssl);
Expand Down Expand Up @@ -326,11 +326,13 @@ Application::Application( int &argc, char **argv )
#endif
, d(new Private)
{
#ifdef CONFIG_URL
d->conf = new Configuration(this);
connect(d->conf, &Configuration::updateReminder,
[&](bool /* expired */, const QString & /* title */, const QString &message){
WarningDialog(message, qApp->activeWindow()).exec();
});
#endif

qRegisterMetaType<TokenData>("TokenData");
qRegisterMetaType<QSmartCardData>("QSmartCardData");
Expand Down Expand Up @@ -404,10 +406,8 @@ Application::Application( int &argc, char **argv )
tl.remove();
QFile::copy(":/TSL/" + file, tl.fileName());
tl.setPermissions(QFile::Permissions(0x6444));
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
if(tl.open(QFile::Append))
tl.setFileTime(tslTime, QFileDevice::FileModificationTime);
#endif
}
}

Expand Down Expand Up @@ -530,7 +530,7 @@ void Application::activate( QWidget *w )
#ifdef Q_OS_WIN
void Application::addTempFile(const QString &file)
{
d->tempFiles << file;
d->tempFiles.append(file);
}
#endif

Expand Down Expand Up @@ -623,7 +623,7 @@ QVariant Application::confValue( ConfParameter parameter, const QVariant &value
{
std::vector<unsigned char> v = cert;
if(!v.empty())
list << QSslCertificate(QByteArray::fromRawData((const char*)v.data(), int(v.size())), QSsl::Der);
list.append(QSslCertificate(QByteArray::fromRawData((const char*)v.data(), int(v.size())), QSsl::Der));
}
return QVariant::fromValue(list);
}
Expand Down Expand Up @@ -983,16 +983,14 @@ 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 << (param != QLatin1String("-crypto") && !url.toLocalFile().isEmpty() ? url.toLocalFile() : param);
params.append(param != QLatin1String("-crypto") && !url.toLocalFile().isEmpty() ? url.toLocalFile() : param);
}
parseArgs( params );
}
Expand Down Expand Up @@ -1118,20 +1116,7 @@ void Application::showClient(const QStringList &params, bool crypto, bool sign,
#ifdef Q_OS_LINUX
else
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
QScreen *screen = [w]() -> QScreen* {
for (const QScreen *screen : QGuiApplication::screens()) {
for (QScreen *sibling : screen->virtualSiblings()) {
if (sibling->geometry().contains(w->pos()))
return sibling;
}
}
return nullptr;
}();
#else
QScreen *screen = QGuiApplication::screenAt(w->pos());
#endif
if(screen)
if(QScreen *screen = QGuiApplication::screenAt(w->pos()))
w->move(screen->availableGeometry().center() - w->frameGeometry().adjusted(0, 0, 10, 40).center());
}
#endif
Expand Down
20 changes: 7 additions & 13 deletions client/Application_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
#include <QtCore/QUrlQuery>
#include <QtGui/QDesktopServices>

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

@implementation NSApplication (ApplicationObjC)

- (void)appReopen:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
Expand All @@ -46,7 +40,7 @@ - (void)openClient:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
Q_UNUSED(error)
QStringList result;
for( NSString *filename in [pboard propertyListForType:NSFilenamesPboardType] )
result << QString::fromNSString(filename).normalized(QString::NormalizationForm_C);
result.append(QString::fromNSString(filename).normalized(QString::NormalizationForm_C));
QMetaObject::invokeMethod( qApp, "showClient", Q_ARG(QStringList,result) );
}

Expand All @@ -56,7 +50,7 @@ - (void)signClient:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
Q_UNUSED(error)
QStringList result;
for(NSString *filename in [pboard propertyListForType:NSFilenamesPboardType])
result << QString::fromNSString(filename).normalized(QString::NormalizationForm_C);
result.append(QString::fromNSString(filename).normalized(QString::NormalizationForm_C));
QMetaObject::invokeMethod(qApp, "showClient", Q_ARG(QStringList,result), Q_ARG(bool,false), Q_ARG(bool,true));
}

Expand All @@ -66,7 +60,7 @@ - (void)openCrypto:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
Q_UNUSED(error)
QStringList result;
for( NSString *filename in [pboard propertyListForType:NSFilenamesPboardType] )
result << QString::fromNSString(filename).normalized(QString::NormalizationForm_C);
result.append(QString::fromNSString(filename).normalized(QString::NormalizationForm_C));
QMetaObject::invokeMethod( qApp, "showClient", Q_ARG(QStringList,result), Q_ARG(bool,true) );
}
@end
Expand Down Expand Up @@ -121,8 +115,8 @@ - (void)openCrypto:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
else if([appUrl.path rangeOfString:@"Entourage"].location != NSNotFound)
{
s << "on run" << Qt::endl
<< "set vattachment to \"" << q.queryItemValue("attachment") << "\"" << Qt::endl
<< "set vsubject to \"" << q.queryItemValue("subject") << "\"" << Qt::endl
<< "set vattachment to \"" << q.queryItemValue(QStringLiteral("attachment")) << "\"" << Qt::endl
<< "set vsubject to \"" << q.queryItemValue(QStringLiteral("subject")) << "\"" << Qt::endl
<< "tell application \"Microsoft Entourage\"" << Qt::endl
<< "set vmessage to make new outgoing message with properties" << Qt::endl
<< "{subject:vsubject, attachments:vattachment}" << Qt::endl
Expand All @@ -134,8 +128,8 @@ - (void)openCrypto:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
else if([appUrl.path rangeOfString:@"Outlook"].location != NSNotFound)
{
s << "on run" << Qt::endl
<< "set vattachment to \"" << q.queryItemValue("attachment") << "\" as POSIX file" << Qt::endl
<< "set vsubject to \"" << q.queryItemValue("subject") << "\"" << Qt::endl
<< "set vattachment to \"" << q.queryItemValue(QStringLiteral("attachment")) << "\" as POSIX file" << Qt::endl
<< "set vsubject to \"" << q.queryItemValue(QStringLiteral("subject")) << "\"" << Qt::endl
<< "tell application \"Microsoft Outlook\"" << Qt::endl
<< "activate" << Qt::endl
<< "set vmessage to make new outgoing message with properties {subject:vsubject}" << Qt::endl
Expand Down
16 changes: 0 additions & 16 deletions client/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,11 @@
#include <QtCore/QTimer>
#include <QtCore/QRegularExpression>

#ifdef Q_OS_WIN32
#include <QtCore/QDebug>
#include <QtCore/qt_windows.h>
#endif

int main( int argc, char *argv[] )
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
#ifdef Q_OS_WIN32
SetProcessDPIAware();
HDC screen = GetDC(nullptr);
qreal dpix = GetDeviceCaps(screen, LOGPIXELSX);
qreal dpiy = GetDeviceCaps(screen, LOGPIXELSY);
qreal scale = dpiy / qreal(96);
qputenv("QT_SCALE_FACTOR", QByteArray::number(scale));
ReleaseDC(nullptr, screen);
qDebug() << "Current DPI x: " << dpix << " y: " << dpiy << " setting scale:" << scale;
#else
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
#endif
#endif

for(int i = 1; i < argc; ++i)
Expand Down
2 changes: 2 additions & 0 deletions client/widgets/ComboBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*
*/

#pragma once

#include <QtWidgets/QComboBox>

class ComboBox: public QComboBox
Expand Down
2 changes: 1 addition & 1 deletion common

0 comments on commit eb0d0ba

Please sign in to comment.