aboutsummaryrefslogtreecommitdiff
path: root/src/gui/tasks/modal.py
blob: 36629477a58c5d004515362a74f8264fece54c8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from PyQt5 import QtCore, QtWidgets

from model.task import Task

import gui.tasks.form.widget

def dialog(
        parent: QtWidgets.QWidget,
        title: str,
        action_title: str,
        task: Task,
        on_validated):

    dialog = QtWidgets.QDialog(parent)
    dialog.setWindowTitle(title)
    dialog.setMinimumSize(QtCore.QSize(320, 240))

    layout = QtWidgets.QVBoxLayout(dialog)
    dialog.setLayout(layout)

    layout.addWidget(gui.tasks.form.widget.widget(
        parent = dialog,
        action_title = action_title,
        task = task,
        on_validated = lambda form: on_dialog_validated(dialog, on_validated, form),
        on_cancel = lambda: dialog.reject()))

    return dialog

def on_dialog_validated(dialog, on_validated, f):
    dialog.accept()
    on_validated(f)