diff --git a/src/fime/data.py b/src/fime/data.py index 14b462d..c1e29ca 100644 --- a/src/fime/data.py +++ b/src/fime/data.py @@ -327,24 +327,27 @@ def duration_to_str(duration: timedelta) -> str: class PrevNextable: def __init__(self, data: LogCommentsData): self._data = data - self.date = date.today() self._prev = None self._next = None - self._update_prev_next() + self._date = date.today() - def _update_prev_next(self): - self._prev, self._next = self._data.get_prev_next_avail(self.date) + @property + def date(self): + return self._date + + @date.setter + def date(self, value): + self._prev, self._next = self._data.get_prev_next_avail(value) + self._date = value def prev_next_avail(self) -> Tuple[bool, bool]: return self._prev is not None, self._next is not None def previous(self): self.date = self._prev - self._update_prev_next() def next(self): self.date = self._next - self._update_prev_next() def date_str(self) -> str: return self.date.strftime("%Y-%m-%d") diff --git a/src/fime/import_task.py b/src/fime/import_task.py index 722e468..e105143 100644 --- a/src/fime/import_task.py +++ b/src/fime/import_task.py @@ -18,6 +18,7 @@ class ImportTask(QtWidgets.QDialog): completer = TaskCompleter(config) self.line_edit.setCompleter(completer) self.line_edit.textChanged.connect(completer.update_picker) + self.line_edit.setFocus() self.indicator = ProgressIndicator(self) self.indicator.setAnimationDelay(70) @@ -75,5 +76,7 @@ class ImportTask(QtWidgets.QDialog): def task_text(self): return self.line_edit.text() - def reset_task_text(self): + def showEvent(self, _): self.line_edit.setText("") + self.raise_() + self.activateWindow() diff --git a/src/fime/main.py b/src/fime/main.py index da67437..df04ab0 100755 --- a/src/fime/main.py +++ b/src/fime/main.py @@ -116,7 +116,7 @@ class App: self.menu.addSeparator() new_action = self.menu.addAction("Import Jira task") - new_action.triggered.connect(self.new_task_slot) + new_action.triggered.connect(self.import_task.show) edit_action = self.menu.addAction("Edit tasks") edit_action.triggered.connect(self.edit_tasks) @@ -148,11 +148,6 @@ class App: else: self.app.exec_() - @QtCore.Slot() - def new_task_slot(self): - self.import_task.reset_task_text() - self.import_task.show() - @QtCore.Slot() def edit_tasks(self): self.taskEdit.tasks = self.tasks.tasks diff --git a/src/fime/report.py b/src/fime/report.py index ea75235..1ec438f 100644 --- a/src/fime/report.py +++ b/src/fime/report.py @@ -83,7 +83,7 @@ class ReportDialog(QtWidgets.QDialog): self.ok_button.setText("OK") self.ok_button.setIcon(get_icon("dialog-ok")) self.ok_button.pressed.connect(self._accept) - self.ok_button.setAutoDefault(False) + self.ok_button.setAutoDefault(True) blayout = QtWidgets.QHBoxLayout() blayout.addWidget(self.previous_button) @@ -102,6 +102,8 @@ class ReportDialog(QtWidgets.QDialog): self.update_title() self.refresh_table() self.update_prev_next() + self.raise_() + self.activateWindow() def save(self): self._report.save(self._report_data) diff --git a/src/fime/task_edit.py b/src/fime/task_edit.py index 9473a92..07dc593 100644 --- a/src/fime/task_edit.py +++ b/src/fime/task_edit.py @@ -85,3 +85,7 @@ class TaskEdit(QtWidgets.QDialog): @tasks.setter def tasks(self, tasks): self.list.setStringList(tasks) + + def showEvent(self, _): + self.raise_() + self.activateWindow() diff --git a/src/fime/worklog.py b/src/fime/worklog.py index 700e4cb..2887b32 100644 --- a/src/fime/worklog.py +++ b/src/fime/worklog.py @@ -6,7 +6,7 @@ from fime.config import Config from fime.data import Worklog, duration_to_str from fime.progressindicator import ProgressIndicator from fime.task_completer import TaskCompleter -from fime.util import get_icon, EditStartedDetector, Status +from fime.util import get_icon, EditStartedDetector, Status, get_screen_height, get_screen_width from fime.worklog_rest import WorklogRest try: @@ -14,8 +14,6 @@ try: except ImportError: from PySide2 import QtCore, QtGui, QtWidgets -from fime.util import get_screen_width - class WorklogDialog(QtWidgets.QDialog): class TabTable(QtWidgets.QTableWidget): @@ -158,7 +156,7 @@ class WorklogDialog(QtWidgets.QDialog): self.ok_button.setText("OK") self.ok_button.setIcon(get_icon("dialog-ok")) self.ok_button.pressed.connect(self._accept) - self.ok_button.setAutoDefault(False) + self.ok_button.setAutoDefault(True) alayout = QtWidgets.QHBoxLayout() alayout.addWidget(self.previous_button) @@ -182,6 +180,8 @@ class WorklogDialog(QtWidgets.QDialog): self._worklog.date = date.today() self.update_all() self.upload_button.setEnabled(False) + self.raise_() + self.activateWindow() def update_all(self): self.refresh_table() @@ -253,6 +253,10 @@ class WorklogDialog(QtWidgets.QDialog): self.tableWidget.setColumnWidth(0, self.tableWidget.columnWidth(0) + self.row_height) desired_width = self.tableWidget.columnWidth(0) + self.tableWidget.columnWidth(1) + self.tableWidget.columnWidth(2) + 4 self.tableWidget.setMinimumWidth(min(desired_width, self.tableWidget.maximumWidth())) + if self.tableWidget.rowCount() > 4: + desired_height = self.tableWidget.rowCount() * self.tableWidget.rowHeight(0) \ + + self.tableWidget.horizontalHeader().height() + 4 + self.tableWidget.setMinimumHeight(min(desired_height, get_screen_height(self.tableWidget) * 0.8)) self.adjustSize() @QtCore.Slot(int)