mirror of
https://github.com/MonitorControl/MonitorControl.git
synced 2026-05-15 14:15:55 -06:00
sorting by name added (#1774)
This commit is contained in:
parent
d4309e6ec5
commit
195a8e88ec
4 changed files with 35 additions and 4 deletions
|
|
@ -19,7 +19,7 @@
|
|||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>7122</string>
|
||||
<string>7141</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
|
|
|||
|
|
@ -240,8 +240,38 @@ class DisplayManager {
|
|||
self.displays.compactMap { $0 as? OtherDisplay }
|
||||
}
|
||||
|
||||
func sortDisplays() {
|
||||
// Opsiyonel: sıralamadan önce log al
|
||||
let before = displays.map { $0.name }
|
||||
os_log("Displays before sorting: %{public}@", before)
|
||||
|
||||
// In‑place sıralama
|
||||
displays.sort { lhs, rhs in
|
||||
lhs.name.localizedStandardCompare(rhs.name) == .orderedAscending
|
||||
}
|
||||
|
||||
// Opsiyonel: sıralamadan sonra log al
|
||||
let after = displays.map { $0.name }
|
||||
os_log("Displays after sorting: %{public}@", after)
|
||||
}
|
||||
|
||||
func sortDisplaysByFriendlyName() -> [Display] {
|
||||
return displays.sorted { lhs, rhs in
|
||||
let lhsTitle = lhs.readPrefAsString(key: .friendlyName).isEmpty
|
||||
? lhs.name
|
||||
: lhs.readPrefAsString(key: .friendlyName)
|
||||
let rhsTitle = rhs.readPrefAsString(key: .friendlyName).isEmpty
|
||||
? rhs.name
|
||||
: rhs.readPrefAsString(key: .friendlyName)
|
||||
return lhsTitle.localizedStandardCompare(rhsTitle) == .orderedDescending
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// displays dizisini sıralar ve döner
|
||||
func getAllDisplays() -> [Display] {
|
||||
self.displays
|
||||
return displays
|
||||
}
|
||||
|
||||
func getDdcCapableDisplays() -> [OtherDisplay] {
|
||||
|
|
@ -283,7 +313,7 @@ class DisplayManager {
|
|||
func clearDisplays() {
|
||||
self.displays = []
|
||||
}
|
||||
|
||||
|
||||
func addDisplayCounterSuffixes() {
|
||||
var nameDisplays: [String: [Display]] = [:]
|
||||
for display in self.displays {
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class MenuHandler: NSMenu, NSMenuDelegate {
|
|||
displays.append(contentsOf: DisplayManager.shared.getAppleDisplays())
|
||||
}
|
||||
displays.append(contentsOf: DisplayManager.shared.getOtherDisplays())
|
||||
displays = DisplayManager.shared.sortDisplaysByFriendlyName()
|
||||
let relevant = prefs.integer(forKey: PrefKey.multiSliders.rawValue) == MultiSliders.relevant.rawValue
|
||||
let combine = prefs.integer(forKey: PrefKey.multiSliders.rawValue) == MultiSliders.combine.rawValue
|
||||
let numOfDisplays = displays.filter { !$0.isDummy }.count
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>7122</string>
|
||||
<string>7141</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSBackgroundOnly</key>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue