Skip to content

Commit

Permalink
Close add build info to About window, #3977 (#4066)
Browse files Browse the repository at this point in the history
* Close add build info to About window, #3977

This commit will:
- Add a new class InfoDictionary that exposes some Info.plist entries as
  properties
- Change AppDelegate, GuideWindowController, InitialWindowController,
  and JavascriptAPICore to use InfoDictionary instead of methods in
  the Utility class
- Remove iinaCopyright and iinaVersion methods from Utility class
- Add FFmpeg version to About window
- Add build date and build branch as hidden entries in About window that
  are exposed via an option-click

* Close add build info to About window, #3977

Addressed review comments.

This commit will:
- Add a new class InfoDictionary that exposes some Info.plist entries as
  properties
- Change AppDelegate, GuideWindowController, InitialWindowController,
  and JavascriptAPICore to use InfoDictionary instead of methods in
  the Utility class
- Remove iinaCopyright and iinaVersion methods from Utility class
- Add FFmpeg version to About window
- Add build date and build branch as hidden entries in About window that
  are exposed via an option-click

* Close add build info to About window, #3977

This commit will:

- Add a new class InfoDictionary that exposes some Info.plist
  entries as properties
- Change AppDelegate, GuideWindowController, InitialWindowController,
  and JavascriptAPICore to use InfoDictionary instead of methods in
  the Utility class
- Remove iinaCopyright and iinaVersion methods from Utility class
- Add FFmpeg version to About window
- Add build date and build branch to About window

Updated to not require an option-click to expose the build info as per
review comments.
  • Loading branch information
low-batt committed Mar 24, 2023
1 parent 0989edc commit 98af145
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 86 deletions.
4 changes: 4 additions & 0 deletions iina.xcodeproj/project.pbxproj
Expand Up @@ -15,6 +15,7 @@
49542986216C34950058F680 /* OpenInIINA.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 49542973216C34950058F680 /* OpenInIINA.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
496B19921E2968530035AF10 /* PIP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 496B19911E2968530035AF10 /* PIP.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
519872FF26879B9B00F84BCC /* AccessibilityPreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519872FE26879B9B00F84BCC /* AccessibilityPreferences.swift */; };
51C1BA3A291CA76700C1208A /* InfoDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51C1BA39291CA76700C1208A /* InfoDictionary.swift */; };
51F7974728C7E00200812D0D /* Lock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51F7974628C7E00200812D0D /* Lock.swift */; };
6100FF2B1EDF9806002CF0FB /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 6100FF2A1EDF9806002CF0FB /* dsa_pub.pem */; };
8400D5C41E17C6D2006785F5 /* AboutWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8400D5C21E17C6D2006785F5 /* AboutWindowController.swift */; };
Expand Down Expand Up @@ -774,6 +775,7 @@
496B19911E2968530035AF10 /* PIP.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PIP.framework; path = ../../../../System/Library/PrivateFrameworks/PIP.framework; sourceTree = "<group>"; };
49F7E3BF2920D65C002DA28E /* Availability.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Availability.xcconfig; sourceTree = "<group>"; };
519872FE26879B9B00F84BCC /* AccessibilityPreferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityPreferences.swift; sourceTree = "<group>"; };
51C1BA39291CA76700C1208A /* InfoDictionary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InfoDictionary.swift; sourceTree = "<group>"; };
51F7974628C7E00200812D0D /* Lock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Lock.swift; sourceTree = "<group>"; };
5879479521A87DD700757A6F /* sk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sk; path = sk.lproj/MiniPlayerWindowController.strings; sourceTree = "<group>"; };
5879479621A87E6100757A6F /* sk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sk; path = sk.lproj/PreferenceWindowController.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2105,6 +2107,7 @@
E301EFD921312AB300BC8588 /* KeychainAccess.swift */,
E38B3215214FF700000F6D27 /* EventController.swift */,
E39A11FC240F176E00A67F9F /* StringEncodingName.swift */,
51C1BA39291CA76700C1208A /* InfoDictionary.swift */,
);
name = Utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -2928,6 +2931,7 @@
845040471E0B0F500079C194 /* CropSettingsViewController.swift in Sources */,
E33836852026223800ABC812 /* PrefOSCToolbarSettingsSheetController.swift in Sources */,
E3958586253309C90096811F /* PluginSidebarView.swift in Sources */,
51C1BA3A291CA76700C1208A /* InfoDictionary.swift in Sources */,
E301EFDA21312AB300BC8588 /* KeychainAccess.swift in Sources */,
8434BAA71D5DF2DA003BECF2 /* Extensions.swift in Sources */,
845404AC1E43980900B02B12 /* LuaScript.swift in Sources */,
Expand Down
17 changes: 15 additions & 2 deletions iina/AboutWindowController.swift
Expand Up @@ -38,6 +38,11 @@ class AboutWindowController: NSWindowController {
}
@IBOutlet weak var versionLabel: NSTextField!
@IBOutlet weak var mpvVersionLabel: NSTextField!
@IBOutlet weak var ffmpegVersionLabel: NSTextField!
@IBOutlet weak var buildView: NSView!
@IBOutlet weak var buildBranchLabel: NSTextField!
@IBOutlet weak var buildDateLabel: NSTextField!

