Changeset View
Changeset View
Standalone View
Standalone View
plugins/extensions/pykrita/plugin/plugins/canvassize/uicanvassize.py
- This file was added.
1 | from canvassize import canvassizedialog | ||||
---|---|---|---|---|---|
2 | from PyQt5.QtCore import Qt | ||||
3 | from PyQt5.QtWidgets import (QFormLayout, QListWidget,QAbstractItemView, | ||||
4 | QDialogButtonBox, QVBoxLayout, QFrame, | ||||
5 | QPushButton, QAbstractScrollArea) | ||||
6 | import krita | ||||
7 | | ||||
8 | | ||||
9 | class UICanvasSize(object): | ||||
10 | | ||||
11 | def __init__(self): | ||||
12 | self.mainDialog = canvassizedialog.CanvasSizeDialog() | ||||
13 | self.mainLayout = QVBoxLayout(self.mainDialog) | ||||
14 | self.formLayout = QFormLayout() | ||||
15 | self.documentLayout = QVBoxLayout() | ||||
16 | self.refreshButton = QPushButton("Refresh") | ||||
17 | self.widgetDocuments = QListWidget() | ||||
18 | self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) | ||||
19 | | ||||
20 | self.kritaInstance = krita.Krita.instance() | ||||
21 | self.documentsList = [] | ||||
22 | | ||||
23 | self.refreshButton.clicked.connect(self.refreshButtonClicked) | ||||
24 | self.buttonBox.accepted.connect(self.confirmButton) | ||||
25 | self.buttonBox.rejected.connect(self.mainDialog.close) | ||||
26 | | ||||
27 | self.mainDialog.setWindowModality(Qt.NonModal) | ||||
28 | self.widgetDocuments.setSelectionMode(QAbstractItemView.MultiSelection) | ||||
29 | self.widgetDocuments.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents) | ||||
30 | | ||||
31 | def initialize(self): | ||||
32 | self.loadDocuments() | ||||
33 | | ||||
34 | self.documentLayout.addWidget(self.widgetDocuments) | ||||
35 | self.documentLayout.addWidget(self.refreshButton) | ||||
36 | | ||||
37 | self.formLayout.addRow('Documents', self.documentLayout) | ||||
38 | | ||||
39 | self.line = QFrame() | ||||
40 | self.line.setFrameShape(QFrame.HLine) | ||||
41 | self.line.setFrameShadow(QFrame.Sunken) | ||||
42 | | ||||
43 | self.mainLayout.addLayout(self.formLayout) | ||||
44 | self.mainLayout.addWidget(self.line) | ||||
45 | self.mainLayout.addWidget(self.buttonBox) | ||||
46 | | ||||
47 | self.mainDialog.resize(500, 300) | ||||
48 | self.mainDialog.setWindowTitle("Canvas Size") | ||||
49 | self.mainDialog.setSizeGripEnabled(True) | ||||
50 | self.mainDialog.show() | ||||
51 | self.mainDialog.activateWindow() | ||||
52 | | ||||
53 | def loadDocuments(self): | ||||
54 | self.widgetDocuments.clear() | ||||
55 | | ||||
56 | self.documentsList = [document for document in self.kritaInstance.documents() if document.fileName()] | ||||
57 | | ||||
58 | for document in self.documentsList: | ||||
59 | self.widgetDocuments.addItem(document.fileName()) | ||||
60 | | ||||
61 | def refreshButtonClicked(self): | ||||
62 | self.loadDocuments() | ||||
63 | | ||||
64 | def confirmButton(self): | ||||
65 | pass |