Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleduo committed Apr 20, 2019
1 parent 0b1e01b commit b0c513a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 33 deletions.
22 changes: 19 additions & 3 deletions source/tinypng4mac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = kyleduo;
TargetAttributes = {
277AAF4E1D23F24900788F37 = {
Expand Down Expand Up @@ -350,14 +350,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -380,7 +388,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand All @@ -398,14 +406,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -422,7 +438,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 26 additions & 24 deletions source/tinypng4mac/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -164,43 +164,46 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="417"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<visualEffectView appearanceType="vibrantLight" blendingMode="behindWindow" material="appearanceBased" state="active" translatesAutoresizingMaskIntoConstraints="NO" id="6R4-nY-g9G">
<rect key="frame" x="0.0" y="0.0" width="320" height="100"/>
<visualEffectView appearanceType="vibrantLight" blendingMode="behindWindow" material="light" state="active" translatesAutoresizingMaskIntoConstraints="NO" id="6R4-nY-g9G">
<rect key="frame" x="0.0" y="-4" width="320" height="104"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="752" translatesAutoresizingMaskIntoConstraints="NO" id="j7S-Iz-wE1">
<rect key="frame" x="18" y="42" width="104" height="16"/>
<rect key="frame" x="18" y="43" width="104" height="18"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Output Path:" id="wAc-5q-1kG">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="752" translatesAutoresizingMaskIntoConstraints="NO" id="NnK-w1-6b9">
<rect key="frame" x="18" y="16" width="104" height="17"/>
<rect key="frame" x="18" y="16" width="104" height="18"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Replace Origion:" id="7il-ST-uVu">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="752" translatesAutoresizingMaskIntoConstraints="NO" id="iOT-w7-ALe">
<rect key="frame" x="18" y="67" width="104" height="17"/>
<rect key="frame" x="18" y="70" width="104" height="18"/>
<constraints>
<constraint firstAttribute="height" constant="18" id="zLS-ML-ggj"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="API Key:" id="tJg-5O-cpK">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fT1-QL-4Nq">
<rect key="frame" x="132" y="39" width="146" height="22"/>
<rect key="frame" x="132" y="41" width="146" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" usesSingleLineMode="YES" id="99a-9k-u4D">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0K4-Mk-HkB">
<rect key="frame" x="284" y="39" width="20" height="22"/>
<rect key="frame" x="284" y="41" width="20" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="7fY-qZ-d52"/>
</constraints>
Expand All @@ -213,15 +216,15 @@
</connections>
</button>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vPz-Tz-wUm">
<rect key="frame" x="132" y="65" width="172" height="22"/>
<rect key="frame" x="132" y="68" width="172" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" usesSingleLineMode="YES" id="OCF-de-u9Q">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button translatesAutoresizingMaskIntoConstraints="NO" id="zRv-TO-bMw">
<rect key="frame" x="132" y="15" width="22" height="18"/>
<rect key="frame" x="132" y="16" width="22" height="18"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="mm5-iS-Q2I"/>
</constraints>
Expand All @@ -239,7 +242,6 @@
<constraint firstItem="NnK-w1-6b9" firstAttribute="leading" secondItem="6R4-nY-g9G" secondAttribute="leading" constant="20" id="4tL-gR-KtL"/>
<constraint firstItem="NnK-w1-6b9" firstAttribute="trailing" secondItem="j7S-Iz-wE1" secondAttribute="trailing" id="GNR-vn-A9H"/>
<constraint firstItem="iOT-w7-ALe" firstAttribute="trailing" secondItem="j7S-Iz-wE1" secondAttribute="trailing" id="Iet-eM-Hzc"/>
<constraint firstAttribute="height" constant="100" id="LgT-sP-QGP"/>
<constraint firstItem="vPz-Tz-wUm" firstAttribute="centerY" secondItem="iOT-w7-ALe" secondAttribute="centerY" id="Nat-jV-mn1"/>
<constraint firstItem="j7S-Iz-wE1" firstAttribute="leading" secondItem="6R4-nY-g9G" secondAttribute="leading" constant="20" id="T3q-PR-wtH"/>
<constraint firstItem="iOT-w7-ALe" firstAttribute="top" secondItem="6R4-nY-g9G" secondAttribute="top" constant="16" id="TCK-an-uSj"/>
Expand Down Expand Up @@ -291,12 +293,12 @@
<rect key="frame" x="0.0" y="97" width="320" height="320"/>
<subviews>
<button translatesAutoresizingMaskIntoConstraints="NO" id="ThG-Q2-7EJ">
<rect key="frame" x="284" y="12" width="24" height="24"/>
<rect key="frame" x="276" y="12" width="32" height="32"/>
<constraints>
<constraint firstAttribute="width" constant="24" id="ZNo-b5-aZ6"/>
<constraint firstAttribute="height" constant="24" id="jTx-Tu-aB7"/>
<constraint firstAttribute="width" constant="32" id="ZNo-b5-aZ6"/>
<constraint firstAttribute="height" constant="32" id="jTx-Tu-aB7"/>
</constraints>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="icon_setting" imagePosition="only" alignment="center" refusesFirstResponder="YES" imageScaling="proportionallyUpOrDown" inset="2" id="YLZ-tQ-gl9">
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="icon_setting" imagePosition="only" alignment="center" refusesFirstResponder="YES" imageScaling="proportionallyDown" inset="2" id="YLZ-tQ-gl9">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
Expand All @@ -305,12 +307,12 @@
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="Wlb-vO-jQD">
<rect key="frame" x="252" y="12" width="24" height="24"/>
<rect key="frame" x="240" y="12" width="32" height="32"/>
<constraints>
<constraint firstAttribute="width" constant="24" id="372-OH-CEV"/>
<constraint firstAttribute="height" constant="24" id="aMm-Cl-9P5"/>
<constraint firstAttribute="width" constant="32" id="372-OH-CEV"/>
<constraint firstAttribute="height" constant="32" id="aMm-Cl-9P5"/>
</constraints>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="icon_finder" imagePosition="only" alignment="center" refusesFirstResponder="YES" imageScaling="proportionallyUpOrDown" inset="2" id="JLJ-vh-qV7">
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="icon_finder" imagePosition="only" alignment="center" refusesFirstResponder="YES" imageScaling="proportionallyDown" inset="2" id="JLJ-vh-qV7">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
Expand All @@ -320,7 +322,7 @@
</button>
</subviews>
<constraints>
<constraint firstItem="ThG-Q2-7EJ" firstAttribute="leading" secondItem="Wlb-vO-jQD" secondAttribute="trailing" constant="8" id="9BD-m0-aC4"/>
<constraint firstItem="ThG-Q2-7EJ" firstAttribute="leading" secondItem="Wlb-vO-jQD" secondAttribute="trailing" constant="4" id="9BD-m0-aC4"/>
<constraint firstAttribute="width" constant="320" id="9XX-J0-wlN"/>
<constraint firstAttribute="height" constant="320" id="LBg-6c-iG7"/>
<constraint firstItem="Wlb-vO-jQD" firstAttribute="centerY" secondItem="ThG-Q2-7EJ" secondAttribute="centerY" id="P4v-m8-c1P"/>
Expand Down Expand Up @@ -427,11 +429,11 @@
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="0.0" colorSpace="calibratedRGB"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="lr0-AL-Hdc">
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="lr0-AL-Hdc">
<rect key="frame" x="0.0" y="233" width="320" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="0.026480521370164448" horizontal="NO" id="x03-Xj-aQ3">
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="0.026480521370164448" horizontal="NO" id="x03-Xj-aQ3">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
Expand All @@ -445,7 +447,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="D8d-TS-a2j">
<rect key="frame" x="14" y="113" width="57" height="17"/>
<rect key="frame" x="14" y="117" width="57" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" sendsActionOnEndEditing="YES" title="Reduce: " id="400-FH-fhZ">
<font key="font" metaFont="system"/>
<color key="textColor" name="highlightColor" catalog="System" colorSpace="catalog"/>
Expand Down Expand Up @@ -499,8 +501,8 @@
</scenes>
<resources>
<image name="icon" width="120" height="120"/>
<image name="icon_finder" width="32" height="32"/>
<image name="icon_finder" width="24" height="24"/>
<image name="icon_finish" width="16" height="16"/>
<image name="icon_setting" width="32" height="32"/>
<image name="icon_setting" width="24" height="24"/>
</resources>
</document>
4 changes: 4 additions & 0 deletions source/tinypng4mac/model/TPTaskInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class TPTaskInfo: NSObject {
self.errorMessage = nil
self.index = 0
}

override var description: String {
return String(format: "Task {}", self.fileName)
}
}

enum TPTaskStatus {
Expand Down
9 changes: 3 additions & 6 deletions source/tinypng4mac/tpclient/TPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,15 @@ class TPClient {
self.updateStatus(t, newStatus: .prepare)
runningTasks += 1
debugPrint("prepare to upload: " + t.fileName + " tasks: " + String(self.runningTasks))
if !executeTask(t) {
runningTasks -= 1
}
executeTask(t)
} else {
break;
}
}
lock.unlock()
}

func executeTask(_ task: TPTaskInfo) -> Bool {
func executeTask(_ task: TPTaskInfo) {
var imageData: Data!
do {
let fileHandler = try FileHandle(forReadingFrom:task.originFile as URL)
Expand Down Expand Up @@ -112,10 +110,8 @@ class TPClient {
self.markError(task, errorMessage: response.result.description)
}
})
return true
} catch {
self.markError(task, errorMessage: "execute error")
return false
}
}

Expand Down Expand Up @@ -156,6 +152,7 @@ class TPClient {
fileprivate func markError(_ task: TPTaskInfo, errorMessage: String?) {
task.errorMessage = errorMessage
updateStatus(task, newStatus: .error)
checkExecution()
}

fileprivate func updateStatus(_ task: TPTaskInfo, newStatus: TPTaskStatus, progress: Progress) {
Expand Down

0 comments on commit b0c513a

Please sign in to comment.