mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
Fix QuickLook (#3001)
* Fix QuickLook symbol not found; add file sort and filesize
This commit is contained in:
@@ -237,7 +237,6 @@
|
||||
A2D77451154CC25700A62B93 /* WebSeedTableView.h in Headers */ = {isa = PBXBuildFile; fileRef = A2D7744F154CC25700A62B93 /* WebSeedTableView.h */; };
|
||||
A2D77452154CC25700A62B93 /* WebSeedTableView.mm in Sources */ = {isa = PBXBuildFile; fileRef = A2D77450154CC25700A62B93 /* WebSeedTableView.mm */; };
|
||||
A2D77453154CC72B00A62B93 /* WebSeedTableView.mm in Sources */ = {isa = PBXBuildFile; fileRef = A2D77450154CC25700A62B93 /* WebSeedTableView.mm */; };
|
||||
A2D8CFBA15F82DFA0056E93D /* NSApplicationAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = A29D84031049C25600D1987A /* NSApplicationAdditions.mm */; };
|
||||
A2D8CFBB15F82E030056E93D /* NSStringAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4DE5CC9C0980656F00BE280E /* NSStringAdditions.mm */; };
|
||||
A2DF37070C220D03006523C1 /* CreatorWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = A2DF37050C220D03006523C1 /* CreatorWindowController.mm */; };
|
||||
A2E384DA130DFB3A001F501B /* templates.h in Headers */ = {isa = PBXBuildFile; fileRef = A2E384D2130DFB3A001F501B /* templates.h */; };
|
||||
@@ -1257,10 +1256,10 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
A2F35BBC15C5A0A100EBF632 /* QuickLook.framework in Frameworks */,
|
||||
C88771AD2803EE7B005C7523 /* libz.tbd in Frameworks */,
|
||||
A2F35BE115C5A7ED00EBF632 /* Cocoa.framework in Frameworks */,
|
||||
A2F35BE315C5A7F900EBF632 /* Foundation.framework in Frameworks */,
|
||||
A2F35BD415C5A19A00EBF632 /* libtransmission.a in Frameworks */,
|
||||
C88771AD2803EE7B005C7523 /* libz.tbd in Frameworks */,
|
||||
C88771B12803EE86005C7523 /* libiconv.tbd in Frameworks */,
|
||||
55869932257074FE00F77A43 /* libcurl.tbd in Frameworks */,
|
||||
);
|
||||
@@ -3103,9 +3102,8 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
A2D8CFBB15F82E030056E93D /* NSStringAdditions.mm in Sources */,
|
||||
A2D8CFBA15F82DFA0056E93D /* NSApplicationAdditions.mm in Sources */,
|
||||
A29304EE15D7497C00B1F726 /* main.cc in Sources */,
|
||||
A2D8CFBB15F82E030056E93D /* NSStringAdditions.mm in Sources */,
|
||||
A2F35BCA15C5A0A100EBF632 /* GenerateThumbnailForURL.mm in Sources */,
|
||||
A2F35BCC15C5A0A100EBF632 /* GeneratePreviewForURL.mm in Sources */,
|
||||
);
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm> // std::sort()
|
||||
#include <cstddef>
|
||||
#include <cstdint> // uint64_t
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -72,6 +74,21 @@ public:
|
||||
total_size_ = uint64_t{};
|
||||
}
|
||||
|
||||
auto sortedByPath() const
|
||||
{
|
||||
auto ret = std::vector<std::pair<std::string /*path*/, uint64_t /*size*/>>{};
|
||||
ret.reserve(std::size(files_));
|
||||
std::transform(
|
||||
std::begin(files_),
|
||||
std::end(files_),
|
||||
std::back_inserter(ret),
|
||||
[](auto const& in) { return std::make_pair(in.path_, in.size_); });
|
||||
|
||||
std::sort(std::begin(ret), std::end(ret), [](auto const& lhs, auto const& rhs) { return lhs.first < rhs.first; });
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
tr_file_index_t add(std::string_view path, uint64_t file_size)
|
||||
{
|
||||
auto const ret = static_cast<tr_file_index_t>(std::size(files_));
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
#include "torrent-metainfo.h"
|
||||
#include "torrent.h"
|
||||
#include "tr-assert.h"
|
||||
#include "tr-assert.h"
|
||||
#include "trevent.h" /* tr_runInEventThread() */
|
||||
#include "utils.h"
|
||||
#include "variant.h"
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <libtransmission/transmission.h>
|
||||
#include <libtransmission/utils.h>
|
||||
|
||||
#import "NSApplicationAdditions.h"
|
||||
#import "NSStringAdditions.h"
|
||||
|
||||
@interface NSString (Private)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
project(trmacql)
|
||||
|
||||
set(${PROJECT_NAME}_SOURCES
|
||||
../NSApplicationAdditions.mm
|
||||
../NSStringAdditions.mm
|
||||
GeneratePreviewForURL.mm
|
||||
GenerateThumbnailForURL.mm
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <CoreFoundation/CFPlugInCOM.h>
|
||||
#import <QuickLook/QuickLook.h>
|
||||
|
||||
#include <string>
|
||||
@@ -9,8 +10,10 @@
|
||||
|
||||
#import "NSStringAdditions.h"
|
||||
|
||||
QL_EXTERN_C_BEGIN
|
||||
OSStatus GeneratePreviewForURL(void* thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options);
|
||||
void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview);
|
||||
QL_EXTERN_C_END
|
||||
|
||||
NSString* generateIconData(NSString* fileExtension, NSUInteger width, NSMutableDictionary* allImgProps)
|
||||
{
|
||||
@@ -187,21 +190,22 @@ OSStatus GeneratePreviewForURL(void* thisInterface, QLPreviewRequestRef preview,
|
||||
stringWithFormat:NSLocalizedStringFromTableInBundle(@"%lu Files", nil, bundle, "quicklook file header"), n_files];
|
||||
[listSection appendFormat:@"<tr><th>%@</th></tr>", fileTitleString];
|
||||
|
||||
#warning display size?
|
||||
#warning display folders?
|
||||
for (tr_file_index_t i = 0; i < n_files; ++i)
|
||||
for (auto const& [path, size] : metainfo.files().sortedByPath())
|
||||
{
|
||||
NSString* fullFilePath = [NSString stringWithUTF8String:metainfo.fileSubpath(i).c_str()];
|
||||
NSString* fullFilePath = [NSString stringWithUTF8String:path.c_str()];
|
||||
NSCAssert([fullFilePath hasPrefix:[name stringByAppendingString:@"/"]], @"Expected file path %@ to begin with %@/", fullFilePath, name);
|
||||
|
||||
NSString* shortenedFilePath = [fullFilePath substringFromIndex:[name length] + 1];
|
||||
NSString* shortenedFilePathAndSize = [NSString
|
||||
stringWithFormat:@"%@ - %@", shortenedFilePath, [NSString stringForFileSize:size]];
|
||||
|
||||
NSUInteger const width = 16;
|
||||
[listSection appendFormat:@"<tr><td><img class=\"icon\" src=\"%@\" width=\"%ld\" height=\"%ld\" />%@<td></tr>",
|
||||
generateIconData([shortenedFilePath pathExtension], width, allImgProps),
|
||||
width,
|
||||
width,
|
||||
shortenedFilePath];
|
||||
shortenedFilePathAndSize];
|
||||
}
|
||||
|
||||
[listSection appendString:@"</table>"];
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#import <CoreFoundation/CoreFoundation.h>
|
||||
#import <CoreServices/CoreServices.h>
|
||||
#import <CoreFoundation/CFPlugInCOM.h>
|
||||
#import <QuickLook/QuickLook.h>
|
||||
|
||||
QL_EXTERN_C_BEGIN
|
||||
OSStatus GenerateThumbnailForURL(void* thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize);
|
||||
void CancelThumbnailGeneration(void* thisInterface, QLThumbnailRequestRef thumbnail);
|
||||
QL_EXTERN_C_END
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
Generate a thumbnail for file
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <CoreFoundation/CFPlugInCOM.h>
|
||||
#import <QuickLook/QuickLook.h>
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <CoreFoundation/CFPlugInCOM.h>
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <QuickLook/QuickLook.h>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -30,6 +29,7 @@
|
||||
// typedefs
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QL_EXTERN_C_BEGIN
|
||||
// The thumbnail generation function to be implemented in GenerateThumbnailForURL.c
|
||||
OSStatus GenerateThumbnailForURL(
|
||||
void* thisInterface,
|
||||
@@ -69,6 +69,7 @@ HRESULT QuickLookGeneratorQueryInterface(void* thisInstance, REFIID iid, LPVOID*
|
||||
void* QuickLookGeneratorPluginFactory(CFAllocatorRef allocator, CFUUIDRef typeID);
|
||||
ULONG QuickLookGeneratorPluginAddRef(void* thisInstance);
|
||||
ULONG QuickLookGeneratorPluginRelease(void* thisInstance);
|
||||
QL_EXTERN_C_END
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// myInterfaceFtbl definition
|
||||
|
||||
Reference in New Issue
Block a user