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

#include <kis_cmb_composite.h>

+ Inheritance diagram for KisCompositeOpComboBox:

Public Member Functions

void connectBlendmodeActions (KisActionManager *manager)
 
void hidePopup () override
 
void keyPressEvent (QKeyEvent *e) override
 
 KisCompositeOpComboBox (bool limitToLayerStyles, QWidget *parent=0)
 
 KisCompositeOpComboBox (QWidget *parent=0)
 
void selectCompositeOp (const KoID &op)
 
KoID selectedCompositeOp () const
 
void validate (const KoColorSpace *cs)
 
void wheelEvent (QWheelEvent *e) override
 
 ~KisCompositeOpComboBox () override
 
- Public Member Functions inherited from KisSqueezedComboBox
void addSqueezedItem (const QIcon &icon, const QString &newItem, QVariant userData=QVariant())
 
void addSqueezedItem (const QString &newItem, QVariant userData=QVariant())
 
bool contains (const QString &text) const
 
QString currentUnsqueezedText ()
 
qint32 findOriginalText (const QString &text) const
 
void insertSqueezedItem (const QIcon &icon, const QString &newItem, int index, QVariant userData=QVariant())
 
void insertSqueezedItem (const QString &newItem, int index, QVariant userData=QVariant())
 
 KisSqueezedComboBox (QWidget *parent=0, const char *name=0)
 
QStringList originalTexts () const
 
void removeSqueezedItem (int index)
 
void resetOriginalTexts (const QStringList &texts)
 
void setCurrent (const QString &itemText)
 
QSize sizeHint () const override
 
 ~KisSqueezedComboBox () override
 

Private Slots

void slotBehind ()
 
void slotCategoryToggled (const QModelIndex &index, bool toggled)
 
void slotClear ()
 
void slotColor ()
 
void slotColorBurn ()
 
void slotColorDodge ()
 
void slotDarken ()
 
void slotDifference ()
 
void slotDissolve ()
 
void slotEntryChecked (const QModelIndex &index)
 
void slotExclusion ()
 
void slotHardLight ()
 
void slotHardMix ()
 
void slotHardOverlay ()
 
void slotHue ()
 
void slotLighten ()
 
void slotLinearBurn ()
 
void slotLinearDodge ()
 
void slotLinearLight ()
 
void slotLuminosity ()
 
void slotMultiply ()
 
void slotNextBlendingMode ()
 
void slotNormal ()
 
void slotOverlay ()
 
void slotPinLight ()
 
void slotPreviousBlendingMode ()
 
void slotSaturation ()
 
void slotScreen ()
 
void slotSoftLight ()
 
void slotVividLight ()
 

Private Member Functions

void selectNeighbouringBlendMode (bool down)
 

Private Attributes

bool m_allowToHidePopup
 
KisSortedCompositeOpListModelm_model
 
KisCategorizedListViewm_view
 

Additional Inherited Members

- Static Public Member Functions inherited from KisSqueezedComboBox
static QString squeezeText (const QString &original, const QWidget *widget)
 

Detailed Description

Definition at line 40 of file kis_cmb_composite.h.

Constructor & Destructor Documentation

◆ KisCompositeOpComboBox() [1/2]

KisCompositeOpComboBox::KisCompositeOpComboBox ( QWidget * parent = 0)

Definition at line 59 of file kis_cmb_composite.cc.

60 : KisCompositeOpComboBox(false, parent)
61{
62}
KisCompositeOpComboBox(QWidget *parent=0)

◆ KisCompositeOpComboBox() [2/2]

KisCompositeOpComboBox::KisCompositeOpComboBox ( bool limitToLayerStyles,
QWidget * parent = 0 )

Definition at line 64 of file kis_cmb_composite.cc.

65 : KisSqueezedComboBox(parent),
66 m_model(new KisSortedCompositeOpListModel(limitToLayerStyles, this)),
68{
71
72 setMaxVisibleItems(100);
73 setSizeAdjustPolicy(AdjustToContents);
74 m_view->setResizeMode(QListView::Adjust);
75
76 setToolTip(i18n("Blending Mode"));
77
78 setModel(m_model);
79 setView(m_view);
80 setItemDelegate(new KisCategorizedItemDelegate(this));
81
82 connect(m_view, SIGNAL(sigCategoryToggled(QModelIndex,bool)), SLOT(slotCategoryToggled(QModelIndex,bool)));
83 connect(m_view, SIGNAL(sigEntryChecked(QModelIndex)), SLOT(slotEntryChecked(QModelIndex)));
84
85 selectCompositeOp(KoCompositeOpRegistry::instance().getDefaultCompositeOp());
86}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void selectCompositeOp(const KoID &op)
KisCategorizedListView * m_view
void slotEntryChecked(const QModelIndex &index)
KisSortedCompositeOpListModel * m_model
void slotCategoryToggled(const QModelIndex &index, bool toggled)
The KisSortedCompositeOpListModel class provides a model for the composite op combobox.
KisSqueezedComboBox(QWidget *parent=0, const char *name=0)
static const KoCompositeOpRegistry & instance()

