Skip to content

Commit

Permalink
Draw Whisky logo
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Sep 9, 2023
1 parent 53f40c3 commit 6fc7f5a
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Whisky.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -172,6 +173,7 @@
6E4353E02AACD7A700E40689 /* ThumbnailProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThumbnailProvider.swift; sourceTree = "<group>"; };
6E4353E22AACD7A700E40689 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6E4353E32AACD7A700E40689 /* WhiskyThumbnail.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WhiskyThumbnail.entitlements; sourceTree = "<group>"; };
6E4D88B42AACF95A00F8767E /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = "<group>"; };
6E50D97F29CD0850008C39F6 /* Wine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Wine.swift; sourceTree = "<group>"; };
6E50D98229CD6066008C39F6 /* BottleVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottleVM.swift; sourceTree = "<group>"; };
6E50D98429CDF25B008C39F6 /* BottleCreationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottleCreationView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -329,6 +331,7 @@
6E4353E02AACD7A700E40689 /* ThumbnailProvider.swift */,
6E4353E22AACD7A700E40689 /* Info.plist */,
6E4353E32AACD7A700E40689 /* WhiskyThumbnail.entitlements */,
6E4D88B42AACF95A00F8767E /* Media.xcassets */,
);
path = WhiskyThumbnail;
sourceTree = "<group>";
Expand Down Expand Up @@ -628,6 +631,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6E4D88B52AACF95A00F8767E /* Media.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
1 change: 0 additions & 1 deletion WhiskyThumbnail/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<dict>
<key>QLSupportedContentTypes</key>
<array>
<string>com.microsoft.msi-installer</string>
<string>com.microsoft.windows-executable</string>
</array>
<key>QLThumbnailMinimumDimension</key>
Expand Down
6 changes: 6 additions & 0 deletions WhiskyThumbnail/Media.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions WhiskyThumbnail/Media.xcassets/Icon.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -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
}
}
21 changes: 18 additions & 3 deletions WhiskyThumbnail/ThumbnailProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand All @@ -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
}

Expand Down

0 comments on commit 6fc7f5a

Please sign in to comment.