File indexing completed on 2024-12-22 04:16:04
0001 /* 0002 * SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #include "KisPaintThicknessOptionWidget.h" 0007 0008 #include <QLabel> 0009 #include <QComboBox> 0010 #include <QFormLayout> 0011 #include <QVBoxLayout> 0012 #include <KisLager.h> 0013 #include <KisPaintThicknessOptionModel.h> 0014 #include <KisWidgetConnectionUtils.h> 0015 0016 struct KisPaintThicknessOptionWidget::Private 0017 { 0018 Private(lager::cursor<KisPaintThicknessOptionData> optionData, 0019 lager::reader<bool> lightnessModeEnabled) 0020 : model{optionData.zoom(kislager::lenses::to_base<KisPaintThicknessOptionMixIn>)}, 0021 warningLabelVisible{lightnessModeEnabled.map(std::logical_not{})} 0022 { 0023 } 0024 0025 KisPaintThicknessOptionModel model; 0026 lager::reader<bool> warningLabelVisible; 0027 }; 0028 0029 KisPaintThicknessOptionWidget::KisPaintThicknessOptionWidget(lager::cursor<KisPaintThicknessOptionData> optionData, 0030 lager::reader<bool> lightnessModeEnabled) 0031 : KisCurveOptionWidget(optionData.zoom(kislager::lenses::to_base<KisCurveOptionDataCommon>), KisPaintOpOption::GENERAL, lightnessModeEnabled) 0032 , m_d(new Private(optionData, lightnessModeEnabled)) 0033 { 0034 using namespace KisWidgetConnectionUtils; 0035 0036 QWidget* page = new QWidget; 0037 0038 QLabel *enabledLabel = new QLabel(i18n("Disabled: brush must be in Lightness mode for this option to apply"), page); 0039 enabledLabel->setEnabled(true); 0040 enabledLabel->setAlignment(Qt::AlignHCenter); 0041 0042 QComboBox *cmbThicknessMode = new QComboBox(page); 0043 cmbThicknessMode->addItem(i18n("Overwrite (Smooth out when low) existing paint thickness")); 0044 cmbThicknessMode->addItem(i18n("Paint over existing paint thickness (controlled by Smudge Length)")); 0045 0046 QFormLayout* formLayout = new QFormLayout(); 0047 formLayout->addRow(i18n("Paint Thickness Mode:"), cmbThicknessMode); 0048 formLayout->addRow(new QLabel(i18n("Describes how the brush's paint thickness interacts with existing thick paint, especially at low values."))); 0049 0050 QVBoxLayout* pageLayout = new QVBoxLayout(page); 0051 pageLayout->setMargin(0); 0052 pageLayout->addWidget(enabledLabel); 0053 pageLayout->addLayout(formLayout); 0054 pageLayout->addWidget(configurationPage()); 0055 0056 m_d->warningLabelVisible.bind(std::bind(&QWidget::setVisible, enabledLabel, std::placeholders::_1)); 0057 0058 setConfigurationPage(page); 0059 0060 connectControl(cmbThicknessMode, &m_d->model, "mode"); 0061 0062 m_d->model.optionData.bind(std::bind(&KisPaintThicknessOptionWidget::emitSettingChanged, this)); 0063 } 0064 0065 KisPaintThicknessOptionWidget::~KisPaintThicknessOptionWidget() 0066 { 0067 } 0068 0069 void KisPaintThicknessOptionWidget::writeOptionSetting(KisPropertiesConfigurationSP setting) const 0070 { 0071 KisCurveOptionWidget::writeOptionSetting(setting); 0072 m_d->model.optionData->write(setting.data()); 0073 } 0074 0075 void KisPaintThicknessOptionWidget::readOptionSetting(const KisPropertiesConfigurationSP setting) 0076 { 0077 KisPaintThicknessOptionMixIn data = *m_d->model.optionData; 0078 data.read(setting.data()); 0079 m_d->model.optionData.set(data); 0080 0081 KisCurveOptionWidget::readOptionSetting(setting); 0082 }