Merge pull request #1110 from correia/bug-1108

The Debug menu can now be enabled in release builds.
This commit is contained in:
Brent Simmons 2019-10-06 21:22:58 -07:00 committed by GitHub
commit fae21082b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 8 deletions

View File

@ -33,6 +33,7 @@ struct AppDefaults {
static let exportOPMLAccountID = "exportOPMLAccountID" static let exportOPMLAccountID = "exportOPMLAccountID"
// Hidden prefs // Hidden prefs
static let showDebugMenu = "ShowDebugMenu"
static let timelineShowsSeparators = "CorreiaSeparators" static let timelineShowsSeparators = "CorreiaSeparators"
static let showTitleOnMainWindow = "KafasisTitleMode" static let showTitleOnMainWindow = "KafasisTitleMode"
static let hideDockUnreadCount = "JustinMillerHideDockUnreadCount" static let hideDockUnreadCount = "JustinMillerHideDockUnreadCount"
@ -143,6 +144,10 @@ struct AppDefaults {
return bool(for: Key.hideDockUnreadCount) return bool(for: Key.hideDockUnreadCount)
} }
static var showDebugMenu: Bool {
return bool(for: Key.showDebugMenu)
}
#if !MAC_APP_STORE #if !MAC_APP_STORE
static var webInspectorEnabled: Bool { static var webInspectorEnabled: Bool {
get { get {
@ -196,7 +201,22 @@ struct AppDefaults {
} }
static func registerDefaults() { static func registerDefaults() {
let defaults: [String : Any] = [Key.lastImageCacheFlushDate: Date(), Key.sidebarFontSize: FontSize.medium.rawValue, Key.timelineFontSize: FontSize.medium.rawValue, Key.detailFontSize: FontSize.medium.rawValue, Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue, "NSScrollViewShouldScrollUnderTitlebar": false, Key.refreshInterval: RefreshInterval.everyHour.rawValue] #if DEBUG
let showDebugMenu = true
#else
let showDebugMenu = false
#endif
let defaults: [String : Any] = [
Key.lastImageCacheFlushDate: Date(),
Key.sidebarFontSize: FontSize.medium.rawValue,
Key.timelineFontSize: FontSize.medium.rawValue,
Key.detailFontSize: FontSize.medium.rawValue,
Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue,
"NSScrollViewShouldScrollUnderTitlebar": false,
Key.refreshInterval: RefreshInterval.everyHour.rawValue,
Key.showDebugMenu: showDebugMenu,
]
UserDefaults.standard.register(defaults: defaults) UserDefaults.standard.register(defaults: defaults)

View File

@ -175,18 +175,25 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
refreshTimer = AccountRefreshTimer() refreshTimer = AccountRefreshTimer()
syncTimer = ArticleStatusSyncTimer() syncTimer = ArticleStatusSyncTimer()
#if RELEASE if AppDefaults.showDebugMenu {
refreshTimer!.update()
syncTimer!.update()
// The Web Inspector uses SPI and can never appear in a MAC_APP_STORE build.
#if MAC_APP_STORE
let debugMenu = debugMenuItem.submenu!
let toggleWebInspectorItemIndex = debugMenu.indexOfItem(withTarget: self, andAction: #selector(toggleWebInspectorEnabled(_:)))
if toggleWebInspectorItemIndex != -1 {
debugMenu.removeItem(at: toggleWebInspectorItemIndex)
}
#endif
} else {
debugMenuItem.menu?.removeItem(debugMenuItem) debugMenuItem.menu?.removeItem(debugMenuItem)
DispatchQueue.main.async { DispatchQueue.main.async {
self.refreshTimer!.timedRefresh(nil) self.refreshTimer!.timedRefresh(nil)
self.syncTimer!.timedRefresh(nil) self.syncTimer!.timedRefresh(nil)
} }
#endif }
#if DEBUG
refreshTimer!.update()
syncTimer!.update()
#endif
#if !MAC_APP_STORE #if !MAC_APP_STORE
DispatchQueue.main.async { DispatchQueue.main.async {
@ -309,11 +316,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
if item.action == #selector(showAddFeedWindow(_:)) || item.action == #selector(showAddFolderWindow(_:)) { if item.action == #selector(showAddFeedWindow(_:)) || item.action == #selector(showAddFolderWindow(_:)) {
return !isDisplayingSheet && !AccountManager.shared.activeAccounts.isEmpty return !isDisplayingSheet && !AccountManager.shared.activeAccounts.isEmpty
} }
#if !MAC_APP_STORE #if !MAC_APP_STORE
if item.action == #selector(toggleWebInspectorEnabled(_:)) { if item.action == #selector(toggleWebInspectorEnabled(_:)) {
(item as! NSMenuItem).state = AppDefaults.webInspectorEnabled ? .on : .off (item as! NSMenuItem).state = AppDefaults.webInspectorEnabled ? .on : .off
} }
#endif #endif
return true return true
} }