File indexing completed on 2024-05-26 04:34:14
0001 # SPDX-License-Identifier: CC0-1.0 0002 0003 from PyQt5.QtCore import Qt 0004 from PyQt5.QtWidgets import (QDialogButtonBox, QDialog, 0005 QMessageBox, QComboBox, QVBoxLayout) 0006 from krita import Extension 0007 0008 0009 class AssignProfileDialog(Extension): 0010 0011 def __init__(self, parent): 0012 super(AssignProfileDialog, self).__init__(parent) 0013 0014 def assignProfile(self): 0015 doc = Application.activeDocument() 0016 if doc is None: 0017 QMessageBox.information( 0018 Application.activeWindow().qwindow(), 0019 i18n("Assign Profile"), 0020 i18n("There is no active document.")) 0021 return 0022 0023 self.dialog = QDialog(Application.activeWindow().qwindow()) 0024 0025 self.cmbProfile = QComboBox(self.dialog) 0026 for profile in sorted( 0027 Application.profiles(doc.colorModel(), doc.colorDepth())): 0028 self.cmbProfile.addItem(profile) 0029 0030 vbox = QVBoxLayout(self.dialog) 0031 vbox.addWidget(self.cmbProfile) 0032 self.buttonBox = QDialogButtonBox(self.dialog) 0033 self.buttonBox.setOrientation(Qt.Horizontal) 0034 self.buttonBox.setStandardButtons( 0035 QDialogButtonBox.Ok | QDialogButtonBox.Cancel) 0036 self.buttonBox.accepted.connect(self.dialog.accept) 0037 self.buttonBox.accepted.connect(self.accept) 0038 self.buttonBox.rejected.connect(self.dialog.reject) 0039 vbox.addWidget(self.buttonBox) 0040 self.dialog.show() 0041 self.dialog.activateWindow() 0042 self.dialog.exec_() 0043 0044 def accept(self): 0045 doc = Application.activeDocument() 0046 doc.setColorProfile(self.cmbProfile.currentText()) 0047 0048 def setup(self): 0049 pass 0050 0051 def createActions(self, window): 0052 action = window.createAction("assing_profile_to_image", 0053 i18n("Assign Profile to Image")) 0054 action.triggered.connect(self.assignProfile)