2009-05-13 02:55:25 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Chani Armitage <chani@kde.org>
|
2009-07-04 06:30:57 +02:00
|
|
|
* Copyright 2008, 2009 Aaron Seigo <aseigo@kde.org>
|
2010-10-13 18:12:43 +02:00
|
|
|
* Copyright 2010 Marco Martin <mart@kde.org>
|
2009-05-13 02:55:25 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef APPLETINTERFACE_H
|
|
|
|
#define APPLETINTERFACE_H
|
|
|
|
|
2010-01-12 09:04:51 +01:00
|
|
|
#include <QAbstractAnimation>
|
2009-05-13 02:55:25 +02:00
|
|
|
#include <QObject>
|
2009-11-06 19:59:41 +01:00
|
|
|
#include <QSizePolicy>
|
2009-05-13 02:55:25 +02:00
|
|
|
#include <QScriptValue>
|
2009-11-13 22:44:51 +01:00
|
|
|
|
|
|
|
#include <Plasma/Applet>
|
2011-02-20 19:45:12 +01:00
|
|
|
#include <Plasma/Containment>
|
2009-12-16 23:05:46 +01:00
|
|
|
#include <Plasma/PopupApplet>
|
2009-05-13 02:55:25 +02:00
|
|
|
#include <Plasma/DataEngine>
|
2010-08-31 22:47:05 +02:00
|
|
|
#include <Plasma/Theme>
|
2009-05-13 02:55:25 +02:00
|
|
|
|
2010-10-13 18:12:43 +02:00
|
|
|
#include "abstractjsappletscript.h"
|
2009-11-13 23:04:16 +01:00
|
|
|
|
2009-05-13 02:55:25 +02:00
|
|
|
class QAction;
|
2010-10-13 18:12:43 +02:00
|
|
|
class QmlAppletScript;
|
2009-05-13 02:55:25 +02:00
|
|
|
class QSignalMapper;
|
|
|
|
class QSizeF;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
class ConfigLoader;
|
2010-01-20 22:40:55 +01:00
|
|
|
class Extender;
|
2009-05-13 02:55:25 +02:00
|
|
|
} // namespace Plasa
|
|
|
|
|
2010-09-05 00:51:13 +02:00
|
|
|
class AppletInterface : public QObject
|
2009-05-13 02:55:25 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_ENUMS(FormFactor)
|
|
|
|
Q_ENUMS(Location)
|
|
|
|
Q_ENUMS(AspectRatioMode)
|
2009-11-13 22:44:51 +01:00
|
|
|
Q_ENUMS(BackgroundHints)
|
2009-05-13 02:55:25 +02:00
|
|
|
Q_ENUMS(QtOrientation)
|
2010-04-02 03:04:06 +02:00
|
|
|
Q_ENUMS(QtModifiers)
|
2009-11-03 04:06:04 +01:00
|
|
|
Q_ENUMS(QtAnchorPoint)
|
2009-11-07 12:46:58 +01:00
|
|
|
Q_ENUMS(QtCorner)
|
2009-11-06 19:59:41 +01:00
|
|
|
Q_ENUMS(QtSizePolicy)
|
2009-05-13 02:55:25 +02:00
|
|
|
Q_ENUMS(QtAlignment)
|
2010-01-21 00:52:32 +01:00
|
|
|
Q_ENUMS(QtMouseButton)
|
2010-01-12 09:04:51 +01:00
|
|
|
Q_ENUMS(AnimationDirection)
|
2010-03-09 23:29:08 +01:00
|
|
|
Q_ENUMS(IntervalAlignment)
|
2010-08-31 22:47:05 +02:00
|
|
|
Q_ENUMS(ThemeColors)
|
2011-04-14 16:35:38 +02:00
|
|
|
Q_ENUMS(ItemStatus)
|
2009-11-13 23:04:16 +01:00
|
|
|
Q_PROPERTY(AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode)
|
2010-10-13 18:12:43 +02:00
|
|
|
Q_PROPERTY(FormFactor formFactor READ formFactor NOTIFY formFactorChanged)
|
|
|
|
Q_PROPERTY(Location location READ location NOTIFY locationChanged)
|
|
|
|
Q_PROPERTY(QString currentActivity READ currentActivity NOTIFY contextChanged)
|
2009-11-13 23:04:16 +01:00
|
|
|
Q_PROPERTY(bool shouldConserveResources READ shouldConserveResources)
|
2009-05-13 02:55:25 +02:00
|
|
|
Q_PROPERTY(QString activeConfig WRITE setActiveConfig READ activeConfig)
|
2009-07-04 06:30:57 +02:00
|
|
|
Q_PROPERTY(bool busy WRITE setBusy READ isBusy)
|
2009-11-13 22:44:51 +01:00
|
|
|
Q_PROPERTY(BackgroundHints backgroundHints WRITE setBackgroundHints READ backgroundHints)
|
2010-10-13 18:12:43 +02:00
|
|
|
Q_PROPERTY(bool immutable READ immutable NOTIFY immutableChanged)
|
2010-02-01 17:19:32 +01:00
|
|
|
Q_PROPERTY(bool userConfiguring READ userConfiguring) // @since 4.5
|
2010-10-13 18:12:43 +02:00
|
|
|
Q_PROPERTY(int apiVersion READ apiVersion CONSTANT)
|
2011-04-14 16:35:38 +02:00
|
|
|
Q_PROPERTY(ItemStatus status READ status WRITE setStatus NOTIFY statusChanged)
|
2010-02-12 20:19:54 +01:00
|
|
|
Q_PROPERTY(QRectF rect READ rect)
|
|
|
|
Q_PROPERTY(QSizeF size READ size)
|
2011-03-27 16:59:08 +02:00
|
|
|
Q_PROPERTY(QString associatedApplication WRITE setAssociatedApplication READ associatedApplication)
|
2009-05-13 02:55:25 +02:00
|
|
|
|
|
|
|
public:
|
2010-10-13 18:12:43 +02:00
|
|
|
AppletInterface(AbstractJsAppletScript *parent);
|
2009-05-13 02:55:25 +02:00
|
|
|
~AppletInterface();
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//enums copy&pasted from plasma.h because qtscript is evil
|
|
|
|
|
|
|
|
enum FormFactor {
|
|
|
|
Planar = 0, /**< The applet lives in a plane and has two
|
|
|
|
degrees of freedom to grow. Optimize for
|
|
|
|
desktop, laptop or tablet usage: a high
|
|
|
|
resolution screen 1-3 feet distant from the
|
|
|
|
viewer. */
|
|
|
|
MediaCenter, /**< As with Planar, the applet lives in a plane
|
|
|
|
but the interface should be optimized for
|
|
|
|
medium-to-high resolution screens that are
|
|
|
|
5-15 feet distant from the viewer. Sometimes
|
|
|
|
referred to as a "ten foot interface".*/
|
|
|
|
Horizontal, /**< The applet is constrained vertically, but
|
|
|
|
can expand horizontally. */
|
|
|
|
Vertical /**< The applet is constrained horizontally, but
|
|
|
|
can expand vertically. */
|
|
|
|
};
|
2009-11-13 22:44:51 +01:00
|
|
|
|
2009-05-13 02:55:25 +02:00
|
|
|
enum Location {
|
|
|
|
Floating = 0, /**< Free floating. Neither geometry or z-ordering
|
|
|
|
is described precisely by this value. */
|
|
|
|
Desktop, /**< On the planar desktop layer, extending across
|
|
|
|
the full screen from edge to edge */
|
|
|
|
FullScreen, /**< Full screen */
|
|
|
|
TopEdge, /**< Along the top of the screen*/
|
|
|
|
BottomEdge, /**< Along the bottom of the screen*/
|
|
|
|
LeftEdge, /**< Along the left side of the screen */
|
|
|
|
RightEdge /**< Along the right side of the screen */
|
|
|
|
};
|
2009-11-13 22:44:51 +01:00
|
|
|
|
2009-05-13 02:55:25 +02:00
|
|
|
enum AspectRatioMode {
|
|
|
|
InvalidAspectRatioMode = -1, /**< Unsetted mode used for dev convenience
|
|
|
|
when there is a need to store the
|
|
|
|
aspectRatioMode somewhere */
|
|
|
|
IgnoreAspectRatio = 0, /**< The applet can be freely resized */
|
|
|
|
KeepAspectRatio = 1, /**< The applet keeps a fixed aspect ratio */
|
|
|
|
Square = 2, /**< The applet is always a square */
|
|
|
|
ConstrainedSquare = 3, /**< The applet is no wider (in horizontal
|
|
|
|
formfactors) or no higher (in vertical
|
|
|
|
ones) than a square */
|
|
|
|
FixedSize = 4 /** The applet cannot be resized */
|
|
|
|
};
|
|
|
|
|
2011-04-14 19:50:57 +02:00
|
|
|
enum ItemStatus {
|
|
|
|
UnknownStatus = 0, /**< The status is unknown **/
|
|
|
|
PassiveStatus = 1, /**< The Item is passive **/
|
|
|
|
ActiveStatus = 2, /**< The Item is active **/
|
|
|
|
NeedsAttentionStatus = 3, /**< The Item needs attention **/
|
|
|
|
AcceptingInputStatus = 4 /**< The Item is accepting input **/
|
|
|
|
};
|
|
|
|
|
2009-05-13 02:55:25 +02:00
|
|
|
//From Qt namespace
|
2010-04-02 03:04:06 +02:00
|
|
|
enum QtModifiers {
|
|
|
|
QtNoModifier = Qt::NoModifier,
|
|
|
|
QtShiftModifier = Qt::ShiftModifier,
|
|
|
|
QtControlModifier = Qt::ControlModifier,
|
|
|
|
QtAltModifier = Qt::AltModifier,
|
|
|
|
QtMetaModifier = Qt::MetaModifier
|
|
|
|
};
|
|
|
|
|
2009-05-13 02:55:25 +02:00
|
|
|
enum QtOrientation {
|
|
|
|
QtHorizontal= Qt::Horizontal,
|
|
|
|
QtVertical = Qt::Vertical
|
|
|
|
};
|
|
|
|
|
2009-11-03 04:06:04 +01:00
|
|
|
enum QtAnchorPoint {
|
|
|
|
QtAnchorLeft = Qt::AnchorLeft,
|
|
|
|
QtAnchorRight = Qt::AnchorRight,
|
|
|
|
QtAnchorBottom = Qt::AnchorBottom,
|
|
|
|
QtAnchorTop = Qt::AnchorTop,
|
|
|
|
QtAnchorHorizontalCenter = Qt::AnchorHorizontalCenter,
|
|
|
|
QtAnchorVerticalCenter = Qt::AnchorVerticalCenter
|
|
|
|
};
|
|
|
|
|
2009-11-07 12:46:58 +01:00
|
|
|
enum QtCorner {
|
|
|
|
QtTopLeftCorner = Qt::TopLeftCorner,
|
|
|
|
QtTopRightCorner = Qt::TopRightCorner,
|
|
|
|
QtBottomLeftCorner = Qt::BottomLeftCorner,
|
|
|
|
QtBottomRightCorner = Qt::BottomRightCorner
|
|
|
|
};
|
|
|
|
|
2009-11-06 19:59:41 +01:00
|
|
|
enum QtSizePolicy {
|
|
|
|
QSizePolicyFixed = QSizePolicy::Fixed,
|
|
|
|
QSizePolicyMinimum = QSizePolicy::Minimum,
|
|
|
|
QSizePolicyMaximum = QSizePolicy::Maximum,
|
|
|
|
QSizePolicyPreferred = QSizePolicy::Preferred,
|
|
|
|
QSizePolicyExpanding = QSizePolicy::Expanding,
|
|
|
|
QSizePolicyMinimumExpanding = QSizePolicy::MinimumExpanding,
|
|
|
|
QSizePolicyIgnored = QSizePolicy::Ignored
|
|
|
|
};
|
|
|
|
|
2009-11-13 22:44:51 +01:00
|
|
|
enum BackgroundHints {
|
|
|
|
NoBackground = Plasma::Applet::NoBackground,
|
|
|
|
StandardBackground = Plasma::Applet::StandardBackground,
|
|
|
|
TranslucentBackground = Plasma::Applet::TranslucentBackground,
|
|
|
|
DefaultBackground = Plasma::Applet::DefaultBackground
|
|
|
|
};
|
|
|
|
|
2010-08-31 22:47:05 +02:00
|
|
|
enum ThemeColors {
|
|
|
|
TextColor = Plasma::Theme::TextColor,
|
|
|
|
HighlightColor = Plasma::Theme::HighlightColor,
|
|
|
|
BackgroundColor = Plasma::Theme::BackgroundColor,
|
|
|
|
ButtonTextColor = Plasma::Theme::ButtonTextColor,
|
|
|
|
ButtonBackgroundColor = Plasma::Theme::ButtonBackgroundColor,
|
|
|
|
LinkColor = Plasma::Theme::LinkColor,
|
|
|
|
VisitedLinkColor = Plasma::Theme::VisitedLinkColor
|
|
|
|
};
|
|
|
|
|
2009-05-13 02:55:25 +02:00
|
|
|
enum QtAlignment {
|
|
|
|
QtAlignLeft = 0x0001,
|
|
|
|
QtAlignRight = 0x0002,
|
|
|
|
QtAlignHCenter = 0x0004,
|
|
|
|
QtAlignJustify = 0x0005,
|
|
|
|
QtAlignTop = 0x0020,
|
|
|
|
QtAlignBottom = 0x0020,
|
|
|
|
QtAlignVCenter = 0x0080
|
|
|
|
};
|
2009-11-03 04:06:04 +01:00
|
|
|
|
2010-01-21 00:52:32 +01:00
|
|
|
enum QtMouseButton {
|
|
|
|
QtNoButton = Qt::NoButton,
|
|
|
|
QtLeftButton = Qt::LeftButton,
|
|
|
|
QtRightButton = Qt::RightButton,
|
|
|
|
QtMidButton = Qt::MidButton,
|
|
|
|
QtXButton1 = Qt::XButton1,
|
|
|
|
QtXButton2 = Qt::XButton2
|
|
|
|
};
|
|
|
|
|
2009-11-14 05:22:31 +01:00
|
|
|
enum QtScrollBarPolicy {
|
|
|
|
QtScrollBarAsNeeded = Qt::ScrollBarAsNeeded,
|
|
|
|
QtScrollBarAlwaysOff = Qt::ScrollBarAlwaysOff,
|
|
|
|
QtScrollBarAlwaysOn = Qt::ScrollBarAlwaysOn
|
|
|
|
};
|
2010-01-12 09:04:51 +01:00
|
|
|
|
|
|
|
enum AnimationDirection {
|
|
|
|
AnimationForward = QAbstractAnimation::Forward,
|
|
|
|
AnimationBackward = QAbstractAnimation::Backward
|
|
|
|
};
|
2010-03-09 23:29:08 +01:00
|
|
|
|
|
|
|
enum IntervalAlignment {
|
|
|
|
NoAlignment = 0,
|
|
|
|
AlignToMinute,
|
|
|
|
AlignToHour
|
|
|
|
};
|
2011-04-14 16:35:38 +02:00
|
|
|
|
2009-05-13 02:55:25 +02:00
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2009-11-18 23:40:38 +01:00
|
|
|
Q_INVOKABLE void gc();
|
2009-11-13 22:44:51 +01:00
|
|
|
Q_INVOKABLE FormFactor formFactor() const;
|
2009-05-13 02:55:25 +02:00
|
|
|
|
2009-11-13 23:04:16 +01:00
|
|
|
Location location() const;
|
|
|
|
QString currentActivity() const;
|
|
|
|
bool shouldConserveResources() const;
|
2009-05-13 02:55:25 +02:00
|
|
|
|
2009-11-13 22:44:51 +01:00
|
|
|
Q_INVOKABLE AspectRatioMode aspectRatioMode() const;
|
2009-05-13 02:55:25 +02:00
|
|
|
Q_INVOKABLE void setAspectRatioMode(AspectRatioMode mode);
|
|
|
|
|
|
|
|
Q_INVOKABLE void setFailedToLaunch(bool failed, const QString &reason = QString());
|
|
|
|
|
2009-11-13 22:44:51 +01:00
|
|
|
Q_INVOKABLE bool isBusy() const;
|
2009-05-13 02:55:25 +02:00
|
|
|
Q_INVOKABLE void setBusy(bool busy);
|
|
|
|
|
2009-11-13 22:44:51 +01:00
|
|
|
Q_INVOKABLE BackgroundHints backgroundHints() const;
|
|
|
|
Q_INVOKABLE void setBackgroundHints(BackgroundHints hint);
|
|
|
|
|
2009-05-13 02:55:25 +02:00
|
|
|
Q_INVOKABLE void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString());
|
|
|
|
|
|
|
|
Q_INVOKABLE QSizeF size() const;
|
2009-10-21 01:30:36 +02:00
|
|
|
Q_INVOKABLE QRectF rect() const;
|
2009-05-13 02:55:25 +02:00
|
|
|
|
2011-10-27 16:43:55 +02:00
|
|
|
Q_INVOKABLE void setActionSeparator(const QString &name);
|
2009-05-13 02:55:25 +02:00
|
|
|
Q_INVOKABLE void setAction(const QString &name, const QString &text,
|
|
|
|
const QString &icon = QString(), const QString &shortcut = QString());
|
|
|
|
|
|
|
|
Q_INVOKABLE void removeAction(const QString &name);
|
|
|
|
|
2011-02-28 20:42:06 +01:00
|
|
|
Q_INVOKABLE QAction *action(QString name) const;
|
|
|
|
|
2009-05-13 02:55:25 +02:00
|
|
|
Q_INVOKABLE void resize(qreal w, qreal h);
|
|
|
|
|
|
|
|
Q_INVOKABLE void setMinimumSize(qreal w, qreal h);
|
|
|
|
|
|
|
|
Q_INVOKABLE void setPreferredSize(qreal w, qreal h);
|
|
|
|
|
|
|
|
Q_INVOKABLE QString activeConfig() const;
|
|
|
|
|
|
|
|
Q_INVOKABLE void setActiveConfig(const QString &name);
|
|
|
|
|
|
|
|
Q_INVOKABLE QScriptValue readConfig(const QString &entry) const;
|
|
|
|
|
|
|
|
Q_INVOKABLE void writeConfig(const QString &entry, const QVariant &value);
|
|
|
|
|
|
|
|
Q_INVOKABLE QString file(const QString &fileType);
|
|
|
|
Q_INVOKABLE QString file(const QString &fileType, const QString &filePath);
|
|
|
|
|
2009-11-14 06:19:19 +01:00
|
|
|
Q_INVOKABLE bool include(const QString &script);
|
|
|
|
|
2009-11-14 08:32:00 +01:00
|
|
|
Q_INVOKABLE void debug(const QString &msg);
|
2010-01-06 01:23:31 +01:00
|
|
|
Q_INVOKABLE QObject *findChild(const QString &name) const;
|
2009-11-14 08:32:00 +01:00
|
|
|
|
2010-01-20 22:40:55 +01:00
|
|
|
Q_INVOKABLE Plasma::Extender *extender() const;
|
|
|
|
|
2009-05-13 02:55:25 +02:00
|
|
|
Plasma::DataEngine *dataEngine(const QString &name);
|
|
|
|
|
|
|
|
QList<QAction*> contextualActions() const;
|
2009-11-13 23:27:30 +01:00
|
|
|
bool immutable() const;
|
2010-02-01 17:19:32 +01:00
|
|
|
bool userConfiguring() const;
|
2009-11-14 01:24:14 +01:00
|
|
|
int apiVersion() const;
|
2009-11-13 23:04:16 +01:00
|
|
|
|
2010-08-06 04:01:40 +02:00
|
|
|
static AppletInterface *extract(QScriptEngine *engine);
|
2009-11-13 23:04:16 +01:00
|
|
|
inline Plasma::Applet *applet() const { return m_appletScriptEngine->applet(); }
|
2009-05-13 02:55:25 +02:00
|
|
|
|
2011-03-27 16:59:08 +02:00
|
|
|
void setAssociatedApplication(const QString &string);
|
|
|
|
QString associatedApplication() const;
|
|
|
|
|
2011-04-14 16:35:38 +02:00
|
|
|
void setStatus(const ItemStatus &status);
|
|
|
|
ItemStatus status() const;
|
|
|
|
|
2011-12-05 22:40:16 +01:00
|
|
|
// Q_INVOKABLE QString downloadPath(const QString &file);
|
|
|
|
Q_INVOKABLE QStringList downloadedFiles() const;
|
|
|
|
|
2009-05-13 02:55:25 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void releaseVisualFocus();
|
|
|
|
void configNeedsSaving();
|
|
|
|
|
2010-10-13 18:12:43 +02:00
|
|
|
void formFactorChanged();
|
|
|
|
void locationChanged();
|
|
|
|
void contextChanged();
|
|
|
|
void immutableChanged();
|
2011-04-14 22:49:13 +02:00
|
|
|
void statusChanged();
|
2010-10-13 18:12:43 +02:00
|
|
|
|
2009-12-16 23:05:46 +01:00
|
|
|
protected:
|
2010-10-13 18:12:43 +02:00
|
|
|
AbstractJsAppletScript *m_appletScriptEngine;
|
2009-12-16 23:05:46 +01:00
|
|
|
|
|
|
|
private:
|
2011-09-28 08:50:07 +02:00
|
|
|
QStringList m_actions;
|
2009-05-13 02:55:25 +02:00
|
|
|
QSignalMapper *m_actionSignals;
|
|
|
|
QString m_currentConfig;
|
|
|
|
QMap<QString, Plasma::ConfigLoader*> m_configs;
|
2009-12-16 23:05:46 +01:00
|
|
|
};
|
|
|
|
|
2011-01-28 20:44:35 +01:00
|
|
|
class JsAppletInterface : public AppletInterface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QGraphicsLayout *layout WRITE setLayout READ layout)
|
|
|
|
Q_PROPERTY(QObject *sender READ sender)
|
|
|
|
|
|
|
|
public:
|
|
|
|
JsAppletInterface(AbstractJsAppletScript *parent)
|
|
|
|
: AppletInterface(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Q_INVOKABLE void update(const QRectF &rect = QRectF());
|
|
|
|
QGraphicsLayout *layout() const;
|
|
|
|
void setLayout(QGraphicsLayout *);
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef USE_JS_SCRIPTENGINE
|
2011-02-20 19:45:12 +01:00
|
|
|
#define APPLETSUPERCLASS JsAppletInterface
|
2011-01-28 20:44:35 +01:00
|
|
|
#else
|
2011-02-20 19:45:12 +01:00
|
|
|
#define APPLETSUPERCLASS AppletInterface
|
2011-01-28 20:44:35 +01:00
|
|
|
#endif
|
2011-02-20 19:45:12 +01:00
|
|
|
class PopupAppletInterface : public APPLETSUPERCLASS
|
2009-12-16 23:05:46 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QIcon popupIcon READ popupIcon WRITE setPopupIcon)
|
2010-02-28 17:11:48 +01:00
|
|
|
Q_PROPERTY(bool passivePopup READ isPassivePopup WRITE setPassivePopup)
|
|
|
|
Q_PROPERTY(QGraphicsWidget *popupWidget READ popupWidget WRITE setPopupWidget)
|
2009-12-16 23:05:46 +01:00
|
|
|
|
|
|
|
public:
|
2010-10-13 18:12:43 +02:00
|
|
|
PopupAppletInterface(AbstractJsAppletScript *parent);
|
2009-12-16 23:05:46 +01:00
|
|
|
|
|
|
|
void setPopupIcon(const QIcon &icon);
|
|
|
|
QIcon popupIcon();
|
|
|
|
|
|
|
|
inline Plasma::PopupApplet *popupApplet() const { return static_cast<Plasma::PopupApplet *>(m_appletScriptEngine->applet()); }
|
|
|
|
|
2010-02-28 17:11:48 +01:00
|
|
|
void setPassivePopup(bool passive);
|
|
|
|
bool isPassivePopup() const;
|
|
|
|
|
|
|
|
void setPopupWidget(QGraphicsWidget *widget);
|
|
|
|
QGraphicsWidget *popupWidget();
|
|
|
|
|
2011-11-24 18:04:43 +01:00
|
|
|
Q_SIGNALS:
|
|
|
|
void popupEvent(bool);
|
|
|
|
|
2009-12-16 23:05:46 +01:00
|
|
|
public Q_SLOTS:
|
|
|
|
void setPopupIconByName(const QString &name);
|
2010-02-28 17:11:48 +01:00
|
|
|
void togglePopup();
|
|
|
|
void hidePopup();
|
|
|
|
void showPopup();
|
2011-11-01 21:30:03 +01:00
|
|
|
void showPopup(int timeout);
|
2009-05-13 02:55:25 +02:00
|
|
|
};
|
|
|
|
|
2011-02-20 19:45:12 +01:00
|
|
|
|
|
|
|
class ContainmentInterface : public APPLETSUPERCLASS
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QScriptValue applets READ applets)
|
2011-02-22 13:23:36 +01:00
|
|
|
Q_PROPERTY(bool drawWallpaper READ drawWallpaper WRITE setDrawWallpaper)
|
2011-02-25 22:12:41 +01:00
|
|
|
Q_PROPERTY(Type containmentType READ containmentType WRITE setContainmentType)
|
2011-03-02 15:40:47 +01:00
|
|
|
Q_PROPERTY(int screen READ screen NOTIFY screenChanged)
|
2011-03-07 20:16:49 +01:00
|
|
|
Q_PROPERTY(bool movableApplets READ hasMovableApplets WRITE setMovableApplets)
|
2011-04-04 15:14:19 +02:00
|
|
|
Q_PROPERTY(QString activityName READ activityName NOTIFY activityNameChanged)
|
|
|
|
Q_PROPERTY(QString activityId READ activityId NOTIFY activityIdChanged)
|
2011-02-25 22:12:41 +01:00
|
|
|
Q_ENUMS(Type)
|
2011-02-20 19:45:12 +01:00
|
|
|
|
|
|
|
public:
|
2011-02-22 13:23:36 +01:00
|
|
|
enum Type {
|
|
|
|
NoContainmentType = -1, /**< @internal */
|
|
|
|
DesktopContainment = 0, /**< A desktop containment */
|
|
|
|
PanelContainment, /**< A desktop panel */
|
|
|
|
CustomContainment = 127, /**< A containment that is neither a desktop nor a panel
|
|
|
|
but something application specific */
|
|
|
|
CustomPanelContainment = 128 /**< A customized desktop panel */
|
|
|
|
};
|
2011-02-20 19:45:12 +01:00
|
|
|
ContainmentInterface(AbstractJsAppletScript *parent);
|
|
|
|
|
|
|
|
inline Plasma::Containment *containment() const { return static_cast<Plasma::Containment *>(m_appletScriptEngine->applet()); }
|
|
|
|
|
2011-02-22 13:23:36 +01:00
|
|
|
QScriptValue applets();
|
|
|
|
|
|
|
|
void setDrawWallpaper(bool drawWallpaper);
|
|
|
|
bool drawWallpaper();
|
|
|
|
Type containmentType() const;
|
|
|
|
void setContainmentType(Type type);
|
2011-03-02 14:41:38 +01:00
|
|
|
int screen() const;
|
|
|
|
|
2011-03-07 20:16:49 +01:00
|
|
|
void setMovableApplets(bool movable);
|
|
|
|
bool hasMovableApplets() const;
|
|
|
|
|
2011-04-04 15:14:19 +02:00
|
|
|
QString activityName() const;
|
|
|
|
QString activityId() const;
|
|
|
|
|
2011-03-02 15:40:47 +01:00
|
|
|
Q_INVOKABLE QScriptValue screenGeometry(int id) const;
|
2011-03-13 17:26:08 +01:00
|
|
|
Q_INVOKABLE QScriptValue availableScreenRegion(int id) const;
|
2011-02-20 19:45:12 +01:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void appletAdded(QGraphicsWidget *applet, const QPointF &pos);
|
|
|
|
void appletRemoved(QGraphicsWidget *applet);
|
2011-03-02 15:40:47 +01:00
|
|
|
void screenChanged();
|
2011-04-04 15:14:19 +02:00
|
|
|
void activityNameChanged();
|
|
|
|
void activityIdChanged();
|
2011-10-01 15:14:00 +02:00
|
|
|
void availableScreenRegionChanged();
|
2011-02-20 19:45:12 +01:00
|
|
|
|
|
|
|
protected Q_SLOTS:
|
|
|
|
void appletAddedForward(Plasma::Applet *applet, const QPointF &pos);
|
|
|
|
void appletRemovedForward(Plasma::Applet *applet);
|
2011-03-07 20:16:49 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_movableApplets;
|
2011-02-20 19:45:12 +01:00
|
|
|
};
|
|
|
|
|
2009-05-13 02:55:25 +02:00
|
|
|
#endif
|