@@ -97,8 +97,12 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
9797 [menu addItem: [NSMenuItem separatorItem ]];
9898 [menu addItemWithTitle: _L (Edit PAC for Auto Proxy Mode...) action: @selector (editPAC ) keyEquivalent: @" " ];
9999 [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: @" " ];
101103 [menu addItem: qrCodeMenuItem];
104+ [menu addItem: [[NSMenuItem alloc ] initWithTitle: _L (Scan QR Code from Screen...) action: @selector (scanQRCode ) keyEquivalent: @" " ]];
105+ [menu addItem: [NSMenuItem separatorItem ]];
102106 [menu addItemWithTitle: _L (Show Logs...) action: @selector (showLogs ) keyEquivalent: @" " ];
103107 [menu addItemWithTitle: _L (Help) action: @selector (showHelp ) keyEquivalent: @" " ];
104108 [menu addItem: [NSMenuItem separatorItem ]];
@@ -264,6 +268,20 @@ - (void)editPAC {
264268 [[NSWorkspace sharedWorkspace ] activateFileViewerSelectingURLs: fileURLs];
265269}
266270
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+
267285- (void )showQRCode {
268286 NSURL *qrCodeURL = [ShadowsocksRunner generateSSURL ];
269287 if (qrCodeURL) {
0 commit comments