2 * Copyright 2008 Chani Armitage <chani@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef APPLETINTERFACE_H
21 #define APPLETINTERFACE_H
24 #include <Plasma/DataEngine>
27 class QGraphicsLayout
;
28 class SimpleJavaScriptApplet
;
40 class AppletInterface
: public QObject
45 Q_ENUMS(AspectRatioMode
)
46 Q_ENUMS(QtOrientation
)
47 Q_PROPERTY(QString activeConfig WRITE setActiveConfig READ activeConfig
)
50 AppletInterface(SimpleJavaScriptApplet
*parent
);
53 //------------------------------------------------------------------
54 //enums copy&pasted from plasma.h because qtscript is evil
57 Planar
= 0, /**< The applet lives in a plane and has two
58 degrees of freedom to grow. Optimize for
59 desktop, laptop or tablet usage: a high
60 resolution screen 1-3 feet distant from the
62 MediaCenter
, /**< As with Planar, the applet lives in a plane
63 but the interface should be optimized for
64 medium-to-high resolution screens that are
65 5-15 feet distant from the viewer. Sometimes
66 referred to as a "ten foot interface".*/
67 Horizontal
, /**< The applet is constrained vertically, but
68 can expand horizontally. */
69 Vertical
/**< The applet is constrained horizontally, but
70 can expand vertically. */
73 Floating
= 0, /**< Free floating. Neither geometry or z-ordering
74 is described precisely by this value. */
75 Desktop
, /**< On the planar desktop layer, extending across
76 the full screen from edge to edge */
77 FullScreen
, /**< Full screen */
78 TopEdge
, /**< Along the top of the screen*/
79 BottomEdge
, /**< Along the bottom of the screen*/
80 LeftEdge
, /**< Along the left side of the screen */
81 RightEdge
/**< Along the right side of the screen */
83 enum AspectRatioMode
{
84 InvalidAspectRatioMode
= -1, /**< Unsetted mode used for dev convenience
85 when there is a need to store the
86 aspectRatioMode somewhere */
87 IgnoreAspectRatio
= 0, /**< The applet can be freely resized */
88 KeepAspectRatio
= 1, /**< The applet keeps a fixed aspect ratio */
89 Square
= 2, /**< The applet is always a square */
90 ConstrainedSquare
= 3, /**< The applet is no wider (in horizontal
91 formfactors) or no higher (in vertical
92 ones) than a square */
93 FixedSize
= 4 /** The applet cannot be resized */
98 QtHorizontal
= Qt::Horizontal
,
99 QtVertical
= Qt::Vertical
102 //-------------------------------------------------------------------
104 Q_INVOKABLE FormFactor
formFactor();
106 Q_INVOKABLE Location
location();
108 Q_INVOKABLE QString
currentActivity();
110 Q_INVOKABLE AspectRatioMode
aspectRatioMode();
112 Q_INVOKABLE
void setAspectRatioMode(AspectRatioMode mode
);
114 Q_INVOKABLE
bool shouldConserveResources();
116 Q_INVOKABLE
void setFailedToLaunch(bool failed
, const QString
&reason
= QString());
118 Q_INVOKABLE
bool isBusy();
120 Q_INVOKABLE
void setBusy(bool busy
);
122 Q_INVOKABLE
void setConfigurationRequired(bool needsConfiguring
, const QString
&reason
= QString());
124 Q_INVOKABLE QSizeF
size() const;
126 Q_INVOKABLE
void setAction(const QString
&name
, const QString
&text
,
127 const QString
&icon
= QString(), const QString
&shortcut
= QString());
129 Q_INVOKABLE
void removeAction(const QString
&name
);
131 Q_INVOKABLE
void resize(qreal w
, qreal h
);
133 Q_INVOKABLE
void setMinimumSize(qreal w
, qreal h
);
135 Q_INVOKABLE
void setPreferredSize(qreal w
, qreal h
);
137 Q_INVOKABLE
void update();
139 Q_INVOKABLE QString
activeConfig() const;
141 Q_INVOKABLE
void setActiveConfig(const QString
&name
);
143 Q_INVOKABLE QVariant
readConfig(const QString
&entry
) const;
145 Q_INVOKABLE
void writeConfig(const QString
&entry
, const QVariant
&value
);
147 Plasma::DataEngine
*dataEngine(const QString
&name
);
149 const Plasma::Package
*package() const;
150 QList
<QAction
*> contextualActions() const;
151 Plasma::Applet
*applet() const;
154 void releaseVisualFocus();
156 void configNeedsSaving();
159 void dataUpdated(QString source
, Plasma::DataEngine::Data data
);
162 SimpleJavaScriptApplet
*m_appletScriptEngine
;
163 QSet
<QString
> m_actions
;
164 QSignalMapper
*m_actionSignals
;
165 QString m_currentConfig
;
166 QMap
<QString
, Plasma::ConfigLoader
*> m_configs
;