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

#include <kis_tool_button.h>

+ Inheritance diagram for KisToolButton:

Public Member Functions

 KisToolButton (QWidget *parent=0)
 

Protected Member Functions

void mousePressEvent (QMouseEvent *e) override
 
void mouseReleaseEvent (QMouseEvent *e) override
 

Private Attributes

bool m_tabletContact
 

Detailed Description

This class exists to work around a bug in QToolButton when in MenuPopupButton mode. The correct (mouse) behavior is to display the menu with the first click, and let the user choose an item with the next click. The buggy behavior presented by the tablet is to present the menu and immediately select an item when the user performs a stylus tip click. This workaround solves this.

Definition at line 21 of file kis_tool_button.h.

Constructor & Destructor Documentation

◆ KisToolButton()

KisToolButton::KisToolButton ( QWidget * parent = 0)
explicit

Definition at line 12 of file kis_tool_button.cpp.

12 :
13 QToolButton(parent)
14{
15 m_tabletContact = false;
16}

References m_tabletContact.

Member Function Documentation

◆ mousePressEvent()

void KisToolButton::mousePressEvent ( QMouseEvent * e)
overrideprotected

Definition at line 18 of file kis_tool_button.cpp.

19{
20 QStyleOptionToolButton opt;
21 initStyleOption(&opt);
22 QRect popupr = style()->subControlRect(QStyle::CC_ToolButton, &opt,
23 QStyle::SC_ToolButtonMenu, this);
24 if (popupr.isValid() && !popupr.contains(e->pos())) {
25 QToolButton::mousePressEvent(e);
26 } else {
27 m_tabletContact = true;
28 }
29}

References m_tabletContact.

◆ mouseReleaseEvent()

void KisToolButton::mouseReleaseEvent ( QMouseEvent * e)
overrideprotected

Definition at line 31 of file kis_tool_button.cpp.

32{
33 if (m_tabletContact) {
34 QToolButton::mousePressEvent(e);
35 } else {
36 QToolButton::mouseReleaseEvent(e);
37 }
38 m_tabletContact = false;
39}

References m_tabletContact.

Member Data Documentation

◆ m_tabletContact

bool KisToolButton::m_tabletContact
private

Definition at line 32 of file kis_tool_button.h.


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