2007-06-01 00:27:33 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 Matt Broadstone <mbroadst@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation
|
|
|
|
*
|
|
|
|
* 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 CORONA_H
|
|
|
|
#define CORONA_H
|
|
|
|
|
2007-07-15 00:40:00 +02:00
|
|
|
#include <QtGui/QGraphicsScene>
|
2007-06-17 01:38:56 +02:00
|
|
|
|
2007-06-10 08:01:15 +02:00
|
|
|
#include <plasma/applet.h>
|
|
|
|
#include <plasma/plasma.h>
|
|
|
|
#include <plasma/plasma_export.h>
|
2007-06-01 00:27:33 +02:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @short A QGraphicsScene for Plasma::Applets
|
|
|
|
*/
|
|
|
|
class PLASMA_EXPORT Corona : public QGraphicsScene
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
//typedef QHash<QString, QList<Plasma::Applet*> > layouts;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit Corona(QObject * parent = 0);
|
|
|
|
explicit Corona(const QRectF & sceneRect, QObject * parent = 0);
|
|
|
|
explicit Corona(qreal x, qreal y, qreal width, qreal height, QObject * parent = 0);
|
|
|
|
~Corona();
|
2007-06-23 00:07:13 +02:00
|
|
|
|
2007-06-04 02:25:44 +02:00
|
|
|
/**
|
2007-07-20 10:06:27 +02:00
|
|
|
* The applets and Corona surface are changeable or not
|
2007-06-04 02:25:44 +02:00
|
|
|
**/
|
2007-07-23 02:24:36 +02:00
|
|
|
bool isImmutable() const;
|
2007-06-01 00:27:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The location of the Corona. @see Plasma::Location
|
|
|
|
*/
|
|
|
|
Plasma::Location location() const;
|
|
|
|
|
2007-06-02 00:06:19 +02:00
|
|
|
/**
|
|
|
|
* The current form factor for this Corona. @see Plasma::FormFactor
|
|
|
|
**/
|
|
|
|
Plasma::FormFactor formFactor() const;
|
|
|
|
|
2007-06-02 06:47:09 +02:00
|
|
|
/**
|
|
|
|
* A rect containing the maximum size a plasmoid on this corona should
|
|
|
|
* consider being.
|
|
|
|
**/
|
|
|
|
QRectF maxSizeHint() const;
|
|
|
|
|
2007-07-17 23:13:41 +02:00
|
|
|
/**
|
|
|
|
* Sets the mimetype of Drag/Drop items. Default is
|
|
|
|
* text/x-plasmoidservicename
|
2007-08-05 15:03:54 +02:00
|
|
|
*/
|
|
|
|
void setAppletMimeType(const QString &mimetype);
|
|
|
|
|
2007-07-17 23:13:41 +02:00
|
|
|
/**
|
|
|
|
* The current mime type of Drag/Drop items.
|
2007-08-05 15:03:54 +02:00
|
|
|
*/
|
|
|
|
QString appletMimeType();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save applets to a config file
|
|
|
|
*
|
|
|
|
* @param config the name of the config file to save to
|
|
|
|
*/
|
|
|
|
void saveApplets(const QString &config) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load applet layout from a config file
|
|
|
|
*
|
|
|
|
* @param config the name of the config file to load from
|
|
|
|
*/
|
|
|
|
void loadApplets(const QString &config);
|
2007-07-17 23:13:41 +02:00
|
|
|
|
2007-06-02 00:06:19 +02:00
|
|
|
public Q_SLOTS:
|
2007-08-06 00:44:07 +02:00
|
|
|
/**
|
|
|
|
* Load applets from the default config file
|
|
|
|
*/
|
|
|
|
void loadApplets();
|
|
|
|
|
2007-08-05 15:03:54 +02:00
|
|
|
/**
|
|
|
|
* Save applets to the default config file
|
|
|
|
*/
|
|
|
|
void saveApplets() const;
|
|
|
|
|
2007-06-01 00:27:33 +02:00
|
|
|
/**
|
|
|
|
* Informs the Corona as to what position it is in. This is informational
|
|
|
|
* only, as the Corona doesn't change it's actual location. This is,
|
|
|
|
* however, passed on to Applets that may be managed by this Corona.
|
|
|
|
*
|
|
|
|
* @param location the new location of this Corona
|
|
|
|
*/
|
2007-06-02 00:06:19 +02:00
|
|
|
void setLocation(Plasma::Location location);
|
2007-06-01 00:27:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the form factor for this Corona. This may cause changes in both
|
|
|
|
* the arrangement of Applets as well as the display choices of individual
|
|
|
|
* Applets.
|
|
|
|
*/
|
2007-06-02 00:06:19 +02:00
|
|
|
void setFormFactor(Plasma::FormFactor formFactor);
|
2007-06-01 00:27:33 +02:00
|
|
|
|
2007-06-01 00:40:38 +02:00
|
|
|
/**
|
2007-08-05 11:39:32 +02:00
|
|
|
* Adds an applet to the Corona
|
2007-06-01 00:40:38 +02:00
|
|
|
*
|
|
|
|
* @param name the plugin name for the applet, as given by
|
|
|
|
* KPluginInfo::pluginName()
|
2007-06-20 10:11:59 +02:00
|
|
|
* @param args argument list to pass to the plasmoid
|
2007-08-05 15:03:54 +02:00
|
|
|
* @param id to assign to this applet, or 0 to auto-assign it a new id
|
|
|
|
* @param geometry where to place the applet, or to auto-place it if an invalid
|
|
|
|
* is provided
|
|
|
|
*
|
|
|
|
* @return a pointer to the applet on success, or 0 on failure
|
2007-06-01 00:40:38 +02:00
|
|
|
*/
|
2007-08-05 15:03:54 +02:00
|
|
|
Applet* addApplet(const QString& name, const QStringList& args = QStringList(),
|
|
|
|
uint id = 0, const QRectF &geometry = QRectF());
|
2007-06-01 00:27:33 +02:00
|
|
|
|
2007-06-01 23:32:03 +02:00
|
|
|
/**
|
|
|
|
* Adds a SuperKaramba theme to the scene
|
|
|
|
*
|
|
|
|
* @param path the path to the theme file
|
|
|
|
*/
|
|
|
|
void addKaramba(const KUrl& path);
|
2007-06-24 08:35:49 +02:00
|
|
|
|
2007-06-04 02:25:44 +02:00
|
|
|
/**
|
|
|
|
* Sets if the applets are Immutable
|
|
|
|
*/
|
|
|
|
void setImmutable(bool immutable_);
|
2007-06-01 23:32:03 +02:00
|
|
|
|
2007-06-01 00:27:33 +02:00
|
|
|
protected:
|
|
|
|
void dragEnterEvent(QGraphicsSceneDragDropEvent* event);
|
|
|
|
void dragLeaveEvent(QGraphicsSceneDragDropEvent* event);
|
|
|
|
void dragMoveEvent(QGraphicsSceneDragDropEvent* event);
|
|
|
|
void dropEvent(QGraphicsSceneDragDropEvent* event);
|
2007-07-17 19:55:05 +02:00
|
|
|
// void contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent);
|
2007-06-01 00:27:33 +02:00
|
|
|
|
|
|
|
protected Q_SLOTS:
|
2007-06-02 09:51:11 +02:00
|
|
|
void appletDestroyed(QObject*);
|
2007-06-01 00:27:33 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private * const d;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|