global shortcut

This commit is contained in:
yanue 2020-02-07 00:23:38 +08:00
parent 65d0dcb0fd
commit 403f03f604
6 changed files with 64 additions and 74 deletions

View File

@ -41,7 +41,7 @@
66FEAD53217EE14C009DECF9 /* ConfigWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 66FEAD4E217EE14C009DECF9 /* ConfigWindow.xib */; };
6D6DF2CF13D9FD3C7C6492A4 /* QrcodeWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D6DF12EA09D2D80788666D0 /* QrcodeWindow.swift */; };
6D6DF2F2DFB2234541488BBD /* PreferenceSubscribe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D6DF5345E4582EE0EBD468D /* PreferenceSubscribe.swift */; };
6D6DF51271B1AF55EACC79F2 /* PreferenceSubscribe.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6D6DF0CCE47F1253DECD5855 /* PreferenceSubscribe.xib */; };
6D6DF51271B1AF55EACC79F2 /* PreferenceSubscribe.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6D6DF0CCE47F1253DECD5855 /* PreferenceSubscribe.strings */; };
6D6DF5F67A917F78FF652D45 /* .gitignore in Resources */ = {isa = PBXBuildFile; fileRef = 6D6DF8F5112A8407EE959998 /* .gitignore */; };
6D6DF6553CF221AEB71913EE /* PreferenceGeneral.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D6DFFB29020127E034AD168 /* PreferenceGeneral.swift */; };
6D6DF6F065067CD879201FF9 /* Scanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D6DF87840CDA04AF0E9D36E /* Scanner.swift */; };
@ -50,10 +50,10 @@
6D6DF87497313615AFE3320A /* PreferencePac.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D6DF3151BBA6E56836AF6DE /* PreferencePac.swift */; };
6D6DF8BFC33F97E9AFCA5A4B /* V2rayConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D6DFD9F5991B38B128888D6 /* V2rayConfig.swift */; };
6D6DF93B58B654D86ACC490E /* PreferenceAbout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D6DF870C8E334815FBA78B2 /* PreferenceAbout.swift */; };
6D6DF95B4749491F1D600B05 /* PreferenceAdvance.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6D6DF586D59F646DD1C552F1 /* PreferenceAdvance.xib */; };
6D6DFC1618D163A9DFE3B628 /* PreferenceGeneral.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6D6DF76CE2762F4A33DB32BD /* PreferenceGeneral.xib */; };
6D6DFEA4ED44E1BE02451B6D /* PreferenceAbout.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6D6DF5D99F2FBB7B53564B3B /* PreferenceAbout.xib */; };
6D6DFFD18860EBE148F6DF1F /* PreferencePac.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6D6DFE89E1A7BFE2AC1D8871 /* PreferencePac.xib */; };
6D6DF95B4749491F1D600B05 /* PreferenceAdvance.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6D6DF586D59F646DD1C552F1 /* PreferenceAdvance.strings */; };
6D6DFC1618D163A9DFE3B628 /* PreferenceGeneral.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6D6DF76CE2762F4A33DB32BD /* PreferenceGeneral.strings */; };
6D6DFEA4ED44E1BE02451B6D /* PreferenceAbout.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6D6DF5D99F2FBB7B53564B3B /* PreferenceAbout.strings */; };
6D6DFFD18860EBE148F6DF1F /* PreferencePac.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6D6DFE89E1A7BFE2AC1D8871 /* PreferencePac.strings */; };
F260898E336CFA5EAB07ADC9 /* Pods_V2rayU.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66A5CE4521706B5A009B08B2 /* Pods_V2rayU.framework */; };
/* End PBXBuildFile section */
@ -331,7 +331,7 @@
664EB37B216C9A5F00B6AE0D /* Info.plist */,
667029D121AFB86E0079EF41 /* QrcodeWindow.xib */,
6D6DF12EA09D2D80788666D0 /* QrcodeWindow.swift */,
6D6DFBED570A0D1FDED0BD53 /* Preference */,
6D6DFBED570A0D1FDED0BD53 /* preference */,
6D6DF1B2E4D0B61B7390F1B1 /* HttpServer.swift */,
6618372823E9BF1A000F7410 /* ToastWindow.swift */,
6618372C23E9BF73000F7410 /* ToastWindow.xib */,
@ -355,7 +355,7 @@
path = Build;
sourceTree = "<group>";
};
6D6DFBED570A0D1FDED0BD53 /* Preference */ = {
6D6DFBED570A0D1FDED0BD53 /* preference */ = {
isa = PBXGroup;
children = (
6D6DF870C8E334815FBA78B2 /* PreferenceAbout.swift */,
@ -363,13 +363,13 @@
6D6DF5345E4582EE0EBD468D /* PreferenceSubscribe.swift */,
6D6DFFB29020127E034AD168 /* PreferenceGeneral.swift */,
6D6DF701C75D8D416096D717 /* PreferenceAdvance.swift */,
6D6DF5D99F2FBB7B53564B3B /* PreferenceAbout.xib */,
6D6DF586D59F646DD1C552F1 /* PreferenceAdvance.xib */,
6D6DF76CE2762F4A33DB32BD /* PreferenceGeneral.xib */,
6D6DFE89E1A7BFE2AC1D8871 /* PreferencePac.xib */,
6D6DF0CCE47F1253DECD5855 /* PreferenceSubscribe.xib */,
6D6DF5D99F2FBB7B53564B3B /* PreferenceAbout.strings */,
6D6DF586D59F646DD1C552F1 /* PreferenceAdvance.strings */,
6D6DF76CE2762F4A33DB32BD /* PreferenceGeneral.strings */,
6D6DFE89E1A7BFE2AC1D8871 /* PreferencePac.strings */,
6D6DF0CCE47F1253DECD5855 /* PreferenceSubscribe.strings */,
);
path = Preference;
path = preference;
sourceTree = "<group>";
};
6D6DFD93CE866018306A090E /* pac */ = {
@ -567,11 +567,11 @@
66FEAD53217EE14C009DECF9 /* ConfigWindow.xib in Resources */,
6618372E23E9BF74000F7410 /* ToastWindow.xib in Resources */,
6D6DF5F67A917F78FF652D45 /* .gitignore in Resources */,
6D6DFEA4ED44E1BE02451B6D /* PreferenceAbout.xib in Resources */,
6D6DF95B4749491F1D600B05 /* PreferenceAdvance.xib in Resources */,
6D6DFC1618D163A9DFE3B628 /* PreferenceGeneral.xib in Resources */,
6D6DFFD18860EBE148F6DF1F /* PreferencePac.xib in Resources */,
6D6DF51271B1AF55EACC79F2 /* PreferenceSubscribe.xib in Resources */,
6D6DFEA4ED44E1BE02451B6D /* PreferenceAbout.strings in Resources */,
6D6DF95B4749491F1D600B05 /* PreferenceAdvance.strings in Resources */,
6D6DFC1618D163A9DFE3B628 /* PreferenceGeneral.strings in Resources */,
6D6DFFD18860EBE148F6DF1F /* PreferencePac.strings in Resources */,
6D6DF51271B1AF55EACC79F2 /* PreferenceSubscribe.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -734,17 +734,17 @@
name = ConfigWindow.xib;
sourceTree = "<group>";
};
6D6DF0CCE47F1253DECD5855 /* PreferenceSubscribe.xib */ = {
6D6DF0CCE47F1253DECD5855 /* PreferenceSubscribe.strings */ = {
isa = PBXVariantGroup;
children = (
6D6DFD730D8572B1FCAB1FFE /* Base */,
66F302A322AAA0A700FCA4E2 /* zh-Hans */,
669A73AE233776B900807CF9 /* zh-HK */,
);
name = PreferenceSubscribe.xib;
name = PreferenceSubscribe.strings;
sourceTree = "<group>";
};
6D6DF586D59F646DD1C552F1 /* PreferenceAdvance.xib */ = {
6D6DF586D59F646DD1C552F1 /* PreferenceAdvance.strings */ = {
isa = PBXVariantGroup;
children = (
6D6DFE1CDFAD9828F2FDE1A5 /* Base */,
@ -752,37 +752,37 @@
669A73AB233776B900807CF9 /* zh-HK */,
66E7807A23781DC000819DA8 /* en */,
);
name = PreferenceAdvance.xib;
name = PreferenceAdvance.strings;
sourceTree = "<group>";
};
6D6DF5D99F2FBB7B53564B3B /* PreferenceAbout.xib */ = {
6D6DF5D99F2FBB7B53564B3B /* PreferenceAbout.strings */ = {
isa = PBXVariantGroup;
children = (
6D6DF3A2857899778B719CE1 /* Base */,
66F3029F22AAA0A600FCA4E2 /* zh-Hans */,
669A73AA233776B900807CF9 /* zh-HK */,
);
name = PreferenceAbout.xib;
name = PreferenceAbout.strings;
sourceTree = "<group>";
};
6D6DF76CE2762F4A33DB32BD /* PreferenceGeneral.xib */ = {
6D6DF76CE2762F4A33DB32BD /* PreferenceGeneral.strings */ = {
isa = PBXVariantGroup;
children = (
6D6DF81E59907A2C7579BFE2 /* Base */,
66F302A122AAA0A600FCA4E2 /* zh-Hans */,
669A73AC233776B900807CF9 /* zh-HK */,
);
name = PreferenceGeneral.xib;
name = PreferenceGeneral.strings;
sourceTree = "<group>";
};
6D6DFE89E1A7BFE2AC1D8871 /* PreferencePac.xib */ = {
6D6DFE89E1A7BFE2AC1D8871 /* PreferencePac.strings */ = {
isa = PBXVariantGroup;
children = (
6D6DF181C5D472DBBB71B72A /* Base */,
66F302A222AAA0A700FCA4E2 /* zh-Hans */,
669A73AD233776B900807CF9 /* zh-HK */,
);
name = PreferencePac.xib;
name = PreferencePac.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
@ -937,6 +937,7 @@
SKIP_INSTALL = NO;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
@ -994,6 +995,7 @@
SKIP_INSTALL = NO;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 4.2;
};
name = Release;
};

View File

@ -36,6 +36,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
self.checkDefault()
// auto Clear Logs
if UserDefaults.getBool(forKey: .autoClearLog) {
print("ClearLogs")
V2rayLaunch.ClearLogs()
}
// check v2ray core
V2rayCore().check()

View File

@ -20,7 +20,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="87d-wY-Ocw">
<rect key="frame" x="46" y="225" width="163" height="18"/>
<rect key="frame" x="64" y="225" width="163" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Launch V2rayU at login" bezelStyle="regularSquare" imagePosition="left" inset="2" id="NZE-cI-j04">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@ -31,12 +31,12 @@
</buttonCell>
</button>
<stackView distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" fixedFrame="YES" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="UJB-Wh-dgF">
<rect key="frame" x="48" y="199" width="216" height="14"/>
<rect key="frame" x="66" y="199" width="214" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tgw-Vy-D08" userLabel="Check for Updates automutically">
<rect key="frame" x="-2" y="-2" width="220" height="18"/>
<buttonCell key="cell" type="check" title="Check for Updates automutically" bezelStyle="regularSquare" imagePosition="left" inset="2" id="m2S-Mu-rFM">
<rect key="frame" x="-2" y="-2" width="218" height="18"/>
<buttonCell key="cell" type="check" title="Check for updates automutically" bezelStyle="regularSquare" imagePosition="left" inset="2" id="m2S-Mu-rFM">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
<connections>
@ -52,36 +52,16 @@
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="SUN-rQ-2fp">
<rect key="frame" x="66" y="146" width="67" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="inline" title="clear logs" bezelStyle="inline" alignment="center" borderStyle="border" inset="2" id="2vr-uU-fMI">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystemBold"/>
</buttonCell>
<connections>
<action selector="clearLogs:" target="-2" id="Hbj-bK-vtm"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FpH-fQ-KqG">
<rect key="frame" x="137" y="145" width="71" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundRect" title="show logs" bezelStyle="roundedRect" alignment="center" borderStyle="border" inset="2" id="0fD-xL-Tly">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="label" size="12"/>
</buttonCell>
<connections>
<action selector="openLogs:" target="-2" id="ZHd-mS-hgK"/>
</connections>
</button>
<stackView distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" fixedFrame="YES" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="WJk-22-Sun">
<rect key="frame" x="48" y="172" width="231" height="14"/>
<rect key="frame" x="66" y="156" width="257" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="59o-dL-xSh" userLabel="Check for Updates automutically">
<rect key="frame" x="-2" y="-2" width="235" height="18"/>
<buttonCell key="cell" type="check" title="Clear Logs Everyday Automutically" bezelStyle="regularSquare" imagePosition="left" inset="2" id="hIN-yp-Qul">
<rect key="frame" x="-2" y="-2" width="261" height="34"/>
<buttonCell key="cell" type="check" bezelStyle="regularSquare" imagePosition="left" inset="2" id="hIN-yp-Qul">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<string key="title">Automatically clear logs after launching
</string>
<font key="font" metaFont="system"/>
<connections>
<action selector="SetAutoClearLogs:" target="-2" id="gGD-G8-Feq"/>
@ -97,7 +77,7 @@
</customSpacing>
</stackView>
<button horizontalHuggingPriority="500" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cPC-Na-pRr">
<rect key="frame" x="60" y="25" width="182" height="32"/>
<rect key="frame" x="60" y="31" width="182" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Check for Updates..." bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="2p9-GL-XZ9">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -108,33 +88,31 @@
</connections>
</button>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Elj-N8-4IK" customClass="MASShortcutView">
<rect key="frame" x="247" y="76" width="139" height="19"/>
<rect key="frame" x="247" y="89" width="139" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="associatedUserDefaultsKey" value="SwitchProxyMode"/>
</userDefinedRuntimeAttributes>
</customView>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ti4-xg-ncf" customClass="MASShortcutView">
<rect key="frame" x="247" y="103" width="139" height="19"/>
<rect key="frame" x="247" y="116" width="139" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="associatedUserDefaultsKey" value="ToggleRunning"/>
</userDefinedRuntimeAttributes>
</customView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="UhI-5l-Ytp">
<rect key="frame" x="64" y="77" width="163" height="17"/>
<rect key="frame" x="64" y="90" width="174" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Switch proxy mode:" id="Eu4-bo-oYs">
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Switch Proxy Mode:" id="Eu4-bo-oYs">
<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" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vtN-0c-sip">
<rect key="frame" x="64" y="104" width="174" height="17"/>
<constraints>
<constraint firstAttribute="width" constant="212" id="yOV-yV-m0h"/>
</constraints>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vtN-0c-sip">
<rect key="frame" x="64" y="117" width="174" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Toggle V2ray On/Off:" id="0rn-re-Wn3">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -142,7 +120,7 @@
</textFieldCell>
</textField>
<button horizontalHuggingPriority="500" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="liJ-Uu-8HQ">
<rect key="frame" x="265" y="25" width="127" height="32"/>
<rect key="frame" x="265" y="31" width="127" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Feedback..." bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="QjX-NH-23u">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>

View File

@ -45,17 +45,21 @@ func makeToast(message: String, displayDuration: Double? = 2) {
toastWindowCtrl.fadeInHud(displayDuration)
}
func ToggleRunning() {
func ToggleRunning(_ toast: Bool = true) {
// turn off
if UserDefaults.getBool(forKey: .v2rayTurnOn) {
menuController.stopV2rayCore()
makeToast(message: "v2ray-core: Off")
if toast {
makeToast(message: "v2ray-core: Off")
}
return
}
// start
menuController.startV2rayCore()
makeToast(message: "v2ray-core: On")
if toast {
makeToast(message: "v2ray-core: On")
}
}
func SwitchProxyMode() {
@ -265,7 +269,7 @@ class MenuController: NSObject, NSMenuDelegate {
}
@IBAction func start(_ sender: NSMenuItem) {
ToggleRunning(false)
}
@IBAction func quitClicked(_ sender: NSMenuItem) {

View File

@ -15,7 +15,7 @@
"QjX-NH-23u.title" = "問題反饋...";
/* Class = "NSButtonCell"; title = "Clear Logs Everyday Automutically"; ObjectID = "hIN-yp-Qul"; */
"hIN-yp-Qul.title" = "每自動清除日誌";
"hIN-yp-Qul.title" = "每次启动自動清除日誌";
/* Class = "NSButtonCell"; title = "Check for Updates automutically"; ObjectID = "m2S-Mu-rFM"; */
"m2S-Mu-rFM.title" = "自動檢測版本更新";

View File

@ -15,7 +15,7 @@
"QjX-NH-23u.title" = "问题反馈...";
/* Class = "NSButtonCell"; title = "Clear Logs Everyday Automutically"; ObjectID = "hIN-yp-Qul"; */
"hIN-yp-Qul.title" = "每自动清除日志";
"hIN-yp-Qul.title" = "每次启动自动清除日志";
/* Class = "NSButtonCell"; title = "Check for Updates automutically"; ObjectID = "m2S-Mu-rFM"; */
"m2S-Mu-rFM.title" = "自动检测版本更新";