-
-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccc172b
commit edcb5cb
Showing
17 changed files
with
354 additions
and
64 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// | ||
// GPTKDownloader.swift | ||
// Whisky | ||
// WhiskyKit | ||
// | ||
// Created by Isaac Marovitz on 19/06/2023. | ||
// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// | ||
// GPTKInstaller.swift | ||
// Whisky | ||
// WhiskyKit | ||
// | ||
// Created by Isaac Marovitz on 14/06/2023. | ||
// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// | ||
// BitmapInfo.swift | ||
// Whisky | ||
// WhiskyKit | ||
// | ||
// Created by Isaac Marovitz on 09/09/2023. | ||
// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// | ||
// ResourceSection.swift | ||
// Whisky | ||
// WhiskyKit | ||
// | ||
|
||
import Foundation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// | ||
// Tar.swift | ||
// Whisky | ||
// WhiskyKit | ||
// | ||
// Created by Isaac Marovitz on 14/06/2023. | ||
// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
21
WhiskyThumbnail/Icons.xcassets/Icon.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "512R512x1.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionAttributes</key> | ||
<dict> | ||
<key>QLSupportedContentTypes</key> | ||
<array> | ||
<string>com.microsoft.windows-executable</string> | ||
</array> | ||
<key>QLThumbnailMinimumDimension</key> | ||
<integer>0</integer> | ||
</dict> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.quicklook.thumbnail</string> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).ThumbnailProvider</string> | ||
</dict> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// ThumbnailProvider.swift | ||
// Whisky | ||
// | ||
// Created by Isaac Marovitz on 09/09/2023. | ||
// | ||
|
||
import Foundation | ||
import QuickLookThumbnailing | ||
import AppKit | ||
import WhiskyKit | ||
|
||
class ThumbnailProvider: QLThumbnailProvider { | ||
override func provideThumbnail(for request: QLFileThumbnailRequest, | ||
_ handler: @escaping (QLThumbnailReply?, Error?) -> Void) { | ||
let thumbnailSize = CGSize(width: request.maximumSize.width, | ||
height: request.maximumSize.height) | ||
|
||
// % of thumbnail occupied by icon | ||
let iconScaleFactor = 0.9 | ||
let whiskyIconScaleFactor = 0.4 | ||
|
||
// AppKit coordinate system origin is in the bottom-left | ||
// Icon is centered | ||
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) | ||
|
||
// Whisky icon is aligned bottom-right | ||
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? | ||
|
||
let peFile = try PEFile(data: Data(contentsOf: request.fileURL)) | ||
image = peFile.bestIcon() | ||
|
||
let reply: QLThumbnailReply = QLThumbnailReply.init(contextSize: thumbnailSize) { () -> Bool in | ||
if let image = image { | ||
image.draw(in: iconFrame) | ||
let whiskyIcon = NSImage(named: NSImage.Name("Icon")) | ||
whiskyIcon?.draw(in: whiskyIconFrame, from: .zero, operation: .sourceOver, fraction: 1) | ||
return true | ||
} | ||
|
||
// We didn't draw anything | ||
return false | ||
} | ||
|
||
handler(reply, nil) | ||
} catch { | ||
handler(nil, nil) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.app-sandbox</key> | ||
<true/> | ||
<key>com.apple.security.files.user-selected.read-only</key> | ||
<true/> | ||
</dict> | ||
</plist> |