References connect(), KoCompositeOpRegistry::instance(), m_model, m_view, selectCompositeOp(), KisCategorizedListView::setCompositeBoxControl(), slotCategoryToggled(), and slotEntryChecked().

◆ ~KisCompositeOpComboBox()

KisCompositeOpComboBox::~KisCompositeOpComboBox ( )
override

Definition at line 88 of file kis_cmb_composite.cc.

89{
90 delete m_view;
91}

References m_view.

Member Function Documentation

◆ connectBlendmodeActions()

void KisCompositeOpComboBox::connectBlendmodeActions ( KisActionManager * manager)

Definition at line 93 of file kis_cmb_composite.cc.

94{
95 KisAction *action = 0;
96
97 action = manager->createAction("Next Blending Mode");
98 connect(action, SIGNAL(triggered()), SLOT(slotNextBlendingMode()));
99
100 action = manager->createAction("Previous Blending Mode");
101 connect(action, SIGNAL(triggered()), SLOT(slotPreviousBlendingMode()));
102
103 action = manager->createAction("Select Normal Blending Mode");
104 connect(action, SIGNAL(triggered()), SLOT(slotNormal()));
105
106 action = manager->createAction("Select Dissolve Blending Mode");
107 connect(action, SIGNAL(triggered()), SLOT(slotDissolve()));
108
109 action = manager->createAction("Select Behind Blending Mode");
110 connect(action, SIGNAL(triggered()), SLOT(slotBehind()));
111
112 action = manager->createAction("Select Clear Blending Mode");
113 connect(action, SIGNAL(triggered()), SLOT(slotClear()));
114
115 action = manager->createAction("Select Darken Blending Mode");
116 connect(action, SIGNAL(triggered()), SLOT(slotDarken()));
117
118 action = manager->createAction("Select Multiply Blending Mode");
119 connect(action, SIGNAL(triggered()), SLOT(slotMultiply()));
120
121 action = manager->createAction("Select Color Burn Blending Mode");
122 connect(action, SIGNAL(triggered()), SLOT(slotColorBurn()));
123
124 action = manager->createAction("Select Linear Burn Blending Mode");
125 connect(action, SIGNAL(triggered()), SLOT(slotLinearBurn()));
126
127 action = manager->createAction("Select Lighten Blending Mode");
128 connect(action, SIGNAL(triggered()), SLOT(slotLighten()));
129
130 action = manager->createAction("Select Screen Blending Mode");
131 connect(action, SIGNAL(triggered()), SLOT(slotScreen()));
132
133 action = manager->createAction("Select Color Dodge Blending Mode");
134 connect(action, SIGNAL(triggered()), SLOT(slotColorDodge()));
135
136 action = manager->createAction("Select Linear Dodge Blending Mode");
137 connect(action, SIGNAL(triggered()), SLOT(slotLinearDodge()));
138
139 action = manager->createAction("Select Overlay Blending Mode");
140 connect(action, SIGNAL(triggered()), SLOT(slotOverlay()));
141
142 action = manager->createAction("Select Hard Overlay Blending Mode");
143 connect(action, SIGNAL(triggered()), SLOT(slotHardOverlay()));
144
145 action = manager->createAction("Select Soft Light Blending Mode");
146 connect(action, SIGNAL(triggered()), SLOT(slotSoftLight()));
147
148 action = manager->createAction("Select Hard Light Blending Mode");
149 connect(action, SIGNAL(triggered()), SLOT(slotHardLight()));
150
151 action = manager->createAction("Select Vivid Light Blending Mode");
152 connect(action, SIGNAL(triggered()), SLOT(slotVividLight()));
153
154 action = manager->createAction("Select Linear Light Blending Mode");
155 connect(action, SIGNAL(triggered()), SLOT(slotLinearLight()));
156
157 action = manager->createAction("Select Pin Light Blending Mode");
158 connect(action, SIGNAL(triggered()), SLOT(slotPinLight()));
159
160 action = manager->createAction("Select Hard Mix Blending Mode");
161 connect(action, SIGNAL(triggered()), SLOT(slotHardMix()));
162
163 action = manager->createAction("Select Difference Blending Mode");
164 connect(action, SIGNAL(triggered()), SLOT(slotDifference()));
165
166 action = manager->createAction("Select Exclusion Blending Mode");
167 connect(action, SIGNAL(triggered()), SLOT(slotExclusion()));
168
169 action = manager->createAction("Select Hue Blending Mode");
170 connect(action, SIGNAL(triggered()), SLOT(slotHue()));
171
172 action = manager->createAction("Select Saturation Blending Mode");
173 connect(action, SIGNAL(triggered()), SLOT(slotSaturation()));
174
175 action = manager->createAction("Select Color Blending Mode");
176 connect(action, SIGNAL(triggered()), SLOT(slotColor()));
177
178 action = manager->createAction("Select Luminosity Blending Mode");
179 connect(action, SIGNAL(triggered()), SLOT(slotLuminosity()));
180}
KisAction * createAction(const QString &name)

