3from .
import exportlayersdialog
7 QDialogButtonBox, QVBoxLayout, QFrame,
8 QPushButton, QAbstractScrollArea, QLineEdit,
9 QMessageBox, QCheckBox, QSpinBox,
10 QComboBox, QListWidgetItem)
14 QDialogButtonBox, QVBoxLayout, QFrame,
15 QPushButton, QAbstractScrollArea, QLineEdit,
16 QMessageBox, QCheckBox, QSpinBox,
17 QComboBox, QListWidgetItem)
19from krita
import Krita, InfoObject, FileDialog
20from builtins
import i18n, Application
40 i18n(
"Export filter layers"))
44 i18n(
"Ignore invisible layers"))
46 i18n(
"Adjust export size to layer content"))
48 i18n(
"Add incrementing prefix"))
56 QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)
65 self.
widgetDocuments.setSelectionMode(QListWidget.SelectionMode.MultiSelection)
72 self.
mainDialog.setWindowModality(Qt.WindowModality.NonModal)
74 QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents)
114 self.
line.setFrameShape(QFrame.Shape.HLine)
115 self.
line.setFrameShadow(QFrame.Shadow.Sunken)
122 self.
mainDialog.setWindowTitle(i18n(
"Export Layers"))
141 fullName = document.fileName()
143 shortName = document.name()
145 shortName = os.path.basename(document.fileName())
146 newListItem= QListWidgetItem(shortName)
147 newListItem.setToolTip(fullName)
148 if fullName == currentDoc:
161 selectedDocuments = [
163 for path
in selectedPaths
if path == document.fileName()
167 if not selectedDocuments:
168 self.
msgBox.setText(i18n(
"Select one document."))
170 self.
msgBox.setText(i18n(
"Select the initial directory."))
172 for doc
in selectedDocuments:
174 self.
msgBox.setText(i18n(
"All layers have been exported."))
179 if (os.path.exists(target_directory)
180 and os.path.isdir(target_directory)):
184 os.makedirs(target_directory)
191 documentName = document.fileName()
if document.fileName()
else 'Untitled'
192 fileName, extension = os.path.splitext(os.path.basename(documentName))
193 self.
mkdir(
'/' + fileName)
199 Application.setBatchmode(
True)
202 """ This method get all sub-nodes from the current node and export then in
203 the defined format."""
205 for node
in parentNode.childNodes():
207 nodeName = node.name()
209 nodeName = str(prefixNum) +
"-" + nodeName
211 if node.type() ==
'grouplayer' and not self.
groupAsLayer.isChecked():
212 newDir = os.path.join(parentDir, nodeName)
215 and 'filter' in node.type()):
218 and not node.visible()):
222 if '[jpeg]' in nodeName:
224 elif '[png]' in nodeName:
232 layerFileName =
'{0}{1}/{2}.{3}'.format(
234 parentDir, nodeName, _fileFormat)
238 if node.childNodes()
and not self.
groupAsLayer.isChecked():
244 i18n(
"Select a Folder"),
245 os.path.expanduser(
"~"))
253 self.
resSpinBox.setValue(document.resolution())
float value(const T *src, size_t ch)
static QString getExistingDirectory(QWidget *parent=nullptr, const QString &caption=QString(), const QString &directory=QString(), const QString &dialogName=QString())
Create and show a file dialog and return the name of an existing directory selected by the user.
static Krita * instance()
instance retrieve the singleton instance of the Application object.
_exportLayers(self, parentNode, fileFormat, parentDir)
_setResolution(self, index)
exportFilterLayersCheckBox
addIncrementPrefixCheckBox
refreshButtonClicked(self)
ignoreInvisibleLayersCheckBox