Skip to content

Commit

Permalink
Merge pull request #6 from nhiroyasu/develop
Browse files Browse the repository at this point in the history
v1.2.2
  • Loading branch information
nhiroyasu authored May 1, 2022
2 parents 9c2dce8 + a646c18 commit 8e31a3f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 8 deletions.
8 changes: 4 additions & 4 deletions slideover-for-macos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@
CODE_SIGN_ENTITLEMENTS = "slideover-for-macos/slideover_for_macos.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6;
CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_TEAM = 2CMV7D36JC;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -564,7 +564,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.2;
MARKETING_VERSION = 1.2.0;
MARKETING_VERSION = 1.2.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.nhiro1109.${BUNDLE_ID_PREFIX}slideover-for-macos";
PRODUCT_NAME = "${TARGET_NAME}";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -584,7 +584,7 @@
CODE_SIGN_ENTITLEMENTS = "slideover-for-macos/slideover_for_macos.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6;
CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_TEAM = 2CMV7D36JC;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -599,7 +599,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.2;
MARKETING_VERSION = 1.2.0;
MARKETING_VERSION = 1.2.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.nhiro1109.slideover-for-macos";
PRODUCT_NAME = "${DISPLAY_NAME_PREFIX}${TARGET_NAME}";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
16 changes: 16 additions & 0 deletions slideover-for-macos/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
private var notificationManager: NotificationManager? {
Injector.shared.buildSafe(NotificationManager.self)
}
private var userSetting: UserSettingService? {
Injector.shared.buildSafe(UserSettingService.self)
}

func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
Expand All @@ -34,6 +37,19 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}

func application(_ application: NSApplication, open urls: [URL]) {
guard let url = urls.first else { return }
let components = NSURLComponents(url: url, resolvingAgainstBaseURL: false)
guard let urlItem = components?.queryItems?.first(where: { item in
item.name == "url"
}) else { return }
guard let targetUrl = urlItem.value else { return }
notificationManager?.push(name: .openUrl, param: targetUrl)
if var userSetting = userSetting {
userSetting.latestPage = URL(string: targetUrl)
}
}

@IBAction func didTapReloadButton(_ sender: Any) {
notificationManager?.push(name: .reload, param: nil)
Expand Down
7 changes: 6 additions & 1 deletion slideover-for-macos/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@
<string>com.nhiroyasu.slideoverformacos</string>
<key>CFBundleURLSchemes</key>
<array>
<string>slideoverformacos</string>
<string>debug-slideoverformacos</string>
</array>
</dict>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class SlideOverWindowInteractor: SlideOverWindowUseCase {
func setUp() {
observeReloadNotification()
observeClearCacheNotification()
observeUrlOpenUrlNotification()
observeHelpNotification()
observeMouseEvent()
setWillMoveNotification()
Expand Down Expand Up @@ -184,4 +185,12 @@ extension SlideOverWindowInteractor {
self?.presenter.loadWebPage(url: self?.helpUrl)
}
}

private func observeUrlOpenUrlNotification() {
notificationManager.observe(name: .openUrl) { [weak self] urlValue in
guard let urlStr = urlValue as? String,
let url = URL(string: urlStr) else { return }
self?.presenter.loadWebPage(url: url)
}
}
}
1 change: 1 addition & 0 deletions slideover-for-macos/Service/NotificationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Foundation
extension Notification.Name {
static let reload = Notification.Name("reload")
static let clearCache = Notification.Name("clearCache")
static let openUrl = Notification.Name("openUrl")
static let openHelp = Notification.Name("openHelp")
}

Expand Down
2 changes: 1 addition & 1 deletion slideover-for-macos/UI/Util/SlideOverWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SlideOverWebView: WKWebView {
override func willOpenMenu(_ menu: NSMenu, with event: NSEvent) {
let menuTree: [MenuItemType] = [
.separator,
.item(data: .init(title: NSLocalizedString("Copy Link", comment: ""), action: #selector(didTapCopyLink), keyEquivalent: "", image: nil, value: nil)),
.item(data: .init(title: NSLocalizedString("Copy Link This Page", comment: ""), action: #selector(didTapCopyLink), keyEquivalent: "", image: nil, value: nil)),
.item(data: .init(title: NSLocalizedString("Open Browser", comment: ""), action: #selector(didTapOpenBrowser), keyEquivalent: "", image: nil, value: nil)),
.separator,
.subMenu(data: .init(title: NSLocalizedString("Window Layout", comment: ""), image: NSImage(systemSymbolName: "uiwindow.split.2x1", accessibilityDescription: nil), items: [
Expand Down
4 changes: 2 additions & 2 deletions slideover-for-macos/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"Copy Link" = "リンクをコピー";
"Open Browser" = "ブラウザで開く";
"Copy Link This Page" = "このページのリンクをコピー";
"Open Browser" = "このページをブラウザで開く";
"Window Layout" = "画面配置";
"Left" = "右端";
"Right" = "左端";
Expand Down

0 comments on commit 8e31a3f

Please sign in to comment.