From 0bc84aa50ca3362d5cc866ff903c4cdc223df27d Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 13 Nov 2017 18:33:23 -0800 Subject: [PATCH] =?UTF-8?q?Show=20the=20Keyboard=20Shortcuts=20menu=20via?= =?UTF-8?q?=20its=20new=20Window=20menu=20command.=20The=20window=E2=80=99?= =?UTF-8?q?s=20HTML=20content=20remains=20to=20be=20done,=20though.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Evergreen.xcodeproj/project.pbxproj | 13 +++++++++++++ Evergreen/AppDelegate.swift | 13 +++++++++++++ Evergreen/Base.lproj/Main.storyboard | 10 ++++++++-- .../KeyboardShortcuts/KeyboardShortcuts.html | 9 +++++++++ .../RSCore/AppKit/WebViewWindowController.swift | 2 ++ 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 Evergreen/Resources/KeyboardShortcuts/KeyboardShortcuts.html diff --git a/Evergreen.xcodeproj/project.pbxproj b/Evergreen.xcodeproj/project.pbxproj index 58257d6a7..4df0e4130 100644 --- a/Evergreen.xcodeproj/project.pbxproj +++ b/Evergreen.xcodeproj/project.pbxproj @@ -93,6 +93,7 @@ 84E46C7D1F75EF7B005ECFB3 /* AppDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E46C7C1F75EF7B005ECFB3 /* AppDefaults.swift */; }; 84E95CF71FABB3C800552D99 /* FeedList.plist in Resources */ = {isa = PBXBuildFile; fileRef = 84E95CF61FABB3C800552D99 /* FeedList.plist */; }; 84E95D241FB1087500552D99 /* ArticlePasteboardWriter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E95D231FB1087500552D99 /* ArticlePasteboardWriter.swift */; }; + 84EB381F1FBA8B9F000D2111 /* KeyboardShortcuts.html in Resources */ = {isa = PBXBuildFile; fileRef = 84EB38101FBA8B9F000D2111 /* KeyboardShortcuts.html */; }; 84F204CE1FAACB660076E152 /* FeedListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F204CD1FAACB660076E152 /* FeedListViewController.swift */; }; 84F204DE1FAACB8B0076E152 /* FeedListTimelineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F204DD1FAACB8B0076E152 /* FeedListTimelineViewController.swift */; }; 84F204E01FAACBB30076E152 /* ArticleArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F204DF1FAACBB30076E152 /* ArticleArray.swift */; }; @@ -467,6 +468,7 @@ 84E46C7C1F75EF7B005ECFB3 /* AppDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDefaults.swift; path = Evergreen/AppDefaults.swift; sourceTree = ""; }; 84E95CF61FABB3C800552D99 /* FeedList.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = FeedList.plist; sourceTree = ""; }; 84E95D231FB1087500552D99 /* ArticlePasteboardWriter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticlePasteboardWriter.swift; sourceTree = ""; }; + 84EB38101FBA8B9F000D2111 /* KeyboardShortcuts.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = KeyboardShortcuts.html; sourceTree = ""; }; 84F204CD1FAACB660076E152 /* FeedListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListViewController.swift; sourceTree = ""; }; 84F204DD1FAACB8B0076E152 /* FeedListTimelineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListTimelineViewController.swift; sourceTree = ""; }; 84F204DF1FAACBB30076E152 /* ArticleArray.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleArray.swift; sourceTree = ""; }; @@ -697,6 +699,7 @@ 849A979A1ED9EFEB007D329B /* styleSheet.css */, 849A979B1ED9EFEB007D329B /* template.html */, 849C646C1ED37A5D003D8FC0 /* Info.plist */, + 84EB380F1FBA8B9F000D2111 /* KeyboardShortcuts */, ); name = Resources; path = Evergreen/Extensions; @@ -864,6 +867,15 @@ path = Importers; sourceTree = ""; }; + 84EB380F1FBA8B9F000D2111 /* KeyboardShortcuts */ = { + isa = PBXGroup; + children = ( + 84EB38101FBA8B9F000D2111 /* KeyboardShortcuts.html */, + ); + name = KeyboardShortcuts; + path = Evergreen/Resources/KeyboardShortcuts; + sourceTree = SOURCE_ROOT; + }; 84FB9A2C1EDCD6A4003D53B9 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -1194,6 +1206,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 84EB381F1FBA8B9F000D2111 /* KeyboardShortcuts.html in Resources */, 849A97951ED9EF7A007D329B /* IndeterminateProgressWindow.xib in Resources */, 849A978F1ED9EE72007D329B /* DefaultFeeds.plist in Resources */, 849A979D1ED9EFEB007D329B /* template.html in Resources */, diff --git a/Evergreen/AppDelegate.swift b/Evergreen/AppDelegate.swift index 3c3bf81ad..ca5508ef8 100644 --- a/Evergreen/AppDelegate.swift +++ b/Evergreen/AppDelegate.swift @@ -13,6 +13,7 @@ import RSTextDrawing import RSTree import RSWeb import Account +import RSCore let appName = "Evergreen" var currentTheme: VSTheme! @@ -27,6 +28,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { var dinosaursWindowController: DinosaursWindowController? var addFeedController: AddFeedController? var addFolderWindowController: AddFolderWindowController? + var keyboardShortcutsWindowController: WebViewWindowController? + let themeLoader = VSThemeLoader() private let appNewsURLString = "https://ranchero.com/evergreen/feed.json" private let dockBadge = DockBadge() @@ -207,6 +210,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { dinosaursWindowController!.showWindow(self) } + @IBAction func showKeyboardShortcutsWindow(_ sender: Any?) { + + if keyboardShortcutsWindowController == nil { + keyboardShortcutsWindowController = WebViewWindowController(title: NSLocalizedString("Keyboard Shortcuts", comment: "window title")) + let htmlFile = Bundle(for: type(of: self)).path(forResource: "KeyboardShortcuts", ofType: "html")! + keyboardShortcutsWindowController?.displayContents(of: htmlFile) + } + keyboardShortcutsWindowController!.showWindow(self) + } + @IBAction func importOPMLFromFile(_ sender: AnyObject) { let panel = NSOpenPanel() diff --git a/Evergreen/Base.lproj/Main.storyboard b/Evergreen/Base.lproj/Main.storyboard index b30ac103b..12414fd00 100644 --- a/Evergreen/Base.lproj/Main.storyboard +++ b/Evergreen/Base.lproj/Main.storyboard @@ -1,7 +1,7 @@ - + - + @@ -464,6 +464,12 @@ + + + + + + diff --git a/Evergreen/Resources/KeyboardShortcuts/KeyboardShortcuts.html b/Evergreen/Resources/KeyboardShortcuts/KeyboardShortcuts.html new file mode 100644 index 000000000..52cfd658f --- /dev/null +++ b/Evergreen/Resources/KeyboardShortcuts/KeyboardShortcuts.html @@ -0,0 +1,9 @@ + + + Keyboard Shortcuts + + +

Keyboard Shortcuts

+

TODO: Keyboard shortcuts window #163

+ + diff --git a/Frameworks/RSCore/RSCore/AppKit/WebViewWindowController.swift b/Frameworks/RSCore/RSCore/AppKit/WebViewWindowController.swift index 943d83702..fde7250e4 100644 --- a/Frameworks/RSCore/RSCore/AppKit/WebViewWindowController.swift +++ b/Frameworks/RSCore/RSCore/AppKit/WebViewWindowController.swift @@ -29,6 +29,8 @@ public final class WebViewWindowController: NSWindowController { // We assume there might be images, style sheets, etc. contained by the folder that the file appears in, so we get read access to the parent folder. + let _ = self.window + let fileURL = URL(fileURLWithPath: path) let folderURL = fileURL.deletingLastPathComponent()