Krita Source Code Documentation
Loading...
Searching...
No Matches
newaction.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
14from krita import Krita
15from builtins import i18n
16
17
18class NewAction(QAction):
19
20 def __init__(self, scripter, parent=None):
21 super(NewAction, self).__init__(parent)
22 self.scripter = scripter
23
24 self.triggered.connect(self.newnew)
25
26 self.setText(i18n("New"))
27 self.setObjectName('new')
28 self.setIcon(Krita.instance().icon("document-new"))
29 self.setShortcut(QKeySequence(Qt.Modifier.CTRL | Qt.Key.Key_N))
30
31 @property
32 def parent(self):
33 return 'File',
34
35 def new(self):
36 msgBox = QMessageBox(self.scripter.uicontroller.mainWidget)
37
38 msgBox.setText(i18n("The document has been modified."))
39 msgBox.setInformativeText(i18n("Do you want to save your changes?"))
40 msgBox.setStandardButtons(QMessageBox.StandardButton.Save | QMessageBox.StandardButton.Discard | QMessageBox.StandardButton.Cancel)
41 msgBox.setDefaultButton(QMessageBox.StandardButton.Save)
42
43 ret = msgBox.exec()
44
45 if ret == QMessageBox.StandardButton.Cancel:
46 return
47 if ret == QMessageBox.StandardButton.Save:
48 self.scripter.uicontroller.invokeAction('save')
49
50 self.scripter.documentcontroller.clearActiveDocument()
51 self.scripter.uicontroller.setStatusBar()
52 self.scripter.uicontroller.clearEditor()
static Krita * instance()
instance retrieve the singleton instance of the Application object.
Definition Krita.cpp:396