mirror of
https://github.com/qinyuhang/ShadowsocksX-NG-R.git
synced 2026-10-21 06:54:41 +00:00
Fix subscribe cannot delete to zero
This commit is contained in:
@@ -378,6 +378,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
}
|
||||
|
||||
@IBAction func updateSubscribeAtLaunch(_ sender: NSMenuItem) {
|
||||
let defaults = UserDefaults.standard
|
||||
defaults.set(!defaults.bool(forKey: "AutoUpdateSubscribe"), forKey: "AutoUpdateSubscribe")
|
||||
updateSubscribeAtLaunchMenuItem.state = defaults.bool(forKey: "AutoUpdateSubscribe") ? 1 : 0
|
||||
}
|
||||
|
||||
|
||||
@@ -718,6 +721,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
}
|
||||
serversMenuItem.submenu?.addItem(editSubscribeItem!)
|
||||
serversMenuItem.submenu?.addItem(autoUpdateSubscribeItem!)
|
||||
autoUpdateSubscribeItem?.state = UserDefaults.standard.bool(forKey: "AutoUpdateSubscribe") ? 1 : 0
|
||||
serversMenuItem.submenu?.addItem(updateSubscribeItem!)
|
||||
serversMenuItem.submenu?.addItem(showQRItem!)
|
||||
serversMenuItem.submenu?.addItem(scanQRItem!)
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<connections>
|
||||
<outlet property="AddSubscribeBtn" destination="nzj-fK-Vip" id="Tlt-DM-cZF"/>
|
||||
<outlet property="DeleteSubscribeBtn" destination="jSv-em-0Gp" id="uDp-Bj-Mb8"/>
|
||||
<outlet property="FeedLabel" destination="uYX-0C-bOD" id="odZ-Tm-7SC"/>
|
||||
<outlet property="FeedTextField" destination="p1W-Md-Wfw" id="zh0-1b-0zw"/>
|
||||
<outlet property="GroupTextField" destination="MrH-Ft-1tn" id="txD-SB-Kpr"/>
|
||||
<outlet property="MaxCountTextField" destination="vQO-bq-Igs" id="feo-Jx-AXK"/>
|
||||
@@ -22,7 +21,7 @@
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
|
||||
<window title="Subscribe Preference" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
|
||||
<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="480" height="270"/>
|
||||
@@ -31,16 +30,8 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uYX-0C-bOD">
|
||||
<rect key="frame" x="18" y="233" width="142" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Subscribe Preferences" id="rMX-5B-Fvs">
|
||||
<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" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="p1W-Md-Wfw">
|
||||
<rect key="frame" x="236" y="203" width="224" height="22"/>
|
||||
<rect key="frame" x="236" y="228" width="224" height="22"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="AuN-e3-13P">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -48,7 +39,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hnP-yo-KBb">
|
||||
<rect key="frame" x="236" y="165" width="224" height="22"/>
|
||||
<rect key="frame" x="236" y="190" width="224" height="22"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="Optional" drawsBackground="YES" id="ASh-mc-Uyt">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -56,7 +47,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MrH-Ft-1tn">
|
||||
<rect key="frame" x="236" y="124" width="224" height="22"/>
|
||||
<rect key="frame" x="236" y="149" width="224" height="22"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="3cf-F8-tBI">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -91,7 +82,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uNY-1k-LwL">
|
||||
<rect key="frame" x="182" y="205" width="30" height="17"/>
|
||||
<rect key="frame" x="182" y="230" width="30" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="URL" id="yBp-oB-gbL">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -99,7 +90,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="P7L-eo-l3V">
|
||||
<rect key="frame" x="182" y="167" width="41" height="17"/>
|
||||
<rect key="frame" x="182" y="192" width="41" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Token" id="IrJ-D8-tlX">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -107,7 +98,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Fkq-Nl-5rY">
|
||||
<rect key="frame" x="182" y="126" width="42" height="17"/>
|
||||
<rect key="frame" x="182" y="151" width="42" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Group" id="f2p-qb-uuE">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -115,7 +106,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vQO-bq-Igs">
|
||||
<rect key="frame" x="236" y="86" width="224" height="22"/>
|
||||
<rect key="frame" x="236" y="111" width="224" height="22"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="224" id="zre-fn-PCG"/>
|
||||
</constraints>
|
||||
@@ -126,34 +117,21 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XLx-TZ-soe">
|
||||
<rect key="frame" x="184" y="88" width="41" height="17"/>
|
||||
<rect key="frame" x="182" y="113" width="43" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Count" id="wbG-HT-bdN">
|
||||
<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>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rC3-mg-tMh">
|
||||
<rect key="frame" x="407" y="13" width="59" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="CfK-8Y-YNP">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
DQ
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="onOk:" target="-2" id="dUz-Tf-zD1"/>
|
||||
</connections>
|
||||
</button>
|
||||
<scrollView focusRingType="none" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="shT-FD-AWs">
|
||||
<rect key="frame" x="20" y="40" width="158" height="185"/>
|
||||
<rect key="frame" x="20" y="39" width="156" height="211"/>
|
||||
<clipView key="contentView" focusRingType="none" id="zJf-T0-5ju">
|
||||
<rect key="frame" x="1" y="1" width="156" height="183"/>
|
||||
<rect key="frame" x="1" y="1" width="154" height="209"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnSelection="YES" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" id="go8-dc-8a6">
|
||||
<rect key="frame" x="0.0" y="0.0" width="156" height="183"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="154" height="209"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<size key="intercellSpacing" width="3" height="2"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -168,7 +146,7 @@ DQ
|
||||
<imageCell key="dataCell" refusesFirstResponder="YES" alignment="left" identifier="status" imageScaling="proportionallyDown" id="GWO-Q7-6lA"/>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
</tableColumn>
|
||||
<tableColumn identifier="main" width="130" minWidth="40" maxWidth="1000" id="3xd-Hy-qcx">
|
||||
<tableColumn identifier="main" width="128" minWidth="40" maxWidth="1000" id="3xd-Hy-qcx">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -190,7 +168,7 @@ DQ
|
||||
</subviews>
|
||||
</clipView>
|
||||
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="r2d-RN-LC6">
|
||||
<rect key="frame" x="1" y="168" width="144" height="16"/>
|
||||
<rect key="frame" x="1" y="168" width="154" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="Kag-9R-Vsj">
|
||||
@@ -198,6 +176,19 @@ DQ
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
</scrollView>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rC3-mg-tMh">
|
||||
<rect key="frame" x="407" y="13" width="59" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="CfK-8Y-YNP">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
DQ
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="onOk:" target="-2" id="dUz-Tf-zD1"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="vQO-bq-Igs" firstAttribute="top" secondItem="MrH-Ft-1tn" secondAttribute="bottom" constant="16" id="71r-dd-ykt"/>
|
||||
@@ -209,16 +200,16 @@ DQ
|
||||
<constraint firstItem="vQO-bq-Igs" firstAttribute="leading" secondItem="MrH-Ft-1tn" secondAttribute="leading" id="KHN-WD-iRw"/>
|
||||
<constraint firstAttribute="trailing" secondItem="MrH-Ft-1tn" secondAttribute="trailing" constant="20" symbolic="YES" id="L6b-S2-rXW"/>
|
||||
<constraint firstItem="MrH-Ft-1tn" firstAttribute="leading" secondItem="p1W-Md-Wfw" secondAttribute="leading" id="NbP-CB-QGM"/>
|
||||
<constraint firstItem="rC3-mg-tMh" firstAttribute="top" secondItem="MrH-Ft-1tn" secondAttribute="bottom" constant="83" id="TKp-sn-xiU"/>
|
||||
<constraint firstItem="rC3-mg-tMh" firstAttribute="top" secondItem="MrH-Ft-1tn" secondAttribute="bottom" constant="108" id="TKp-sn-xiU"/>
|
||||
<constraint firstItem="vQO-bq-Igs" firstAttribute="leading" secondItem="XLx-TZ-soe" secondAttribute="trailing" constant="13" id="Urz-tT-Oyy"/>
|
||||
<constraint firstItem="vQO-bq-Igs" firstAttribute="trailing" secondItem="MrH-Ft-1tn" secondAttribute="trailing" id="VKk-Df-fQc"/>
|
||||
<constraint firstItem="jSv-em-0Gp" firstAttribute="top" secondItem="shT-FD-AWs" secondAttribute="bottom" constant="1" id="VzA-No-qVy"/>
|
||||
<constraint firstItem="uYX-0C-bOD" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="20" symbolic="YES" id="Wcn-sc-qJ2"/>
|
||||
<constraint firstItem="jSv-em-0Gp" firstAttribute="top" secondItem="shT-FD-AWs" secondAttribute="bottom" id="VzA-No-qVy"/>
|
||||
<constraint firstAttribute="bottom" secondItem="nzj-fK-Vip" secondAttribute="bottom" constant="21" id="Y3H-aQ-YNb"/>
|
||||
<constraint firstItem="nzj-fK-Vip" firstAttribute="leading" secondItem="uYX-0C-bOD" secondAttribute="leading" id="Za5-x5-eJr"/>
|
||||
<constraint firstItem="XLx-TZ-soe" firstAttribute="leading" secondItem="uNY-1k-LwL" secondAttribute="leading" id="Zeh-Nz-h3d"/>
|
||||
<constraint firstItem="Fkq-Nl-5rY" firstAttribute="centerY" secondItem="MrH-Ft-1tn" secondAttribute="centerY" id="bK9-gp-UzV"/>
|
||||
<constraint firstAttribute="bottom" secondItem="XLx-TZ-soe" secondAttribute="bottom" constant="88" id="c8d-Bj-YQd"/>
|
||||
<constraint firstAttribute="bottom" secondItem="XLx-TZ-soe" secondAttribute="bottom" constant="113" id="c8d-Bj-YQd"/>
|
||||
<constraint firstItem="P7L-eo-l3V" firstAttribute="centerY" secondItem="hnP-yo-KBb" secondAttribute="centerY" id="dQh-T9-QP5"/>
|
||||
<constraint firstItem="P7L-eo-l3V" firstAttribute="leading" secondItem="uNY-1k-LwL" secondAttribute="leading" id="fDy-fs-ZnP"/>
|
||||
<constraint firstItem="MrH-Ft-1tn" firstAttribute="trailing" secondItem="p1W-Md-Wfw" secondAttribute="trailing" id="iTW-Og-aCE"/>
|
||||
<constraint firstItem="vQO-bq-Igs" firstAttribute="centerY" secondItem="XLx-TZ-soe" secondAttribute="centerY" id="jkd-CC-vo0"/>
|
||||
<constraint firstItem="P7L-eo-l3V" firstAttribute="leading" secondItem="uNY-1k-LwL" secondAttribute="leading" id="lCH-5t-qVb"/>
|
||||
@@ -232,6 +223,7 @@ DQ
|
||||
<constraint firstItem="P7L-eo-l3V" firstAttribute="top" secondItem="uNY-1k-LwL" secondAttribute="bottom" constant="21" id="wl6-VJ-tLB"/>
|
||||
<constraint firstItem="Fkq-Nl-5rY" firstAttribute="leading" secondItem="uNY-1k-LwL" secondAttribute="leading" id="xnv-Ha-oeD"/>
|
||||
<constraint firstItem="jSv-em-0Gp" firstAttribute="leading" secondItem="nzj-fK-Vip" secondAttribute="trailing" id="y0j-ol-6WV"/>
|
||||
<constraint firstItem="Fkq-Nl-5rY" firstAttribute="leading" secondItem="uNY-1k-LwL" secondAttribute="leading" id="ySw-mv-aeO"/>
|
||||
<constraint firstItem="nzj-fK-Vip" firstAttribute="baseline" secondItem="jSv-em-0Gp" secondAttribute="baseline" id="zGB-7i-cIR"/>
|
||||
</constraints>
|
||||
</view>
|
||||
|
||||
@@ -172,7 +172,10 @@ class Subscribe: NSObject{
|
||||
fileprivate func pushNotification(){
|
||||
|
||||
}
|
||||
fileprivate func isSame(source: Subscribe, target: Subscribe) -> Bool {
|
||||
class func isSame(source: Subscribe, target: Subscribe) -> Bool {
|
||||
return source.subscribeFeed == target.subscribeFeed && source.token == target.token && source.maxCount == target.maxCount
|
||||
}
|
||||
func isExist(_ target: Subscribe) -> Bool {
|
||||
return self.subscribeFeed == target.subscribeFeed
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,19 +25,25 @@ class SubscribeManager:NSObject{
|
||||
}
|
||||
}
|
||||
func addSubscribe(oneSubscribe: Subscribe) -> Bool {
|
||||
for (index, value) in subscribes.enumerated() {
|
||||
if Subscribe.isSame(source: oneSubscribe, target: value) {
|
||||
return true
|
||||
}
|
||||
if value.isExist(oneSubscribe) {
|
||||
subscribes.replaceSubrange(Range(index..<index + 1), with: [oneSubscribe])
|
||||
return true
|
||||
}
|
||||
}
|
||||
subscribes.append(oneSubscribe)
|
||||
defaults.set(subscribesToDefaults(data: subscribes), forKey: "Subscribes")
|
||||
return true
|
||||
}
|
||||
func deleteSubscribe(toDeleteSubscribe: Subscribe) -> Bool {
|
||||
subscribes.enumerated().forEach({ (index, oneSubscribe) -> Void in
|
||||
if(oneSubscribe.getFeed() == toDeleteSubscribe.getFeed()){
|
||||
subscribes.remove(at: index)
|
||||
}
|
||||
})
|
||||
defaults.set(subscribesToDefaults(data: subscribes), forKey: "Subscribes")
|
||||
func deleteSubscribe(atIndex: Int) -> Bool {
|
||||
subscribes.remove(at: atIndex)
|
||||
return true
|
||||
}
|
||||
func save() {
|
||||
defaults.set(subscribesToDefaults(data: subscribes), forKey: "Subscribes")
|
||||
}
|
||||
fileprivate func subscribesToDefaults(data: [Subscribe]) -> [[String: AnyObject]]{
|
||||
var ret : [[String: AnyObject]] = []
|
||||
for value in data {
|
||||
|
||||
@@ -34,6 +34,7 @@ class SubscribePreferenceWindowController: NSWindowController
|
||||
sbMgr = SubscribeManager.instance
|
||||
defaults = UserDefaults.standard
|
||||
SubscribeTableView.reloadData()
|
||||
updateSubscribeBoxVisible()
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
@@ -42,14 +43,14 @@ class SubscribePreferenceWindowController: NSWindowController
|
||||
}
|
||||
|
||||
@IBAction func onOk(_ sender: NSButton) {
|
||||
// TODO append to manager and save
|
||||
let subscribe = Subscribe.init(initUrlString: FeedTextField.stringValue, initGroupName: GroupTextField.stringValue, initToken: TokenTextField.stringValue, initMaxCount: MaxCountTextField.integerValue)
|
||||
if !subscribe.feedValidator() {
|
||||
return shakeWindows()
|
||||
if editingSubscribe != nil {
|
||||
if !editingSubscribe.feedValidator() {
|
||||
// Done Shake window
|
||||
shakeWindows()
|
||||
return
|
||||
}
|
||||
}
|
||||
_ = sbMgr.addSubscribe(oneSubscribe: subscribe)
|
||||
subscribe.updateServerFromFeed()
|
||||
SubscribeTableView.reloadData()
|
||||
sbMgr.save()
|
||||
window?.performClose(self)
|
||||
}
|
||||
|
||||
@@ -77,10 +78,12 @@ class SubscribePreferenceWindowController: NSWindowController
|
||||
if index >= 0 {
|
||||
SubscribeTableView.beginUpdates()
|
||||
for (_, toDeleteIndex) in SubscribeTableView.selectedRowIndexes.enumerated() {
|
||||
print(sbMgr.subscribes.count)
|
||||
sbMgr.subscribes.remove(at: toDeleteIndex - deleteCount)
|
||||
_ = sbMgr.deleteSubscribe(atIndex: toDeleteIndex - deleteCount)
|
||||
SubscribeTableView.removeRows(at: IndexSet(integer: toDeleteIndex - deleteCount), withAnimation: .effectFade)
|
||||
deleteCount += 1
|
||||
if sbMgr.subscribes.count == 0 {
|
||||
cleanField()
|
||||
}
|
||||
}
|
||||
SubscribeTableView.endUpdates()
|
||||
}
|
||||
@@ -92,8 +95,16 @@ class SubscribePreferenceWindowController: NSWindowController
|
||||
func updateSubscribeBoxVisible() {
|
||||
if sbMgr.subscribes.count <= 0 {
|
||||
DeleteSubscribeBtn.isEnabled = false
|
||||
FeedTextField.isEnabled = false
|
||||
TokenTextField.isEnabled = false
|
||||
GroupTextField.isEnabled = false
|
||||
MaxCountTextField.isEnabled = false
|
||||
}else{
|
||||
DeleteSubscribeBtn.isEnabled = true
|
||||
FeedTextField.isEnabled = true
|
||||
TokenTextField.isEnabled = true
|
||||
GroupTextField.isEnabled = true
|
||||
MaxCountTextField.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,6 +247,13 @@ class SubscribePreferenceWindowController: NSWindowController
|
||||
}
|
||||
}
|
||||
|
||||
func cleanField(){
|
||||
FeedTextField.stringValue = ""
|
||||
TokenTextField.stringValue = ""
|
||||
GroupTextField.stringValue = ""
|
||||
MaxCountTextField.stringValue = ""
|
||||
}
|
||||
|
||||
func shakeWindows(){
|
||||
let numberOfShakes:Int = 8
|
||||
let durationOfShake:Float = 0.5
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
"CfK-8Y-YNP.title" = "OK";
|
||||
|
||||
/* Class = "NSWindow"; title = "Window"; ObjectID = "F0z-JX-Cv5"; */
|
||||
"F0z-JX-Cv5.title" = "Window";
|
||||
"F0z-JX-Cv5.title" = "订阅设置";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Token"; ObjectID = "IrJ-D8-tlX"; */
|
||||
"IrJ-D8-tlX.title" = "Token";
|
||||
"IrJ-D8-tlX.title" = "口令";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Group"; ObjectID = "f2p-qb-uuE"; */
|
||||
"f2p-qb-uuE.title" = "Group";
|
||||
"f2p-qb-uuE.title" = "组名";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Text"; ObjectID = "ik7-wS-gok"; */
|
||||
"ik7-wS-gok.title" = "Text";
|
||||
@@ -18,7 +18,7 @@
|
||||
"rMX-5B-Fvs.title" = "订阅设置";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Count"; ObjectID = "wbG-HT-bdN"; */
|
||||
"wbG-HT-bdN.title" = "Count";
|
||||
"wbG-HT-bdN.title" = "最大数量";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "URL"; ObjectID = "yBp-oB-gbL"; */
|
||||
"yBp-oB-gbL.title" = "URL";
|
||||
"yBp-oB-gbL.title" = "订阅地址";
|
||||
|
||||
Reference in New Issue
Block a user