Skip to content

Commit

Permalink
Switch to Swift 3
Browse files Browse the repository at this point in the history
  • Loading branch information
vishaltelangre committed Feb 4, 2017
1 parent 387b028 commit 0a69a0b
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 68 deletions.
10 changes: 9 additions & 1 deletion Kyapchar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0730;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = "Vishal Telangre";
TargetAttributes = {
089CD7501DC7B742005067DB = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0820;
};
};
};
Expand Down Expand Up @@ -168,8 +169,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
Expand Down Expand Up @@ -213,8 +216,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
Expand All @@ -233,6 +238,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.11;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
Expand All @@ -245,6 +251,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.vishaltelangre.Kyapchar;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -257,6 +264,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.vishaltelangre.Kyapchar;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions Kyapchar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

func applicationDidFinishLaunching(aNotification: NSNotification) {
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
}

func applicationWillTerminate(aNotification: NSNotification) {
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}

Expand Down
36 changes: 18 additions & 18 deletions Kyapchar/MenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,46 @@ class MenuController: NSObject {
@IBOutlet weak var recordStopItem: NSMenuItem!
@IBOutlet weak var pauseResumeItem: NSMenuItem!

let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(NSSquareStatusItemLength)
let statusItem = NSStatusBar.system().statusItem(withLength: NSSquareStatusItemLength)

var recorder: Recorder!

var menubarIconAnimationTimer: NSTimer?
var menubarIconAnimationTimer: Timer?
var menubarIconCurrentIndex = 0

@IBAction func onRecordStopItemClick(sender: NSMenuItem) {
@IBAction func onRecordStopItemClick(_ sender: NSMenuItem) {
if recorder.recording {
recorder.stop()
recordStopItem.enabled = false
recordStopItem.isEnabled = false
recordStopItem.title = "Please wait..."
} else {
recorder.start()
}
}

@IBAction func onPauseResumeItemClick(sender: NSMenuItem) {
@IBAction func onPauseResumeItemClick(_ sender: NSMenuItem) {
if recorder.paused {
recorder.resume()
} else {
recorder.pause()
}
}

@IBAction func onQuitItemClick(sender: NSMenuItem) {
NSApplication.sharedApplication().terminate(self)
@IBAction func onQuitItemClick(_ sender: NSMenuItem) {
NSApplication.shared().terminate(self)
}

override func awakeFromNib() {
statusItem.button?.image = NSImage(named: "record")

pauseResumeItem.enabled = false
pauseResumeItem.isEnabled = false

statusItem.menu = barMenu
recorder = Recorder(delegate: self)
}

func animateMenubarIcon() {
menubarIconAnimationTimer = NSTimer.scheduledTimerWithTimeInterval(1/2, target: self, selector: #selector(MenuController.changeMenubarIcon), userInfo: nil, repeats: true)
menubarIconAnimationTimer = Timer.scheduledTimer(timeInterval: 1/2, target: self, selector: #selector(MenuController.changeMenubarIcon), userInfo: nil, repeats: true)
}

func stopMenubarIconAnimation() {
Expand All @@ -74,44 +74,44 @@ class MenuController: NSObject {

extension MenuController: RecorderDelegate {

func recordingDidStart(recordingInfo: RecordingInfo?) {
func recordingDidStart(_ recordingInfo: RecordingInfo?) {
recordStopItem.title = "Stop"
animateMenubarIcon()

pauseResumeItem.enabled = true
pauseResumeItem.isEnabled = true
pauseResumeItem.title = "Pause"
}

func recordingDidStop(recordingInfo: RecordingInfo?) {
recordStopItem.enabled = true
func recordingDidStop(_ recordingInfo: RecordingInfo?) {
recordStopItem.isEnabled = true
recordStopItem.title = "Record"

stopMenubarIconAnimation()

statusItem.button?.image = NSImage(named: "record")

pauseResumeItem.enabled = false
pauseResumeItem.isEnabled = false
pauseResumeItem.title = "Pause"

recorder = nil
recorder = Recorder(delegate: self)

if recordingInfo?.location != nil {
NSWorkspace.sharedWorkspace().activateFileViewerSelectingURLs([recordingInfo!.location])
NSWorkspace.shared().activateFileViewerSelecting([recordingInfo!.location as URL])
}
}

func recordingDidResume(recordingInfo: RecordingInfo?) {
func recordingDidResume(_ recordingInfo: RecordingInfo?) {
pauseResumeItem.title = "Pause"
animateMenubarIcon()
}

func recordingDidPause(recordingInfo: RecordingInfo?) {
func recordingDidPause(_ recordingInfo: RecordingInfo?) {
pauseResumeItem.title = "Resume"

stopMenubarIconAnimation()

statusItem.button?.image = NSImage(named: "pause")
}

}
}
Loading

0 comments on commit 0a69a0b

Please sign in to comment.