Various improvements
This commit is contained in:
parent
30c4035eff
commit
56285caeab
2
data.py
2
data.py
@ -51,9 +51,7 @@ class Tasks:
|
|||||||
return self._jira_tasks
|
return self._jira_tasks
|
||||||
|
|
||||||
def add_jira_task(self, task_name):
|
def add_jira_task(self, task_name):
|
||||||
print(f"before: {self._jira_tasks}")
|
|
||||||
self._jira_tasks.append(task_name)
|
self._jira_tasks.append(task_name)
|
||||||
print(f"after: {self._jira_tasks}")
|
|
||||||
self._jira_tasks_usage[task_name] = datetime.now()
|
self._jira_tasks_usage[task_name] = datetime.now()
|
||||||
if len(self._jira_tasks_usage) > max_jira_tasks:
|
if len(self._jira_tasks_usage) > max_jira_tasks:
|
||||||
sorted_tasks = sorted(self._jira_tasks_usage.keys(), key=lambda x: self._jira_tasks_usage[x])
|
sorted_tasks = sorted(self._jira_tasks_usage.keys(), key=lambda x: self._jira_tasks_usage[x])
|
||||||
|
25
main.py
25
main.py
@ -12,6 +12,7 @@ from exceptions import FimeFrackingException
|
|||||||
from new_task import NewTask
|
from new_task import NewTask
|
||||||
from task_edit import TaskEdit
|
from task_edit import TaskEdit
|
||||||
from report import Report
|
from report import Report
|
||||||
|
from util import get_screen_height
|
||||||
|
|
||||||
|
|
||||||
class App:
|
class App:
|
||||||
@ -21,7 +22,7 @@ class App:
|
|||||||
data = Data()
|
data = Data()
|
||||||
self.tasks = Tasks(data)
|
self.tasks = Tasks(data)
|
||||||
self.log = Log(data)
|
self.log = Log(data)
|
||||||
self.active_task = self.log.last_log() or "Nothing"
|
self._active_task = self.log.last_log() or "Nothing"
|
||||||
|
|
||||||
icon = QtGui.QIcon.fromTheme("appointment-new")
|
icon = QtGui.QIcon.fromTheme("appointment-new")
|
||||||
|
|
||||||
@ -57,29 +58,41 @@ class App:
|
|||||||
@QtCore.Slot()
|
@QtCore.Slot()
|
||||||
def report_done(self):
|
def report_done(self):
|
||||||
self.active_task = self.log.last_log() or "Nothing"
|
self.active_task = self.log.last_log() or "Nothing"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def active_task(self):
|
||||||
|
return self._active_task
|
||||||
|
|
||||||
|
@active_task.setter
|
||||||
|
def active_task(self, task):
|
||||||
|
self._active_task = task
|
||||||
|
self.tasks.update_jira_task_usage(self._active_task)
|
||||||
self.update_tray_menu()
|
self.update_tray_menu()
|
||||||
|
|
||||||
def change_task(self, task):
|
def change_task(self, task):
|
||||||
self.active_task = task
|
self.active_task = task
|
||||||
if task == "Nothing":
|
|
||||||
return
|
|
||||||
self.log.log(task)
|
self.log.log(task)
|
||||||
self.update_tray_menu()
|
|
||||||
|
|
||||||
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)
|
a = self.menu.addAction(t)
|
||||||
|
action_height = self.menu.actionGeometry(a).height()
|
||||||
a.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"))
|
a.setIcon(QtGui.QIcon.fromTheme("go-next"))
|
||||||
|
return action_height
|
||||||
|
|
||||||
self.menu.clear()
|
self.menu.clear()
|
||||||
|
|
||||||
add_tasks(self.tasks.tasks)
|
action_height = add_tasks(self.tasks.tasks)
|
||||||
|
already_taken = (len(self.tasks.tasks) + 4) * action_height
|
||||||
|
available_space = get_screen_height(self.menu) * 0.8 - already_taken
|
||||||
|
jira_entry_count = int(available_space // action_height)
|
||||||
|
|
||||||
self.menu.addSeparator()
|
self.menu.addSeparator()
|
||||||
add_tasks(self.tasks.jira_tasks)
|
add_tasks(self.tasks.jira_tasks[:jira_entry_count])
|
||||||
|
|
||||||
self.menu.addSeparator()
|
self.menu.addSeparator()
|
||||||
add_tasks(["Pause"])
|
add_tasks(["Pause"])
|
||||||
|
@ -5,6 +5,7 @@ from datetime import datetime
|
|||||||
from PySide2.QtWidgets import QHeaderView
|
from PySide2.QtWidgets import QHeaderView
|
||||||
|
|
||||||
from data import Tasks
|
from data import Tasks
|
||||||
|
from util import get_screen_height
|
||||||
|
|
||||||
|
|
||||||
class Report(QtWidgets.QDialog):
|
class Report(QtWidgets.QDialog):
|
||||||
@ -120,13 +121,8 @@ class Report(QtWidgets.QDialog):
|
|||||||
self.tableWidget.resizeColumnToContents(0)
|
self.tableWidget.resizeColumnToContents(0)
|
||||||
|
|
||||||
if self.tableWidget.rowCount() > 4:
|
if self.tableWidget.rowCount() > 4:
|
||||||
if hasattr(self.tableWidget, "screen"):
|
|
||||||
screen_height = self.tableWidget.screen().size().height()
|
|
||||||
else:
|
|
||||||
print("unable to detect screen height falling back to default value of 1080")
|
|
||||||
screen_height = 1080
|
|
||||||
self.tableWidget.setMinimumHeight(min((self.tableWidget.rowCount() + 2) * self.tableWidget.rowHeight(0),
|
self.tableWidget.setMinimumHeight(min((self.tableWidget.rowCount() + 2) * self.tableWidget.rowHeight(0),
|
||||||
screen_height * 0.8))
|
get_screen_height(self.tableWidget) * 0.8))
|
||||||
|
|
||||||
def update_prev_next(self):
|
def update_prev_next(self):
|
||||||
prev, _next = self._report.prev_next_avail()
|
prev, _next = self._report.prev_next_avail()
|
||||||
|
@ -24,7 +24,7 @@ class TaskCompleter(QCompleter):
|
|||||||
self.search_url = os.path.join(self.config.jira_url, "rest/api/2/search")
|
self.search_url = os.path.join(self.config.jira_url, "rest/api/2/search")
|
||||||
self.text = ""
|
self.text = ""
|
||||||
self.response_text = ""
|
self.response_text = ""
|
||||||
self.model_string_list = []
|
self.model_data = set()
|
||||||
self.escalate = False
|
self.escalate = False
|
||||||
self.update_timer = QTimer(self)
|
self.update_timer = QTimer(self)
|
||||||
self.update_timer.timeout.connect(self.process_response)
|
self.update_timer.timeout.connect(self.process_response)
|
||||||
@ -39,10 +39,10 @@ class TaskCompleter(QCompleter):
|
|||||||
if result_dict["response_text"] == self.text:
|
if result_dict["response_text"] == self.text:
|
||||||
if self.text == self.response_text:
|
if self.text == self.response_text:
|
||||||
self.response_text = result_dict["response_text"]
|
self.response_text = result_dict["response_text"]
|
||||||
self.model_string_list = result_dict["result"]
|
self.model_data = set(result_dict["result"])
|
||||||
else:
|
else:
|
||||||
self.model_string_list += result_dict["result"]
|
self.model_data = self.model_data.union(set(result_dict["result"]))
|
||||||
self.model().setStringList(self.model_string_list)
|
self.model().setStringList(self.model_data)
|
||||||
self.complete()
|
self.complete()
|
||||||
except Empty:
|
except Empty:
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user