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 25 of file KisPopupButton.cpp.

Constructor & Destructor Documentation

◆ KisPopupButtonFrame()

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

Definition at line 30 of file KisPopupButton.cpp.

31 : QFrame(parent)
32 {
33 setObjectName("KisPopupButtonFrame");
34 setProperty("_kis_excludeFromLayoutThumbnail", true);
35 frameLayout = new QHBoxLayout(this);
36 frameLayout->setContentsMargins(0, 0, 0, 0);
37
38 setDetached(detach, popupIsMenu);
39 }
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 83 of file KisPopupButton.cpp.

84 {
85 if (e->type() == QEvent::Close) {
86 e->ignore();
87 hide();
88 return true;
89 }
90 return QFrame::event(e);
91 }

◆ keyPressEvent()

void KisPopupButtonFrame::keyPressEvent ( QKeyEvent * event)
inlineoverrideprotected

Definition at line 73 of file KisPopupButton.cpp.

74 {
75 if (event->matches(QKeySequence::Cancel)) {
76 event->accept();
77 hide();
78 } else {
79 QFrame::keyPressEvent(event);
80 }
81 }
bool event(QEvent *e) override

References event().

◆ setDetached()

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

Definition at line 41 of file KisPopupButton.cpp.

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

Member Data Documentation

◆ frameLayout

QHBoxLayout* KisPopupButtonFrame::frameLayout {0}
private

Definition at line 27 of file KisPopupButton.cpp.

27{0};

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