References connect(), KisActionManager::createAction(), slotBehind(), slotClear(), slotColor(), slotColorBurn(), slotColorDodge(), slotDarken(), slotDifference(), slotDissolve(), slotExclusion(), slotHardLight(), slotHardMix(), slotHardOverlay(), slotHue(), slotLighten(), slotLinearBurn(), slotLinearDodge(), slotLinearLight(), slotLuminosity(), slotMultiply(), slotNextBlendingMode(), slotNormal(), slotOverlay(), slotPinLight(), slotPreviousBlendingMode(), slotSaturation(), slotScreen(), slotSoftLight(), and slotVividLight().

◆ hidePopup()

void KisCompositeOpComboBox::hidePopup ( )
override

Definition at line 229 of file kis_cmb_composite.cc.

230{
231 if (m_allowToHidePopup) {
232 QComboBox::hidePopup();
233 }
234 else {
235 QComboBox::showPopup();
236 }
237
238 m_allowToHidePopup = true;
239}

References m_allowToHidePopup.

◆ keyPressEvent()

void KisCompositeOpComboBox::keyPressEvent ( QKeyEvent * e)
override

This code is a copy of QComboBox::keyPressEvent. It does the same thing, except that it skips "Category" items, by checking m_model->entryAt() on each step.

Definition at line 437 of file kis_cmb_composite.cc.

438{
445 enum Move { NoMove=0 , MoveUp , MoveDown , MoveFirst , MoveLast};
446
447 Move move = NoMove;
448 int newIndex = currentIndex();
449 switch (e->key()) {
450 case Qt::Key_Up:
451 if (e->modifiers() & Qt::ControlModifier)
452 break; // pass to line edit for auto completion
453 Q_FALLTHROUGH();
454 case Qt::Key_PageUp:
455 move = MoveUp;
456 break;
457 case Qt::Key_Down:
458 if (e->modifiers() & Qt::AltModifier) {
459 showPopup();
460 return;
461 } else if (e->modifiers() & Qt::ControlModifier)
462 break; // pass to line edit for auto completion
463 Q_FALLTHROUGH();
464 case Qt::Key_PageDown:
465 move = MoveDown;
466 break;
467 case Qt::Key_Home:
468 move = MoveFirst;
469 break;
470 case Qt::Key_End:
471 move = MoveLast;
472 break;
473 case Qt::Key_F4:
474 if (!e->modifiers()) {
475 showPopup();
476 return;
477 }
478 break;
479 case Qt::Key_Space:
480 showPopup();
481 return;
482 default:
483 break;
484 }
485
486 const int rowCount = count();
487
488 if (move != NoMove) {
489 KoID op;
490
491 e->accept();
492 switch (move) {
493 case MoveFirst:
494 newIndex = -1;
495 Q_FALLTHROUGH();
496 case MoveDown:
497 newIndex++;
498 while (newIndex < rowCount &&
499 (!(model()->index(newIndex, modelColumn(), rootModelIndex()).flags() & Qt::ItemIsEnabled) ||
500 !m_model->entryAt(op, m_model->index(newIndex, modelColumn()))))
501 newIndex++;
502 break;
503 case MoveLast:
504 newIndex = rowCount;
505 Q_FALLTHROUGH();
506 case MoveUp:
507 newIndex--;
508 while ((newIndex >= 0) &&
509 (!(model()->flags(model()->index(newIndex, modelColumn(), rootModelIndex())) & Qt::ItemIsEnabled) ||
510 !m_model->entryAt(op, m_model->index(newIndex, modelColumn()))))
511 newIndex--;
512 break;
513 default:
514 e->ignore();
515 break;
516 }
517
518 if (newIndex >= 0 && newIndex < rowCount && newIndex != currentIndex()) {
519 setCurrentIndex(newIndex);
520 Q_EMIT activated(newIndex);
521
522 if (m_model->entryAt(op, m_model->index(newIndex, 0))) {
523 Q_EMIT textActivated(op.name());
524 }
525 }
526 } else {
527 KisSqueezedComboBox::keyPressEvent(e);
528 }
529}
bool entryAt(Entry_Type &entry, QModelIndex index) const
Definition KoID.h:30
QString name() const
Definition KoID.cpp:68

