diff --git a/plugins/extensions/pykrita/plugin/plugins/colorspace/colorspace.qrc b/plugins/extensions/pykrita/plugin/plugins/colorspace/colorspace.qrc
new file mode 100644
index 0000000000..e18c8e5f30
--- /dev/null
+++ b/plugins/extensions/pykrita/plugin/plugins/colorspace/colorspace.qrc
@@ -0,0 +1,5 @@
+
+
+ icons/refresh.svg
+
+
diff --git a/plugins/extensions/pykrita/plugin/plugins/colorspace/components/__init__.py b/plugins/extensions/pykrita/plugin/plugins/colorspace/components/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/plugins/extensions/pykrita/plugin/plugins/colorspace/components/colordepthcombobox.py b/plugins/extensions/pykrita/plugin/plugins/colorspace/components/colordepthcombobox.py
new file mode 100644
index 0000000000..11c6733991
--- /dev/null
+++ b/plugins/extensions/pykrita/plugin/plugins/colorspace/components/colordepthcombobox.py
@@ -0,0 +1,14 @@
+from PyQt5.QtWidgets import QComboBox
+
+
+class ColorDepthComboBox(QComboBox):
+
+ def __init__(self, uiColorSpace, parent=None):
+ super(ColorDepthComboBox, self).__init__(parent)
+
+ self.uiColorSpace = uiColorSpace
+
+ self.currentTextChanged.connect(self.changedTextColorDepthComboBox)
+
+ def changedTextColorDepthComboBox(self, colorDepth):
+ self.uiColorSpace.loadColorProfiles()
diff --git a/plugins/extensions/pykrita/plugin/plugins/colorspace/components/colormodelcombobox.py b/plugins/extensions/pykrita/plugin/plugins/colorspace/components/colormodelcombobox.py
new file mode 100644
index 0000000000..8cfdeab7a0
--- /dev/null
+++ b/plugins/extensions/pykrita/plugin/plugins/colorspace/components/colormodelcombobox.py
@@ -0,0 +1,14 @@
+from PyQt5.QtWidgets import QComboBox
+
+
+class ColorModelComboBox(QComboBox):
+
+ def __init__(self, uiColorSpace, parent=None):
+ super(ColorModelComboBox, self).__init__(parent)
+
+ self.uiColorSpace = uiColorSpace
+
+ self.currentTextChanged.connect(self.changedTextColorModelComboBox)
+
+ def changedTextColorModelComboBox(self, colorModel):
+ self.uiColorSpace.loadColorDepths()
diff --git a/plugins/extensions/pykrita/plugin/plugins/colorspace/components/colorprofilecombobox.py b/plugins/extensions/pykrita/plugin/plugins/colorspace/components/colorprofilecombobox.py
new file mode 100644
index 0000000000..70628e5fdb
--- /dev/null
+++ b/plugins/extensions/pykrita/plugin/plugins/colorspace/components/colorprofilecombobox.py
@@ -0,0 +1,10 @@
+from PyQt5.QtWidgets import QComboBox
+
+
+class ColorProfileComboBox(QComboBox):
+
+ def __init__(self, uiColorSpace, parent=None):
+ super(ColorProfileComboBox, self).__init__(parent)
+
+ self.uiColorSpace = uiColorSpace
+ self.setSizeAdjustPolicy(self.AdjustToContents)
diff --git a/plugins/extensions/pykrita/plugin/plugins/colorspace/icons/refresh.svg b/plugins/extensions/pykrita/plugin/plugins/colorspace/icons/refresh.svg
new file mode 100644
index 0000000000..e352bcedcb
--- /dev/null
+++ b/plugins/extensions/pykrita/plugin/plugins/colorspace/icons/refresh.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/plugins/extensions/pykrita/plugin/plugins/colorspace/resources_rc.py b/plugins/extensions/pykrita/plugin/plugins/colorspace/resources_rc.py
new file mode 100644
index 0000000000..e4de2a73cf
--- /dev/null
+++ b/plugins/extensions/pykrita/plugin/plugins/colorspace/resources_rc.py
@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+
+# Resource object code
+#
+# Created by: The Resource Compiler for PyQt5 (Qt v5.9.0)
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt5 import QtCore
+
+qt_resource_data = b"\
+\x00\x00\x02\x24\
+\x3c\
+\x3f\x78\x6d\x6c\x20\x76\x65\x72\x73\x69\x6f\x6e\x3d\x22\x31\x2e\
+\x30\x22\x20\x3f\x3e\x3c\x21\x44\x4f\x43\x54\x59\x50\x45\x20\x73\
+\x76\x67\x20\x20\x50\x55\x42\x4c\x49\x43\x20\x27\x2d\x2f\x2f\x57\
+\x33\x43\x2f\x2f\x44\x54\x44\x20\x53\x56\x47\x20\x31\x2e\x31\x2f\
+\x2f\x45\x4e\x27\x20\x20\x27\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\
+\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x47\x72\x61\x70\x68\x69\x63\
+\x73\x2f\x53\x56\x47\x2f\x31\x2e\x31\x2f\x44\x54\x44\x2f\x73\x76\
+\x67\x31\x31\x2e\x64\x74\x64\x27\x3e\x3c\x73\x76\x67\x20\x65\x6e\
+\x61\x62\x6c\x65\x2d\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\x64\x3d\
+\x22\x6e\x65\x77\x20\x30\x20\x30\x20\x34\x31\x20\x33\x34\x22\x20\
+\x68\x65\x69\x67\x68\x74\x3d\x22\x33\x34\x70\x78\x22\x20\x69\x64\
+\x3d\x22\x4c\x61\x79\x65\x72\x5f\x31\x22\x20\x76\x65\x72\x73\x69\
+\x6f\x6e\x3d\x22\x31\x2e\x31\x22\x20\x76\x69\x65\x77\x42\x6f\x78\
+\x3d\x22\x30\x20\x30\x20\x34\x31\x20\x33\x34\x22\x20\x77\x69\x64\
+\x74\x68\x3d\x22\x34\x31\x70\x78\x22\x20\x78\x6d\x6c\x3a\x73\x70\
+\x61\x63\x65\x3d\x22\x70\x72\x65\x73\x65\x72\x76\x65\x22\x20\x78\
+\x6d\x6c\x6e\x73\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\
+\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x32\x30\x30\x30\x2f\x73\x76\x67\
+\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6c\x69\x6e\x6b\x3d\x22\x68\
+\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\
+\x2f\x31\x39\x39\x39\x2f\x78\x6c\x69\x6e\x6b\x22\x3e\x3c\x70\x61\
+\x74\x68\x20\x64\x3d\x22\x4d\x33\x33\x2e\x39\x34\x39\x2c\x31\x36\
+\x43\x33\x33\x2e\x34\x32\x39\x2c\x37\x2e\x30\x38\x2c\x32\x36\x2e\
+\x30\x35\x31\x2c\x30\x2c\x31\x37\x2c\x30\x43\x37\x2e\x36\x31\x31\
+\x2c\x30\x2c\x30\x2c\x37\x2e\x36\x31\x31\x2c\x30\x2c\x31\x37\x73\
+\x37\x2e\x36\x31\x31\x2c\x31\x37\x2c\x31\x37\x2c\x31\x37\x76\x2d\
+\x36\x63\x2d\x36\x2e\x30\x37\x35\x2c\x30\x2d\x31\x31\x2d\x34\x2e\
+\x39\x32\x35\x2d\x31\x31\x2d\x31\x31\x20\x20\x53\x31\x30\x2e\x39\
+\x32\x35\x2c\x36\x2c\x31\x37\x2c\x36\x63\x35\x2e\x37\x33\x37\x2c\
+\x30\x2c\x31\x30\x2e\x34\x34\x33\x2c\x34\x2e\x33\x39\x34\x2c\x31\
+\x30\x2e\x39\x34\x39\x2c\x31\x30\x68\x2d\x36\x2e\x38\x34\x39\x4c\
+\x33\x31\x2c\x32\x35\x2e\x38\x39\x39\x4c\x34\x30\x2e\x38\x39\x39\
+\x2c\x31\x36\x48\x33\x33\x2e\x39\x34\x39\x7a\x22\x20\x66\x69\x6c\
+\x6c\x3d\x22\x23\x32\x33\x31\x46\x32\x30\x22\x2f\x3e\x3c\x2f\x73\
+\x76\x67\x3e\
+"
+
+qt_resource_name = b"\
+\x00\x05\
+\x00\x6f\xa6\x53\
+\x00\x69\
+\x00\x63\x00\x6f\x00\x6e\x00\x73\
+\x00\x0b\
+\x0c\x6a\x21\xc7\
+\x00\x72\
+\x00\x65\x00\x66\x00\x72\x00\x65\x00\x73\x00\x68\x00\x2e\x00\x73\x00\x76\x00\x67\
+"
+
+qt_resource_struct = b"\
+\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
+\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
+\x00\x00\x00\x10\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
+"
+
+def qInitResources():
+ QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
+
+def qCleanupResources():
+ QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
+
+qInitResources()
diff --git a/plugins/extensions/pykrita/plugin/plugins/colorspace/uicolorspace.py b/plugins/extensions/pykrita/plugin/plugins/colorspace/uicolorspace.py
index db03536c39..08f9a46053 100644
--- a/plugins/extensions/pykrita/plugin/plugins/colorspace/uicolorspace.py
+++ b/plugins/extensions/pykrita/plugin/plugins/colorspace/uicolorspace.py
@@ -1,113 +1,117 @@
from colorspace import colorspacedialog
+from colorspace.components import colormodelcombobox, colordepthcombobox, colorprofilecombobox
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (QFormLayout, QListWidget, QListWidgetItem,
QAbstractItemView, QComboBox, QDialogButtonBox,
- QVBoxLayout, QFrame, QMessageBox)
+ QVBoxLayout, QFrame, QMessageBox, QPushButton,
+ QHBoxLayout)
+from PyQt5.QtGui import QIcon
import krita
+from colorspace import resources_rc
class UIColorSpace(object):
def __init__(self):
self.mainDialog = colorspacedialog.ColorSpaceDialog()
self.mainLayout = QVBoxLayout(self.mainDialog)
self.formLayout = QFormLayout()
+ self.documentLayout = QVBoxLayout()
+ self.refreshButton = QPushButton(QIcon(':/icons/refresh.svg'), "Refresh")
self.widgetDocuments = QListWidget()
- self.colorModelComboBox = QComboBox()
- self.colorDepthComboBox = QComboBox()
- self.colorProfileComboBox = QComboBox()
+ self.colorModelComboBox = colormodelcombobox.ColorModelComboBox(self)
+ self.colorDepthComboBox = colordepthcombobox.ColorDepthComboBox(self)
+ self.colorProfileComboBox = colorprofilecombobox.ColorProfileComboBox(self)
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.kritaInstance = krita.Krita.instance()
self.documentsList = []
self.colorModelsList = []
self.colorDepthsList = []
self.colorProfilesList = []
- self.colorModelComboBox.currentTextChanged.connect(self.changedColorModelComboBox)
- self.colorDepthComboBox.currentTextChanged.connect(self.changedColorDepthComboBox)
+ self.refreshButton.clicked.connect(self.refreshButtonClicked)
self.buttonBox.accepted.connect(self.confirmButton)
self.buttonBox.rejected.connect(self.mainDialog.close)
self.mainDialog.setWindowModality(Qt.NonModal)
self.widgetDocuments.setSelectionMode(QAbstractItemView.MultiSelection)
def initialize(self):
self.loadDocuments()
self.loadColorModels()
self.loadColorDepths()
self.loadColorProfiles()
- self.formLayout.addRow('Documents', self.widgetDocuments)
+ self.documentLayout.addWidget(self.widgetDocuments)
+ self.documentLayout.addWidget(self.refreshButton)
+
+ self.formLayout.addRow('Documents', self.documentLayout)
self.formLayout.addRow('Color Model', self.colorModelComboBox)
self.formLayout.addRow('Color Depth', self.colorDepthComboBox)
self.formLayout.addRow('Color Profile', self.colorProfileComboBox)
self.line = QFrame()
self.line.setFrameShape(QFrame.HLine)
self.line.setFrameShadow(QFrame.Sunken)
self.mainLayout.addLayout(self.formLayout)
self.mainLayout.addWidget(self.line)
self.mainLayout.addWidget(self.buttonBox)
self.mainDialog.resize(500, 300)
self.mainDialog.setWindowTitle("Color Space")
self.mainDialog.setSizeGripEnabled(True)
self.mainDialog.show()
self.mainDialog.activateWindow()
def loadColorModels(self):
self.colorModelsList = sorted(self.kritaInstance.colorModels())
self.colorModelComboBox.addItems(self.colorModelsList)
- def loadColorDepths(self, colorModel=None):
+ def loadColorDepths(self):
self.colorDepthComboBox.clear()
- if not colorModel:
- colorModel = self.colorModelComboBox.currentText()
+ colorModel = self.colorModelComboBox.currentText()
self.colorDepthsList = sorted(self.kritaInstance.colorDepths(colorModel))
self.colorDepthComboBox.addItems(self.colorDepthsList)
- def loadColorProfiles(self, colorModel=None, colorDepth=None):
+ def loadColorProfiles(self):
self.colorProfileComboBox.clear()
- if not colorModel:
- colorModel = self.colorModelComboBox.currentText()
- if not colorDepth:
- colorDepth = self.colorDepthComboBox.currentText()
-
+ colorModel = self.colorModelComboBox.currentText()
+ colorDepth = self.colorDepthComboBox.currentText()
self.colorProfilesList = sorted(self.kritaInstance.profiles(colorModel, colorDepth))
+
self.colorProfileComboBox.addItems(self.colorProfilesList)
def loadDocuments(self):
self.widgetDocuments.clear()
self.documentsList = [document for document in self.kritaInstance.documents() if document.fileName()]
for document in self.documentsList:
self.widgetDocuments.addItem(document.fileName())
- def changedColorModelComboBox(self, colorModel):
- self.loadColorDepths(colorModel=colorModel)
-
- def changedColorDepthComboBox(self, colorDepth):
- self.loadColorProfiles(colorDepth=colorDepth)
+ def refreshButtonClicked(self):
+ self.loadDocuments()
def confirmButton(self):
selectedPaths = [item.text() for item in self.widgetDocuments.selectedItems()]
selectedDocuments = [document for document in self.documentsList for path in selectedPaths if path==document.fileName()]
- self.convertColorSpace(selectedDocuments)
-
self.msgBox = QMessageBox(self.mainDialog)
- self.msgBox.setText("The selected documents has been converted.")
+ if selectedDocuments:
+ self.convertColorSpace(selectedDocuments)
+ self.msgBox.setText("The selected documents has been converted.")
+ else:
+ self.msgBox.setText("Select at least one document.")
self.msgBox.exec_()
def convertColorSpace(self, documents):
for document in documents:
document.setColorSpace(self.colorModelComboBox.currentText(),
self.colorDepthComboBox.currentText(),
self.colorProfileComboBox.currentText())