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

#include <WGSelectorPopup.h>

+ Inheritance diagram for WGSelectorPopup:

Public Slots

void slotShowPopup ()
 

Signals

void sigPopupClosed (WGSelectorPopup *popup)
 

Public Member Functions

WGSelectorWidgetBaseselectorWidget () const
 
void setSelectorWidget (KisVisualColorSelector *selector)
 
void setSelectorWidget (WGSelectorWidgetBase *selector)
 
 WGSelectorPopup (QWidget *parent=nullptr)
 

Protected Member Functions

void enterEvent (QEnterEvent *event) override
 
void hideEvent (QHideEvent *event) override
 
void keyPressEvent (QKeyEvent *event) override
 
void leaveEvent (QEvent *event) override
 
void paintEvent (QPaintEvent *event) override
 

Private Slots

void slotInteraction (bool active)
 

Private Member Functions

void replaceCentranWidget (QWidget *widget)
 

Private Attributes

QTimer * m_hideTimer
 
bool m_isInteracting {false}
 
int m_margin {10}
 
WGSelectorWidgetBasem_selectorWidget {0}
 

Detailed Description

Definition at line 16 of file WGSelectorPopup.h.

Constructor & Destructor Documentation

◆ WGSelectorPopup()

WGSelectorPopup::WGSelectorPopup ( QWidget * parent = nullptr)
explicit

Definition at line 20 of file WGSelectorPopup.cpp.

21 : QWidget(parent, Qt::Popup | Qt::FramelessWindowHint), m_hideTimer(new QTimer(this))
22{
23 setAttribute(Qt::WA_TranslucentBackground);
24 QBoxLayout *lo = new QBoxLayout(QBoxLayout::LeftToRight, this);
25 lo->setObjectName("WGSelectorPopupLayout");
26 lo->setSizeConstraint(QLayout::SetFixedSize);
27 lo->setContentsMargins(m_margin, m_margin, m_margin, m_margin);
28 m_hideTimer->setSingleShot(true);
29 m_hideTimer->setInterval(50);
30 connect(m_hideTimer, SIGNAL(timeout()), this, SLOT(hide()));
31
32}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))

References connect(), m_hideTimer, and m_margin.

Member Function Documentation

◆ enterEvent()

void WGSelectorPopup::enterEvent ( QEnterEvent * event)
overrideprotected

Definition at line 85 of file WGSelectorPopup.cpp.

87{
88 Q_UNUSED(event);
89 if (m_hideTimer->isActive()) {
90 m_hideTimer->stop();
91 }
92}

◆ hideEvent()

void WGSelectorPopup::hideEvent ( QHideEvent * event)
overrideprotected

Definition at line 109 of file WGSelectorPopup.cpp.

110{
111 QWidget::hideEvent(event);
112 Q_EMIT sigPopupClosed(this);
113}
void sigPopupClosed(WGSelectorPopup *popup)

References sigPopupClosed().

◆ keyPressEvent()

void WGSelectorPopup::keyPressEvent ( QKeyEvent * event)
overrideprotected

Definition at line 103 of file WGSelectorPopup.cpp.

104{
105 Q_UNUSED(event);
106 hide();
107}

◆ leaveEvent()

void WGSelectorPopup::leaveEvent ( QEvent * event)
overrideprotected

Definition at line 94 of file WGSelectorPopup.cpp.

95{
96 Q_UNUSED(event);
97
98 if (!m_isInteracting) {
99 m_hideTimer->start();
100 }
101}

References m_hideTimer, and m_isInteracting.

◆ paintEvent()

void WGSelectorPopup::paintEvent ( QPaintEvent * event)
overrideprotected

Definition at line 72 of file WGSelectorPopup.cpp.

73{
74 Q_UNUSED(event);
75 QPainter painter(this);
76 painter.setRenderHint(QPainter::Antialiasing);
77 painter.setPen(Qt::NoPen);
78 painter.setBrush(palette().window());
79 painter.drawRoundedRect(QRect(0, 0, width(), height()), m_margin, m_margin);
80}
rgba palette[MAX_PALETTE]
Definition palette.c:35