References KisSortedCategorizedListModel< TModel >::entryAt(), m_model, and KoID::name().

◆ selectCompositeOp()

void KisCompositeOpComboBox::selectCompositeOp ( const KoID & op)

Definition at line 186 of file kis_cmb_composite.cc.

186 {
187 KoID currentOp;
188 if (m_model->entryAt(currentOp, m_model->index(currentIndex(), 0)) &&
189 currentOp == op) {
190
191 return;
192 }
193
194 QModelIndex index = m_model->indexOf(op);
195
196 setCurrentIndex(index.row());
197 Q_EMIT activated(index.row());
198 Q_EMIT textActivated(op.name());
199}
QModelIndex indexOf(const Entry_Type &entry) const

References KisSortedCategorizedListModel< TModel >::entryAt(), KisSortedCategorizedListModel< TModel >::indexOf(), m_model, and KoID::name().

◆ selectedCompositeOp()

KoID KisCompositeOpComboBox::selectedCompositeOp ( ) const

Definition at line 201 of file kis_cmb_composite.cc.

201 {
202 KoID op;
203
204 if (m_model->entryAt(op, m_model->index(currentIndex(), 0))) {
205 return op;
206 }
208}

References KisSortedCategorizedListModel< TModel >::entryAt(), KoCompositeOpRegistry::getDefaultCompositeOp(), KoCompositeOpRegistry::instance(), and m_model.

◆ selectNeighbouringBlendMode()

void KisCompositeOpComboBox::selectNeighbouringBlendMode ( bool down)
private

Definition at line 381 of file kis_cmb_composite.cc.

382{
383 const int rowCount = count();
384 int newIndex = currentIndex();
385
386 QAbstractItemModel *model = this->model();
387 KoID op;
388
389 if (!down) {
390 newIndex--;
391 while ((newIndex >= 0) &&
392 (!(model->flags(model->index(newIndex, modelColumn(), rootModelIndex())) & Qt::ItemIsEnabled) ||
393 !m_model->entryAt(op, m_model->index(newIndex, modelColumn()))))
394
395 newIndex--;
396 } else {
397 newIndex++;
398 while (newIndex < rowCount &&
399 (!(model->index(newIndex, modelColumn(), rootModelIndex()).flags() & Qt::ItemIsEnabled) ||
400 !m_model->entryAt(op, m_model->index(newIndex, modelColumn()))))
401
402 newIndex++;
403 }
404
405 if (newIndex >= 0 && newIndex < rowCount && newIndex != currentIndex()) {
406 setCurrentIndex(newIndex);
407
408 Q_EMIT activated(newIndex);
409 if (m_model->entryAt(op, m_model->index(newIndex, 0))) {
410 Q_EMIT textActivated(op.name());
411 }
412 }
413}

References KisSortedCategorizedListModel< TModel >::entryAt(), m_model, and KoID::name().

◆ slotBehind

void KisCompositeOpComboBox::slotBehind ( )
privateslot

◆ slotCategoryToggled

void KisCompositeOpComboBox::slotCategoryToggled ( const QModelIndex & index,
bool toggled )
privateslot

Definition at line 210 of file kis_cmb_composite.cc.

211{
212 Q_UNUSED(index);
213 Q_UNUSED(toggled);
214
215 //NOTE: this will (should) fit the size of the
216 // popup widget to the view
217 // don't know if this is expected behaviour
218 // on all supported platforms.
219 // There is nothing written about this in the docs.
220 showPopup();
221}

◆ slotClear

void KisCompositeOpComboBox::slotClear ( )
privateslot

◆ slotColor

void KisCompositeOpComboBox::slotColor ( )
privateslot

◆ slotColorBurn

void KisCompositeOpComboBox::slotColorBurn ( )
privateslot

◆ slotColorDodge

void KisCompositeOpComboBox::slotColorDodge ( )
privateslot

