2021-11-16 18:57:09 +00:00
|
|
|
from PySide2 import QtGui, QtWidgets
|
|
|
|
|
|
|
|
from task_completer import TaskCompleter
|
|
|
|
|
|
|
|
|
2021-11-17 03:29:51 +00:00
|
|
|
class ImportTask(QtWidgets.QDialog):
|
2021-11-16 18:57:09 +00:00
|
|
|
def __init__(self, parent, *args, **kwargs):
|
|
|
|
super().__init__(parent, *args, **kwargs)
|
|
|
|
self.setWindowTitle("New Tasks")
|
|
|
|
|
|
|
|
self.line_edit = QtWidgets.QLineEdit()
|
|
|
|
completer = TaskCompleter()
|
|
|
|
self.line_edit.setCompleter(completer)
|
|
|
|
self.line_edit.textChanged.connect(completer.update_picker)
|
|
|
|
|
|
|
|
ok_button = QtWidgets.QPushButton()
|
2021-11-16 22:55:58 +00:00
|
|
|
ok_button.setText("OK")
|
2021-11-17 02:12:22 +00:00
|
|
|
ok_button.setIcon(QtGui.QIcon.fromTheme("dialog-ok"))
|
2021-11-16 22:55:58 +00:00
|
|
|
ok_button.pressed.connect(self.accept)
|
|
|
|
ok_button.setAutoDefault(True)
|
|
|
|
|
|
|
|
cancel_button = QtWidgets.QPushButton()
|
|
|
|
cancel_button.setText("Cancel")
|
|
|
|
cancel_button.setIcon(QtGui.QIcon.fromTheme("dialog-cancel"))
|
|
|
|
cancel_button.pressed.connect(self.reject)
|
|
|
|
cancel_button.setAutoDefault(False)
|
2021-11-16 18:57:09 +00:00
|
|
|
|
|
|
|
blayout = QtWidgets.QHBoxLayout()
|
|
|
|
blayout.addSpacing(300)
|
|
|
|
blayout.addWidget(cancel_button)
|
2021-11-16 22:55:58 +00:00
|
|
|
blayout.addWidget(ok_button)
|
2021-11-16 18:57:09 +00:00
|
|
|
|
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
|
|
layout.addWidget(self.line_edit)
|
|
|
|
layout.addLayout(blayout)
|
|
|
|
self.setLayout(layout)
|
|
|
|
self.resize(500, 0)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def task_text(self):
|
|
|
|
return self.line_edit.text()
|
2021-11-16 22:55:58 +00:00
|
|
|
|
|
|
|
def reset_task_text(self):
|
|
|
|
self.line_edit.setText("")
|