Krita Source Code Documentation
Loading...
Searching...
No Matches
KisLodAvailabilityWidget Class Reference

#include <kis_lod_availability_widget.h>

+ Inheritance diagram for KisLodAvailabilityWidget:

Classes

struct  Private
 

Public Slots

void slotLodAvailabilityStateChanged (KisLodAvailabilityModel::AvailabilityState state, const KisPaintopLodLimitations &l, bool isLodUserAllowed)
 

Signals

void sigUserChangedLodAvailability (bool value)
 
void sigUserChangedLodThreshold (qreal value)
 

Public Member Functions

 KisLodAvailabilityWidget (QWidget *parent)
 
void setLodAvailabilityModel (KisLodAvailabilityModel *model)
 
 ~KisLodAvailabilityWidget () override
 

Private Slots

void showLodThresholdWidget (const QPoint &pos)
 
void showLodToolTip ()
 

Private Attributes

const QScopedPointer< Privatem_d
 

Detailed Description

Definition at line 19 of file kis_lod_availability_widget.h.

Constructor & Destructor Documentation

◆ KisLodAvailabilityWidget()

KisLodAvailabilityWidget::KisLodAvailabilityWidget ( QWidget * parent)

Definition at line 44 of file kis_lod_availability_widget.cpp.

45 : QWidget(parent),
46 m_d(new Private)
47{
48 m_d->chkLod = new QCheckBox(this);
49
50 m_d->btnLod = new QPushButton(this);
51 m_d->btnLod->setFlat(true);
52
53 connect(m_d->btnLod, SIGNAL(clicked()), SLOT(showLodToolTip()));
54
55 {
56 m_d->thresholdMenu.reset(new QMenu());
57 m_d->thresholdMenu->addSection(i18n("Enable after:"));
58
59 m_d->btnLod->setContextMenuPolicy(Qt::CustomContextMenu);
60 connect(m_d->btnLod, SIGNAL(customContextMenuRequested(QPoint)),
61 this, SLOT(showLodThresholdWidget(QPoint)));
62
63 KisImageConfig cfg(true);
64 m_d->thresholdSlider = new KisDoubleSliderSpinBox(m_d->thresholdMenu.data());
65
66 m_d->thresholdSlider->setRange(0, cfg.maxBrushSize(), 2);
67 m_d->thresholdSlider->setValue(100);
68 m_d->thresholdSlider->setSingleStep(1);
69 m_d->thresholdSlider->setExponentRatio(3.0);
70 m_d->thresholdSlider->setSuffix(i18n(" px"));
71 m_d->thresholdSlider->setBlockUpdateSignalOnDrag(true);
72
73 QWidgetAction *sliderAction = new QWidgetAction(this);
74 sliderAction->setDefaultWidget(m_d->thresholdSlider);
75
76 m_d->thresholdMenu->addAction(sliderAction);
77 }
78
79 QHBoxLayout *layout = new QHBoxLayout(this);
80 layout->setSpacing(0);
81 layout->addWidget(m_d->chkLod);
82 layout->addWidget(m_d->btnLod);
83}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
This class is a spinbox in which you can click and drag to set the value. A slider like bar is displa...
void showLodThresholdWidget(const QPoint &pos)
const QScopedPointer< Private > m_d

References connect(), m_d, KisImageConfig::maxBrushSize(), showLodThresholdWidget(), and showLodToolTip().

◆ ~KisLodAvailabilityWidget()

KisLodAvailabilityWidget::~KisLodAvailabilityWidget ( )
override

Definition at line 85 of file kis_lod_availability_widget.cpp.

86{
87}

Member Function Documentation

◆ setLodAvailabilityModel()

void KisLodAvailabilityWidget::setLodAvailabilityModel ( KisLodAvailabilityModel * model)

Definition at line 89 of file kis_lod_availability_widget.cpp.