@IBOutlet var detailTextView: NSTextView!
@IBOutlet var creditsTextView: NSTextView!

Expand All @@ -63,11 +68,19 @@ class AboutWindowController: NSWindowController {
windowBackgroundBox.fillColor = .windowBackgroundColor
iconImageView.image = NSApp.applicationIconImage

let (version, build) = Utility.iinaVersion()
let (version, build) = InfoDictionary.shared.version
versionLabel.stringValue = "\(version) Build \(build)"
// let copyright = infoDic["NSHumanReadableCopyright"] as! String

mpvVersionLabel.stringValue = PlayerCore.active.mpv.mpvVersion
ffmpegVersionLabel.stringValue = "FFmpeg \(String(cString: av_version_info()))"

if let buildDate = InfoDictionary.shared.buildDate,
let buildBranch = InfoDictionary.shared.buildBranch {
buildDateLabel.stringValue = buildDate
buildDateLabel.isHidden = false
buildBranchLabel.stringValue = buildBranch
buildBranchLabel.isHidden = false
}

if let contrubutionFile = Bundle.main.path(forResource: "Contribution", ofType: "rtf") {
detailTextView.readRTFD(fromFile: contrubutionFile)
Expand Down
25 changes: 6 additions & 19 deletions iina/AppDelegate.swift
Expand Up @@ -112,36 +112,23 @@ class AppDelegate: NSObject, NSApplicationDelegate, SPUUpdaterDelegate {
/// - The git branch
/// - The git commit
private func logBuildDetails() {
// Xcode refused to allow the build date in the Info.plist to use Date as the type because the
// value specified in the Info.plist is an identifier that is replaced at build time using the
// C preprocessor. So we need to convert from the ISO formatted string to a Date object.
let fromString = ISO8601DateFormatter()
// As recommended by Apple IINA's custom Info.plist keys start with the bundle identifier.
guard let infoDic = Bundle.main.infoDictionary,
let bundleIdentifier = infoDic["CFBundleIdentifier"] as? String else { return }
let keyPrefix = bundleIdentifier + ".build"
guard let branch = infoDic["\(keyPrefix).branch"] as? String,
let commit = infoDic["\(keyPrefix).commit"] as? String,
let date = infoDic["\(keyPrefix).date"] as? String,
let dateObj = fromString.date(from: date) else { return }
// Use a localized date in the log message.
let toString = DateFormatter()
toString.dateStyle = .medium
toString.timeStyle = .medium
Logger.log("Built \(toString.string(from: dateObj)) from branch \(branch), commit \(commit)")
guard let branch = InfoDictionary.shared.buildBranch,
let commit = InfoDictionary.shared.buildCommit,
let date = InfoDictionary.shared.buildDate else { return }
Logger.log("Built \(date) from branch \(branch), commit \(commit)")
}

func applicationWillFinishLaunching(_ notification: Notification) {
// Must setup preferences before logging so log level is set correctly.
registerUserDefaultValues()

// Start the log file by logging the version of IINA producing the log file.
let (version, build) = Utility.iinaVersion()
let (version, build) = InfoDictionary.shared.version
Logger.log("IINA \(version) Build \(build)")

// The copyright is used in the Finder "Get Info" window which is a narrow window so the
// copyright consists of multiple lines.
let copyright = Utility.iinaCopyright()
let copyright = InfoDictionary.shared.copyright
copyright.enumerateLines { line, _ in
Logger.log(line)
}
Expand Down

0 comments on commit 98af145

Please sign in to comment.