diff options
Diffstat (limited to 'src/gui/tasks/form/widget.py')
-rw-r--r-- | src/gui/tasks/form/widget.py | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/src/gui/tasks/form/widget.py b/src/gui/tasks/form/widget.py index 49bf5f7..846ce90 100644 --- a/src/gui/tasks/form/widget.py +++ b/src/gui/tasks/form/widget.py @@ -1,9 +1,9 @@ from PyQt5 import QtWidgets, QtCore -from typing import Optional, Tuple +from typing import Optional, Tuple, List, Any import db.tasks from model.task import Task, ValidTaskForm - +from model import difficulty, priority import gui.icons import gui.tasks.form.state import gui.tasks.duration @@ -45,6 +45,24 @@ def widget( init_tag = task.tag if task is not None else '' tag_input = line_edit(grid, grid_layout, 2, 'Tag', init_tag) + init_difficulty = task.difficulty if task is not None else difficulty.Difficulty.MEDIUM + difficulty_input = combo_box( + grid, + grid_layout, + 3, + 'Difficulty', + [difficulty.format(d) for d in difficulty.values], + int(init_difficulty)) + + init_priority = task.priority if task is not None else priority.Priority.MEDIUM + priority_input = combo_box( + grid, + grid_layout, + 4, + 'Priority', + [priority.format(d) for d in priority.values], + int(init_priority)) + init_description = task.description if task is not None else '' (description_input, description_signal) = text_edit(widget, 'Description', init_description) layout.addWidget(description_input) @@ -52,12 +70,16 @@ def widget( task_form_edition = gui.tasks.form.state.TaskFormEdition( init_name, name_input.textChanged, - init_description, - description_signal, init_duration, duration_input.textChanged, init_tag, - tag_input.textChanged) + tag_input.textChanged, + init_difficulty, + difficulty_input.currentIndexChanged, + init_priority, + priority_input.currentIndexChanged, + init_description, + description_signal) def on_validate(): form = task_form_edition.get() @@ -90,6 +112,26 @@ def line_edit( return edit +def combo_box( + parent, + layout: QtWidgets.QGridLayout, + n: int, + label: str, + values: List[str], + default_value: int) -> QtWidgets.QComboBox: + + label = QtWidgets.QLabel(label, parent) + layout.addWidget(label, n, 0) + + box = QtWidgets.QComboBox(parent) + for value in values: + box.addItem(value) + if default_value != None: + box.setCurrentIndex(default_value) + layout.addWidget(box, n, 1) + + return box + def text_edit( parent, label: str, |