Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
feat: All options
Browse files Browse the repository at this point in the history
  • Loading branch information
zengxs committed Jul 4, 2019
1 parent 3720961 commit bf66bd6
Show file tree
Hide file tree
Showing 5 changed files with 477 additions and 40 deletions.
24 changes: 22 additions & 2 deletions EhautX/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,24 @@ extension PreferencePane.Identifier {
}

extension DefaultsKeys {
static let server = DefaultsKey<String>("server", defaultValue: "http://172.16.154.130:69/cgi-bin/srun_portal")
static let authServer = DefaultsKey<String>("authServer", defaultValue: "http://172.16.154.130/cgi-bin/srun_portal")
static let msgServer = DefaultsKey<String>("msgServer", defaultValue: "http://172.16.154.130/get_msg.php")
static let infoServer = DefaultsKey<String>("infoServer", defaultValue: "http://172.16.154.130/cgi-bin/rad_user_info")
static let username = DefaultsKey<String?>("username")
static let password = DefaultsKey<String?>("password")
static let passwordKey = DefaultsKey<String>("passwordKey", defaultValue: "1234567890")

static let acid = DefaultsKey<String>("acid", defaultValue: "1")
static let type = DefaultsKey<String>("type", defaultValue: "10")
static let n = DefaultsKey<String>("n", defaultValue: "117")
static let drop = DefaultsKey<String>("drop", defaultValue: "0")
static let pop = DefaultsKey<String>("pop", defaultValue: "1")
static let mbytes = DefaultsKey<String>("mbytes", defaultValue: "0")
static let minutes = DefaultsKey<String>("minutes", defaultValue: "0")

static let only_acid = DefaultsKey<Bool>("only_acid", defaultValue: false)

static let timeout = DefaultsKey<Int>("timeout", defaultValue: 3)
}

@NSApplicationMain
Expand Down Expand Up @@ -47,7 +61,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let menu = NSMenu()
menu.addItem(NSMenuItem(
title: "About",
action: #selector(NSApplication.shared.orderFrontStandardAboutPanel(options:)),
action: #selector(NSApplication.shared.orderFrontStandardAboutPanel(_:)),
keyEquivalent: ""
))
menu.addItem(NSMenuItem.separator())
Expand All @@ -56,6 +70,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
action: #selector(self.preferencesMenuItemActionHandler(_:)),
keyEquivalent: ","
))
menu.addItem(NSMenuItem.separator())
menu.addItem(NSMenuItem(
title: "Quit",
action: #selector(NSApplication.shared.terminate(_:)),
keyEquivalent: "q"
))

statusItem.menu = menu
}
Expand Down
56 changes: 53 additions & 3 deletions EhautX/Views/AdvancedPrefsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,66 @@ class AdvancedPrefsViewController: NSViewController, PreferencePane {
let preferencePaneTitle = "Advanced"
let toolbarItemIcon = NSImage(named: NSImage.advancedName)!

@objc dynamic var server: String {
get { return Defaults[.server] }
set { Defaults[.server] = newValue }
@objc dynamic var authServer: String {
get { return Defaults[.authServer] }
set { Defaults[.authServer] = newValue }
}

@objc dynamic var msgServer: String {
get { return Defaults[.msgServer] }
set { Defaults[.msgServer] = newValue }
}

@objc dynamic var infoServer: String {
get { return Defaults[.infoServer] }
set { Defaults[.infoServer] = newValue }
}

@objc dynamic var passwordKey: String {
get { return Defaults[.passwordKey] }
set { Defaults[.passwordKey] = newValue }
}

@objc dynamic var acid: String {
get { return Defaults[.acid] }
set { Defaults[.acid] = newValue }
}

@objc dynamic var only_acid: Bool {
get { return Defaults[.only_acid] }
set { Defaults[.only_acid] = newValue }
}

@objc dynamic var type: String {
get { return Defaults[.type] }
set { Defaults[.type] = newValue }
}

@objc dynamic var n: String {
get { return Defaults[.n] }
set { Defaults[.n] = newValue }
}

@objc dynamic var drop: String {
get { return Defaults[.drop] }
set { Defaults[.drop] = newValue }
}

@objc dynamic var pop: String {
get { return Defaults[.pop] }
set { Defaults[.pop] = newValue }
}

@objc dynamic var mbytes: String {
get { return Defaults[.mbytes] }
set { Defaults[.mbytes] = newValue }
}

@objc dynamic var minutes: String {
get { return Defaults[.minutes] }
set { Defaults[.minutes] = newValue }
}

override func viewDidLoad() {
super.viewDidLoad()
// Do view setup here.
Expand Down
Loading

0 comments on commit bf66bd6

Please sign in to comment.