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

#include <kis_selection_actions_panel_handle.h>

+ Inheritance diagram for KisSelectionActionsPanelHandle:

Classes

struct  Private
 

Public Member Functions

void draw (QPainter &painter, const KoColorDisplayRendererInterface *renderInterface)
 
 KisSelectionActionsPanelHandle (int size, Orientation orientation, QWidget *parent)
 
void set_held (bool held)
 
void setOrientation (Orientation orientation)
 
void themeChanged ()
 
 ~KisSelectionActionsPanelHandle ()
 

Protected Member Functions

void contextMenuEvent (QContextMenuEvent *event) override
 
void mousePressEvent (QMouseEvent *event) override
 

Private Attributes

QScopedPointer< Privated
 

Detailed Description

Definition at line 15 of file kis_selection_actions_panel_handle.h.

Constructor & Destructor Documentation

◆ KisSelectionActionsPanelHandle()

KisSelectionActionsPanelHandle::KisSelectionActionsPanelHandle ( int size,
Orientation orientation,
QWidget * parent )

Definition at line 23 of file kis_selection_actions_panel_handle.cpp.

24 : QWidget(parent)
25 , d(new Private(size))
26{
27 d->orientation = orientation;
28 d->default_cursor = Qt::OpenHandCursor;
29 d->held_cursor = Qt::ClosedHandCursor;
30 d->handle_icon = KisIconUtils::loadIcon("drag-handle");
31 this->setCursor(d->default_cursor);
32 setFixedSize(size, size);
33 setAttribute(Qt::WA_AcceptTouchEvents);
34}
QIcon loadIcon(const QString &name)

References d, and KisIconUtils::loadIcon().

◆ ~KisSelectionActionsPanelHandle()

KisSelectionActionsPanelHandle::~KisSelectionActionsPanelHandle ( )

Definition at line 36 of file kis_selection_actions_panel_handle.cpp.

37{
38}

Member Function Documentation

◆ contextMenuEvent()

void KisSelectionActionsPanelHandle::contextMenuEvent ( QContextMenuEvent * event)
overrideprotected

Definition at line 81 of file kis_selection_actions_panel_handle.cpp.

82{
83 Q_EMIT customContextMenuRequested(mapToGlobal(event->pos()));
84 event->accept();
85}

◆ draw()

void KisSelectionActionsPanelHandle::draw ( QPainter & painter,
const KoColorDisplayRendererInterface * renderInterface )

Definition at line 52 of file kis_selection_actions_panel_handle.cpp.

53{
54 QRect rect = geometry();
55 QPoint offset;
56
57 // Adjust the rect a bit to fill the right side of the bar properly
58 if (d->orientation == Orientation::Horizontal) {
59 painter.fillRect(rect.marginsAdded(QMargins(-3, 4, 1, 4)),
60 renderInterface->systemPaletteForDisplayColorSpace().window().color());
61 offset = QPoint(3, 0);
62 } else {
63 painter.fillRect(rect.marginsAdded(QMargins(4, -3, 4, 1)),
64 renderInterface->systemPaletteForDisplayColorSpace().window().color());
65 offset = QPoint(0, 3);
66 }
67
68 // Adjusting the icon location a bit to be properly centered
69
70
71#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
72 d->handle_icon.paint(&painter, QRect(QPoint(rect.topLeft() + offset), QSize(d->size, d->size)));
73#else
74 QImage ic = renderInterface->convertImageToDisplayColorSpace(d->handle_icon.pixmap(d->size, d->size).toImage());
75 QRect target = QRect(QPoint(0, 0), ic.deviceIndependentSize().toSize());
76 target.moveCenter(rect.center() + offset);
77 painter.drawImage(target, ic);
78#endif
79}
KisMagneticGraph::vertex_descriptor target(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
virtual QImage convertImageToDisplayColorSpace(const QImage source) const =0
convertImageToDisplayColorSpace
virtual QPalette systemPaletteForDisplayColorSpace() const =0
systemPaletteForDisplayColorSpace

References KoColorDisplayRendererInterface::convertImageToDisplayColorSpace(), d, KoColorDisplayRendererInterface::systemPaletteForDisplayColorSpace(), and target().

◆ mousePressEvent()

void KisSelectionActionsPanelHandle::mousePressEvent ( QMouseEvent * event)
overrideprotected

Definition at line 87 of file kis_selection_actions_panel_handle.cpp.

88{
89 //Do not propagate the rmb event, to prevent other tool context menus from appearing
90 if (event->button() == Qt::RightButton) {
91 event->accept();
92 } else {
93 QWidget::mousePressEvent(event);
94 }
95}

◆ set_held()

void KisSelectionActionsPanelHandle::set_held ( bool held)

Definition at line 40 of file kis_selection_actions_panel_handle.cpp.

41{
42 if(held)
43 {
44 this->setCursor(d->held_cursor);
45 }
46 else
47 {
48 this->setCursor(d->default_cursor);
49 }
50}

References d.

◆ setOrientation()

void KisSelectionActionsPanelHandle::setOrientation ( Orientation orientation)

Definition at line 97 of file kis_selection_actions_panel_handle.cpp.

98{
99 d->orientation = orientation;
100}

References d.

◆ themeChanged()

void KisSelectionActionsPanelHandle::themeChanged ( )

Definition at line 102 of file kis_selection_actions_panel_handle.cpp.

103{
104 d->handle_icon = KisIconUtils::loadIcon(d->handle_icon.name());
105}

References d, and KisIconUtils::loadIcon().

Member Data Documentation

◆ d

QScopedPointer<Private> KisSelectionActionsPanelHandle::d
private

Definition at line 31 of file kis_selection_actions_panel_handle.h.


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