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>
|
2012-08-22 12:03:27 +02:00
|
|
|
#include <Plasma/ToolTipContent>
|
2009-05-13 02:55:25 +02:00
|
|
|
|
2010-10-13 18:12:43 +02:00
|
|
|
#include "abstractjsappletscript.h"
|
ToolBox bindings for declarative containments
This adds the necessary bits, actions handling, showing / hiding of
toolbox and a hooks for config interface and add widgets.
The interesting bits:
Toolbox separate on the scene
For declarative containments, we add a declarativewidget on top of the
view which loads the "org.kde.toolbox" package. The toolbox can differ
per platform, layout of toolbox and containment can not "leak" into each
other.
ToolBox import
The most important and interesting bit is the list of actions the
ToolBox exposes, it's collected from corona, containment. The latter is
actually problematic, since we don't get access to the actions
internally provided by Containment
(ContainmentPrivate::addDefaultActions).
Containment::setToolBox(AbstractToolBox) being protected, we cannot
register our declarative ToolBoxProxy implementation to the containment,
so we have to wire up settings and addwidgets separately. Sorting of the
actions is "random", and expected to be done by the QML toolbox
implementation, based on objectName strings.
REVIEW:107232
2012-11-07 17:21:26 +01:00
|
|
|
#include "../declarative/toolboxproxy.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)
|
2012-08-01 20:38:35 +02:00
|
|
|
Q_PROPERTY(QtSizePolicy horizontalSizePolicy READ horizontalSizePolicy WRITE setHorizontalSizePolicy)
|
|
|
|
Q_PROPERTY(QtSizePolicy verticalSizePolicy READ verticalSizePolicy WRITE setVerticalSizePolicy)
|
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. */
|
2012-11-23 17:46:26 +01:00
|
|
|
Vertical, /**< The applet is constrained horizontally, but
|
2009-05-13 02:55:25 +02:00
|
|
|
can expand vertically. */
|
2012-11-23 17:46:26 +01:00
|
|
|
Application /**< The Applet lives in a plane and should be optimized to look as a full application,
|
|
|
|
for the desktop or the particular device. */
|
2009-05-13 02:55:25 +02:00
|
|
|
};
|
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;
|
|
|
|
|
2012-08-01 20:38:35 +02:00
|
|
|
void setHorizontalSizePolicy(QtSizePolicy policy);
|
|
|
|
QtSizePolicy horizontalSizePolicy() const;
|
|
|
|
|
|
|
|
void setVerticalSizePolicy(QtSizePolicy policy);
|
|
|
|
QtSizePolicy verticalSizePolicy() 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)
|
2012-08-22 12:03:27 +02:00
|
|
|
Q_PROPERTY(QVariantHash popupIconToolTip READ popupIconToolTip WRITE setPopupIconToolTip NOTIFY popupIconToolTipChanged)
|
2012-09-20 17:07:07 +02:00
|
|
|
Q_PROPERTY(bool popupShowing READ isPopupShowing WRITE setPopupShowing NOTIFY popupEvent)
|
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();
|
|
|
|
|
2012-08-22 12:03:27 +02:00
|
|
|
void setPopupIconToolTip(const QVariantHash &data);
|
|
|
|
QVariantHash popupIconToolTip() const;
|
|
|
|
|
2009-12-16 23:05:46 +01:00
|
|
|
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;
|
|
|
|
|
2012-09-20 17:07:07 +02:00
|
|
|
bool isPopupShowing() const;
|
|
|
|
void setPopupShowing(bool show);
|
|
|
|
|
2010-02-28 17:11:48 +01:00
|
|
|
void setPopupWidget(QGraphicsWidget *widget);
|
|
|
|
QGraphicsWidget *popupWidget();
|
|
|
|
|
2011-11-24 18:04:43 +01:00
|
|
|
Q_SIGNALS:
|
2012-09-20 17:07:07 +02:00
|
|
|
void popupEvent(bool popupShowing);
|
2012-08-22 12:03:27 +02:00
|
|
|
void popupIconToolTipChanged();
|
2011-11-24 18:04:43 +01:00
|
|
|
|
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);
|
2012-08-22 12:03:27 +02:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void sourceAppletPopupEvent(bool show);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QVariantHash m_rawToolTipData;
|
|
|
|
Plasma::ToolTipContent m_toolTipData;
|
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)
|
ToolBox bindings for declarative containments
This adds the necessary bits, actions handling, showing / hiding of
toolbox and a hooks for config interface and add widgets.
The interesting bits:
Toolbox separate on the scene
For declarative containments, we add a declarativewidget on top of the
view which loads the "org.kde.toolbox" package. The toolbox can differ
per platform, layout of toolbox and containment can not "leak" into each
other.
ToolBox import
The most important and interesting bit is the list of actions the
ToolBox exposes, it's collected from corona, containment. The latter is
actually problematic, since we don't get access to the actions
internally provided by Containment
(ContainmentPrivate::addDefaultActions).
Containment::setToolBox(AbstractToolBox) being protected, we cannot
register our declarative ToolBoxProxy implementation to the containment,
so we have to wire up settings and addwidgets separately. Sorting of the
actions is "random", and expected to be done by the QML toolbox
implementation, based on objectName strings.
REVIEW:107232
2012-11-07 17:21:26 +01:00
|
|
|
Q_PROPERTY(ToolBoxProxy* toolBox READ toolBox CONSTANT)
|
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;
|
|
|
|
|
ToolBox bindings for declarative containments
This adds the necessary bits, actions handling, showing / hiding of
toolbox and a hooks for config interface and add widgets.
The interesting bits:
Toolbox separate on the scene
For declarative containments, we add a declarativewidget on top of the
view which loads the "org.kde.toolbox" package. The toolbox can differ
per platform, layout of toolbox and containment can not "leak" into each
other.
ToolBox import
The most important and interesting bit is the list of actions the
ToolBox exposes, it's collected from corona, containment. The latter is
actually problematic, since we don't get access to the actions
internally provided by Containment
(ContainmentPrivate::addDefaultActions).
Containment::setToolBox(AbstractToolBox) being protected, we cannot
register our declarative ToolBoxProxy implementation to the containment,
so we have to wire up settings and addwidgets separately. Sorting of the
actions is "random", and expected to be done by the QML toolbox
implementation, based on objectName strings.
REVIEW:107232
2012-11-07 17:21:26 +01:00
|
|
|
ToolBoxProxy* toolBox();
|
|
|
|
|
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;
|
ToolBox bindings for declarative containments
This adds the necessary bits, actions handling, showing / hiding of
toolbox and a hooks for config interface and add widgets.
The interesting bits:
Toolbox separate on the scene
For declarative containments, we add a declarativewidget on top of the
view which loads the "org.kde.toolbox" package. The toolbox can differ
per platform, layout of toolbox and containment can not "leak" into each
other.
ToolBox import
The most important and interesting bit is the list of actions the
ToolBox exposes, it's collected from corona, containment. The latter is
actually problematic, since we don't get access to the actions
internally provided by Containment
(ContainmentPrivate::addDefaultActions).
Containment::setToolBox(AbstractToolBox) being protected, we cannot
register our declarative ToolBoxProxy implementation to the containment,
so we have to wire up settings and addwidgets separately. Sorting of the
actions is "random", and expected to be done by the QML toolbox
implementation, based on objectName strings.
REVIEW:107232
2012-11-07 17:21:26 +01:00
|
|
|
ToolBoxProxy* m_toolBox;
|
2011-02-20 19:45:12 +01:00
|
|
|
};
|
|
|
|
|
2009-05-13 02:55:25 +02:00
|
|
|
#endif
|