mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-11-09 21:20:07 +01:00
✨ Improve multi-window handling
This commit is contained in:
@@ -16,27 +16,36 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
||||
|
||||
@IBOutlet weak var tableView: NSTableView!
|
||||
|
||||
public var editorAvailability: [String] = []
|
||||
|
||||
public var sites: [Valet.Site] = []
|
||||
// MARK: - Variables
|
||||
|
||||
var sites: [Valet.Site] = []
|
||||
var editorAvailability: [String] = []
|
||||
var lastSearchedFor = ""
|
||||
|
||||
// MARK: - Display
|
||||
|
||||
public static func create(delegate: NSWindowDelegate?) {
|
||||
let storyboard = NSStoryboard(name: "Main" , bundle : nil)
|
||||
|
||||
let windowController = storyboard.instantiateController(
|
||||
withIdentifier: "siteListWindow"
|
||||
) as! SiteListWC
|
||||
|
||||
windowController.window!.title = "site_list.title".localized
|
||||
windowController.window!.subtitle = "site_list.subtitle".localized
|
||||
windowController.window!.delegate = delegate
|
||||
windowController.window!.styleMask = [
|
||||
.titled, .closable, .resizable, .miniaturizable
|
||||
]
|
||||
windowController.window!.minSize = NSSize(width: 550, height: 200)
|
||||
windowController.window!.delegate = windowController
|
||||
|
||||
App.shared.siteListWindowController = windowController
|
||||
}
|
||||
|
||||
public static func show(delegate: NSWindowDelegate? = nil) {
|
||||
if (App.shared.siteListWindowController == nil) {
|
||||
let storyboard = NSStoryboard(name: "Main" , bundle : nil)
|
||||
let windowController = (storyboard.instantiateController(withIdentifier: "siteListWindow")) as! SiteListWC
|
||||
|
||||
windowController.window!.title = "site_list.title".localized
|
||||
windowController.window!.subtitle = "site_list.subtitle".localized
|
||||
windowController.window!.delegate = delegate
|
||||
windowController.window!.styleMask = [.titled, .closable, .resizable]
|
||||
windowController.window!.minSize = NSSize(width: 550, height: 200)
|
||||
windowController.window!.maxSize = NSSize(width: 800, height: 10000)
|
||||
|
||||
App.shared.siteListWindowController = windowController
|
||||
Self.create(delegate: delegate)
|
||||
}
|
||||
|
||||
App.shared.siteListWindowController!.showWindow(self)
|
||||
@@ -57,9 +66,7 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
||||
self.sites = Valet.shared.sites
|
||||
}
|
||||
|
||||
override func viewWillAppear() {}
|
||||
|
||||
override func viewWillDisappear() {}
|
||||
|
||||
|
||||
// MARK: - Site Data Loading
|
||||
|
||||
|
||||
@@ -8,16 +8,28 @@
|
||||
|
||||
import Cocoa
|
||||
|
||||
class SiteListWC: NSWindowController, NSSearchFieldDelegate, NSToolbarDelegate {
|
||||
class SiteListWC: PMWindowController, NSSearchFieldDelegate, NSToolbarDelegate {
|
||||
|
||||
// MARK: - Window Identifier
|
||||
|
||||
override var windowName: String {
|
||||
return "SiteList"
|
||||
}
|
||||
|
||||
// MARK: - Outlets
|
||||
|
||||
@IBOutlet weak var searchToolbarItem: NSSearchToolbarItem!
|
||||
|
||||
// MARK: - Window Lifecycle
|
||||
|
||||
override func windowDidLoad() {
|
||||
super.windowDidLoad()
|
||||
self.searchToolbarItem.searchField.delegate = self
|
||||
self.searchToolbarItem.searchField.becomeFirstResponder()
|
||||
}
|
||||
|
||||
// MARK: - Search functionality
|
||||
|
||||
var contentVC: SiteListVC {
|
||||
return self.contentViewController as! SiteListVC
|
||||
}
|
||||
@@ -31,6 +43,8 @@ class SiteListWC: NSWindowController, NSSearchFieldDelegate, NSToolbarDelegate {
|
||||
contentVC.searchedFor(text: searchField.stringValue)
|
||||
}
|
||||
|
||||
// MARK: - Reload functionality
|
||||
|
||||
@IBAction func pressedReload(_ sender: Any) {
|
||||
contentVC.reloadSites()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user