mirror of
https://github.com/qinyuhang/ShadowsocksX-NG-R.git
synced 2026-10-20 06:24:32 +00:00
修正menu bar 颜色问题
修正menu bar 颜色问题
This commit is contained in:
@@ -104,11 +104,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
|
||||
setUpMenu(defaults.bool(forKey: "enable_showSpeed"))
|
||||
|
||||
// statusItem = NSStatusBar.system().statusItem(withLength: 20)
|
||||
// let image = NSImage(named: "menu_icon")
|
||||
// image?.isTemplate = true
|
||||
// statusItem.image = image
|
||||
// statusItem.menu = statusMenu
|
||||
statusItem = NSStatusBar.system().statusItem(withLength: 20)
|
||||
let image = NSImage(named: "menu_icon")
|
||||
image?.isTemplate = true
|
||||
statusItem?.image = image
|
||||
statusItem?.menu = statusMenu
|
||||
|
||||
let notifyCenter = NotificationCenter.default
|
||||
notifyCenter.addObserver(forName: NSNotification.Name(rawValue: NOTIFY_ADV_PROXY_CONF_CHANGED), object: nil, queue: nil
|
||||
@@ -585,21 +585,23 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
runningStatusMenuItem.title = "Shadowsocks: On".localized
|
||||
toggleRunningMenuItem.title = "Turn Shadowsocks Off".localized
|
||||
var image = NSImage(named: "menu_icon")
|
||||
if SystemThemeChangeHelper.isCurrentDark() {
|
||||
image = NSImage(named: "menu_icon_dark_mode")
|
||||
}
|
||||
image?.isTemplate = true
|
||||
// if SystemThemeChangeHelper.isCurrentDark() {
|
||||
// image = NSImage(named: "menu_icon_dark_mode")
|
||||
// }
|
||||
|
||||
statusItemView.setIcon(image!)
|
||||
// statusItem!.image = image
|
||||
// statusItemView.setIcon(image!)
|
||||
statusItem!.image = image
|
||||
} else {
|
||||
runningStatusMenuItem.title = "Shadowsocks: Off".localized
|
||||
toggleRunningMenuItem.title = "Turn Shadowsocks On".localized
|
||||
var image = NSImage(named: "menu_icon_disabled")
|
||||
if SystemThemeChangeHelper.isCurrentDark() {
|
||||
image = NSImage(named: "menu_icon_disabled_dark_mode")
|
||||
}
|
||||
// statusItem.image = image
|
||||
statusItemView.setIcon(image!)
|
||||
// if SystemThemeChangeHelper.isCurrentDark() {
|
||||
// image = NSImage(named: "menu_icon_disabled_dark_mode")
|
||||
// }
|
||||
image?.isTemplate = true
|
||||
statusItem!.image = image
|
||||
// statusItemView.setIcon(image!)
|
||||
}
|
||||
|
||||
if defaults.bool(forKey: "enable_showSpeed") {
|
||||
@@ -666,25 +668,27 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
}
|
||||
|
||||
func setUpMenu(_ showSpeed:Bool){
|
||||
if statusItem == nil{
|
||||
statusItem = NSStatusBar.system().statusItem(withLength: 85)
|
||||
let image = NSImage(named: "menu_icon")
|
||||
image?.isTemplate = true
|
||||
statusItem!.image = image
|
||||
statusItemView = StatusItemView(statusItem: statusItem!, menu: statusMenu)
|
||||
statusItem!.view = statusItemView
|
||||
}
|
||||
if showSpeed{
|
||||
if speedMonitor == nil{
|
||||
speedMonitor = NetWorkMonitor(statusItemView: statusItemView)
|
||||
}
|
||||
statusItem?.length = 85
|
||||
speedMonitor?.start()
|
||||
}else{
|
||||
speedMonitor?.stop()
|
||||
speedMonitor = nil
|
||||
statusItem?.length = 20
|
||||
}
|
||||
// should not operate the system status bar
|
||||
// we can add sub menu like bittorrent sync
|
||||
// if statusItem == nil{
|
||||
// statusItem = NSStatusBar.system().statusItem(withLength: 85)
|
||||
// let image = NSImage(named: "menu_icon")
|
||||
// image?.isTemplate = true
|
||||
// statusItem!.image = image
|
||||
// statusItemView = StatusItemView(statusItem: statusItem!, menu: statusMenu)
|
||||
// statusItem!.view = statusItemView
|
||||
// }
|
||||
// if showSpeed{
|
||||
// if speedMonitor == nil{
|
||||
// speedMonitor = NetWorkMonitor(statusItemView: statusItemView)
|
||||
// }
|
||||
// statusItem?.length = 85
|
||||
// speedMonitor?.start()
|
||||
// }else{
|
||||
// speedMonitor?.stop()
|
||||
// speedMonitor = nil
|
||||
// statusItem?.length = 20
|
||||
// }
|
||||
}
|
||||
|
||||
// MARK:
|
||||
|
||||
@@ -119,6 +119,8 @@ class PreferencesWindowController: NSWindowController
|
||||
profilesTableView.removeRows(at: IndexSet(integer: index), withAnimation: .effectFade)
|
||||
profilesTableView.endUpdates()
|
||||
}
|
||||
self.profilesTableView.scrollRowToVisible(index)
|
||||
self.profilesTableView.selectRowIndexes(IndexSet(integer: index), byExtendingSelection: false)
|
||||
updateProfileBoxVisible()
|
||||
}
|
||||
|
||||
@@ -258,7 +260,7 @@ class PreferencesWindowController: NSWindowController
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// For NSTableViewDataSource
|
||||
// MARK: For NSTableViewDataSource
|
||||
|
||||
func numberOfRows(in tableView: NSTableView) -> Int {
|
||||
if let mgr = profileMgr {
|
||||
@@ -285,7 +287,7 @@ class PreferencesWindowController: NSWindowController
|
||||
return ""
|
||||
}
|
||||
|
||||
// Drag & Drop reorder rows
|
||||
// MARK: Drag & Drop reorder rows
|
||||
|
||||
func tableView(_ tableView: NSTableView, pasteboardWriterForRow row: Int) -> NSPasteboardWriting? {
|
||||
let item = NSPasteboardItem()
|
||||
|
||||
Reference in New Issue
Block a user