-
Notifications
You must be signed in to change notification settings - Fork 0
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
36e17a7
commit c406989
Showing
4 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import Cocoa | ||
|
||
fileprivate func BasicLink( | ||
text: String, | ||
href: String, | ||
font: NSFont | ||
) -> NSAttributedString { | ||
return NSAttributedString( | ||
string: text, | ||
attributes: [ | ||
.font: font, | ||
.link: NSURL(string: href) ?? "", | ||
.toolTip: href, | ||
.underlineColor: NSColor.clear, | ||
] | ||
) | ||
} | ||
|
||
fileprivate func join(_ parts: [NSAttributedString]) -> NSMutableAttributedString { | ||
let joinedString = NSMutableAttributedString(string: "") | ||
parts.forEach{ joinedString.append($0) } | ||
return joinedString | ||
} | ||
|
||
extension NSApplication.AboutPanelOptionKey { | ||
static let copyright = NSApplication.AboutPanelOptionKey(rawValue: "Copyright") | ||
} | ||
|
||
class AboutWindow { | ||
static let shared = AboutWindow() | ||
@objc func show() { | ||
NSApp.orderFrontStandardAboutPanel(options: [ | ||
.copyright: "", | ||
.credits: join([ | ||
BasicLink( | ||
text: "Source Code", | ||
href: "https://github.com/leonardodino/SilkScreen", | ||
font: NSFont.systemFont(ofSize: 12, weight: .medium) | ||
), | ||
NSAttributedString( | ||
string: "\n\n", | ||
attributes: [.font: NSFont.systemFont(ofSize: 6)] | ||
), | ||
BasicLink( | ||
text: "Leonardo Dino", | ||
href: "https://leonardodino.com/", | ||
font: NSFont.systemFont(ofSize: 10) | ||
), | ||
]), | ||
]) | ||
NSApp.activate(ignoringOtherApps: true) | ||
} | ||
} |
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