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, QIcon
9 from PyQt6.QtCore import Qt
10except:
11 from PyQt5.QtWidgets import QAction, QMessageBox
12 from PyQt5.QtGui import QKeySequence, QIcon
13 from PyQt5.QtCore import Qt
14from krita import Krita
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.setIcon(Krita.instance().icon("application-exit"))
28 self.setShortcut(QKeySequence(Qt.Modifier.CTRL | Qt.Key.Key_Q))
29
30 @property
31 def parent(self):
32 return 'File',
33
34 def close(self):
35 msgBox = QMessageBox(self.scripter.uicontroller.mainWidget)
36
37 msgBox.setInformativeText(i18n("Do you want to save the current document?"))
38 msgBox.setStandardButtons(QMessageBox.StandardButton.Save | QMessageBox.StandardButton.Discard | QMessageBox.StandardButton.Cancel)
39 msgBox.setDefaultButton(QMessageBox.StandardButton.Save)
40
41 ret = msgBox.exec()
42
43 if ret == QMessageBox.StandardButton.Cancel:
44 return
45 if ret == QMessageBox.StandardButton.Save:
46 if not self.scripter.uicontroller.invokeAction('save'):
47 return
48
49 self.scripter.uicontroller.closeScripter()
static Krita * instance()
instance retrieve the singleton instance of the Application object.
Definition Krita.cpp:396