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 builtins import i18n
15
16
17class NewAction(QAction):
18
19 def __init__(self, scripter, parent=None):
20 super(NewAction, self).__init__(parent)
21 self.scripter = scripter
22
23 self.triggered.connect(self.newnew)
24
25 self.setText(i18n("New"))
26 self.setObjectName('new')
27 self.setShortcut(QKeySequence(Qt.Modifier.CTRL | Qt.Key.Key_N))
28
29 @property
30 def parent(self):
31 return 'File',
32
33 def new(self):
34 msgBox = QMessageBox(self.scripter.uicontroller.mainWidget)
35
36 msgBox.setText(i18n("The document has been modified."))
37 msgBox.setInformativeText(i18n("Do you want to save your changes?"))
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 self.scripter.uicontroller.invokeAction('save')
47
48 self.scripter.documentcontroller.clearActiveDocument()
49 self.scripter.uicontroller.setStatusBar()
50 self.scripter.uicontroller.clearEditor()
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))