Krita Source Code Documentation
Loading...
Searching...
No Matches
assignprofiledialog.py
Go to the documentation of this file.
1# SPDX-License-Identifier: CC0-1.0
2
3try:
4 from PyQt6.QtCore import Qt
5 from PyQt6.QtWidgets import (QDialogButtonBox, QDialog,
6 QMessageBox, QComboBox, QVBoxLayout)
7except:
8 from PyQt5.QtCore import Qt
9 from PyQt5.QtWidgets import (QDialogButtonBox, QDialog,
10 QMessageBox, QComboBox, QVBoxLayout)
11from krita import Extension
12from builtins import Application, i18n
13
14
15class AssignProfileDialog(Extension):
16
17 def __init__(self, parent):
18 super(AssignProfileDialog, self).__init__(parent)
19
20 def assignProfile(self):
21 doc = Application.activeDocument()
22 if doc is None:
23 QMessageBox.information(
24 Application.activeWindow().qwindow(),
25 i18n("Assign Profile"),
26 i18n("There is no active document."))
27 return
28
29 self.dialog = QDialog(Application.activeWindow().qwindow())
30
31 self.cmbProfile = QComboBox(self.dialog)
32 for profile in sorted(
33 Application.profiles(doc.colorModel(), doc.colorDepth())):
34 self.cmbProfile.addItem(profile)
35
36 vbox = QVBoxLayout(self.dialog)
37 vbox.addWidget(self.cmbProfile)
38 self.buttonBox = QDialogButtonBox(self.dialog)
39 self.buttonBox.setOrientation(Qt.Orientation.Horizontal)
40 self.buttonBox.setStandardButtons(
41 QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)
42 self.buttonBox.accepted.connect(self.dialog.accept)
43 self.buttonBox.accepted.connect(self.acceptaccept)
44 self.buttonBox.rejected.connect(self.dialog.reject)
45 vbox.addWidget(self.buttonBox)
46 self.dialog.show()
47 self.dialog.activateWindow()
48 self.dialog.exec()
49
50 def accept(self):
51 doc = Application.activeDocument()
52 doc.setColorProfile(self.cmbProfile.currentText())
53
54 def setup(self):
55 pass
56
57 def createActions(self, window):
58 action = window.createAction("assing_profile_to_image",
59 i18n("Assign Profile to Image"))
60 action.triggered.connect(self.assignProfileassignProfile)