Krita Source Code Documentation
Loading...
Searching...
No Matches
KisQQuickWidget Class Reference

The KisQQuickWidget class. More...

#include <KisQQuickWidget.h>

+ Inheritance diagram for KisQQuickWidget:

Public Member Functions

void connectMinimumHeightToRootObject ()
 connectMinimumHeightToRootObject By default we scale rootObject to widget, but in some situations we need the widget to have the minimum required height of the root object. This sets up a connection that links the minimum height to the root object implicitHeight.
 
void connectMinimumWidthToRootObject ()
 connectMinimumWidthToRootObject Same as for connectMinimumHeightToRootObject, but then for width.
 
 KisQQuickWidget (QWidget *parent=nullptr)
 
 ~KisQQuickWidget ()
 

Private Slots

void setMinimumHeightFromRoot ()
 
void setMinimumWidthFromRoot ()
 
void updatePaletteFromConfig ()
 

Detailed Description

The KisQQuickWidget class.

The purpose of KisQQuickWidget is to tackle a number of configuration steps that need to be taken when using the QQuickWidget, amongst which the setup of the engine.

Definition at line 20 of file KisQQuickWidget.h.

Constructor & Destructor Documentation

◆ KisQQuickWidget()

KisQQuickWidget::KisQQuickWidget ( QWidget * parent = nullptr)

Our version of Qt has a special handling of the color space passed to the surface of the QQuickWidget. It will allow it to render correctly on a Rec2020PQ window.

WARNING: The following selector is only for KisQQuickWidget. Do not copy it to other engines.

Definition at line 22 of file KisQQuickWidget.cpp.

22 : QQuickWidget(parent)
23{
24#if !defined(Q_OS_MACOS) || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
25 QSurfaceFormat format;
26
27 {
33 format.setRedBufferSize(8);
34 format.setGreenBufferSize(8);
35 format.setBlueBufferSize(8);
36 format.setAlphaBufferSize(8);
38 }
39
40 setFormat(format);
41#endif
42
43 engine()->rootContext()->setContextProperty("mainWindow", parent);
44 engine()->rootContext()->setContextObject(new KLocalizedContext(parent));
45
46 // Clear color is the 'default background color', which, in qwidget context is the window bg.
47 setClearColor(palette().window().color());
48 connect(KisConfigNotifier::instance(), SIGNAL(signalColorThemeChanged(QString)), this, SLOT(updatePaletteFromConfig()));
49
50 // Default to fusion style unless the user forces another style
51 const QString fusion = "Fusion";
52 if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE") && QQuickStyle::name() != fusion) {
53 QQuickStyle::setStyle(fusion);
54 }
55
56 engine()->addImportPath(KoResourcePaths::getApplicationRoot() + "/lib/qml/");
57 engine()->addImportPath(KoResourcePaths::getApplicationRoot() + "/lib64/qml/");
58
59 engine()->addPluginPath(KoResourcePaths::getApplicationRoot() + "/lib/qml/");
60 engine()->addPluginPath(KoResourcePaths::getApplicationRoot() + "/lib64/qml/");
61
62 QQmlFileSelector* selector = new QQmlFileSelector(engine());
63 QStringList extraSelectors;
64 /*
65 * This allows for Style specific components, which it'll load from
66 * a "+StyleName" folder.
67 */
68 extraSelectors << QQuickStyle::name();
69#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
70 extraSelectors << "qt6";
71#elif QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
72 extraSelectors << "qt5";
73#endif
78 extraSelectors << "qquickwidget";
79
80 selector->setExtraSelectors(extraSelectors);
81
82
83 setResizeMode(QQuickWidget::SizeRootObjectToView);
84}
static KisConfigNotifier * instance()
static constexpr KisSurfaceColorSpaceWrapper makeSRGBColorSpace()
static QString getApplicationRoot()
rgba palette[MAX_PALETTE]
Definition palette.c:35

References KoResourcePaths::getApplicationRoot(), KisConfigNotifier::instance(), KisSurfaceColorSpaceWrapper::makeSRGBColorSpace(), palette, and updatePaletteFromConfig().

◆ ~KisQQuickWidget()

KisQQuickWidget::~KisQQuickWidget ( )

Prevent accessing destroyed objects in QML engine See:

Definition at line 86 of file KisQQuickWidget.cpp.

87{
92 setParent(nullptr);
93}

Member Function Documentation

◆ connectMinimumHeightToRootObject()

void KisQQuickWidget::connectMinimumHeightToRootObject ( )

connectMinimumHeightToRootObject By default we scale rootObject to widget, but in some situations we need the widget to have the minimum required height of the root object. This sets up a connection that links the minimum height to the root object implicitHeight.

Definition at line 95 of file KisQQuickWidget.cpp.

96{
97 if (rootObject()) {
98 connect(rootObject(), SIGNAL(implicitHeightChanged()), this, SLOT(setMinimumHeightFromRoot()));
100 }
101}

References setMinimumHeightFromRoot().

◆ connectMinimumWidthToRootObject()

void KisQQuickWidget::connectMinimumWidthToRootObject ( )

connectMinimumWidthToRootObject Same as for connectMinimumHeightToRootObject, but then for width.

Definition at line 103 of file KisQQuickWidget.cpp.

104{
105 if (rootObject()) {
106 connect(rootObject(), SIGNAL(implicitWidthChanged()), this, SLOT(setMinimumWidthFromRoot()));
108 }
109}

References setMinimumWidthFromRoot().

◆ setMinimumHeightFromRoot

void KisQQuickWidget::setMinimumHeightFromRoot ( )
privateslot

Definition at line 116 of file KisQQuickWidget.cpp.

117{
118 if (rootObject()) {
119 setMinimumHeight(rootObject()->implicitHeight());
120 }
121}

◆ setMinimumWidthFromRoot

void KisQQuickWidget::setMinimumWidthFromRoot ( )
privateslot

Definition at line 123 of file KisQQuickWidget.cpp.

124{
125 if (rootObject()) {
126 setMinimumWidth(rootObject()->implicitWidth());
127 }
128}

◆ updatePaletteFromConfig

void KisQQuickWidget::updatePaletteFromConfig ( )
privateslot

Definition at line 111 of file KisQQuickWidget.cpp.

112{
113 setClearColor(palette().window().color());
114}

References palette.


The documentation for this class was generated from the following files: