Krita Source Code Documentation
Loading...
Searching...
No Matches
closeaction.py
Go to the documentation of this file.
1"""
2SPDX-FileCopyrightText: 2017 Eliakin Costa <eliakim170@gmail.com>
3
4SPDX-License-Identifier: GPL-2.0-or-later
5"""
6try:
7 from PyQt6.QtWidgets import QMessageBox
8 from PyQt6.QtGui import QKeySequence, QAction
9 from PyQt6.QtCore import Qt
10except:
11 from PyQt5.QtWidgets import QAction, QMessageBox
12 from PyQt5.QtGui import QKeySequence
13 from PyQt5.QtCore import Qt
14
15from builtins import i18n
16
17class CloseAction(QAction):
18
19 def __init__(self, scripter, parent=None):
20 super(CloseAction, self).__init__(parent)
21 self.scripter = scripter
22
23 self.triggered.connect(self.closeclose)
24
25 self.setText(i18n("Close"))
26 self.setObjectName('close')
27 self.setShortcut(QKeySequence(Qt.Modifier.CTRL | Qt.Key.Key_Q))
28
29 @property
30 def parent(self):
31 return 'File',
32
33 def close(self):
34 msgBox = QMessageBox(self.scripter.uicontroller.mainWidget)
35
36 msgBox.setInformativeText(i18n("Do you want to save the current document?"))
37 msgBox.setStandardButtons(QMessageBox.StandardButton.Save | QMessageBox.StandardButton.Discard | QMessageBox.StandardButton.Cancel)
38 msgBox.setDefaultButton(QMessageBox.StandardButton.Save)
39
40 ret = msgBox.exec()
41
42 if ret == QMessageBox.StandardButton.Cancel:
43 return
44 if ret == QMessageBox.StandardButton.Save:
45 if not self.scripter.uicontroller.invokeAction('save'):
46 return
47
48 self.scripter.uicontroller.closeScripter()
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))