2 * Copyright 2008 by Alessandro Diaferia <alediaferia@gmail.com>
3 * Copyright 2007 by Alexis Ménard <darktears31@gmail.com>
4 * Copyright 2007 Sebastian Kuegler <sebas@kde.org>
5 * Copyright 2006 Aaron Seigo <aseigo@kde.org>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301 USA
23 #ifndef PLASMA_DIALOG_H
24 #define PLASMA_DIALOG_H
26 #include <QtGui/QWidget>
27 #include <QtGui/QGraphicsSceneEvent>
28 #include <QtGui/QGraphicsView>
30 #include <plasma/plasma_export.h>
38 * @class Dialog plasma/dialog.h <Plasma/Dialog>
40 * @short A dialog that uses the Plasma style
42 * Dialog provides a dialog-like widget that can be used to display additional
45 * Dialog uses the plasma theme, and usually has no window decoration. It's meant
46 * as an interim solution to display widgets as extension to plasma applets, for
47 * example when you click on an applet like the devicenotifier or the clock, the
48 * widget that is then displayed, is a Dialog.
50 class PLASMA_EXPORT Dialog
: public QWidget
56 * Use these flags to choose the active resize corners.
64 All
= NorthEast
| SouthEast
| NorthWest
| SouthWest
66 Q_DECLARE_FLAGS(ResizeCorners
, ResizeCorner
)
69 * @arg parent the parent widget, for plasmoids, this is usually 0.
70 * @arg f the Qt::WindowFlags, default is to not show a windowborder.
72 explicit Dialog(QWidget
* parent
= 0, Qt::WindowFlags f
= Qt::Window
);
75 void setGraphicsWidget(QGraphicsWidget
*widget
);
76 QGraphicsWidget
*graphicsWidget();
79 * @arg corners the corners the resize handlers should be placed in.
81 void setResizeHandleCorners(ResizeCorners corners
);
84 * Convenience method to get the enabled resize corners.
85 * @return which resize corners are active.
87 ResizeCorners
resizeCorners() const;
91 * Fires when the dialog automatically resizes.
96 * Emit a signal when the dialog become visible/invisible
98 void dialogVisible(bool status
);
102 * Reimplemented from QWidget
104 void paintEvent(QPaintEvent
*e
);
105 bool event(QEvent
*event
);
106 void resizeEvent(QResizeEvent
*e
);
107 bool eventFilter(QObject
*watched
, QEvent
*event
);
108 void hideEvent(QHideEvent
*event
);
109 void showEvent(QShowEvent
*event
);
110 void mouseMoveEvent(QMouseEvent
*event
);
111 void mousePressEvent(QMouseEvent
*event
);
112 void mouseReleaseEvent(QMouseEvent
*event
);
113 void keyPressEvent(QKeyEvent
*event
);
114 void moveEvent(QMoveEvent
*event
);
117 * Convenience method to know whether the point is in a control area (e.g. resize area)
119 * @return true if the point is in the control area.
121 bool inControlArea(const QPoint
&point
);
124 DialogPrivate
*const d
;
126 friend class DialogPrivate
;
128 * React to theme changes
130 Q_PRIVATE_SLOT(d
, void themeUpdated())
133 } // Plasma namespace
135 Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Dialog::ResizeCorners
)