Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPopupButtonFrame Class Reference
+ Inheritance diagram for KisPopupButtonFrame:

Public Member Functions

 KisPopupButtonFrame (QWidget *parent, bool detach, bool popupIsMenu)
 
void setDetached (bool detach, bool popupIsMenu)
 

Protected Member Functions

bool event (QEvent *e) override
 
void keyPressEvent (QKeyEvent *event) override
 

Private Attributes

QHBoxLayout * frameLayout {0}
 

Detailed Description

Definition at line 36 of file KisPopupButton.cpp.

Constructor & Destructor Documentation

◆ KisPopupButtonFrame()

KisPopupButtonFrame::KisPopupButtonFrame ( QWidget * parent,
bool detach,
bool popupIsMenu )
inline

Definition at line 41 of file KisPopupButton.cpp.

42 : QFrame(parent, Qt::Window)
43 {
44 setObjectName("KisPopupButtonFrame");
45 setProperty("_kis_excludeFromLayoutThumbnail", true);
46 frameLayout = new QHBoxLayout(this);
47 frameLayout->setContentsMargins(0, 0, 0, 0);
48
49 setDetached(detach, popupIsMenu);
50 }
void setDetached(bool detach, bool popupIsMenu)
QHBoxLayout * frameLayout

References frameLayout, and setDetached().

Member Function Documentation

◆ event()

bool KisPopupButtonFrame::event ( QEvent * e)
inlineoverrideprotected

Definition at line 94 of file KisPopupButton.cpp.

95 {
96 if (e->type() == QEvent::Close) {
97 e->ignore();
98 hide();
99 return true;
100 }
101 return QFrame::event(e);
102 }

◆ keyPressEvent()

void KisPopupButtonFrame::keyPressEvent ( QKeyEvent * event)
inlineoverrideprotected

Definition at line 84 of file KisPopupButton.cpp.

85 {
86 if (event->matches(QKeySequence::Cancel)) {
87 event->accept();
88 hide();
89 } else {
90 QFrame::keyPressEvent(event);
91 }
92 }
bool event(QEvent *e) override

References event().

◆ setDetached()

void KisPopupButtonFrame::setDetached ( bool detach,
bool popupIsMenu )
inline

Definition at line 52 of file KisPopupButton.cpp.

53 {
54#if defined Q_OS_ANDROID || defined Q_OS_MACOS
55 // for some reason when calling destroy() the platform window isn't
56 // hidden first, this corrupts state of the window stack
57 hide();
58#endif
59
60 // Need to destroy the platform window before changing window flags
61 // so that Qt knows to actually apply the new flags...
62 // At least on Windows, not doing this may result in weird window drop
63 // shadows.
64 destroy();
65
66 if (detach) {
67 setWindowFlags(Qt::Dialog);
68 setFrameStyle(QFrame::NoFrame);
69 }
70 else {
71 setWindowFlags(Qt::Popup);
72 // Menus already have a frame, don't need another.
73 if (popupIsMenu) {
74 setFrameStyle(QFrame::NoFrame);
75 } else {
76 setFrameStyle(QFrame::Box | QFrame::Plain);
77 }
78 }
79
80 updateGeometry();
81 }

Member Data Documentation

◆ frameLayout

QHBoxLayout* KisPopupButtonFrame::frameLayout {0}
private

Definition at line 38 of file KisPopupButton.cpp.

38{0};

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