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 KPOPUPFRAME_H
12
13#include <kwidgetsaddons_export.h>
14
15#include <QFrame>
16#include <memory>
17
18/*!
19 * \class KPopupFrame
20 * \inmodule KWidgetsAddons
21 *
22 * \brief Frame with popup menu behavior.
23 */
24class KWIDGETSADDONS_EXPORT KPopupFrame : public QFrame
25{
26 Q_OBJECT
27protected:
28 void keyPressEvent(QKeyEvent *e) override;
29
30 void hideEvent(QHideEvent *e) override;
31
32public Q_SLOTS:
33 /*!
34 * Close the popup window. This is called from the main widget, usually.
35 *
36 * \a r is the result returned from exec()
37 */
38 void close(int r);
39
40public:
41 /*!
42 * The constructor. Creates a dialog without buttons.
43 */
44 KPopupFrame(QWidget *parent = nullptr);
45
46 ~KPopupFrame() override;
47
48 /*!
49 * Set the main widget. You cannot set the main widget from the constructor,
50 * since it must be a child of the frame itself.
51 * Be careful: the size is set to the main widgets size. It is up to you to
52 * set the main widgets correct size before setting it as the main
53 * widget.
54 */
55 void setMainWidget(QWidget *m);
56
57 /*!
58 * The resize event. Simply resizes the main widget to the whole
59 * widgets client size.
60 */
61 void resizeEvent(QResizeEvent *resize) override;
62
63 /*!
64 * Open the popup window at position pos.
65 */
66 void popup(const QPoint &pos);
67
68 /*!
69 * Execute the popup window.
70 */
71 int exec(const QPoint &p);
72
73 /*!
74 * Execute the popup window.
75 */
76 int exec(int x, int y);
77
78Q_SIGNALS:
79 /*!
80 *
81 */
82 void leaveModality();
83
84private:
85 friend class KPopupFramePrivate;
86 std::unique_ptr<class KPopupFramePrivate> const d;
87
88 Q_DISABLE_COPY(KPopupFrame)
89};
90
91#endif // KPOPUPFRAME_H
92

source code of kwidgetsaddons/src/kpopupframe.h