1 | /* -*- C++ -*- |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 1997 Tim D. Gilman <tdgilman@best.org> |
4 | SPDX-FileCopyrightText: 1998-2001 Mirko Boehm <mirko@kde.org> |
5 | SPDX-FileCopyrightText: 2007 John Layt <john@layt.net> |
6 | |
7 | SPDX-License-Identifier: LGPL-2.0-or-later |
8 | */ |
9 | |
10 | #ifndef KPOPUPFRAME_H |
11 | #define |
12 | |
13 | #include <kwidgetsaddons_export.h> |
14 | |
15 | #include <QFrame> |
16 | #include <memory> |
17 | |
18 | /** |
19 | * @class KPopupFrame kpopupframe.h KPopupFrame |
20 | * |
21 | * Frame with popup menu behavior. |
22 | * @author Tim Gilman, Mirko Boehm |
23 | */ |
24 | class KWIDGETSADDONS_EXPORT : public QFrame |
25 | { |
26 | Q_OBJECT |
27 | protected: |
28 | /** |
29 | * Catch key press events. |
30 | */ |
31 | void (QKeyEvent *e) override; |
32 | |
33 | /** |
34 | * Catch hide events. |
35 | */ |
36 | void (QHideEvent *e) override; |
37 | |
38 | public Q_SLOTS: |
39 | /** |
40 | * Close the popup window. This is called from the main widget, usually. |
41 | * |
42 | * @param r is the result returned from exec() |
43 | */ |
44 | void (int r); |
45 | |
46 | public: |
47 | /** |
48 | * The constructor. Creates a dialog without buttons. |
49 | */ |
50 | (QWidget *parent = nullptr); |
51 | |
52 | /** |
53 | * The destructor |
54 | */ |
55 | () override; |
56 | |
57 | /** |
58 | * Set the main widget. You cannot set the main widget from the constructor, |
59 | * since it must be a child of the frame itself. |
60 | * Be careful: the size is set to the main widgets size. It is up to you to |
61 | * set the main widgets correct size before setting it as the main |
62 | * widget. |
63 | */ |
64 | void setMainWidget(QWidget *m); |
65 | |
66 | /** |
67 | * The resize event. Simply resizes the main widget to the whole |
68 | * widgets client size. |
69 | */ |
70 | void (QResizeEvent *resize) override; |
71 | |
72 | /** |
73 | * Open the popup window at position pos. |
74 | */ |
75 | void (const QPoint &pos); |
76 | |
77 | /** |
78 | * Execute the popup window. |
79 | */ |
80 | int (const QPoint &p); |
81 | |
82 | /** |
83 | * Execute the popup window. |
84 | */ |
85 | int (int x, int y); |
86 | |
87 | Q_SIGNALS: |
88 | void (); |
89 | |
90 | private: |
91 | friend class ; |
92 | std::unique_ptr<class KPopupFramePrivate> const ; |
93 | |
94 | Q_DISABLE_COPY() |
95 | }; |
96 | |
97 | #endif // KPOPUPFRAME_H |
98 | |