From b14c2aabab33618174516aa879d437a7d3a7b41b Mon Sep 17 00:00:00 2001 From: John Date: Wed, 26 Aug 2020 20:23:43 +0100 Subject: [PATCH] Adds version/build number to Preferences window. --- SyncthingBar/Base.lproj/PreferencesWindow.xib | 54 ++++++++++++------- .../PreferencesWindowController.swift | 14 +++++ 2 files changed, 50 insertions(+), 18 deletions(-) diff --git a/SyncthingBar/Base.lproj/PreferencesWindow.xib b/SyncthingBar/Base.lproj/PreferencesWindow.xib index 056b223..ec7c33a 100644 --- a/SyncthingBar/Base.lproj/PreferencesWindow.xib +++ b/SyncthingBar/Base.lproj/PreferencesWindow.xib @@ -1,8 +1,8 @@ - + - + @@ -11,6 +11,7 @@ + @@ -18,14 +19,14 @@ - - - - + + + + - + @@ -61,7 +62,7 @@ - + @@ -97,7 +98,7 @@ - + @@ -105,10 +106,10 @@ - + - + @@ -119,7 +120,7 @@ - + + + + + + + + + + + + + + - + + + @@ -194,6 +210,8 @@ + + @@ -204,7 +222,7 @@ - + diff --git a/SyncthingBar/PreferencesWindowController.swift b/SyncthingBar/PreferencesWindowController.swift index 3349471..1c9651b 100644 --- a/SyncthingBar/PreferencesWindowController.swift +++ b/SyncthingBar/PreferencesWindowController.swift @@ -22,6 +22,20 @@ class PreferencesWindowController: NSWindowController { @IBOutlet weak var syncthingPathTextField: NSTextField! + @IBOutlet weak var versionLabel: NSTextField! + + override func windowDidLoad() { + super.windowDidLoad() + + if let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String, + let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String { + self.versionLabel.stringValue = "Syncthing Bar v\(version) (\(build))" + self.versionLabel.isHidden = false + } else { + self.versionLabel.isHidden = true + } + } + @objc func windowWillClose(_ notification: Notification) { // Ensure we sync UserDefaults: bindings do not update when the window closes.