Skip to content

Commit

Permalink
feat: fit window to center after launch
Browse files Browse the repository at this point in the history
  • Loading branch information
1000ch committed Aug 9, 2020
1 parent d763741 commit 35783a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions WebPonize/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import Defaults
class AppDelegate: NSObject, NSApplicationDelegate {
static var statusList: [Status] = []
static var queue = OperationQueue()

var mainWindow: NSWindow?
lazy var mainWindowController = MainWindowController()

override init() {
super.init()
Expand All @@ -15,15 +14,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

func applicationDidFinishLaunching(_ aNotification: Notification) {
mainWindow = NSApplication.shared.windows.first
mainWindowController.showWindow(self)
mainWindowController.alignToCenter()
}

func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}

func application(_ application: NSApplication, open urls: [URL]) {
ConvertManager.openSavePanel(for: mainWindow!, target: urls)
ConvertManager.openSavePanel(for: mainWindowController.window!, target: urls)
}
}

Expand Down
4 changes: 4 additions & 0 deletions WebPonize/controller/MainWindowController.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import Cocoa

class MainWindowController: NSWindowController {
func alignToCenter() {
window?.center()
}

@IBAction func openDocument(_ sender: AnyObject?) {
let panel = NSOpenPanel()
panel.canChooseDirectories = false
Expand Down

0 comments on commit 35783a0

Please sign in to comment.