◆ slotDarken

void KisCompositeOpComboBox::slotDarken ( )
privateslot

◆ slotDifference

void KisCompositeOpComboBox::slotDifference ( )
privateslot

◆ slotDissolve

void KisCompositeOpComboBox::slotDissolve ( )
privateslot

◆ slotEntryChecked

void KisCompositeOpComboBox::slotEntryChecked ( const QModelIndex & index)
privateslot

Definition at line 223 of file kis_cmb_composite.cc.

224{
225 Q_UNUSED(index);
226 m_allowToHidePopup = false;
227}

References m_allowToHidePopup.

◆ slotExclusion

void KisCompositeOpComboBox::slotExclusion ( )
privateslot

◆ slotHardLight

void KisCompositeOpComboBox::slotHardLight ( )
privateslot

◆ slotHardMix

void KisCompositeOpComboBox::slotHardMix ( )
privateslot

◆ slotHardOverlay

void KisCompositeOpComboBox::slotHardOverlay ( )
privateslot

◆ slotHue

void KisCompositeOpComboBox::slotHue ( )
privateslot

◆ slotLighten

void KisCompositeOpComboBox::slotLighten ( )
privateslot

◆ slotLinearBurn

void KisCompositeOpComboBox::slotLinearBurn ( )
privateslot

◆ slotLinearDodge

void KisCompositeOpComboBox::slotLinearDodge ( )
privateslot

◆ slotLinearLight

void KisCompositeOpComboBox::slotLinearLight ( )
privateslot

◆ slotLuminosity

void KisCompositeOpComboBox::slotLuminosity ( )
privateslot

◆ slotMultiply

void KisCompositeOpComboBox::slotMultiply ( )
privateslot

◆ slotNextBlendingMode

void KisCompositeOpComboBox::slotNextBlendingMode ( )
privateslot

Definition at line 241 of file kis_cmb_composite.cc.

242{
244}
void selectNeighbouringBlendMode(bool down)

References selectNeighbouringBlendMode().

◆ slotNormal

void KisCompositeOpComboBox::slotNormal ( )
privateslot

◆ slotOverlay

void KisCompositeOpComboBox::slotOverlay ( )
privateslot

◆ slotPinLight

void KisCompositeOpComboBox::slotPinLight ( )
privateslot

◆ slotPreviousBlendingMode

void KisCompositeOpComboBox::slotPreviousBlendingMode ( )
privateslot

Definition at line 246 of file kis_cmb_composite.cc.

247{
249}

References selectNeighbouringBlendMode().

◆ slotSaturation

void KisCompositeOpComboBox::slotSaturation ( )
privateslot

◆ slotScreen

void KisCompositeOpComboBox::slotScreen ( )
privateslot

◆ slotSoftLight

void KisCompositeOpComboBox::slotSoftLight ( )
privateslot

◆ slotVividLight

void KisCompositeOpComboBox::slotVividLight ( )
privateslot

◆ validate()

void KisCompositeOpComboBox::validate ( const KoColorSpace * cs)

Definition at line 182 of file kis_cmb_composite.cc.

182 {
183 m_model->validate(cs);
184}
void validate(const KoColorSpace *cs)

References m_model, and KisSortedCompositeOpListModel::validate().

◆ wheelEvent()

void KisCompositeOpComboBox::wheelEvent ( QWheelEvent * e)
override

This code is a copy of QComboBox::wheelEvent. It does the same thing, except that it skips "Category" items, by checking m_model->entryAt() on each step.

Definition at line 415 of file kis_cmb_composite.cc.

416{
423 QStyleOptionComboBox opt;
424 initStyleOption(&opt);
425
426 if (style()->styleHint(QStyle::SH_ComboBox_AllowWheelScrolling, &opt, this)) {
427 if (e->angleDelta().y() != 0) {
428 selectNeighbouringBlendMode(e->angleDelta().y() < 0);
429 }
430
431 e->accept();
432 } else {
433 KisSqueezedComboBox::wheelEvent(e);
434 }
435}

References selectNeighbouringBlendMode().

Member Data Documentation

◆ m_allowToHidePopup

bool KisCompositeOpComboBox::m_allowToHidePopup
private

Definition at line 98 of file kis_cmb_composite.h.

◆ m_model

KisSortedCompositeOpListModel* KisCompositeOpComboBox::m_model
private

Definition at line 96 of file kis_cmb_composite.h.

◆ m_view

KisCategorizedListView* KisCompositeOpComboBox::m_view
private

Definition at line 97 of file kis_cmb_composite.h.


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