2008-09-07 23:33:02 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2008 by Montel Laurent <montel@kde.org>
|
|
|
|
*
|
2008-09-08 19:32:25 +02:00
|
|
|
* 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.
|
2008-09-07 23:33:02 +02:00
|
|
|
*
|
2008-09-08 19:32:25 +02:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2008-09-07 23:33:02 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-09-08 19:32:25 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2008-09-07 23:33:02 +02:00
|
|
|
*
|
2008-09-08 19:32:25 +02:00
|
|
|
* 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,
|
2008-09-07 23:33:02 +02:00
|
|
|
* Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2008-07-17 11:30:57 +02:00
|
|
|
|
2008-08-27 02:38:26 +02:00
|
|
|
#ifndef POPUPAPPLET_H
|
|
|
|
#define POPUPAPPLET_H
|
2008-07-17 11:30:57 +02:00
|
|
|
|
|
|
|
#include <plasma/applet.h>
|
|
|
|
#include <plasma/plasma_export.h>
|
|
|
|
|
|
|
|
class QGraphicsProxyWidget;
|
|
|
|
class QGraphicsLinearLayout;
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class Dialog;
|
|
|
|
class Icon;
|
|
|
|
class PopupAppletPrivate;
|
|
|
|
|
2008-08-26 01:46:00 +02:00
|
|
|
/**
|
|
|
|
* Allows applets to automatically 'collapse' into an icon when put in an panel, and is a convenient
|
|
|
|
* base class for any applet that wishes to use extenders.
|
|
|
|
* Applets that subclass this class should implement either widget() or graphicsWidget() to return a
|
|
|
|
* widget that will be displayed in the applet if the applet is in a Planar or MediaCenter form
|
|
|
|
* factor. If the applet is put in a panel, an icon will be displayed instead, which shows the
|
|
|
|
* widget in a popup when clicked.
|
|
|
|
* If you use this class as a base class for your extender using applet, you should implement
|
|
|
|
* graphicsWidget() to return extender(), and connect the extenders geometryChanged() signal to the
|
|
|
|
* widgetGeometryChanged() slot.
|
|
|
|
*/
|
|
|
|
|
2008-07-17 11:30:57 +02:00
|
|
|
class PLASMA_EXPORT PopupApplet : public Plasma::Applet
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
PopupApplet(QObject *parent, const QVariantList &args);
|
|
|
|
~PopupApplet();
|
|
|
|
|
2008-08-26 01:46:00 +02:00
|
|
|
/**
|
|
|
|
* @arg icon the icon that has to be displayed when the applet is in a panel.
|
|
|
|
*/
|
2008-07-17 11:30:57 +02:00
|
|
|
void setIcon(const QIcon &icon);
|
2008-08-26 01:46:00 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @arg icon the icon that has to be displayed when the applet is in a panel.
|
|
|
|
*/
|
2008-07-17 11:30:57 +02:00
|
|
|
void setIcon(const QString &iconName);
|
2008-08-26 01:46:00 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the icon that is displayed when the applet is in a panel.
|
|
|
|
*/
|
2008-07-17 11:30:57 +02:00
|
|
|
QIcon icon() const;
|
|
|
|
|
2008-08-26 01:46:00 +02:00
|
|
|
/**
|
2008-09-07 22:49:10 +02:00
|
|
|
* Implement either this function or graphicsWidget().
|
|
|
|
* @return the widget that will get shown in either a layout, in the applet or in a Dialog,
|
2008-08-26 01:46:00 +02:00
|
|
|
* depending on the form factor of the applet.
|
|
|
|
*/
|
2008-07-28 01:23:57 +02:00
|
|
|
virtual QWidget *widget();
|
2008-08-26 01:46:00 +02:00
|
|
|
|
|
|
|
/**
|
2008-09-07 22:49:10 +02:00
|
|
|
* Implement either this function or widget().
|
|
|
|
* @return the widget that will get shown in either a layout, in the applet or in a Dialog,
|
2008-08-26 01:46:00 +02:00
|
|
|
* depending on the form factor of the applet.
|
|
|
|
*/
|
2008-07-28 01:23:57 +02:00
|
|
|
virtual QGraphicsWidget *graphicsWidget();
|
2008-07-17 11:30:57 +02:00
|
|
|
|
2008-08-26 01:46:00 +02:00
|
|
|
/**
|
|
|
|
* Shows the dialog showing the widget if the applet is in a panel.
|
|
|
|
* @arg displayTime the time in ms that the popup should be displayed, defaults to 0 which means
|
|
|
|
* always (until the user closes it again, that is).
|
|
|
|
*/
|
2008-07-28 01:23:57 +02:00
|
|
|
void showPopup(uint displayTime = 0);
|
2008-08-13 16:46:48 +02:00
|
|
|
|
2008-08-28 20:49:37 +02:00
|
|
|
/**
|
2008-09-07 22:49:10 +02:00
|
|
|
* This event handler can be reimplemented in a subclass to receive an event before the popup is shown or hidden.
|
|
|
|
* @arg show true if the popup is going to be shown, false if the popup is going to be hidden.
|
|
|
|
* Note that showing and hiding the popup on click is already done in PopupApplet.
|
2008-08-28 20:49:37 +02:00
|
|
|
*/
|
|
|
|
virtual void popupEvent(bool show);
|
|
|
|
|
2008-08-17 09:20:39 +02:00
|
|
|
public Q_SLOTS:
|
2008-08-26 01:46:00 +02:00
|
|
|
/**
|
|
|
|
* Hides the popup.
|
|
|
|
*/
|
2008-07-28 01:23:57 +02:00
|
|
|
void hidePopup();
|
2008-08-26 01:46:00 +02:00
|
|
|
|
2008-07-17 11:30:57 +02:00
|
|
|
protected:
|
|
|
|
void constraintsEvent(Plasma::Constraints constraints);
|
2008-08-29 21:00:10 +02:00
|
|
|
bool eventFilter(QObject *watched, QEvent *event);
|
2008-09-05 22:44:43 +02:00
|
|
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
2008-07-17 11:30:57 +02:00
|
|
|
|
|
|
|
private:
|
2008-07-17 12:46:02 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void togglePopup())
|
2008-07-28 01:23:57 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void hideTimedPopup())
|
2008-08-28 16:32:48 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void dialogSizeChanged())
|
2008-09-01 13:38:23 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void dialogStatusChanged(bool))
|
2008-07-17 11:30:57 +02:00
|
|
|
PopupAppletPrivate * const d;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
2008-08-27 02:38:26 +02:00
|
|
|
#endif /* POPUPAPPLET_H */
|
2008-07-17 11:30:57 +02:00
|
|
|
|