Skip to content

Commit f3b245c

Browse files
committed
Rewrite QuickLook plugin based on QLPreviewProvider (#1087)
IB-7359 Signed-off-by: Raul Metsma <[email protected]>
1 parent cec030a commit f3b245c

16 files changed

+312
-562
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
container: ubuntu:${{ matrix.container }}
5757
strategy:
5858
matrix:
59-
container: ['22.04', '24.04', '24.10', '25.04']
59+
container: ['22.04', '24.04', '25.04']
6060
arch: ['amd64', 'arm64']
6161
env:
6262
DEBIAN_FRONTEND: noninteractive
@@ -130,12 +130,10 @@ jobs:
130130
runs-on: ${{ matrix.image }}
131131
strategy:
132132
matrix:
133-
vcver: [143, 142]
133+
vcver: [143]
134134
include:
135135
- vcver: 143
136136
image: windows-2022
137-
- vcver: 142
138-
image: windows-2019
139137
env:
140138
VER_SUFFIX: .VS${{ matrix.vcver }}
141139
steps:
@@ -159,7 +157,7 @@ jobs:
159157
uses: lukka/run-vcpkg@v7
160158
with:
161159
vcpkgArguments: openssl zlib flatbuffers
162-
vcpkgGitCommitId: e4644bd15436d406bba71928d086c809e5c9ca45
160+
vcpkgGitCommitId: 4008642a50a01a7115c2406b04d5273898e7fe1c
163161
vcpkgTriplet: x64-windows
164162
- name: Install Qt
165163
uses: jurplel/install-qt-action@v4

client/Application.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ class DigidocConf final: public digidoc::XmlConfCurrent
147147

148148
#ifdef Q_OS_MAC
149149
std::string TSLCache() const final
150-
{ return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation).toStdString(); }
150+
{
151+
return Application::groupContainerPath().toStdString();
152+
}
151153
#endif
152154

153155
std::vector<digidoc::X509Cert> TSCerts() const final

client/Application.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ class Application final: public BaseApplication
7575
static uint readTSLVersion(const QString &path);
7676
static void showClient(const QStringList &params = {}, bool crypto = false, bool sign = false, bool newWindow = false);
7777
static void updateTSLCache(const QDateTime &tslTime);
78+
#if defined(Q_OS_MAC)
79+
static QString groupContainerPath();
80+
#endif
7881

7982
private Q_SLOTS:
8083
static void browse(const QUrl &url);

client/Application_mac.mm

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <QtCore/QUrlQuery>
2626
#include <QtGui/QDesktopServices>
2727

28+
using namespace Qt::StringLiterals;
29+
2830
@implementation NSApplication (ApplicationObjC)
2931

3032
- (void)appReopen:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
@@ -96,7 +98,7 @@ - (void)openCrypto:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
9698
void Application::mailTo( const QUrl &url )
9799
{
98100
QUrlQuery q(url);
99-
if(NSURL *appUrl = CFBridgingRelease(LSCopyDefaultApplicationURLForURL((__bridge CFURLRef)url.toNSURL(), kLSRolesAll, nil)))
101+
if(NSURL *appUrl = [NSWorkspace.sharedWorkspace URLForApplicationToOpenURL:url.toNSURL()])
100102
{
101103
QString p;
102104
QTextStream s( &p );
@@ -112,24 +114,11 @@ - (void)openCrypto:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
112114
<< "end tell" << Qt::endl
113115
<< "end run" << Qt::endl;
114116
}
115-
else if([appUrl.path rangeOfString:@"Entourage"].location != NSNotFound)
116-
{
117-
s << "on run" << Qt::endl
118-
<< "set vattachment to \"" << q.queryItemValue(QStringLiteral("attachment")) << "\"" << Qt::endl
119-
<< "set vsubject to \"" << q.queryItemValue(QStringLiteral("subject")) << "\"" << Qt::endl
120-
<< "tell application \"Microsoft Entourage\"" << Qt::endl
121-
<< "set vmessage to make new outgoing message with properties" << Qt::endl
122-
<< "{subject:vsubject, attachments:vattachment}" << Qt::endl
123-
<< "open vmessage" << Qt::endl
124-
<< "activate" << Qt::endl
125-
<< "end tell" << Qt::endl
126-
<< "end run" << Qt::endl;
127-
}
128117
else if([appUrl.path rangeOfString:@"Outlook"].location != NSNotFound)
129118
{
130119
s << "on run" << Qt::endl
131-
<< "set vattachment to \"" << q.queryItemValue(QStringLiteral("attachment")) << "\" as POSIX file" << Qt::endl
132-
<< "set vsubject to \"" << q.queryItemValue(QStringLiteral("subject")) << "\"" << Qt::endl
120+
<< "set vattachment to \"" << q.queryItemValue(u"attachment"_s) << "\" as POSIX file" << Qt::endl
121+
<< "set vsubject to \"" << q.queryItemValue(u"subject"_s) << "\"" << Qt::endl
133122
<< "tell application \"Microsoft Outlook\"" << Qt::endl
134123
<< "activate" << Qt::endl
135124
<< "set vmessage to make new outgoing message with properties {subject:vsubject}" << Qt::endl
@@ -153,3 +142,10 @@ - (void)openCrypto:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
153142
}
154143
QDesktopServices::openUrl( url );
155144
}
145+
146+
QString Application::groupContainerPath()
147+
{
148+
return QString::fromNSString([NSFileManager.defaultManager
149+
containerURLForSecurityApplicationGroupIdentifier:@"group.ee.ria.qdigidoc4.tsl"].path);
150+
}
151+

