2008-11-04 00:08:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2008 by Alessandro Diaferia <alediaferia@gmail.com>
|
|
|
|
* Copyright 2007 by Alexis Ménard <darktears31@gmail.com>
|
|
|
|
* Copyright 2007 Sebastian Kuegler <sebas@kde.org>
|
|
|
|
* Copyright 2006 Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_DIALOG_H
|
|
|
|
#define PLASMA_DIALOG_H
|
|
|
|
|
|
|
|
#include <QtGui/QWidget>
|
|
|
|
#include <QtGui/QGraphicsSceneEvent>
|
|
|
|
#include <QtGui/QGraphicsView>
|
|
|
|
|
|
|
|
#include <plasma/plasma_export.h>
|
2009-04-16 05:19:02 +02:00
|
|
|
#include <plasma/plasma.h>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class DialogPrivate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class Dialog plasma/dialog.h <Plasma/Dialog>
|
|
|
|
*
|
|
|
|
* @short A dialog that uses the Plasma style
|
|
|
|
*
|
|
|
|
* Dialog provides a dialog-like widget that can be used to display additional
|
|
|
|
* information.
|
|
|
|
*
|
|
|
|
* Dialog uses the plasma theme, and usually has no window decoration. It's meant
|
|
|
|
* as an interim solution to display widgets as extension to plasma applets, for
|
|
|
|
* example when you click on an applet like the devicenotifier or the clock, the
|
|
|
|
* widget that is then displayed, is a Dialog.
|
|
|
|
*/
|
|
|
|
class PLASMA_EXPORT Dialog : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Use these flags to choose the active resize corners.
|
|
|
|
*/
|
|
|
|
enum ResizeCorner {
|
|
|
|
NoCorner = 0,
|
|
|
|
NorthEast = 1,
|
|
|
|
SouthEast = 2,
|
|
|
|
NorthWest = 4,
|
|
|
|
SouthWest = 8,
|
|
|
|
All = NorthEast | SouthEast | NorthWest | SouthWest
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(ResizeCorners, ResizeCorner)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @arg parent the parent widget, for plasmoids, this is usually 0.
|
|
|
|
* @arg f the Qt::WindowFlags, default is to not show a windowborder.
|
|
|
|
*/
|
|
|
|
explicit Dialog(QWidget * parent = 0, Qt::WindowFlags f = Qt::Window);
|
|
|
|
virtual ~Dialog();
|
|
|
|
|
2009-10-20 18:37:25 +02:00
|
|
|
/**
|
|
|
|
* Sets a QGraphicsWidget to be shown as the content in this dialog.
|
|
|
|
* The dialog will then set up a QGraphicsView and coordinate geometry with
|
|
|
|
* the widget automatically.
|
|
|
|
*
|
|
|
|
* @arg widget the QGraphicsWidget to display in this dialog
|
|
|
|
*/
|
2008-11-04 00:08:39 +01:00
|
|
|
void setGraphicsWidget(QGraphicsWidget *widget);
|
2009-10-20 18:37:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the graphics widget shown in this dialog
|
|
|
|
*/
|
2011-05-20 08:10:39 +02:00
|
|
|
QGraphicsWidget *graphicsWidget() const;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @arg corners the corners the resize handlers should be placed in.
|
|
|
|
*/
|
|
|
|
void setResizeHandleCorners(ResizeCorners corners);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience method to get the enabled resize corners.
|
|
|
|
* @return which resize corners are active.
|
|
|
|
*/
|
|
|
|
ResizeCorners resizeCorners() const;
|
|
|
|
|
2009-04-16 05:19:02 +02:00
|
|
|
/**
|
|
|
|
* Causes an animated hide; requires compositing to work, otherwise
|
|
|
|
* the dialog will simply hide.
|
2009-09-12 02:18:26 +02:00
|
|
|
* @since 4.3
|
2009-04-16 05:19:02 +02:00
|
|
|
*/
|
|
|
|
void animatedHide(Plasma::Direction direction);
|
|
|
|
|
2009-04-16 06:19:03 +02:00
|
|
|
/**
|
2009-12-06 13:29:05 +01:00
|
|
|
* Causes an animated show; requires compositing to work, otherwise
|
|
|
|
* the dialog will simply show.
|
2009-09-12 02:18:26 +02:00
|
|
|
* @since 4.3
|
2009-04-16 06:19:03 +02:00
|
|
|
*/
|
|
|
|
void animatedShow(Plasma::Direction direction);
|
|
|
|
|
2009-11-18 21:11:03 +01:00
|
|
|
/**
|
|
|
|
* @return the preferred aspect ratio mode for placement and resizing
|
|
|
|
* @since 4.4
|
|
|
|
*/
|
|
|
|
Plasma::AspectRatioMode aspectRatioMode() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the preferred aspect ratio mode for placement and resizing
|
|
|
|
* @since 4.4
|
|
|
|
*/
|
|
|
|
void setAspectRatioMode(Plasma::AspectRatioMode mode);
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
|
|
|
* Fires when the dialog automatically resizes.
|
|
|
|
*/
|
|
|
|
void dialogResized();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Emit a signal when the dialog become visible/invisible
|
|
|
|
*/
|
|
|
|
void dialogVisible(bool status);
|
|
|
|
|
2010-01-11 23:52:08 +01:00
|
|
|
public Q_SLOTS:
|
|
|
|
/**
|
|
|
|
* Adjusts the dialog to the associated QGraphicsWidget's geometry
|
|
|
|
* Should not normally need to be called by users of Dialog as Dialog
|
|
|
|
* does it automatically. Event compression may cause unwanted delays,
|
|
|
|
* however, and so this method may be called to immediately cause a
|
|
|
|
* synchronization.
|
|
|
|
* @since 4.5
|
|
|
|
*/
|
|
|
|
void syncToGraphicsWidget();
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Reimplemented from QWidget
|
|
|
|
*/
|
|
|
|
void paintEvent(QPaintEvent *e);
|
2008-12-10 19:52:26 +01:00
|
|
|
bool event(QEvent *event);
|
2008-11-04 00:08:39 +01:00
|
|
|
void resizeEvent(QResizeEvent *e);
|
|
|
|
bool eventFilter(QObject *watched, QEvent *event);
|
2009-01-04 08:59:55 +01:00
|
|
|
void hideEvent(QHideEvent *event);
|
|
|
|
void showEvent(QShowEvent *event);
|
2009-07-26 20:58:27 +02:00
|
|
|
void focusInEvent(QFocusEvent *event);
|
2009-01-04 08:59:55 +01:00
|
|
|
void mouseMoveEvent(QMouseEvent *event);
|
|
|
|
void mousePressEvent(QMouseEvent *event);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event);
|
|
|
|
void keyPressEvent(QKeyEvent *event);
|
2009-03-02 21:32:01 +01:00
|
|
|
void moveEvent(QMoveEvent *event);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience method to know whether the point is in a control area (e.g. resize area)
|
|
|
|
* or not.
|
|
|
|
* @return true if the point is in the control area.
|
|
|
|
*/
|
|
|
|
bool inControlArea(const QPoint &point);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DialogPrivate *const d;
|
|
|
|
|
|
|
|
friend class DialogPrivate;
|
|
|
|
/**
|
|
|
|
* React to theme changes
|
|
|
|
*/
|
2009-06-02 07:49:31 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void themeChanged())
|
2010-03-16 21:40:59 +01:00
|
|
|
Q_PRIVATE_SLOT(d, void checkBorders())
|
2010-05-11 09:20:46 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void delayedAdjustSize())
|
2010-12-17 23:37:09 +01:00
|
|
|
|
|
|
|
friend class PopupAppletPrivate;
|
2008-11-04 00:08:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Dialog::ResizeCorners)
|
|
|
|
|
|
|
|
#endif
|