@@ -97,8 +97,12 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
97
97
[menu addItem: [NSMenuItem separatorItem ]];
98
98
[menu addItemWithTitle: _L (Edit PAC for Auto Proxy Mode...) action: @selector (editPAC ) keyEquivalent: @" " ];
99
99
[menu addItemWithTitle: _L (Update PAC from GFWList) action: @selector (updatePACFromGFWList ) keyEquivalent: @" " ];
100
- qrCodeMenuItem = [[NSMenuItem alloc ] initWithTitle: _L (Show QR Code...) action: @selector (showQRCode ) keyEquivalent: @" " ];
100
+ [menu addItemWithTitle: _L (Edit User Rule for GFWList...) action: @selector (editUserRule ) keyEquivalent: @" " ];
101
+ [menu addItem: [NSMenuItem separatorItem ]];
102
+ qrCodeMenuItem = [[NSMenuItem alloc ] initWithTitle: _L (Generate QR Code...) action: @selector (showQRCode ) keyEquivalent: @" " ];
101
103
[menu addItem: qrCodeMenuItem];
104
+ [menu addItem: [[NSMenuItem alloc ] initWithTitle: _L (Scan QR Code from Screen...) action: @selector (scanQRCode ) keyEquivalent: @" " ]];
105
+ [menu addItem: [NSMenuItem separatorItem ]];
102
106
[menu addItemWithTitle: _L (Show Logs...) action: @selector (showLogs ) keyEquivalent: @" " ];
103
107
[menu addItemWithTitle: _L (Help) action: @selector (showHelp ) keyEquivalent: @" " ];
104
108
[menu addItem: [NSMenuItem separatorItem ]];
@@ -264,6 +268,20 @@ - (void)editPAC {
264
268
[[NSWorkspace sharedWorkspace ] activateFileViewerSelectingURLs: fileURLs];
265
269
}
266
270
271
+
272
+ - (void )editUserRule {
273
+
274
+ if (![[NSFileManager defaultManager ] fileExistsAtPath: userRulePath]) {
275
+ NSError *error = nil ;
276
+ [[NSFileManager defaultManager ] createDirectoryAtPath: configPath withIntermediateDirectories: NO attributes: nil error: &error];
277
+ // TODO check error
278
+ [@" ! Put user rules line by line in this file.\n ! See https://adblockplus.org/en/filter-cheatsheet\n " writeToFile: userRulePath atomically: YES encoding: NSUTF8StringEncoding error: &error];
279
+ }
280
+
281
+ NSArray *fileURLs = @[[NSURL fileURLWithPath: userRulePath]];
282
+ [[NSWorkspace sharedWorkspace ] activateFileViewerSelectingURLs: fileURLs];
283
+ }
284
+
267
285
- (void )showQRCode {
268
286
NSURL *qrCodeURL = [ShadowsocksRunner generateSSURL ];
269
287
if (qrCodeURL) {
0 commit comments