Improve/Fix action_height detection
This commit is contained in:
parent
a3a2c45832
commit
5177bc4706
@ -75,23 +75,22 @@ class App:
|
|||||||
|
|
||||||
def update_tray_menu(self):
|
def update_tray_menu(self):
|
||||||
def add_tasks(tasks):
|
def add_tasks(tasks):
|
||||||
action_height = None
|
|
||||||
for t in tasks:
|
for t in tasks:
|
||||||
a = self.menu.addAction(t)
|
action = self.menu.addAction(t)
|
||||||
action_height = self.menu.actionGeometry(a).height()
|
action.triggered.connect(partial(self.change_task, t))
|
||||||
a.triggered.connect(partial(self.change_task, t))
|
|
||||||
if t == self.active_task:
|
if t == self.active_task:
|
||||||
a.setIcon(QtGui.QIcon.fromTheme("go-next"))
|
action.setIcon(QtGui.QIcon.fromTheme("go-next"))
|
||||||
return action_height
|
|
||||||
|
tmp_action = self.menu.addAction("tmp")
|
||||||
|
action_height = self.menu.actionGeometry(tmp_action).height()
|
||||||
|
|
||||||
self.menu.clear()
|
self.menu.clear()
|
||||||
|
add_tasks(self.tasks.tasks)
|
||||||
|
|
||||||
action_height = add_tasks(self.tasks.tasks)
|
self.menu.addSeparator()
|
||||||
already_taken = (len(self.tasks.tasks) + 4) * action_height
|
already_taken = (len(self.tasks.tasks) + 4) * action_height
|
||||||
available_space = get_screen_height(self.menu) * 0.8 - already_taken
|
available_space = get_screen_height(self.menu) * 0.8 - already_taken
|
||||||
jira_entry_count = int(available_space // action_height)
|
jira_entry_count = int(available_space // action_height)
|
||||||
|
|
||||||
self.menu.addSeparator()
|
|
||||||
add_tasks(self.tasks.jira_tasks[:jira_entry_count])
|
add_tasks(self.tasks.jira_tasks[:jira_entry_count])
|
||||||
|
|
||||||
self.menu.addSeparator()
|
self.menu.addSeparator()
|
||||||
|
Loading…
Reference in New Issue
Block a user