References m_margin, and palette.

◆ replaceCentranWidget()

void WGSelectorPopup::replaceCentranWidget ( QWidget * widget)
private

Definition at line 123 of file WGSelectorPopup.cpp.

124{
125 widget->setParent(this);
126 while (QLayoutItem *child = layout()->takeAt(0)) {
127 delete child->widget();
128 delete child;
129 }
130 layout()->addWidget(widget);
131 widget->show();
132 layout()->update();
133 adjustSize();
134}

◆ selectorWidget()

WGSelectorWidgetBase * WGSelectorPopup::selectorWidget ( ) const

Definition at line 48 of file WGSelectorPopup.cpp.

49{
50 return m_selectorWidget;
51}
WGSelectorWidgetBase * m_selectorWidget

References m_selectorWidget.

◆ setSelectorWidget() [1/2]

void WGSelectorPopup::setSelectorWidget ( KisVisualColorSelector * selector)

Definition at line 34 of file WGSelectorPopup.cpp.

35{
36 replaceCentranWidget(selector);
37 connect(selector, SIGNAL(sigInteraction(bool)), SLOT(slotInteraction(bool)));
39}
void replaceCentranWidget(QWidget *widget)
void slotInteraction(bool active)

References connect(), m_selectorWidget, replaceCentranWidget(), and slotInteraction().

◆ setSelectorWidget() [2/2]

void WGSelectorPopup::setSelectorWidget ( WGSelectorWidgetBase * selector)

Definition at line 41 of file WGSelectorPopup.cpp.

42{
43 replaceCentranWidget(selector);
44 connect(selector, SIGNAL(sigColorInteraction(bool)), SLOT(slotInteraction(bool)));
45 m_selectorWidget = selector;
46}

References connect(), m_selectorWidget, replaceCentranWidget(), and slotInteraction().

◆ sigPopupClosed

void WGSelectorPopup::sigPopupClosed ( WGSelectorPopup * popup)
signal

◆ slotInteraction

void WGSelectorPopup::slotInteraction ( bool active)
privateslot

Definition at line 115 of file WGSelectorPopup.cpp.

116{
117 m_isInteracting = active;
118 if (!active && !underMouse()) {
119 hide();
120 }
121}

References m_isInteracting.

◆ slotShowPopup

void WGSelectorPopup::slotShowPopup ( )
slot

Definition at line 53 of file WGSelectorPopup.cpp.

54{
55 QPoint cursorPos = QCursor::pos();
56 const QRect availRect = this->screen()->availableGeometry();
57
58 QRect popupRect(geometry());
60 : popupRect.center() - popupRect.topLeft();
61
62 popupRect.moveTopLeft(cursorPos - offset);
63 popupRect = kisEnsureInRect(popupRect, availRect);
64
65
66 move(popupRect.topLeft());
67
68 show();
69 //m_colorPreviewPopup->show();
70}
virtual QPoint popupOffset() const
The position, relative to the top left corner, where the cursor of the cursor shall be when showing t...
QRect kisEnsureInRect(QRect rc, const QRect &bounds)
Definition kis_global.h:267

References kisEnsureInRect(), m_selectorWidget, and WGSelectorWidgetBase::popupOffset().

Member Data Documentation

◆ m_hideTimer

QTimer* WGSelectorPopup::m_hideTimer
private

Definition at line 48 of file WGSelectorPopup.h.

◆ m_isInteracting

bool WGSelectorPopup::m_isInteracting {false}
private

Definition at line 46 of file WGSelectorPopup.h.

46{false};

◆ m_margin

int WGSelectorPopup::m_margin {10}
private

Definition at line 45 of file WGSelectorPopup.h.

45{10};

◆ m_selectorWidget

WGSelectorWidgetBase* WGSelectorPopup::m_selectorWidget {0}
private

Definition at line 47 of file WGSelectorPopup.h.

47{0};

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