client/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ if( APPLE )
175175
find_library(PKCS11_MODULE NAMES opensc-pkcs11.so HINTS /Library/OpenSC/lib)
176176
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
177177
COMMAND cp -a ${PKCS11_MODULE} $<TARGET_FILE_DIR:${PROJECT_NAME}>
178-
COMMAND mkdir -p $<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Library/QuickLook
179-
COMMAND cp -a $<TARGET_BUNDLE_DIR:DigiDocQL> $<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Library/QuickLook
178+
COMMAND mkdir -p $<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/PlugIns
179+
COMMAND cp -a $<TARGET_BUNDLE_DIR:DigiDocQL> $<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/PlugIns
180180
)
181181
add_custom_target(macdeployqt DEPENDS ${PROJECT_NAME}
182182
COMMAND ${qtCore_install_prefix}/macdeployqt $<TARGET_BUNDLE_DIR:${PROJECT_NAME}>
@@ -196,11 +196,12 @@ if( APPLE )
196196
$<TARGET_FILE_DIR:${PROJECT_NAME}>/*.*
197197
$<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Frameworks/digidocpp.framework/Libraries/*
198198
$<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Frameworks/*.framework
199-
$<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/PlugIns/*/*
200-
$<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Library/QuickLook/DigiDocQL.qlgenerator
199+
$<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/PlugIns/*/*.dylib
201200
COMMAND if echo \"$$SIGNCERT\" | grep -q "Developer ID" \; then
201+
codesign -f --options runtime -s \"$$SIGNCERT\" $<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/PlugIns/DigiDocQL.appex --entitlements ${CMAKE_SOURCE_DIR}/extensions/DigiDocQL/DigiDocQL.entitlements\;
202202
codesign -f --options runtime -s \"$$SIGNCERT\" $<TARGET_BUNDLE_DIR:${PROJECT_NAME}> --entitlements ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.eToken.entitlements\;
203203
else
204+
codesign -f -s \"$$SIGNCERT\" $<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/PlugIns/DigiDocQL.appex --entitlements ${CMAKE_SOURCE_DIR}/extensions/DigiDocQL/DigiDocQL.entitlements\;
204205
codesign -f -s \"$$SIGNCERT\" $<TARGET_BUNDLE_DIR:${PROJECT_NAME}> --entitlements ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.entitlements\;
205206
fi
206207
)
Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
set( RESOURCES ../../client/mac/Resources/asic.icns )
2-
add_library( DigiDocQL MODULE
3-
${RESOURCES}
4-
Info.plist
5-
main.c
6-
GenerateThumbnailForURL.c
7-
GeneratePreviewForURL.mm
1+
set(RESOURCES ../../client/mac/Resources/asic.icns)
2+
add_executable(DigiDocQL MACOSX_BUNDLE
3+
${RESOURCES}
4+
PreviewViewController.mm
85
)
9-
set_source_files_properties( GeneratePreviewForURL.mm PROPERTIES COMPILE_FLAGS "-fobjc-arc" )
10-
set_source_files_properties( Info.plist PROPERTIES MACOSX_PACKAGE_LOCATION . )
11-
set_target_properties( DigiDocQL PROPERTIES
12-
BUNDLE YES
13-
BUNDLE_EXTENSION qlgenerator
14-
RESOURCE "${RESOURCES}"
15-
XCODE_ATTRIBUTE_WRAPPER_EXTENSION qlgenerator
16-
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
17-
AUTOMOC OFF
18-
COMPILE_FLAGS "-Wno-unused-parameter"
19-
LINK_LIBRARIES "-framework QuickLook;-framework Cocoa"
20-
LINK_FLAGS "-F/Library/Frameworks -fobjc-arc"
21-
BUILD_WITH_INSTALL_RPATH YES
22-
INSTALL_RPATH "@loader_path/../../../../../Frameworks"
6+
set_target_properties(DigiDocQL PROPERTIES
7+
BUNDLE YES
8+
BUNDLE_EXTENSION appex
9+
RESOURCE ${RESOURCES}
10+
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.cmake
11+
MACOSX_BUNDLE_BUNDLE_NAME DigiDocQL
12+
MACOSX_BUNDLE_GUI_IDENTIFIER "ee.ria.qdigidoc4.DigiDocQL"
13+
MACOSX_BUNDLE_COPYRIGHT "(C) 2010-2025 Estonian Information System Authority"
14+
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}
15+
MACOSX_BUNDLE_BUNDLE_VERSION ${BUILD_NUMBER}
16+
AUTOMOC OFF
17+
COMPILE_FLAGS "-Wno-unused-parameter -fobjc-arc"
18+
LINK_LIBRARIES "-framework QuickLookUI;-framework UniformTypeIdentifiers"
19+
LINK_FLAGS "-F/Library/Frameworks -fobjc-arc -e _NSExtensionMain -fapplication-extension"
20+
BUILD_WITH_INSTALL_RPATH YES
21+
INSTALL_RPATH "@loader_path/../../../../Frameworks"
22+
XCODE_ATTRIBUTE_WRAPPER_EXTENSION appex
23+
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
24+
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "ee.ria.qdigidoc4.DigiDocQL"
2325
)
2426
target_link_libraries(DigiDocQL digidocpp::digidocpp)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.application-identifier</key>
6+
<string>ET847QJV9F.ee.ria.qdigidoc4.DigiDocQL</string>
7+
<key>com.apple.security.app-sandbox</key>
8+
<true/>
9+
<key>com.apple.security.application-groups</key>
10+
<array>
11+
<string>group.ee.ria.qdigidoc4.tsl</string>
12+
</array>
13+
</dict>
14+
</plist>

extensions/DigiDocQL/GeneratePreviewForURL.mm

Lines changed: 0 additions & 201 deletions
This file was deleted.

0 commit comments

Comments
 (0)