|
@@ -13,6 +13,7 @@ from PySide2.QtWidgets import (
|
13
|
13
|
QGridLayout,
|
14
|
14
|
QInputDialog,
|
15
|
15
|
QMainWindow,
|
|
16
|
+ QMessageBox,
|
16
|
17
|
QPushButton,
|
17
|
18
|
QSizePolicy,
|
18
|
19
|
QToolBar,
|
|
@@ -175,6 +176,10 @@ class PiketMainWindow(QMainWindow):
|
175
|
176
|
)
|
176
|
177
|
self.toolbar.addAction(self.load_icon("undo.svg"), "Oeps")
|
177
|
178
|
|
|
179
|
+ self.toolbar.addAction(
|
|
180
|
+ self.load_icon("quit.svg"), "Afsluiten", self.confirm_quit
|
|
181
|
+ )
|
|
182
|
+
|
178
|
183
|
self.toolbar.addWidget(self.create_spacer())
|
179
|
184
|
|
180
|
185
|
# Right
|
|
@@ -263,6 +268,20 @@ class PiketMainWindow(QMainWindow):
|
263
|
268
|
|
264
|
269
|
self.main_widget.init_ui()
|
265
|
270
|
|
|
271
|
+ def confirm_quit(self) -> None:
|
|
272
|
+ """ Ask for confirmation that the user wishes to quit, then do so. """
|
|
273
|
+ ok = QMessageBox.warning(
|
|
274
|
+ self,
|
|
275
|
+ "Wil je echt afsluiten?",
|
|
276
|
+ "Bevestig dat je wilt afsluiten.",
|
|
277
|
+ QMessageBox.Yes,
|
|
278
|
+ QMessageBox.Cancel,
|
|
279
|
+ )
|
|
280
|
+
|
|
281
|
+ if ok == QMessageBox.Yes:
|
|
282
|
+ LOG.warning("Shutdown by user.")
|
|
283
|
+ QApplication.instance().quit()
|
|
284
|
+
|
266
|
285
|
@staticmethod
|
267
|
286
|
def create_spacer() -> QWidget:
|
268
|
287
|
""" Return an empty QWidget that automatically expands. """
|