KWidgetsAddons

kpopupframe.h
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 kpopupframe.h KPopupFrame
20 *
21 * Frame with popup menu behavior.
22 * @author Tim Gilman, Mirko Boehm
23 */
24class KWIDGETSADDONS_EXPORT KPopupFrame : public QFrame
25{
26 Q_OBJECT
27protected:
28 /**
29 * Catch key press events.
30 */
31 void keyPressEvent(QKeyEvent *e) override;
32
33 /**
34 * Catch hide events.
35 */
36 void hideEvent(QHideEvent *e) override;
37
38public 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 close(int r);
45
46public:
47 /**
48 * The constructor. Creates a dialog without buttons.
49 */
50 KPopupFrame(QWidget *parent = nullptr);
51
52 /**
53 * The destructor
54 */
55 ~KPopupFrame() 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 resizeEvent(QResizeEvent *resize) override;
71
72 /**
73 * Open the popup window at position pos.
74 */
75 void popup(const QPoint &pos);
76
77 /**
78 * Execute the popup window.
79 */
80 int exec(const QPoint &p);
81
82 /**
83 * Execute the popup window.
84 */
85 int exec(int x, int y);
86
88 void leaveModality();
89
90private:
91 friend class KPopupFramePrivate;
92 std::unique_ptr<class KPopupFramePrivate> const d;
93
94 Q_DISABLE_COPY(KPopupFrame)
95};
96
97#endif // KPOPUPFRAME_H
Frame with popup menu behavior.
Definition kpopupframe.h:25
~KPopupFrame() override
The destructor.
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
bool close()
virtual void hideEvent(QHideEvent *event)
virtual void keyPressEvent(QKeyEvent *event)
virtual void resizeEvent(QResizeEvent *event)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 19 2024 11:51:03 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.