from PyQt5 import QtWidgets

import gui.tasks.signal
import gui.tasks.table.widget
import gui.icon
import gui.signal

def widget(parent, on_show: gui.signal.Reload):
    widget = QtWidgets.QWidget(parent)

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

    add_task_signal = gui.tasks.signal.AddTask()

    add_task_button = QtWidgets.QPushButton("Add a task", widget)
    add_task_button.setIcon(gui.icon.new_folder(widget.style()))
    add_task_button.clicked.connect(lambda: gui.tasks.dialog.add(widget, add_task_signal).exec_())
    layout.addWidget(add_task_button)

    table = gui.tasks.table.widget.Widget(widget, on_show, add_task_signal)
    layout.addWidget(table)

    return widget