File indexing completed on 2024-12-22 04:16:11

0001 /*
0002  *  SPDX-FileCopyrightText: 2008 Lukas Tvrdy <lukast.dev@gmail.com>
0003  *  SPDX-FileCopyrightText: 2010 José Luis Vergara <pentalis@gmail.com>
0004  *
0005  *  SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 #include "KisHatchingPreferencesWidget.h"
0008 
0009 #include <lager/constant.hpp>
0010 #include "ui_wdghatchingpreferences.h"
0011 
0012 #include "KisHatchingPreferencesModel.h"
0013 #include <kis_paintop_lod_limitations.h>
0014 
0015 namespace {
0016 
0017 
0018 class KisHatchingPreferences: public QWidget, public Ui::WdgHatchingPreferences
0019 {
0020 public:
0021     KisHatchingPreferences(QWidget *parent = 0)
0022         : QWidget(parent) {
0023         setupUi(this);
0024     }
0025 };
0026 
0027 
0028 }
0029 
0030 
0031 struct KisHatchingPreferencesWidget::Private
0032 {
0033     Private(lager::cursor<KisHatchingPreferencesData> optionData)
0034         : model(optionData)
0035     {
0036     }
0037 
0038     KisHatchingPreferencesModel model;
0039 };
0040 
0041 
0042 KisHatchingPreferencesWidget::KisHatchingPreferencesWidget(lager::cursor<KisHatchingPreferencesData> optionData)
0043     : KisPaintOpOption(i18n("Hatching preferences"), KisPaintOpOption::GENERAL, true)
0044     , m_d(new Private(optionData))
0045 {
0046 
0047     KisHatchingPreferences *widget = new KisHatchingPreferences();
0048     setObjectName("KisHatchingPreferences");
0049 
0050     m_checkable = false;
0051 
0052     using namespace KisWidgetConnectionUtils;
0053 
0054     connectControl(widget->antialiasCheckBox, &m_d->model, "useAntialias");
0055     connectControl(widget->opaqueBackgroundCheckBox, &m_d->model, "useOpaqueBackground");
0056     connectControl(widget->subpixelPrecisionCheckBox, &m_d->model, "useSubpixelPrecision");
0057 
0058     m_d->model.optionData.bind(std::bind(&KisHatchingPreferencesWidget::emitSettingChanged, this));
0059 
0060     setConfigurationPage(widget);
0061 }
0062 
0063 KisHatchingPreferencesWidget::~KisHatchingPreferencesWidget()
0064 {
0065 }
0066 
0067 void KisHatchingPreferencesWidget::writeOptionSetting(KisPropertiesConfigurationSP setting) const
0068 {
0069     KisHatchingPreferencesData data = *m_d->model.optionData;
0070     data.write(setting.data());
0071 }
0072 
0073 void KisHatchingPreferencesWidget::readOptionSetting(const KisPropertiesConfigurationSP setting)
0074 {
0075     KisHatchingPreferencesData data = *m_d->model.optionData;
0076     data.read(setting.data());
0077     m_d->model.optionData.set(data);
0078 }