Skip to content

Commit

Permalink
Optimize set menu title.
Browse files Browse the repository at this point in the history
  • Loading branch information
HsOjo committed Dec 17, 2019
1 parent 71f7a13 commit aa45013
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions app/base/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, config_class):
self.is_admin = system_api.check_admin()
threading.Thread(target=self.check_update, args=(False,)).start()

def add_menu(self, name, title='', callback=None, parent=None):
def add_menu(self, name, title=None, callback=None, parent=None):
if parent is None:
parent = self.app.menu

Expand All @@ -52,9 +52,11 @@ def add_menu(self, name, title='', callback=None, parent=None):
menu = rumps.MenuItem(name)
parent.add(menu)

menu.title = title if title != '' else str(name)
if title is None:
title = str(name)

item = {'object': menu, 'name': name, 'callback': None, 'parent': parent}
menu.title = title
item = {'object': menu, 'name': name, 'callback': None, 'parent': parent, 'title': title}
self.menu[name] = item
self.menu[id(menu)] = item
self.set_menu_callback(name, callback)
Expand All @@ -70,7 +72,9 @@ def inject_menus(self):

def set_menu_title(self, name, title):
menu = self.app.menu[name] # type: rumps.MenuItem
if menu.title != title:
item = self.menu[id(menu)]
if item['title'] != title:
item['title'] = title
menu.title = title

def set_menu_callback(self, key, callback=None):
Expand Down
2 changes: 1 addition & 1 deletion app/res/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Const:
author = 'HsOjo'
app_name = 'SleeperX'
app_env = '%s_ENV' % app_name.upper()
version = '1.7.2'
version = '1.7.3'
github_page = 'https://github.com/%s/%s' % (author, app_name)
releases_url = '%s/releases' % github_page
protector = '[protector]'
Expand Down

0 comments on commit aa45013

Please sign in to comment.