second commit, working app
This commit is contained in:
parent
847b69272a
commit
e6494b7ea5
9 changed files with 204 additions and 81 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
ScreenshotUpload.xcodeproj/xcuserdata/
|
|
@ -399,6 +399,7 @@
|
|||
1F80F6441956FFD600925040 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
1F80F6451956FFD600925040 /* Build configuration list for PBXNativeTarget "ScreenshotUploadTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
|
@ -407,6 +408,7 @@
|
|||
1F80F6471956FFD600925040 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0600"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
allowLocationSimulation = "YES">
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
|
@ -1,27 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>ScreenshotUpload.xcscheme</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
<dict>
|
||||
<key>1F80F6251956FFD500925040</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>1F80F6371956FFD600925040</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
|
@ -7,20 +7,119 @@
|
|||
//
|
||||
|
||||
import Cocoa
|
||||
import Foundation
|
||||
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
@IBOutlet var window: NSWindow
|
||||
@IBOutlet var takeScreenshotButton : NSButton
|
||||
|
||||
|
||||
func applicationDidFinishLaunching(aNotification: NSNotification?) {
|
||||
|
||||
if !self.handledURL(aNotification) {
|
||||
|
||||
// Insert code here to initialize your application
|
||||
let defaults = NSUserDefaults.standardUserDefaults()
|
||||
let fileName = defaults.stringForKey("fileName")
|
||||
let scpPath = defaults.stringForKey("scpPath")
|
||||
let httpPath = defaults.stringForKey("httpPath")
|
||||
|
||||
if fileName? && scpPath? && httpPath? {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
|
||||
NSOperationQueue.mainQueue().addOperationWithBlock {
|
||||
self.takeScreenshot(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func applicationWillTerminate(aNotification: NSNotification?) {
|
||||
// Insert code here to tear down your application
|
||||
}
|
||||
|
||||
func handledURL(aNotification: NSNotification?) -> Bool {
|
||||
|
||||
if let urlString = aNotification?.userInfo["openUrl"] as? String {
|
||||
|
||||
let url = NSURL.URLWithString(urlString)
|
||||
NSWorkspace.sharedWorkspace().openURL(url)
|
||||
println(url)
|
||||
|
||||
NSApp.terminate(self)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@IBAction func takeScreenshot(sender : NSObject) {
|
||||
|
||||
window.miniaturize(self)
|
||||
NSRunningApplication.currentApplication().hide()
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
|
||||
// do some async stuff
|
||||
|
||||
let httpUrl = self.runSystemCallsAssync()
|
||||
|
||||
NSOperationQueue.mainQueue().addOperationWithBlock {
|
||||
// do some main thread stuff stuff
|
||||
|
||||
if httpUrl? {
|
||||
let notification = NSUserNotification()
|
||||
notification.title = "Screenshot uploaded to"
|
||||
notification.informativeText = httpUrl
|
||||
notification.userInfo = ["openUrl": httpUrl]
|
||||
//notification.identifier = httpUrl
|
||||
notification.soundName = "NSUserNotificationDefaultSoundName"
|
||||
notification.actionButtonTitle = "Open"
|
||||
notification.otherButtonTitle = ""
|
||||
|
||||
NSUserNotificationCenter.defaultUserNotificationCenter().deliverNotification(
|
||||
notification
|
||||
)
|
||||
|
||||
NSApp.terminate(self)
|
||||
|
||||
} else {
|
||||
self.window.orderFront(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func runSystemCallsAssync() -> String! {
|
||||
|
||||
let tmpName = NSTemporaryDirectory() + "nu.jabs.apps.ScreenshotUpload.png"
|
||||
|
||||
systemCall("screencapture -i \(tmpName)")
|
||||
|
||||
if NSFileManager.defaultManager().isReadableFileAtPath(tmpName) {
|
||||
|
||||
let defaults = NSUserDefaults.standardUserDefaults()
|
||||
let fileName = defaults.stringForKey("fileName")
|
||||
let scpPath = defaults.stringForKey("scpPath")
|
||||
let httpPath = defaults.stringForKey("httpPath")
|
||||
|
||||
systemCall("scp \(tmpName) \(scpPath)\(fileName)")
|
||||
systemCall("rm \(tmpName)")
|
||||
|
||||
let httpUrl = "\(httpPath)\(fileName)"
|
||||
systemCall("echo \(httpUrl) | pbcopy")
|
||||
|
||||
return httpUrl
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func systemCall(cmd : String) {
|
||||
println(cmd)
|
||||
system(cmd.bridgeToObjectiveC().UTF8String)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6157" systemVersion="14A237a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6154.17" systemVersion="13D65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6157"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6154.17"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
||||
|
@ -11,8 +11,9 @@
|
|||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application"/>
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModuleProvider="target">
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="ScreenshotUpload" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="takeScreenshotButton" destination="PVq-S9-dQU" id="U9l-Zq-FdS"/>
|
||||
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
|
@ -666,15 +667,104 @@
|
|||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
<window title="ScreenshotUpload" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<window title="ScreenshotUpload" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/>
|
||||
<rect key="contentRect" x="335" y="390" width="480" height="264"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1418"/>
|
||||
<view key="contentView" id="EiT-Mj-1SZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="264"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mAq-aQ-q2J">
|
||||
<rect key="frame" x="18" y="227" width="65" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="File name" id="shb-I6-8lK">
|
||||
<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="W06-EN-vtT">
|
||||
<rect key="frame" x="20" y="197" width="438" height="22"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="screenshot.png" drawsBackground="YES" id="3gY-LZ-ipI">
|
||||
<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>
|
||||
<binding destination="v2M-a4-bCd" name="value" keyPath="values.fileName" id="nxy-iV-WkM"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<box autoresizesSubviews="NO" verticalHuggingPriority="750" fixedFrame="YES" title="Box" boxType="separator" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="woG-vS-iEL">
|
||||
<rect key="frame" x="20" y="186" width="438" height="5"/>
|
||||
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
|
||||
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<font key="titleFont" metaFont="system"/>
|
||||
</box>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DBO-ex-TaV">
|
||||
<rect key="frame" x="18" y="163" width="60" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="SSH path" id="Tmc-J4-8ga">
|
||||
<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="86j-cv-KKm">
|
||||
<rect key="frame" x="20" y="133" width="438" height="22"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="user@example.com:~/screens/" drawsBackground="YES" id="LkU-Mw-667">
|
||||
<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>
|
||||
<binding destination="v2M-a4-bCd" name="value" keyPath="values.scpPath" id="KnH-L3-WMb"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<box autoresizesSubviews="NO" verticalHuggingPriority="750" fixedFrame="YES" title="Box" boxType="separator" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="xT4-IR-w5j">
|
||||
<rect key="frame" x="20" y="122" width="438" height="5"/>
|
||||
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
|
||||
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<font key="titleFont" metaFont="system"/>
|
||||
</box>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="sQB-S7-mc4">
|
||||
<rect key="frame" x="18" y="99" width="69" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="HTTP path" id="5Yp-YZ-0WT">
|
||||
<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="ypW-gJ-cwj">
|
||||
<rect key="frame" x="20" y="69" width="438" height="22"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="https://example.com/s/" drawsBackground="YES" id="FMC-WC-7Ov">
|
||||
<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>
|
||||
<binding destination="v2M-a4-bCd" name="value" keyPath="values.httpPath" id="ccJ-Bh-l3f"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<box autoresizesSubviews="NO" verticalHuggingPriority="750" fixedFrame="YES" title="Box" boxType="separator" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="Ghi-qI-PKx">
|
||||
<rect key="frame" x="20" y="58" width="438" height="5"/>
|
||||
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
|
||||
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<font key="titleFont" metaFont="system"/>
|
||||
</box>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="PVq-S9-dQU">
|
||||
<rect key="frame" x="250" y="12" width="216" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Take and upload screenshot" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="rM2-Bf-Znu">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="takeScreenshot:" target="Voe-Tx-rLC" id="EhE-r8-Wa0"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</view>
|
||||
<point key="canvasLocation" x="140" y="110"/>
|
||||
</window>
|
||||
<userDefaultsController representsSharedInstance="YES" id="v2M-a4-bCd"/>
|
||||
</objects>
|
||||
</document>
|
||||
|
|
|
@ -21,8 +21,9 @@
|
|||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "128x128",
|
||||
"idiom" : "mac",
|
||||
"filename" : "Screenshot-App-icon.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
|
@ -9,7 +9,7 @@
|
|||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>nu.jabs.apps.ScreenshotUpload.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<string>nu.jabs.apps.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue