Remember last OPML export account, suggest account name for OPML export file name, allow export of inactive accounts. Issue #659 & Issue #652
This commit is contained in:
parent
0da916fa68
commit
4667035e61
|
@ -29,6 +29,7 @@ struct AppDefaults {
|
||||||
static let addFeedAccountID = "addFeedAccountID"
|
static let addFeedAccountID = "addFeedAccountID"
|
||||||
static let addFolderAccountID = "addFolderAccountID"
|
static let addFolderAccountID = "addFolderAccountID"
|
||||||
static let importOPMLAccountID = "importOPMLAccountID"
|
static let importOPMLAccountID = "importOPMLAccountID"
|
||||||
|
static let exportOPMLAccountID = "exportOPMLAccountID"
|
||||||
|
|
||||||
// Hidden prefs
|
// Hidden prefs
|
||||||
static let showTitleOnMainWindow = "KafasisTitleMode"
|
static let showTitleOnMainWindow = "KafasisTitleMode"
|
||||||
|
@ -109,6 +110,15 @@ struct AppDefaults {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static var exportOPMLAccountID: String? {
|
||||||
|
get {
|
||||||
|
return string(for: Key.exportOPMLAccountID)
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
setString(for: Key.exportOPMLAccountID, newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static var showTitleOnMainWindow: Bool {
|
static var showTitleOnMainWindow: Bool {
|
||||||
return bool(for: Key.showTitleOnMainWindow)
|
return bool(for: Key.showTitleOnMainWindow)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,17 +19,23 @@ class ExportOPMLWindowController: NSWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
override func windowDidLoad() {
|
override func windowDidLoad() {
|
||||||
|
|
||||||
accountPopUpButton.removeAllItems()
|
accountPopUpButton.removeAllItems()
|
||||||
|
|
||||||
let menu = NSMenu()
|
let menu = NSMenu()
|
||||||
for oneAccount in AccountManager.shared.sortedActiveAccounts {
|
accountPopUpButton.menu = menu
|
||||||
|
|
||||||
|
for oneAccount in AccountManager.shared.sortedAccounts {
|
||||||
|
|
||||||
let oneMenuItem = NSMenuItem()
|
let oneMenuItem = NSMenuItem()
|
||||||
oneMenuItem.title = oneAccount.nameForDisplay
|
oneMenuItem.title = oneAccount.nameForDisplay
|
||||||
oneMenuItem.representedObject = oneAccount
|
oneMenuItem.representedObject = oneAccount
|
||||||
menu.addItem(oneMenuItem)
|
menu.addItem(oneMenuItem)
|
||||||
}
|
|
||||||
accountPopUpButton.menu = menu
|
|
||||||
|
|
||||||
|
if oneAccount.accountID == AppDefaults.exportOPMLAccountID {
|
||||||
|
accountPopUpButton.select(oneMenuItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: API
|
// MARK: API
|
||||||
|
@ -38,8 +44,8 @@ class ExportOPMLWindowController: NSWindowController {
|
||||||
|
|
||||||
self.hostWindow = hostWindow
|
self.hostWindow = hostWindow
|
||||||
|
|
||||||
if AccountManager.shared.activeAccounts.count == 1 {
|
if AccountManager.shared.accounts.count == 1 {
|
||||||
let account = AccountManager.shared.activeAccounts.first!
|
let account = AccountManager.shared.accounts.first!
|
||||||
exportOPML(account: account)
|
exportOPML(account: account)
|
||||||
} else {
|
} else {
|
||||||
hostWindow.beginSheet(window!)
|
hostWindow.beginSheet(window!)
|
||||||
|
@ -60,6 +66,7 @@ class ExportOPMLWindowController: NSWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
let account = menuItem.representedObject as! Account
|
let account = menuItem.representedObject as! Account
|
||||||
|
AppDefaults.exportOPMLAccountID = account.accountID
|
||||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
||||||
exportOPML(account: account)
|
exportOPML(account: account)
|
||||||
|
|
||||||
|
@ -75,7 +82,9 @@ class ExportOPMLWindowController: NSWindowController {
|
||||||
panel.nameFieldLabel = NSLocalizedString("Export to:", comment: "Export OPML")
|
panel.nameFieldLabel = NSLocalizedString("Export to:", comment: "Export OPML")
|
||||||
panel.message = NSLocalizedString("Choose a location for the exported OPML file.", comment: "Export OPML")
|
panel.message = NSLocalizedString("Choose a location for the exported OPML file.", comment: "Export OPML")
|
||||||
panel.isExtensionHidden = false
|
panel.isExtensionHidden = false
|
||||||
panel.nameFieldStringValue = "MySubscriptions.opml"
|
|
||||||
|
let accountName = account.nameForDisplay.replacingOccurrences(of: " ", with: "").trimmingCharacters(in: .whitespaces)
|
||||||
|
panel.nameFieldStringValue = "\(accountName).opml"
|
||||||
|
|
||||||
panel.beginSheetModal(for: hostWindow!) { result in
|
panel.beginSheetModal(for: hostWindow!) { result in
|
||||||
if result == NSApplication.ModalResponse.OK, let url = panel.url {
|
if result == NSApplication.ModalResponse.OK, let url = panel.url {
|
||||||
|
|
Loading…
Reference in New Issue