Krita Source Code Documentation
Loading...
Searching...
No Matches
KDcrawIface::RArrowClickLabel Class Reference

#include <rexpanderbox.h>

+ Inheritance diagram for KDcrawIface::RArrowClickLabel:

Signals

void leftClicked ()
 

Public Member Functions

Qt::ArrowType arrowType () const
 
 RArrowClickLabel (QWidget *const parent=0)
 
void setArrowType (Qt::ArrowType arrowType)
 
QSize sizeHint () const override
 
 ~RArrowClickLabel () override
 

Protected Member Functions

void mousePressEvent (QMouseEvent *event) override
 
void mouseReleaseEvent (QMouseEvent *event) override
 
void paintEvent (QPaintEvent *event) override
 

Protected Attributes

Qt::ArrowType m_arrowType
 
int m_margin
 
int m_size
 

Detailed Description

Definition at line 103 of file rexpanderbox.h.

Constructor & Destructor Documentation

◆ RArrowClickLabel()

KDcrawIface::RArrowClickLabel::RArrowClickLabel ( QWidget *const parent = 0)

Definition at line 172 of file rexpanderbox.cpp.

173 : QWidget(parent), m_arrowType(Qt::DownArrow)
174{
175 setCursor(Qt::PointingHandCursor);
176 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
177 m_size = 8;
178 m_margin = 2;
179}

References m_margin, and m_size.

◆ ~RArrowClickLabel()

KDcrawIface::RArrowClickLabel::~RArrowClickLabel ( )
override

Definition at line 187 of file rexpanderbox.cpp.

188{
189}

Member Function Documentation

◆ arrowType()

Qt::ArrowType KDcrawIface::RArrowClickLabel::arrowType ( ) const

Definition at line 191 of file rexpanderbox.cpp.

192{
193 return m_arrowType;
194}

References m_arrowType.

◆ leftClicked

void KDcrawIface::RArrowClickLabel::leftClicked ( )
signal

◆ mousePressEvent()

void KDcrawIface::RArrowClickLabel::mousePressEvent ( QMouseEvent * event)
overrideprotected

Definition at line 196 of file rexpanderbox.cpp.

197{
198 /*
199 * In some contexts, like QGraphicsView, there will be no
200 * release event if the press event was not accepted.
201 */
202 if (event->button() == Qt::LeftButton)
203 {
204 event->accept();
205 }
206}

◆ mouseReleaseEvent()

void KDcrawIface::RArrowClickLabel::mouseReleaseEvent ( QMouseEvent * event)
overrideprotected

Definition at line 208 of file rexpanderbox.cpp.

209{
210 if (event->button() == Qt::LeftButton)
211 {
212 Q_EMIT leftClicked();
213 }
214}

References leftClicked().

◆ paintEvent()

void KDcrawIface::RArrowClickLabel::paintEvent ( QPaintEvent * event)
overrideprotected

Definition at line 216 of file rexpanderbox.cpp.

217{
218 // Inspired by karrowbutton.cpp,
219 // Copyright (C) 2001 Frerich Raabe <raabe@kde.org>
220
221 QPainter p(this);
222
223 QStyleOptionFrame opt;
224 opt.initFrom(this);
225 opt.lineWidth = 2;
226 opt.midLineWidth = 0;
227
228 /*
229 p.fillRect( rect(), palette().brush( QPalette::Window ) );
230 style()->drawPrimitive( QStyle::PE_Frame, &opt, &p, this);
231 */
232
233 if (m_arrowType == Qt::NoArrow)
234 return;
235
236 if (width() < m_size + m_margin || height() < m_size + m_margin)
237 return; // don't draw arrows if we are too small
238
239 unsigned int x = 0, y = 0;
240 if (m_arrowType == Qt::DownArrow)
241 {
242 x = (width() - m_size) / 2;
243 y = height() - (m_size + m_margin);
244 }
245 else if (m_arrowType == Qt::UpArrow)
246 {
247 x = (width() - m_size) / 2;
248 y = m_margin;
249 }
250 else if (m_arrowType == Qt::RightArrow)
251 {
252 x = width() - (m_size + m_margin);
253 y = (height() - m_size) / 2;
254 }
255 else // arrowType == LeftArrow
256 {
257 x = m_margin;
258 y = (height() - m_size) / 2;
259 }
260
261/*
262 if (isDown())
263 {
264 ++x;
265 ++y;
266 }
267*/
268
269 QStyle::PrimitiveElement e = QStyle::PE_IndicatorArrowLeft;
270
271 switch (m_arrowType)
272 {
273 case Qt::LeftArrow:
274 e = QStyle::PE_IndicatorArrowLeft;
275 break;
276 case Qt::RightArrow:
277 e = QStyle::PE_IndicatorArrowRight;
278 break;
279 case Qt::UpArrow:
280 e = QStyle::PE_IndicatorArrowUp;
281 break;
282 case Qt::DownArrow:
283 e = QStyle::PE_IndicatorArrowDown;
284 break;
285 case Qt::NoArrow:
286 break;
287 }
288
289 opt.state |= QStyle::State_Enabled;
290 opt.rect = QRect( x, y, m_size, m_size);
291
292 style()->drawPrimitive( e, &opt, &p, this );
293}
const Params2D p

References m_arrowType, m_margin, m_size, and p.

◆ setArrowType()

void KDcrawIface::RArrowClickLabel::setArrowType ( Qt::ArrowType arrowType)

Definition at line 181 of file rexpanderbox.cpp.

182{
183 m_arrowType = type;
184 update();
185}
bool update(QSpinBox *spinBox)

References m_arrowType.

◆ sizeHint()

QSize KDcrawIface::RArrowClickLabel::sizeHint ( ) const
override

Definition at line 295 of file rexpanderbox.cpp.

296{
297 return QSize(m_size + 2*m_margin, m_size + 2*m_margin);
298}

References m_margin, and m_size.

Member Data Documentation

◆ m_arrowType

Qt::ArrowType KDcrawIface::RArrowClickLabel::m_arrowType
protected

Definition at line 129 of file rexpanderbox.h.

◆ m_margin

int KDcrawIface::RArrowClickLabel::m_margin
protected

Definition at line 131 of file rexpanderbox.h.

◆ m_size

int KDcrawIface::RArrowClickLabel::m_size
protected

Definition at line 130 of file rexpanderbox.h.


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