Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Fix color proofing dialog not working on Qt5
Dmitry Kazakov152f429d7aa2
diff --git a/libs/image/KisProofingConfiguration.cpp b/libs/image/KisProofingConfiguration.cppindex 60edf4ac78..8f0de44dfd 100644--- a/libs/image/KisProofingConfiguration.cpp+++ b/libs/image/KisProofingConfiguration.cpp@@ -6,6 +6,11 @@#include "KisProofingConfiguration.h"+#include <KisStaticInitializer.h>++KIS_DECLARE_STATIC_INITIALIZER {+ qRegisterMetaType<KisProofingConfiguration::DisplayTransformState>();+}KisProofingConfiguration::KisProofingConfiguration(): conversionIntent(KoColorConversionTransformation::IntentRelativeColorimetric),diff --git a/libs/image/KisProofingConfiguration.h b/libs/image/KisProofingConfiguration.hindex 3308d91531..caae6a8aaf 100644--- a/libs/image/KisProofingConfiguration.h+++ b/libs/image/KisProofingConfiguration.h@@ -51,4 +51,6 @@ public:bool operator!=(const KisProofingConfiguration &other) const;};+Q_DECLARE_METATYPE(KisProofingConfiguration::DisplayTransformState);+#endif // KISPROOFINGCONFIGURATION_Hdiff --git a/libs/pigment/KoColorConversionTransformation.cpp b/libs/pigment/KoColorConversionTransformation.cppindex fb7f666f73..299a69d276 100644--- a/libs/pigment/KoColorConversionTransformation.cpp+++ b/libs/pigment/KoColorConversionTransformation.cpp@@ -8,6 +8,12 @@#include "KoColorSpace.h"+#include <KisStaticInitializer.h>++KIS_DECLARE_STATIC_INITIALIZER {+ qRegisterMetaType<KoColorConversionTransformation::Intent>();+}+struct Q_DECL_HIDDEN KoColorConversionTransformation::Private {const KoColorSpace* srcColorSpace;const KoColorSpace* dstColorSpace;diff --git a/libs/pigment/KoColorConversionTransformation.h b/libs/pigment/KoColorConversionTransformation.hindex c3fdb0879f..e02369da75 100644--- a/libs/pigment/KoColorConversionTransformation.h+++ b/libs/pigment/KoColorConversionTransformation.h@@ -7,9 +7,9 @@#ifndef _KO_COLOR_CONVERSION_TRANSFORMATION_H_#define _KO_COLOR_CONVERSION_TRANSFORMATION_H_-#include "KoColorTransformation.h"-#include "kritapigment_export.h"+#include "KoColorTransformation.h"+#include <QMetaType>class KoColorSpace;class KoColorConversionCache;@@ -132,6 +132,7 @@ private:Private * const d;};-Q_DECLARE_OPERATORS_FOR_FLAGS(KoColorConversionTransformation::ConversionFlags)+Q_DECLARE_OPERATORS_FOR_FLAGS(KoColorConversionTransformation::ConversionFlags);+Q_DECLARE_METATYPE(KoColorConversionTransformation::Intent);#endifdiff --git a/libs/ui/dialogs/kis_dlg_image_properties.cc b/libs/ui/dialogs/kis_dlg_image_properties.ccindex af9ac5f8d9..dd4dc1bbf0 100644--- a/libs/ui/dialogs/kis_dlg_image_properties.cc+++ b/libs/ui/dialogs/kis_dlg_image_properties.cc@@ -27,13 +27,11 @@struct KisDlgImageProperties::Private {Private(KisDisplayColorConverter *colorConverter)- : proofingModel(KisProofingConfigModel())- , compressor(KisSignalCompressor(500 /* ms */, KisSignalCompressor::POSTPONE))+ : compressor(KisSignalCompressor(500 /* ms */, KisSignalCompressor::POSTPONE)), colorConverter(colorConverter){}KisImageWSP image;- KisProofingConfigModel proofingModel;KisProofingConfigurationSP originalProofingConfig;bool firstProofingConfigChange {true};QLabel *colorWarningLabel {0};diff --git a/libs/widgets/KisWidgetConnectionUtils.cpp b/libs/widgets/KisWidgetConnectionUtils.cppindex 2390d07f91..0a2c16b510 100644--- a/libs/widgets/KisWidgetConnectionUtils.cpp+++ b/libs/widgets/KisWidgetConnectionUtils.cpp@@ -31,6 +31,14 @@*/#define SANITY_CHECK_PROPERTY_EXISTS(prop) Q_ASSERT(prop.isValid())#define SANITY_CHECK_PROPERTY_EXISTS_AND_WRITABLE(prop) do { Q_ASSERT(prop.isValid()); Q_ASSERT(prop.isWritable()); } while (0)+#define SANITY_CHECK_PROPERTY_METATYPE_REGISTERED(prop) do { \+ const int metaTypeId = QMetaType::type(prop.typeName()); \+ if (metaTypeId <= 0) { \+ qWarning().nospace() << "WARNING: metatype for property \"" << prop.name() << "\" is not register. Please register type \"" << prop.typeName() << "\""; \+ } \+ Q_ASSERT(metaTypeId > 0); \+ Q_ASSERT(QMetaType::isRegistered(metaTypeId)); \+} while (0)class ConnectButtonStateHelper : public QObject{@@ -512,6 +520,14 @@ void connectControlState(QComboBox *button, QObject *source, const char *readStaQMetaProperty writeProp = meta->property(meta->indexOfProperty(writePropertyName));SANITY_CHECK_PROPERTY_EXISTS_AND_WRITABLE(writeProp);++ /**+ * On Qt5 to perform conversion from int to enum, the enum should be registered as+ * a metatype, so we should manually verify that. For some reason, on Qt6 it is not+ * necessary.+ */+ SANITY_CHECK_PROPERTY_METATYPE_REGISTERED(writeProp);+if (writeProp.isWritable()) {QObject::connect(button, qOverload<int>(&QComboBox::currentIndexChanged),source, [writeProp, source] (int value) { writeProp.write(source, value); });@@ -540,6 +556,8 @@ void connectControl(QComboBox *button, QObject *source, const char *property)button->setCurrentIndex(stateProp.read(source).value<int>());if (stateProp.isWritable()) {+ // see a comment in connectControlState(QComboBox *button, ...)+ SANITY_CHECK_PROPERTY_METATYPE_REGISTERED(stateProp);QObject::connect(button, qOverload<int>(&QComboBox::currentIndexChanged),source, [stateProp, source] (int value) { stateProp.write(source, value); });}