Commit 39e5b30d authored by Boudewijn Rempt's avatar Boudewijn Rempt

Use KisAirbrushOptionProperties instead of KisAirbrushOptionWidget

A KisPaintOp cannot create QWidget based objects because it doesn't
run in the gui thread.

BUG:392190

Special thanks to Peter Eszlari for finding the commit that
introduced the bug!
parent 58aead0c
......@@ -23,7 +23,6 @@ KisPaintopPropertiesBase::~KisPaintopPropertiesBase()
{
}
void KisPaintopPropertiesBase::readOptionSetting(KisPropertiesConfigurationSP settings)
{
readOptionSettingImpl(settings.data());
......
......@@ -75,7 +75,7 @@ KisBrushOp::KisBrushOp(const KisPaintOpSettingsSP settings, KisPainter *painter,
*/
m_brush->setThreadingAllowed(false);
m_airbrushOptionWidget.readOptionSetting(settings);
m_airbrushOption.readOptionSetting(settings);
m_opacityOption.readOptionSetting(settings);
m_flowOption.readOptionSetting(settings);
......@@ -167,7 +167,7 @@ KisSpacingInformation KisBrushOp::paintAt(const KisPaintInformation& info)
KisSpacingInformation spacingInfo =
effectiveSpacing(scale, rotation, &m_airbrushOptionWidget, &m_spacingOption, info);
effectiveSpacing(scale, rotation, &m_airbrushOption, &m_spacingOption, info);
// gather statistics about dabs
m_avgSpacing(spacingInfo.scalarApprox());
......@@ -392,12 +392,12 @@ KisSpacingInformation KisBrushOp::updateSpacingImpl(const KisPaintInformation &i
{
const qreal scale = m_sizeOption.apply(info) * KisLodTransform::lodToScale(painter()->device());
qreal rotation = m_rotationOption.apply(info);
return effectiveSpacing(scale, rotation, &m_airbrushOptionWidget, &m_spacingOption, info);
return effectiveSpacing(scale, rotation, &m_airbrushOption, &m_spacingOption, info);
}
KisTimingInformation KisBrushOp::updateTimingImpl(const KisPaintInformation &info) const
{
return KisPaintOpPluginUtils::effectiveTiming(&m_airbrushOptionWidget, &m_rateOption, info);
return KisPaintOpPluginUtils::effectiveTiming(&m_airbrushOption, &m_rateOption, info);
}
void KisBrushOp::paintLine(const KisPaintInformation& pi1, const KisPaintInformation& pi2, KisDistanceInformation *currentDistance)
......
......@@ -78,7 +78,7 @@ protected:
private:
KisAirbrushOptionWidget m_airbrushOptionWidget;
KisAirbrushOptionProperties m_airbrushOption;
KisPressureSizeOption m_sizeOption;
KisPressureRatioOption m_ratioOption;
KisPressureSpacingOption m_spacingOption;
......
......@@ -58,7 +58,7 @@ KisDeformPaintOp::KisDeformPaintOp(const KisPaintOpSettingsSP settings, KisPaint
m_sizeProperties.readOptionSetting(settings);
m_properties.readOptionSetting(settings);
m_airbrushOptionWidget.readOptionSetting(settings);
m_airbrushOption.readOptionSetting(settings);
// sensors
m_sizeOption.readOptionSetting(settings);
......@@ -151,10 +151,10 @@ KisSpacingInformation KisDeformPaintOp::updateSpacingImpl(const KisPaintInformat
return KisPaintOpPluginUtils::effectiveSpacing(1.0, 1.0, true, 0.0, false, m_spacing, false,
1.0,
KisLodTransform::lodToScale(painter()->device()),
&m_airbrushOptionWidget, nullptr, info);
&m_airbrushOption, nullptr, info);
}
KisTimingInformation KisDeformPaintOp::updateTimingImpl(const KisPaintInformation &info) const
{
return KisPaintOpPluginUtils::effectiveTiming(&m_airbrushOptionWidget, &m_rateOption, info);
return KisPaintOpPluginUtils::effectiveTiming(&m_airbrushOption, &m_rateOption, info);
}
......@@ -58,7 +58,7 @@ private:
DeformOption m_properties;
KisBrushSizeOptionProperties m_sizeProperties;
KisAirbrushOptionWidget m_airbrushOptionWidget;
KisAirbrushOptionProperties m_airbrushOption;
KisPressureSizeOption m_sizeOption;
KisPressureOpacityOption m_opacityOption;
......
......@@ -150,7 +150,7 @@ void KisAirbrushOptionProperties::readOptionSettingImpl(const KisPropertiesConfi
ignoreSpacing = setting->getBool(AIRBRUSH_IGNORE_SPACING, false);
}
void KisAirbrushOptionProperties::writeOptionSettingImpl(KisPropertiesConfiguration *setting) const{
void KisAirbrushOptionProperties::writeOptionSettingImpl(KisPropertiesConfiguration *setting) const {
setting->setProperty(AIRBRUSH_ENABLED, enabled);
setting->setProperty(AIRBRUSH_RATE, 1000.0 / airbrushInterval > 0 ? airbrushInterval : 1.0);
setting->setProperty(AIRBRUSH_IGNORE_SPACING, ignoreSpacing);
......
......@@ -63,14 +63,15 @@ private:
Private *const m_d;
};
struct KisAirbrushOptionProperties : public KisPaintopPropertiesBase
class PAINTOP_EXPORT KisAirbrushOptionProperties : public KisPaintopPropertiesBase
{
public:
bool enabled {false};
qreal airbrushInterval {1000.0 / 20.0};
bool ignoreSpacing {false};
void readOptionSettingImpl(const KisPropertiesConfiguration *setting) override;
void writeOptionSettingImpl(KisPropertiesConfiguration *setting) const override;
protected:
void readOptionSettingImpl(const KisPropertiesConfiguration *settings) override;
void writeOptionSettingImpl(KisPropertiesConfiguration *settings) const override;
};
......
......@@ -136,7 +136,7 @@ KisSpacingInformation KisBrushBasedPaintOp::effectiveSpacing(qreal scale, qreal
}
KisSpacingInformation KisBrushBasedPaintOp::effectiveSpacing(qreal scale, qreal rotation,
const KisAirbrushOptionWidget *airbrushOption,
const KisAirbrushOptionProperties *airbrushOption,
const KisPressureSpacingOption *spacingOption,
const KisPaintInformation &pi) const
{
......
......@@ -73,7 +73,7 @@ public:
KisSpacingInformation effectiveSpacing(qreal scale, qreal rotation, const KisPressureSpacingOption &spacingOption, const KisPaintInformation &pi) const;
KisSpacingInformation effectiveSpacing(qreal scale,
qreal rotation,
const KisAirbrushOptionWidget *airbrushOption,
const KisAirbrushOptionProperties *airbrushOption,
const KisPressureSpacingOption *spacingOption,
const KisPaintInformation &pi) const;
......
......@@ -47,14 +47,14 @@ KisSpacingInformation effectiveSpacing(qreal dabWidth,
bool autoSpacingActive,
qreal autoSpacingCoeff,
qreal lodScale,
const KisAirbrushOptionWidget *airbrushOption,
const KisAirbrushOptionProperties *airbrushOption,
const KisPressureSpacingOption *spacingOption,
const KisPaintInformation &pi)
{
// Extract required parameters.
bool distanceSpacingEnabled = true;
if (airbrushOption && airbrushOption->isChecked()) {
distanceSpacingEnabled = !airbrushOption->ignoreSpacing();
if (airbrushOption && airbrushOption->enabled) {
distanceSpacingEnabled = !airbrushOption->ignoreSpacing;
}
qreal extraScale = 1.0;
if (spacingOption && spacingOption->isChecked()) {
......@@ -77,7 +77,7 @@ KisSpacingInformation effectiveSpacing(qreal dabWidth,
* @param rateOption - The pressure-curve airbrush rate option. Can be null for paintops that don't
* support a pressure-based airbrush rate.
*/
KisTimingInformation effectiveTiming(const KisAirbrushOptionWidget *airbrushOption,
KisTimingInformation effectiveTiming(const KisAirbrushOptionProperties *airbrushOption,
const KisPressureRateOption *rateOption,
const KisPaintInformation &pi)
{
......@@ -85,8 +85,8 @@ KisTimingInformation effectiveTiming(const KisAirbrushOptionWidget *airbrushOpti
bool timingEnabled = false;
qreal timingInterval = LONG_TIME;
if (airbrushOption) {
timingEnabled = airbrushOption->isChecked();
timingInterval = airbrushOption->airbrushInterval();
timingEnabled = airbrushOption->enabled;
timingInterval = airbrushOption->airbrushInterval;
}
qreal rateExtraScale = 1.0;
if (rateOption && rateOption->isChecked()) {
......
......@@ -56,7 +56,7 @@ KisParticlePaintOp::KisParticlePaintOp(const KisPaintOpSettingsSP settings, KisP
m_particleBrush.setProperties(&m_properties);
m_particleBrush.initParticles();
m_airbrushOptionWidget.readOptionSetting(settings);
m_airbrushOption.readOptionSetting(settings);
m_rateOption.readOptionSetting(settings);
m_rateOption.resetAllSensors();
......@@ -78,12 +78,12 @@ KisSpacingInformation KisParticlePaintOp::updateSpacingImpl(const KisPaintInform
{
return KisPaintOpPluginUtils::effectiveSpacing(0.0, 0.0, true, 0.0, false, 0.0, false, 0.0,
KisLodTransform::lodToScale(painter()->device()),
&m_airbrushOptionWidget, nullptr, info);
&m_airbrushOption, nullptr, info);
}
KisTimingInformation KisParticlePaintOp::updateTimingImpl(const KisPaintInformation &info) const
{
return KisPaintOpPluginUtils::effectiveTiming(&m_airbrushOptionWidget, &m_rateOption, info);
return KisPaintOpPluginUtils::effectiveTiming(&m_airbrushOption, &m_rateOption, info);
}
void KisParticlePaintOp::paintLine(const KisPaintInformation &pi1, const KisPaintInformation &pi2,
......
......@@ -54,7 +54,7 @@ private:
KisParticleBrushProperties m_properties;
KisPaintDeviceSP m_dab;
ParticleBrush m_particleBrush;
KisAirbrushOptionWidget m_airbrushOptionWidget;
KisAirbrushOptionProperties m_airbrushOption;
KisPressureRateOption m_rateOption;
bool m_first;
};
......
......@@ -69,7 +69,7 @@ KisSketchPaintOp::KisSketchPaintOp(const KisPaintOpSettingsSP settings, KisPaint
Q_UNUSED(image);
Q_UNUSED(node);
m_airbrushOptionWidget.readOptionSetting(settings);
m_airbrushOption.readOptionSetting(settings);
m_opacityOption.readOptionSetting(settings);
m_sizeOption.readOptionSetting(settings);
m_rotationOption.readOptionSetting(settings);
......@@ -134,7 +134,7 @@ void KisSketchPaintOp::paintLine(const KisPaintInformation &pi1, const KisPaintI
else {
doPaintLine(pi1, pi2);
}
}
}
void KisSketchPaintOp::doPaintLine(const KisPaintInformation &pi1, const KisPaintInformation &pi2)
{
if (!m_brush || !painter()) return;
......@@ -316,10 +316,10 @@ KisSpacingInformation KisSketchPaintOp::updateSpacingImpl(const KisPaintInformat
{
return KisPaintOpPluginUtils::effectiveSpacing(0.0, 0.0, true, 0.0, false, 0.0, false, 0.0,
KisLodTransform::lodToScale(painter()->device()),
&m_airbrushOptionWidget, nullptr, info);
&m_airbrushOption, nullptr, info);
}
KisTimingInformation KisSketchPaintOp::updateTimingImpl(const KisPaintInformation &info) const
{
return KisPaintOpPluginUtils::effectiveTiming(&m_airbrushOptionWidget, &m_rateOption, info);
return KisPaintOpPluginUtils::effectiveTiming(&m_airbrushOption, &m_rateOption, info);
}
......@@ -74,7 +74,7 @@ private:
KisDensityOption m_densityOption;
KisLineWidthOption m_lineWidthOption;
KisOffsetScaleOption m_offsetScaleOption;
KisAirbrushOptionWidget m_airbrushOptionWidget;
KisAirbrushOptionProperties m_airbrushOption;
KisBrushOptionProperties m_brushOption;
SketchProperties m_sketchProperties;
......
......@@ -50,7 +50,7 @@ KisSprayPaintOp::KisSprayPaintOp(const KisPaintOpSettingsSP settings, KisPainter
Q_ASSERT(painter);
Q_UNUSED(image);
m_airbrushOptionWidget.readOptionSetting(settings);
m_airbrushOption.readOptionSetting(settings);
m_rotationOption.readOptionSetting(settings);
m_opacityOption.readOptionSetting(settings);
......@@ -141,7 +141,7 @@ KisSpacingInformation KisSprayPaintOp::updateSpacingImpl(const KisPaintInformati
KisTimingInformation KisSprayPaintOp::updateTimingImpl(const KisPaintInformation &info) const
{
return KisPaintOpPluginUtils::effectiveTiming(&m_airbrushOptionWidget, &m_rateOption, info);
return KisPaintOpPluginUtils::effectiveTiming(&m_airbrushOption, &m_rateOption, info);
}
KisSpacingInformation KisSprayPaintOp::computeSpacing(const KisPaintInformation &info,
......@@ -149,5 +149,5 @@ KisSpacingInformation KisSprayPaintOp::computeSpacing(const KisPaintInformation
{
return KisPaintOpPluginUtils::effectiveSpacing(1.0, 1.0, true, 0.0, false,
m_spacing * lodScale, false, 1.0, lodScale,
&m_airbrushOptionWidget, nullptr, info);
&m_airbrushOption, nullptr, info);
}
......@@ -64,7 +64,7 @@ private:
SprayBrush m_sprayBrush;
qreal m_xSpacing, m_ySpacing, m_spacing;
bool m_isPresetValid;
KisAirbrushOptionWidget m_airbrushOptionWidget;
KisAirbrushOptionProperties m_airbrushOption;
KisPressureRotationOption m_rotationOption;
KisPressureSizeOption m_sizeOption;
KisPressureOpacityOption m_opacityOption;
......
......@@ -43,7 +43,7 @@ KisTangentNormalPaintOp::KisTangentNormalPaintOp(const KisPaintOpSettingsSP sett
Q_UNUSED(image);
//Init, read settings, etc//
m_tangentTiltOption.readOptionSetting(settings);
m_airbrushOptionWidget.readOptionSetting(settings);
m_airbrushOption.readOptionSetting(settings);
m_sizeOption.readOptionSetting(settings);
m_opacityOption.readOptionSetting(settings);
m_flowOption.readOptionSetting(settings);
......@@ -180,13 +180,13 @@ KisSpacingInformation KisTangentNormalPaintOp::updateSpacingImpl(const KisPaintI
KisTimingInformation KisTangentNormalPaintOp::updateTimingImpl(const KisPaintInformation &info) const
{
return KisPaintOpPluginUtils::effectiveTiming(&m_airbrushOptionWidget, &m_rateOption, info);
return KisPaintOpPluginUtils::effectiveTiming(&m_airbrushOption, &m_rateOption, info);
}
KisSpacingInformation KisTangentNormalPaintOp::computeSpacing(const KisPaintInformation &info,
qreal scale, qreal rotation) const
{
return effectiveSpacing(scale, rotation, &m_airbrushOptionWidget, &m_spacingOption, info);
return effectiveSpacing(scale, rotation, &m_airbrushOption, &m_spacingOption, info);
}
void KisTangentNormalPaintOp::paintLine(const KisPaintInformation& pi1, const KisPaintInformation& pi2, KisDistanceInformation *currentDistance)
......
......@@ -71,7 +71,7 @@ private:
KisPressureRotationOption m_rotationOption;
KisPressureScatterOption m_scatterOption;
KisTangentTiltOption m_tangentTiltOption;
KisAirbrushOptionWidget m_airbrushOptionWidget;
KisAirbrushOptionProperties m_airbrushOption;
KisPressureSoftnessOption m_softnessOption;
KisPressureSharpnessOption m_sharpnessOption;
KisPressureFlowOption m_flowOption;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment