QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskPopup.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_POPUP_H
7#define QSK_POPUP_H
8
9#include "QskControl.h"
10
11class QSK_EXPORT QskPopup : public QskControl
12{
13 Q_OBJECT
14
15 Q_PROPERTY( bool open READ isOpen WRITE setOpen NOTIFY openChanged )
16 Q_PROPERTY( bool modal READ isModal WRITE setModal NOTIFY modalChanged )
17 Q_PROPERTY( bool fading READ isFading NOTIFY fadingChanged )
18
19 Q_PROPERTY( bool overlay READ hasOverlay
20 WRITE setOverlay RESET resetOverlay NOTIFY overlayChanged )
21
22 Q_PROPERTY( uint priority READ priority WRITE setPriority NOTIFY priorityChanged )
23
24 using Inherited = QskControl;
25
26 public:
27 QSK_SUBCONTROLS( Overlay )
28 QSK_STATES( Closed )
29
30 enum PopupFlag
31 {
32 DeleteOnClose = 1 << 0,
33 CloseOnPressOutside = 1 << 1
34 };
35
36 Q_ENUM( PopupFlag )
37 Q_DECLARE_FLAGS( PopupFlags, PopupFlag )
38
39 QskPopup( QQuickItem* parent = nullptr );
40 ~QskPopup() override;
41
42 void setPopupFlags( PopupFlags );
43 PopupFlags popupFlags() const;
44
45 void setPopupFlag( PopupFlag, bool on = true );
46 bool testPopupFlag( PopupFlag ) const;
47
48 void setModal( bool on = true );
49 bool isModal() const;
50
51 void setOverlay( bool on = true );
52 void resetOverlay();
53 bool hasOverlay() const;
54
55 // allows for stacking orders based on priorities
56 void setPriority( uint );
57 uint priority() const;
58
59 bool isOpen() const;
60 bool isClosed() const;
61
62 bool isFading() const;
63 qreal fadingFactor() const;
64 virtual QskAspect fadingAspect() const;
65
66 virtual QRectF overlayRect() const;
67
68 public Q_SLOTS:
69 void open();
70 void close();
71 void toggle();
72
73 void setOpen( bool );
74
75 Q_SIGNALS:
76 void opened();
77 void closed();
78 void openChanged( bool );
79 void fadingChanged( bool );
80
81 void modalChanged( bool );
82 void overlayChanged( bool );
83 void priorityChanged( uint );
84
85 protected:
86 void aboutToShow() override;
87 int execPopup();
88
89 bool event( QEvent* ) override;
90 void focusInEvent( QFocusEvent* ) override;
91 void focusOutEvent( QFocusEvent* ) override;
92 void keyPressEvent( QKeyEvent* ) override;
94
95 void itemChange( QQuickItem::ItemChange,
96 const QQuickItem::ItemChangeData& ) override;
97
98 virtual QQuickItem* focusSuccessor() const;
99 bool isTransitionAccepted( QskAspect ) const override;
100
101 void grabFocus( bool );
102
103 private:
104 void show() = delete;
105 void hide() = delete;
106 void setVisible( bool ) = delete;
107
108 void updateInputGrabber();
109
110 class PrivateData;
111 std::unique_ptr< PrivateData > m_data;
112};
113
114inline bool QskPopup::isClosed() const
115{
116 return !isOpen();
117}
118
119Q_DECLARE_OPERATORS_FOR_FLAGS( QskPopup::PopupFlags )
120
121#endif
Lookup key for a QskSkinHintTable.
Definition QskAspect.h:15
Base class of all controls.
Definition QskControl.h:23
void itemChange(ItemChange, const ItemChangeData &) override
void show()
Definition QskItem.cpp:310
virtual void aboutToShow()
Definition QskItem.cpp:1091
virtual void windowChangeEvent(QskWindowChangeEvent *)
Definition QskItem.cpp:851
void hide()
Definition QskItem.cpp:315
virtual bool isTransitionAccepted(QskAspect) const
Additional check if an transition should be started.