Skip to content

Commit

Permalink
add shortcut setting, rock & roll ~~~
Browse files Browse the repository at this point in the history
  • Loading branch information
qfish committed Dec 3, 2013
1 parent e3b43e2 commit aa30c3f
Show file tree
Hide file tree
Showing 17 changed files with 495 additions and 52 deletions.
4 changes: 4 additions & 0 deletions main/main.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@
E9E24B331837D9960040C1B4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -340,13 +341,15 @@
GCC_PREFIX_HEADER = "main/main-Prefix.pch";
INFOPLIST_FILE = "main/main-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
VALID_ARCHS = "i386 x86_64";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
E9E24B341837D9960040C1B4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -359,6 +362,7 @@
GCC_PREFIX_HEADER = "main/main-Prefix.pch";
INFOPLIST_FILE = "main/main-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
VALID_ARCHS = "i386 x86_64";
WRAPPER_EXTENSION = app;
};
name = Release;
Expand Down
1 change: 1 addition & 0 deletions main/main/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@

- (IBAction)format:(id)sender;
- (IBAction)selectFormatter:(id)sender;
- (IBAction)showSetting:(id)sender;

@end
10 changes: 10 additions & 0 deletions main/main/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "AppDelegate.h"
#import "NSString+XAlign.h"
#import "SettingWindowController.h"
#import <CoreText/CoreText.h>

@implementation AppDelegate
Expand All @@ -24,7 +25,16 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
NSString * replace = [[self testFile:@"2.txt"] stringByAligningWithPatterns:pgs[1]];

NSLog( @"\n%@", replace );
}

- (void)showSetting:(id)sender
{
if ( nil == self.settingWindow )
{
self.settingWindow = [[SettingWindowController alloc] initWithWindowNibName:@"SettingWindowController"];
}

[self.settingWindow showWindow:self.settingWindow];
}

- (IBAction)format:(id)sender
Expand Down
2 changes: 1 addition & 1 deletion main/main/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="format:" target="494" id="9xI-Fe-gb2"/>
<action selector="showSetting:" target="494" id="a9U-O9-UTW"/>
</connections>
</button>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rpU-Fd-yjH">
Expand Down
16 changes: 16 additions & 0 deletions main/main/SettingWindowController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// SettingWindowController.h
// XAlign
//
// Created by QFish on 12/3/13.
// Copyright (c) 2013 net.qfish. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface SettingWindowController : NSWindowController<NSTextFieldDelegate>

@property (nonatomic, strong) IBOutlet NSTextField * key;
@property (nonatomic, strong) IBOutlet NSTextField * mask;

@end
35 changes: 35 additions & 0 deletions main/main/SettingWindowController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// SettingWindowController.m
// XAlign
//
// Created by QFish on 12/3/13.
// Copyright (c) 2013 net.qfish. All rights reserved.
//

//#import "XAlignPluginConfig.h"
#import "SettingWindowController.h"

@interface SettingWindowController ()

@end

@implementation SettingWindowController

- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
{
NSLog( @"\ntextShouldEndEditing:%@", fieldEditor.string );

return YES;
}

- (void)windowDidLoad
{
[super windowDidLoad];
//
// NSDictionary * shortcut = [XAlignPluginConfig keyShortcut];

// self.key.stringValue = shortcut[kMenuShortcutKey];
// self.mask.stringValue = shortcut[kMenuShortcutMask];
}

