Changeset View
Changeset View
Standalone View
Standalone View
src/QuickEditor/QuickEditor.cpp
Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Line(s) | 107 | QMetaObject::invokeMethod( | |||
---|---|---|---|---|---|
109 | Q_ARG(QVariant, cropRegion.x() / pixelRatio), | 109 | Q_ARG(QVariant, cropRegion.x() / pixelRatio), | ||
110 | Q_ARG(QVariant, cropRegion.y() / pixelRatio), | 110 | Q_ARG(QVariant, cropRegion.y() / pixelRatio), | ||
111 | Q_ARG(QVariant, cropRegion.width() / pixelRatio), | 111 | Q_ARG(QVariant, cropRegion.width() / pixelRatio), | ||
112 | Q_ARG(QVariant, cropRegion.height() / pixelRatio) | 112 | Q_ARG(QVariant, cropRegion.height() / pixelRatio) | ||
113 | ); | 113 | ); | ||
114 | } | 114 | } | ||
115 | } | 115 | } | ||
116 | 116 | | |||
117 | rootItem->setProperty("showMagnifier", config->showMagnifierChecked()); | ||||
118 | | ||||
117 | if (config->useLightRegionMaskColour()) { | 119 | if (config->useLightRegionMaskColour()) { | ||
118 | rootItem->setProperty("maskColour", QColor(255, 255, 255, 100)); | 120 | rootItem->setProperty("maskColour", QColor(255, 255, 255, 100)); | ||
119 | rootItem->setProperty("strokeColour", QColor(96, 96, 96, 255)); | 121 | rootItem->setProperty("strokeColour", QColor(96, 96, 96, 255)); | ||
122 | rootItem->setProperty("crossColour", QColor(96, 96, 96, 127)); | ||||
alexeymin: It is considered bad practice to directly manupulate QML from C++. Good practice: instead of… | |||||
120 | } | 123 | } | ||
121 | } | 124 | } | ||
122 | 125 | | |||
123 | QuickEditor::~QuickEditor() | 126 | QuickEditor::~QuickEditor() | ||
124 | { | 127 | { | ||
125 | Q_D(QuickEditor); | 128 | Q_D(QuickEditor); | ||
126 | delete d->mQuickView; | 129 | delete d->mQuickView; | ||
127 | delete d->mDecl; | 130 | delete d->mDecl; | ||
Show All 22 Lines |
It is considered bad practice to directly manupulate QML from C++. Good practice: instead of connecting to signals from QML to C++, just expose slots from C++ objects into QML. From QML, call those slots to notify about events.
Do not set properties manually, just expose them from C++ objects as Q_PROPERTY so QML code can use them directly. Global application settings should be exposed into QML with context properties (d->mQuickView->rootContext()->setContextProperty()).
In this case you could directly modify showMagnifier property, instead of invoking a method by QMetaObject::invokeMethod(), if you already have root item:
I know, this how it was done in existing code already, but do not write new code like this example in Spectacle. It is bad. Perhaps, the whole QuickEditor thing in Specatcle (and its corresponding QML) should be rewritten, but this is unrelated to this diff...