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.

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
74 selector->setExtraSelectors(extraSelectors);
75
76
77 setResizeMode(QQuickWidget::SizeRootObjectToView);
78}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
static KisConfigNotifier * instance()
static constexpr KisSurfaceColorSpaceWrapper makeSRGBColorSpace()
static QString getApplicationRoot()
rgba palette[MAX_PALETTE]
Definition palette.c:35

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

◆ ~KisQQuickWidget()

KisQQuickWidget::~KisQQuickWidget ( )

Prevent accessing destroyed objects in QML engine See:

Definition at line 80 of file KisQQuickWidget.cpp.

81{
86 setParent(nullptr);
87}

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 89 of file KisQQuickWidget.cpp.

90{
91 if (rootObject()) {
92 connect(rootObject(), SIGNAL(implicitHeightChanged()), this, SLOT(setMinimumHeightFromRoot()));
94 }
95}

References connect(), and setMinimumHeightFromRoot().

◆ connectMinimumWidthToRootObject()

void KisQQuickWidget::connectMinimumWidthToRootObject ( )

connectMinimumWidthToRootObject Same as for connectMinimumHeightToRootObject, but then for width.

Definition at line 97 of file KisQQuickWidget.cpp.

98{
99 if (rootObject()) {
100 connect(rootObject(), SIGNAL(implicitWidthChanged()), this, SLOT(setMinimumWidthFromRoot()));
102 }
103}

References connect(), and setMinimumWidthFromRoot().

◆ setMinimumHeightFromRoot

void KisQQuickWidget::setMinimumHeightFromRoot ( )
privateslot

Definition at line 110 of file KisQQuickWidget.cpp.

111{
112 if (rootObject()) {
113 setMinimumHeight(rootObject()->implicitHeight());
114 }
115}

◆ setMinimumWidthFromRoot

void KisQQuickWidget::setMinimumWidthFromRoot ( )
privateslot

Definition at line 117 of file KisQQuickWidget.cpp.

118{
119 if (rootObject()) {
120 setMinimumWidth(rootObject()->implicitWidth());
121 }
122}

◆ updatePaletteFromConfig

void KisQQuickWidget::updatePaletteFromConfig ( )
privateslot

Definition at line 105 of file KisQQuickWidget.cpp.

106{
107 setClearColor(palette().window().color());
108}

References palette.


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