@end
84 changes: 84 additions & 0 deletions main/main/SettingWindowController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4511" systemVersion="13A603" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4511"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="SettingWindowController">
<connections>
<outlet property="key" destination="p5K-Et-nA0" id="lQT-oo-2qd"/>
<outlet property="mask" destination="ghy-uR-ecW" id="PCL-5X-ou1"/>
<outlet property="window" destination="1" id="3"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" wantsToBeColor="NO" animationBehavior="default" id="1">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="347" height="138"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="778"/>
<view key="contentView" id="2">
<rect key="frame" x="0.0" y="0.0" width="347" height="138"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ghy-uR-ecW">
<rect key="frame" x="73" y="101" width="173" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="center" placeholderString="[ cmd | shift | ctrl | alt ]" drawsBackground="YES" id="McV-xA-DNJ">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<outlet property="delegate" destination="-2" id="hPS-nD-AvX"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hHx-7U-Kg1">
<rect key="frame" x="4" y="104" width="66" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Shortcut :" id="EBz-hG-EqB">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jya-9H-Yhn">
<rect key="frame" x="251" y="104" width="15" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="+" id="YGg-1K-Rpw">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="p5K-Et-nA0">
<rect key="frame" x="270" y="101" width="68" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="center" placeholderString="[a-z]" drawsBackground="YES" id="kdW-x6-djU">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<outlet property="delegate" destination="-2" id="yyr-Lc-5fV"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pjR-TN-4Pk">
<rect key="frame" x="5" y="4" width="337" height="82"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" id="7hp-yr-uaj">
<font key="font" metaFont="system"/>
<string key="title">1. cmd, ctrl, shift, alt connected with '+' or '-'
2. if dosen't work, it may conflict with Xcode default.
 please check the keybinds of Xcode.
3. enter return to apply</string>
<color key="textColor" white="0.0" alpha="0.67000000000000004" colorSpace="deviceWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
<connections>
<outlet property="delegate" destination="-2" id="4"/>
</connections>
</window>
</objects>
</document>
19 changes: 0 additions & 19 deletions main/main/patterns.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>title</key>
<string>Auto Align</string>
<key>selector</key>
<string>autoAlign</string>
<key>shortcut</key>
<dict>
<key>key</key>
<string>x</string>
<key>mask</key>
<string>cmd+shfit</string>
</dict>
</dict>
<dict>
<key>id</key>
<string>0</string>
Expand Down Expand Up @@ -231,11 +218,5 @@
</dict>
</array>
</dict>
<dict>
<key>title</key>
<string>Help</string>
<key>selector</key>
<string>showHelp</string>
</dict>
</array>
</plist>
14 changes: 14 additions & 0 deletions plugin/XAlign.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/* Begin PBXBuildFile section */
E90675DA184B066C00DF234A /* patterns.plist in Resources */ = {isa = PBXBuildFile; fileRef = E90675D9184B066C00DF234A /* patterns.plist */; };
E945FD06184DF37800EC90D5 /* SettingWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = E945FD04184DF37800EC90D5 /* SettingWindowController.m */; };
E945FD07184DF37800EC90D5 /* SettingWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E945FD05184DF37800EC90D5 /* SettingWindowController.xib */; };
E958D428184DE3C600A4A3AC /* setting.plist in Resources */ = {isa = PBXBuildFile; fileRef = E958D427184DE3C600A4A3AC /* setting.plist */; };
E9750DB41837A15F0044F9C7 /* DVTKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E9750DB31837A15F0044F9C7 /* DVTKit.framework */; };
E9750DB81837A1700044F9C7 /* DVTFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E9750DB51837A1700044F9C7 /* DVTFoundation.framework */; };
E9750DB91837A1700044F9C7 /* IDEFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E9750DB61837A1700044F9C7 /* IDEFoundation.framework */; };
Expand All @@ -23,6 +26,10 @@

/* Begin PBXFileReference section */
E90675D9184B066C00DF234A /* patterns.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = patterns.plist; path = ../../main/main/patterns.plist; sourceTree = "<group>"; };
E945FD03184DF37800EC90D5 /* SettingWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingWindowController.h; sourceTree = "<group>"; };
E945FD04184DF37800EC90D5 /* SettingWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingWindowController.m; sourceTree = "<group>"; };
E945FD05184DF37800EC90D5 /* SettingWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SettingWindowController.xib; sourceTree = "<group>"; };
E958D427184DE3C600A4A3AC /* setting.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = setting.plist; sourceTree = "<group>"; };
E9750DB31837A15F0044F9C7 /* DVTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DVTKit.framework; path = ../../../../../../Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework; sourceTree = "<group>"; };
E9750DB51837A1700044F9C7 /* DVTFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DVTFoundation.framework; path = ../../../../../../Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework; sourceTree = "<group>"; };
E9750DB61837A1700044F9C7 /* IDEFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IDEFoundation.framework; path = ../../../../../../Applications/Xcode.app/Contents/Frameworks/IDEFoundation.framework; sourceTree = "<group>"; };
Expand Down Expand Up @@ -135,8 +142,12 @@
isa = PBXGroup;
children = (
E90675D9184B066C00DF234A /* patterns.plist */,
E958D427184DE3C600A4A3AC /* setting.plist */,
E99A085E184A5CA400E5333A /* XAlignPluginConfig.h */,
E99A085F184A5CA400E5333A /* XAlignPluginConfig.m */,
E945FD03184DF37800EC90D5 /* SettingWindowController.h */,
E945FD04184DF37800EC90D5 /* SettingWindowController.m */,
E945FD05184DF37800EC90D5 /* SettingWindowController.xib */,
E98CEAE6184A2BD600EFD95A /* XAlignPlugin.h */,
E98CEAE7184A2BD600EFD95A /* XAlignPlugin.m */,
E9F8D3CE1837349200F0CF4B /* Supporting Files */,
Expand Down Expand Up @@ -206,7 +217,9 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E958D428184DE3C600A4A3AC /* setting.plist in Resources */,
E90675DA184B066C00DF234A /* patterns.plist in Resources */,
E945FD07184DF37800EC90D5 /* SettingWindowController.xib in Resources */,
E9F8D3D21837349200F0CF4B /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -238,6 +251,7 @@
files = (
E98CEAE2184A2B8400EFD95A /* NSString+XAlign.m in Sources */,
E99A0860184A5CA400E5333A /* XAlignPluginConfig.m in Sources */,
E945FD06184DF37800EC90D5 /* SettingWindowController.m in Sources */,
E98CEAE4184A2B8400EFD95A /* SharedXcode.m in Sources */,
E98CEAE3184A2B8400EFD95A /* XAlignPattern.m in Sources */,
E98CEAE8184A2BD600EFD95A /* XAlignPlugin.m in Sources */,
Expand Down
16 changes: 16 additions & 0 deletions plugin/XAlign/SettingWindowController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// SettingWindowController.h
// XAlign
//
// Created by QFish on 12/3/13.
// Copyright (c) 2013 net.qfish. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface SettingWindowController : NSWindowController<NSTextFieldDelegate>

@property (nonatomic, strong) IBOutlet NSTextField * key;
@property (nonatomic, strong) IBOutlet NSTextField * mask;

@end
42 changes: 42 additions & 0 deletions plugin/XAlign/SettingWindowController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// SettingWindowController.m
// XAlign
//
// Created by QFish on 12/3/13.
// Copyright (c) 2013 net.qfish. All rights reserved.
//

#import "XAlignPluginConfig.h"
#import "SettingWindowController.h"

@interface SettingWindowController ()

@end

@implementation SettingWindowController

- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
{
NSString * key = self.key.stringValue;
NSString * mask = self.mask.stringValue;

if ( key && mask )
{
NSDictionary * shortcut = @{ @"mask": mask, @"key": key };
[XAlignPluginConfig setKeyShortcut:shortcut];
}

return YES;
}

- (void)windowDidLoad
{
[super windowDidLoad];

NSDictionary * shortcut = [XAlignPluginConfig keyShortcut];

self.key.stringValue = shortcut[kMenuShortcutKey];
self.mask.stringValue = shortcut[kMenuShortcutMask];
}

@end
Loading

0 comments on commit aa30c3f

Please sign in to comment.