123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- //
- // KMNBaseViewController.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2023/5/5.
- //
- import Cocoa
- class KMNBaseViewController: NSViewController {
-
- var progressC: SKProgressController?
-
- deinit {
- KMPrint(self.className + " deinit.")
-
- self.removeNotifations()
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- initContentView()
- self.addNotifations()
- }
-
- // Noti
- func addNotifations() {
- updateUIThemeColor()
- NotificationCenter.default.addObserver(self, selector: #selector(updateUIThemeColor), name: APPAppearanceChangedNotificationName, object: nil)
-
- updateUILanguage()
- NotificationCenter.default.addObserver(self, selector: #selector(updateUILanguage), name: APPLanguageChangedNotificationName, object: nil)
- }
-
- func removeNotifations() {
- NotificationCenter.default.removeObserver(self)
- }
-
- @objc func updateUIThemeColor() {}
-
- @objc func updateUILanguage() {}
-
- func initContentView() {}
-
- func showProgressWindow(message: String = "") {
- if (self.progressC != nil) {
- self.hiddenProgressWindow()
- }
-
- let progressC = SKProgressController()
- progressC.window?.backgroundColor = NSColor.km_init(hex: "#36383B")
- progressC.window?.contentView?.wantsLayer = true
- progressC.window?.contentView?.layer?.backgroundColor = NSColor.km_init(hex: "#36383B").cgColor
- progressC.progressField.textColor = NSColor.white
- progressC.showClose = false
- progressC.message = message
- self.progressC = progressC
- self.view.window?.beginSheet(progressC.window!)
- }
-
- func hiddenProgressWindow() {
- if let _progressC = self.progressC {
- if let _window = _progressC.window {
- self.view.window?.endSheet(_window)
- }
- self.progressC = nil
- }
- }
-
- }
|