Minor GUI changes
This commit is contained in:
parent
d953cdd5ed
commit
f390029899
@ -25,7 +25,6 @@ class Report(QtWidgets.QDialog):
|
|||||||
|
|
||||||
def __init__(self, tasks: Tasks, parent, *args, **kwargs):
|
def __init__(self, tasks: Tasks, parent, *args, **kwargs):
|
||||||
super().__init__(parent, *args, **kwargs)
|
super().__init__(parent, *args, **kwargs)
|
||||||
self._tasks = tasks
|
|
||||||
self._report = None
|
self._report = None
|
||||||
self._report_data = None
|
self._report_data = None
|
||||||
self._changing_items = False
|
self._changing_items = False
|
||||||
@ -40,7 +39,7 @@ class Report(QtWidgets.QDialog):
|
|||||||
self.tableWidget.setColumnCount(3)
|
self.tableWidget.setColumnCount(3)
|
||||||
self.tableWidget.setHorizontalHeaderLabels(["Task", "Start time", "Duration"])
|
self.tableWidget.setHorizontalHeaderLabels(["Task", "Start time", "Duration"])
|
||||||
self.tableWidget.cellChanged.connect(self.cell_changed)
|
self.tableWidget.cellChanged.connect(self.cell_changed)
|
||||||
taskItemCompleter = Report.TaskItemCompleter(self._tasks, self)
|
taskItemCompleter = Report.TaskItemCompleter(tasks, self)
|
||||||
taskItemCompleter.editStarted.connect(self.disable_buttons)
|
taskItemCompleter.editStarted.connect(self.disable_buttons)
|
||||||
taskItemCompleter.editFinished.connect(self.enable_buttons)
|
taskItemCompleter.editFinished.connect(self.enable_buttons)
|
||||||
self.tableWidget.setItemDelegateForColumn(0, taskItemCompleter)
|
self.tableWidget.setItemDelegateForColumn(0, taskItemCompleter)
|
||||||
|
@ -35,5 +35,6 @@ class EditStartedDetector(QtWidgets.QStyledItemDelegate):
|
|||||||
def createEditor(self, parent, option, index):
|
def createEditor(self, parent, option, index):
|
||||||
editor = super().createEditor(parent, option, index)
|
editor = super().createEditor(parent, option, index)
|
||||||
editor.editingFinished.connect(self.editFinished)
|
editor.editingFinished.connect(self.editFinished)
|
||||||
|
editor.selectionChanged.connect(self.editFinished)
|
||||||
self.editStarted.emit()
|
self.editStarted.emit()
|
||||||
return editor
|
return editor
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import enum
|
import enum
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
from fime.progressindicator import ProgressIndicator
|
from fime.progressindicator import ProgressIndicator
|
||||||
from fime.util import get_icon, get_screen_height
|
from fime.task_completer import TaskCompleter
|
||||||
|
from fime.util import get_icon, get_screen_height, EditStartedDetector
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PySide6 import QtCore, QtGui, QtWidgets
|
from PySide6 import QtCore, QtGui, QtWidgets
|
||||||
@ -61,12 +63,25 @@ class Worklog(QtWidgets.QDialog):
|
|||||||
self.setFixedHeight(self.document().size().toSize().height())
|
self.setFixedHeight(self.document().size().toSize().height())
|
||||||
self.text_changed.emit(self.document().toPlainText(), self.row)
|
self.text_changed.emit(self.document().toPlainText(), self.row)
|
||||||
|
|
||||||
|
class TaskItemCompleter(EditStartedDetector):
|
||||||
|
def __init__(self, config, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.config = config
|
||||||
|
|
||||||
|
def createEditor(self, parent, option, index):
|
||||||
|
editor = super().createEditor(parent, option, index)
|
||||||
|
completer = TaskCompleter(self.config)
|
||||||
|
completer.setFilterMode(QtCore.Qt.MatchFlag.MatchContains)
|
||||||
|
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
|
||||||
|
editor.setCompleter(completer)
|
||||||
|
return editor
|
||||||
|
|
||||||
class Status(enum.Enum):
|
class Status(enum.Enum):
|
||||||
PROGRESS = enum.auto()
|
PROGRESS = enum.auto()
|
||||||
OK = enum.auto()
|
OK = enum.auto()
|
||||||
ERROR = enum.auto()
|
ERROR = enum.auto()
|
||||||
|
|
||||||
def __init__(self, parent, *args, **kwargs):
|
def __init__(self, config, parent, *args, **kwargs):
|
||||||
super().__init__(parent, *args, **kwargs)
|
super().__init__(parent, *args, **kwargs)
|
||||||
|
|
||||||
self.setWindowTitle("Worklog")
|
self.setWindowTitle("Worklog")
|
||||||
@ -75,11 +90,16 @@ class Worklog(QtWidgets.QDialog):
|
|||||||
self._report_data = []
|
self._report_data = []
|
||||||
self._status = []
|
self._status = []
|
||||||
self.row_height = None
|
self.row_height = None
|
||||||
|
self.focussed = False
|
||||||
|
|
||||||
self.tableWidget = Worklog.TabTable(self)
|
self.tableWidget = Worklog.TabTable(self)
|
||||||
self.tableWidget.setColumnCount(3)
|
self.tableWidget.setColumnCount(3)
|
||||||
self.tableWidget.setHorizontalHeaderLabels(["Task", "Comment", "Duration"])
|
self.tableWidget.setHorizontalHeaderLabels(["Task", "Comment", "Duration"])
|
||||||
self.tableWidget.cellChanged.connect(self.cell_changed)
|
self.tableWidget.cellChanged.connect(self.cell_changed)
|
||||||
|
taskItemCompleter = Worklog.TaskItemCompleter(config, self)
|
||||||
|
taskItemCompleter.editStarted.connect(self.disable_buttons)
|
||||||
|
taskItemCompleter.editFinished.connect(self.enable_ok)
|
||||||
|
self.tableWidget.setItemDelegateForColumn(0, taskItemCompleter)
|
||||||
self.hheader = QtWidgets.QHeaderView(QtCore.Qt.Orientation.Horizontal)
|
self.hheader = QtWidgets.QHeaderView(QtCore.Qt.Orientation.Horizontal)
|
||||||
self.hheader.setMinimumSectionSize(10)
|
self.hheader.setMinimumSectionSize(10)
|
||||||
self.tableWidget.setHorizontalHeader(self.hheader)
|
self.tableWidget.setHorizontalHeader(self.hheader)
|
||||||
@ -99,6 +119,7 @@ class Worklog(QtWidgets.QDialog):
|
|||||||
#self.upload_button.pressed.connect(self.del_log)
|
#self.upload_button.pressed.connect(self.del_log)
|
||||||
self.upload_button.setAutoDefault(False)
|
self.upload_button.setAutoDefault(False)
|
||||||
self.upload_button.setMinimumWidth(self.upload_button.minimumSizeHint().width() * 1.33)
|
self.upload_button.setMinimumWidth(self.upload_button.minimumSizeHint().width() * 1.33)
|
||||||
|
self.upload_button.setEnabled(False)
|
||||||
|
|
||||||
self.ok_button = QtWidgets.QPushButton()
|
self.ok_button = QtWidgets.QPushButton()
|
||||||
self.ok_button.setText("OK")
|
self.ok_button.setText("OK")
|
||||||
@ -119,14 +140,15 @@ class Worklog(QtWidgets.QDialog):
|
|||||||
def set_data(self, data):
|
def set_data(self, data):
|
||||||
self._report_data = data
|
self._report_data = data
|
||||||
for i, _ in enumerate(self._report_data):
|
for i, _ in enumerate(self._report_data):
|
||||||
self._status.append(
|
self._status.append((Worklog.Status.PROGRESS, "Fetching"))
|
||||||
(Worklog.Status.PROGRESS, "Fetching")
|
|
||||||
)
|
|
||||||
self.refresh_table()
|
self.refresh_table()
|
||||||
|
|
||||||
def update_status(self, row, new_status, status_text="Could not find specified issue"):
|
def update_status(self, row, new_status, status_text="Could not find specified issue"):
|
||||||
self._status[row] = (new_status, status_text)
|
self._status[row] = (new_status, status_text)
|
||||||
self.update_status_view(row)
|
self.update_status_view(row)
|
||||||
|
all_ok = reduce(lambda acc, it: acc and it[0] is Worklog.Status.OK, self._status, True)
|
||||||
|
if all_ok:
|
||||||
|
self.upload_button.setEnabled(True)
|
||||||
|
|
||||||
def refresh_table(self):
|
def refresh_table(self):
|
||||||
self._changing_items = True
|
self._changing_items = True
|
||||||
@ -146,8 +168,9 @@ class Worklog(QtWidgets.QDialog):
|
|||||||
text_edit.setFrameStyle(QtWidgets.QFrame.NoFrame)
|
text_edit.setFrameStyle(QtWidgets.QFrame.NoFrame)
|
||||||
text_edit.text_changed.connect(self.text_edit_changed)
|
text_edit.text_changed.connect(self.text_edit_changed)
|
||||||
self.tableWidget.setCellWidget(row, 1, text_edit)
|
self.tableWidget.setCellWidget(row, 1, text_edit)
|
||||||
if row == 0:
|
if row == 0 and not self.focussed:
|
||||||
text_edit.setFocus()
|
text_edit.setFocus()
|
||||||
|
self.focussed = True
|
||||||
item2 = QtWidgets.QTableWidgetItem(self._report_data[row][2])
|
item2 = QtWidgets.QTableWidgetItem(self._report_data[row][2])
|
||||||
self.tableWidget.setItem(row, 2, item2)
|
self.tableWidget.setItem(row, 2, item2)
|
||||||
item2.setFlags(item2.flags() & QtCore.Qt.ItemIsEnabled)
|
item2.setFlags(item2.flags() & QtCore.Qt.ItemIsEnabled)
|
||||||
@ -156,6 +179,7 @@ class Worklog(QtWidgets.QDialog):
|
|||||||
self.tableWidget.resizeColumnToContents(0)
|
self.tableWidget.resizeColumnToContents(0)
|
||||||
desired_width = self.tableWidget.columnWidth(0) + self.tableWidget.columnWidth(1) + self.tableWidget.columnWidth(2)
|
desired_width = self.tableWidget.columnWidth(0) + self.tableWidget.columnWidth(1) + self.tableWidget.columnWidth(2)
|
||||||
self.tableWidget.setMinimumWidth(min(desired_width, self.tableWidget.maximumWidth()))
|
self.tableWidget.setMinimumWidth(min(desired_width, self.tableWidget.maximumWidth()))
|
||||||
|
|
||||||
screen = QtGui.QGuiApplication.screenAt(self.pos())
|
screen = QtGui.QGuiApplication.screenAt(self.pos())
|
||||||
x = ((screen.size().width() - self.tableWidget.width()) // 2) + screen.geometry().left()
|
x = ((screen.size().width() - self.tableWidget.width()) // 2) + screen.geometry().left()
|
||||||
y = ((screen.size().height() - self.height()) // 2) + screen.geometry().top()
|
y = ((screen.size().height() - self.height()) // 2) + screen.geometry().top()
|
||||||
@ -190,11 +214,12 @@ class Worklog(QtWidgets.QDialog):
|
|||||||
|
|
||||||
@QtCore.Slot()
|
@QtCore.Slot()
|
||||||
def disable_buttons(self):
|
def disable_buttons(self):
|
||||||
pass
|
self.upload_button.setEnabled(False)
|
||||||
|
self.ok_button.setEnabled(False)
|
||||||
|
|
||||||
@QtCore.Slot()
|
@QtCore.Slot()
|
||||||
def enable_buttons(self):
|
def enable_ok(self):
|
||||||
pass
|
self.ok_button.setEnabled(True)
|
||||||
|
|
||||||
@QtCore.Slot()
|
@QtCore.Slot()
|
||||||
def cell_changed(self, row, _):
|
def cell_changed(self, row, _):
|
||||||
|
Loading…
Reference in New Issue
Block a user