diff --git a/Whisky.xcodeproj/project.pbxproj b/Whisky.xcodeproj/project.pbxproj index db3326865..cc033a9ed 100644 --- a/Whisky.xcodeproj/project.pbxproj +++ b/Whisky.xcodeproj/project.pbxproj @@ -31,6 +31,7 @@ 6E4354082AACE2B400E40689 /* ResourceSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E8A3B3F2A36140300D19632 /* ResourceSection.swift */; }; 6E4354092AACE2E000E40689 /* DataExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E26058929D9282000DDD788 /* DataExtensions.swift */; }; 6E43540A2AACE30600E40689 /* ShellLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E26058529D9267B00DDD788 /* ShellLink.swift */; }; + 6E4D88B52AACF95A00F8767E /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6E4D88B42AACF95A00F8767E /* Media.xcassets */; }; 6E50D98029CD0850008C39F6 /* Wine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E50D97F29CD0850008C39F6 /* Wine.swift */; }; 6E50D98329CD6066008C39F6 /* BottleVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E50D98229CD6066008C39F6 /* BottleVM.swift */; }; 6E50D98529CDF25B008C39F6 /* BottleCreationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E50D98429CDF25B008C39F6 /* BottleCreationView.swift */; }; @@ -172,6 +173,7 @@ 6E4353E02AACD7A700E40689 /* ThumbnailProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThumbnailProvider.swift; sourceTree = ""; }; 6E4353E22AACD7A700E40689 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 6E4353E32AACD7A700E40689 /* WhiskyThumbnail.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WhiskyThumbnail.entitlements; sourceTree = ""; }; + 6E4D88B42AACF95A00F8767E /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = ""; }; 6E50D97F29CD0850008C39F6 /* Wine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Wine.swift; sourceTree = ""; }; 6E50D98229CD6066008C39F6 /* BottleVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottleVM.swift; sourceTree = ""; }; 6E50D98429CDF25B008C39F6 /* BottleCreationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottleCreationView.swift; sourceTree = ""; }; @@ -329,6 +331,7 @@ 6E4353E02AACD7A700E40689 /* ThumbnailProvider.swift */, 6E4353E22AACD7A700E40689 /* Info.plist */, 6E4353E32AACD7A700E40689 /* WhiskyThumbnail.entitlements */, + 6E4D88B42AACF95A00F8767E /* Media.xcassets */, ); path = WhiskyThumbnail; sourceTree = ""; @@ -628,6 +631,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 6E4D88B52AACF95A00F8767E /* Media.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/WhiskyThumbnail/Info.plist b/WhiskyThumbnail/Info.plist index b01b106bf..ae2809e5a 100644 --- a/WhiskyThumbnail/Info.plist +++ b/WhiskyThumbnail/Info.plist @@ -8,7 +8,6 @@ QLSupportedContentTypes - com.microsoft.msi-installer com.microsoft.windows-executable QLThumbnailMinimumDimension diff --git a/WhiskyThumbnail/Media.xcassets/Contents.json b/WhiskyThumbnail/Media.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/WhiskyThumbnail/Media.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/WhiskyThumbnail/Media.xcassets/Icon.imageset/256R256x1.png b/WhiskyThumbnail/Media.xcassets/Icon.imageset/256R256x1.png new file mode 100644 index 000000000..02cdd20b4 Binary files /dev/null and b/WhiskyThumbnail/Media.xcassets/Icon.imageset/256R256x1.png differ diff --git a/WhiskyThumbnail/Media.xcassets/Icon.imageset/Contents.json b/WhiskyThumbnail/Media.xcassets/Icon.imageset/Contents.json new file mode 100644 index 000000000..e2888da18 --- /dev/null +++ b/WhiskyThumbnail/Media.xcassets/Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "256R256x1.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/WhiskyThumbnail/ThumbnailProvider.swift b/WhiskyThumbnail/ThumbnailProvider.swift index fd3a98ba6..510b7e29e 100644 --- a/WhiskyThumbnail/ThumbnailProvider.swift +++ b/WhiskyThumbnail/ThumbnailProvider.swift @@ -13,7 +13,20 @@ import WhiskyKit class ThumbnailProvider: QLThumbnailProvider { override func provideThumbnail(for request: QLFileThumbnailRequest, _ handler: @escaping (QLThumbnailReply?, Error?) -> Void) { - let thumbnailFrame = CGRect(x: 0, y: 0, width: request.maximumSize.width, height: request.maximumSize.height) + let thumbnailSize = CGSize(width: request.maximumSize.width, + height: request.maximumSize.height) + + let iconScaleFactor = 0.8 + let whiskyIconScaleFactor = 0.4 + + let iconFrame = CGRect(x: (request.maximumSize.width - request.maximumSize.width * iconScaleFactor) / 2.0, + y: (request.maximumSize.height - request.maximumSize.height * iconScaleFactor) / 2.0, + width: request.maximumSize.width * iconScaleFactor, + height: request.maximumSize.height * iconScaleFactor) + let whiskyIconFrame = CGRect(x: request.maximumSize.width - request.maximumSize.width * whiskyIconScaleFactor, + y: 0, + width: request.maximumSize.width * whiskyIconScaleFactor, + height: request.maximumSize.height * whiskyIconScaleFactor) do { var image: NSImage? var icons: [NSImage] = [] @@ -30,9 +43,11 @@ class ThumbnailProvider: QLThumbnailProvider { image = icons[0] } - let reply: QLThumbnailReply = QLThumbnailReply.init(contextSize: thumbnailFrame.size) { () -> Bool in + let reply: QLThumbnailReply = QLThumbnailReply.init(contextSize: thumbnailSize) { () -> Bool in if let image = image { - image.draw(in: thumbnailFrame) + image.draw(in: iconFrame) + let whiskyIcon = NSImage(named: NSImage.Name("Icon")) + whiskyIcon?.draw(in: whiskyIconFrame, from: .zero, operation: .sourceOver, fraction: 1) return true }