90{
91 m_d->model.reset(model);
92
93 m_d->model->LAGER_QT(availabilityState).bind(
95 this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
96
97 connect(m_d->chkLod, &QCheckBox::toggled,
98 m_d->model.data(), &KisLodAvailabilityModel::setisLodUserAllowed);
99
100 using namespace KisWidgetConnectionUtils;
101 connectControl(m_d->thresholdSlider, m_d->model.data(), "lodSizeThreshold");
102}
void slotLodAvailabilityStateChanged(KisLodAvailabilityModel::AvailabilityState state, const KisPaintopLodLimitations &l, bool isLodUserAllowed)
void connectControl(KisCompositeOpListWidget *widget, QObject *source, const char *property)
constexpr auto unzip_wrapper
Definition KisMpl.h:70

References connect(), m_d, slotLodAvailabilityStateChanged(), and kismpl::unzip_wrapper.

◆ showLodThresholdWidget

void KisLodAvailabilityWidget::showLodThresholdWidget ( const QPoint & pos)
privateslot

Definition at line 109 of file kis_lod_availability_widget.cpp.

110{
111 Q_UNUSED(pos);
112
113 if (m_d->model && m_d->model->isLodSizeThresholdSupported()) {
114 m_d->thresholdMenu->popup(QCursor::pos());
115 }
116}

References m_d.

◆ showLodToolTip

void KisLodAvailabilityWidget::showLodToolTip ( )
privateslot

Definition at line 104 of file kis_lod_availability_widget.cpp.

105{
106 QToolTip::showText(QCursor::pos(), m_d->btnLod->toolTip(), m_d->btnLod);
107}

References m_d.

◆ sigUserChangedLodAvailability

void KisLodAvailabilityWidget::sigUserChangedLodAvailability ( bool value)
signal

◆ sigUserChangedLodThreshold

void KisLodAvailabilityWidget::sigUserChangedLodThreshold ( qreal value)
signal

◆ slotLodAvailabilityStateChanged

void KisLodAvailabilityWidget::slotLodAvailabilityStateChanged ( KisLodAvailabilityModel::AvailabilityState state,
const KisPaintopLodLimitations & l,
bool isLodUserAllowed )
slot

If LoD is really blocked by some limitation we sneakily reset the checkbox to let the user know it is fully disabled.

Definition at line 118 of file kis_lod_availability_widget.cpp.

119{
120 QString toolTip;
121
123 QString blockersText;
124 Q_FOREACH (const KoID &id, l.blockers) {
125 blockersText.append("<li>");
126 blockersText.append(id.name());
127 blockersText.append("</li>");
128 }
129
130 toolTip = i18nc("@info:tooltip",
131 "<p>Instant Preview Mode is "
132 "disabled by the following options:"
133 "<ul>%1</ul></p>", blockersText);
135
136 const qreal effectiveBrushSize = m_d->model->effectiveBrushSize.get();
137 const qreal sizeThreshold = m_d->model->lodSizeThreshold();
138
139 toolTip = i18nc("@info:tooltip",
140 "<p>Instant Preview Mode is "
141 "disabled by instant preview threshold. "
142 "Please right-click here to change the threshold"
143 "<ul><li>Brush size %1</li>"
144 "<li>Threshold: %2</li></ul></p>",
145 effectiveBrushSize, sizeThreshold);
146
147 } else if (state == KisLodAvailabilityModel::Limited) {
148
149 QString limitationsText;
150 Q_FOREACH (const KoID &id, l.limitations) {
151 limitationsText.append("<li>");
152 limitationsText.append(id.name());
153 limitationsText.append("</li>");
154 }
155
156 toolTip = i18nc("@info:tooltip",
157 "<p>Instant Preview may look different "
158 "from the final result. In case of troubles "
159 "try disabling the following options:"
160 "<ul>%1</ul></p>", limitationsText);
161 } else {
162 toolTip = i18nc("@info:tooltip", "<p>Instant Preview Mode is available</p>");
163 }
164
165 const QString text = state == KisLodAvailabilityModel::Limited ?
166 i18n("(Instant Preview)*") : i18n("Instant Preview");
167
168
169 {
170 QFont font;
171 font.setStrikeOut(state >= KisLodAvailabilityModel::BlockedByThreshold);
172 m_d->chkLod->setEnabled(state < KisLodAvailabilityModel::BlockedFully);
173 m_d->btnLod->setEnabled(state < KisLodAvailabilityModel::BlockedFully);
174 m_d->btnLod->setFont(font);
175 m_d->btnLod->setText(text);
176 m_d->btnLod->setToolTip(toolTip);
177
184 KisSignalsBlocker b(m_d->chkLod);
185 m_d->chkLod->setChecked(false);
186 } else {
187 KisSignalsBlocker b(m_d->chkLod);
188 m_d->chkLod->setChecked(isLodUserAllowed);
189 }
190 }
191}
Definition KoID.h:30
const char * name(StandardAction id)

References KisLodAvailabilityModel::BlockedByThreshold, KisLodAvailabilityModel::BlockedFully, KisPaintopLodLimitations::blockers, KisPaintopLodLimitations::limitations, KisLodAvailabilityModel::Limited, and m_d.

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisLodAvailabilityWidget::m_d
private

Definition at line 42 of file kis_lod_availability_widget.h.


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