Browse Source

Menu options!

pull/92/head
Abhishek 5 years ago
parent
commit
6487bf27c1
  1. 2
      Clocker/Clocker/en.lproj/Panel.xib
  2. 45
      Clocker/Panel/ParentPanelController.swift

2
Clocker/Clocker/en.lproj/Panel.xib

@ -461,7 +461,7 @@
</buttonCell>
<accessibility identifier="Close"/>
<connections>
<action selector="terminate:" target="-1" id="ZY8-sG-rkC"/>
<action selector="showMoreOptions:" target="-2" id="xl5-rm-4JK"/>
</connections>
</button>
<button toolTip="Switch between Menubar/Floating mode." verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="YXE-4J-5cn">

45
Clocker/Panel/ParentPanelController.swift

@ -922,6 +922,51 @@ class ParentPanelController: NSWindowController {
sliderDatePicker.dateValue = Date()
setTimezoneDatasourceSlider(sliderValue: 0)
}
@objc func terminateClocker() {
NSApplication.shared.terminate(nil)
}
@objc func reportIssue() {
feedbackWindow.showWindow(nil)
NSApp.activate(ignoringOtherApps: true)
window?.orderOut(nil)
if let countryCode = Locale.autoupdatingCurrent.regionCode {
let custom: [String: Any] = ["Country": countryCode]
Logger.log(object: custom, for: "Report Issue Opened")
}
}
@objc func openCrowdin() {
guard let localizationURL = URL(string: AboutUsConstants.CrowdInLocalizationLink),
let languageCode = Locale.preferredLanguages.first else { return }
NSWorkspace.shared.open(localizationURL)
// Log this
let custom: [String: Any] = ["Language": languageCode]
Logger.log(object: custom, for: "Opened Localization Link")
}
@IBAction func showMoreOptions(_ sender: NSButton) {
let menuItem = NSMenu(title: "More Options")
let terminateOption = NSMenuItem(title: "Quit Clocker",
action: #selector(terminateClocker), keyEquivalent: "")
let rateClocker = NSMenuItem(title: "Support Clocker",
action: #selector(terminateClocker), keyEquivalent: "")
let sendFeedback = NSMenuItem(title: "Send Feedback",
action: #selector(reportIssue), keyEquivalent: "")
let localizeClocker = NSMenuItem(title: "Localize Clocker in your own language",
action: #selector(openCrowdin), keyEquivalent: "")
menuItem.addItem(terminateOption)
menuItem.addItem(rateClocker)
menuItem.addItem(sendFeedback)
menuItem.addItem(localizeClocker)
NSMenu.popUpContextMenu(menuItem,
with: NSApp.currentEvent!,
for: sender)
}
}
extension ParentPanelController: NSPopoverDelegate {

Loading…
Cancel
Save