Skip to content

Commit

Permalink
Fix Quick Look when window is inactive on completion (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Aug 5, 2019
1 parent 56511ac commit 0070d3d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Gifski/ConversionCompletedViewController.swift
Expand Up @@ -41,6 +41,9 @@ final class ConversionCompletedViewController: NSViewController {
override func viewDidAppear() {
super.viewDidAppear()

// This is needed for Quick Look to work.
self.view.window?.makeFirstResponder(self)

if #available(macOS 10.14, *), defaults[.successfulConversionsCount] == 5 {
SKStoreReviewController.requestReview()
}
Expand Down
12 changes: 9 additions & 3 deletions Gifski/ConversionViewController.swift
Expand Up @@ -42,14 +42,20 @@ final class ConversionViewController: NSViewController {
view = wrapper
}

override func viewDidLoad() {
super.viewDidLoad()
override func viewDidAppear() {
super.viewDidAppear()

view.window?.makeFirstResponder(self)

start(conversion: conversion)
}

/// Gets called when the Esc key is pressed.
/// Reference: https://stackoverflow.com/a/42440020
override func cancelOperation(_ sender: Any?) {
cancelConversion()
}

// TODO: Remove this when we target macOS 10.14.
@objc
func cancel(_ sender: Any?) {
cancelConversion()
Expand Down
1 change: 0 additions & 1 deletion Gifski/util.swift
Expand Up @@ -2449,7 +2449,6 @@ extension NSViewController {
}, completionHandler: {
window.contentViewController = viewController
viewController.view.animator().alphaValue = 1.0
window.makeFirstResponder(viewController)
completion?()
})
}
Expand Down

0 comments on commit 0070d3d

Please sign in to comment.