Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change new shortcut recorder #78

Merged
merged 9 commits into from Jun 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bundle/config
@@ -1,3 +1,3 @@
---
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: true
BUNDLE_DISABLE_SHARED_GEMS: '1'
142 changes: 84 additions & 58 deletions Clipy.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Clipy/AppDelegate.swift
Expand Up @@ -15,6 +15,7 @@ import RxSwift
import RxOptional
import NSObject_Rx
import LoginServiceKit
import Magnet

@NSApplicationMain
class AppDelegate: NSObject {
Expand Down Expand Up @@ -153,7 +154,7 @@ extension AppDelegate: NSApplicationDelegate {
CPYUtilities.registerUserDefaultKeys()

// Regist Hotkeys
CPYHotKeyManager.sharedManager.registerHotKeys()
HotKeyManager.sharedManager.setupDefaultHoyKey()

// Show Login Item
if !defaults.boolForKey(Constants.UserDefaults.loginItem) && !defaults.boolForKey(Constants.UserDefaults.suppressAlertForLoginItem) {
Expand All @@ -176,7 +177,7 @@ extension AppDelegate: NSApplicationDelegate {
}

func applicationWillTerminate(aNotification: NSNotification) {
CPYHotKeyManager.sharedManager.unRegisterHotKeys()
HotKeyCenter.sharedCenter.unregisterAll()
}
}

Expand Down
11 changes: 0 additions & 11 deletions Clipy/Clipy-Bridging-Header.h

This file was deleted.

7 changes: 7 additions & 0 deletions Clipy/Constants.swift
Expand Up @@ -79,4 +79,11 @@ struct Constants {
static let contentElement = "content"
}

struct HotKey {
static let mainKeyCombo = "kCPYHotKeyMainKeyCombo"
static let historyKeyCombo = "kCPYHotKeyHistoryKeyCombo"
static let snippetKeyCombo = "kCPYHotKeySnippetKeyCombo"
static let migrateNewKeyCombo = "kCPYMigrateNewKeyCombo"
}

}
38 changes: 38 additions & 0 deletions Clipy/Enums/MenuType.swift
@@ -0,0 +1,38 @@
//
// MenuType.swift
// Clipy
//
// Created by 古林俊佑 on 2016/06/26.
// Copyright © 2016年 Shunsuke Furubayashi. All rights reserved.
//

import Foundation

enum MenuType: String {
case Main = "ClipMenu"
case History = "HistoryMenu"
case Snippet = "SnippetMenu"

var userDefaultsKey: String {
switch self {
case .Main:
return Constants.HotKey.mainKeyCombo
case .History:
return Constants.HotKey.historyKeyCombo
case .Snippet:
return Constants.HotKey.snippetKeyCombo
}
}

var hotKeySelector: Selector {
switch self {
case .Main:
return #selector(HotKeyManager.popUpClipMenu)
case .History:
return #selector(HotKeyManager.popUpHistoryMenu)
case .Snippet:
return #selector(HotKeyManager.popUpSnippetMenu)
}
}

}
1 change: 1 addition & 0 deletions Clipy/Extensions/NSColor+Clipy.swift
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import Cocoa

extension NSColor {
static func clipyColor() -> NSColor {
Expand Down
1 change: 1 addition & 0 deletions Clipy/Extensions/NSImage+AssetCatalog.swift
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import Cocoa

extension NSImage {

Expand Down
1 change: 1 addition & 0 deletions Clipy/Extensions/NSImage+Resize.swift
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import Cocoa

extension NSImage {
func resizeImage(width: CGFloat, _ height: CGFloat) -> NSImage? {
Expand Down
1 change: 1 addition & 0 deletions Clipy/Extensions/NSMenuItem+Initialize.swift
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import Cocoa

extension NSMenuItem {
convenience init(title: String, action: Selector) {
Expand Down
23 changes: 23 additions & 0 deletions Clipy/Extensions/NSUserDefaults+ArchiveData.swift
@@ -0,0 +1,23 @@
//
// NSUserDefaults+ArchiveData.swift
// Clipy
//
// Created by 古林俊佑 on 2016/06/23.
// Copyright © 2016年 Shunsuke Furubayashi. All rights reserved.
//

import Foundation
import Cocoa

extension NSUserDefaults {
func setArchiveData<T: NSCoding>(object: T, forKey key: String) {
let data = NSKeyedArchiver.archivedDataWithRootObject(object)
setObject(data, forKey: key)
}

func archiveDataForKey<T: NSCoding>(_: T.Type, key: String) -> T? {
guard let data = objectForKey(key) as? NSData else { return nil }
guard let object = NSKeyedUnarchiver.unarchiveObjectWithData(data) as? T else { return nil }
return object
}
}
192 changes: 0 additions & 192 deletions Clipy/Libraries/ShortcutRecorder/SRCommon.h

This file was deleted.