2007-06-01 00:27:33 +02:00
|
|
|
/*
|
2007-11-09 01:44:35 +01:00
|
|
|
* Copyright 2007 Aaron Seigo <aseigo@kde.org>
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2007 Matt Broadstone <mbroadst@gmail.com>
|
2007-06-01 00:27:33 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-09-14 21:06:18 +02:00
|
|
|
* 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.
|
2007-06-01 00:27:33 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
{
|
|
|
|
|
2007-09-18 23:25:15 +02:00
|
|
|
class Containment;
|
2007-06-01 00:27:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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);
|
2007-11-09 01:44:35 +01:00
|
|
|
Corona(qreal x, qreal y, qreal width, qreal height, QObject * parent = 0);
|
2007-06-01 00:27:33 +02:00
|
|
|
~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
|
|
|
|
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-09-18 23:25:15 +02:00
|
|
|
/**
|
|
|
|
* Loads the default (system wide) layout for this user
|
|
|
|
**/
|
|
|
|
virtual void loadDefaultSetup();
|
|
|
|
|
2007-08-08 19:32:32 +02:00
|
|
|
/**
|
|
|
|
* Clear the Corona from all applets.
|
|
|
|
*/
|
|
|
|
void clearApplets();
|
2007-09-18 23:25:15 +02:00
|
|
|
|
2007-11-25 00:38:37 +01:00
|
|
|
/**
|
|
|
|
* Returns the the config file used to store the configuration for this Corona
|
|
|
|
*/
|
|
|
|
KSharedConfig::Ptr config();
|
|
|
|
|
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
|
|
|
/**
|
2007-09-18 23:25:15 +02:00
|
|
|
* Adds an applet to the default Containment
|
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-29 04:33:22 +02:00
|
|
|
Applet* addApplet(const QString& name, const QVariantList& args = QVariantList(),
|
2007-09-18 23:25:15 +02:00
|
|
|
uint id = 0, const QRectF &geometry = QRectF(-1, -1, -1, -1));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a Containment to the Corona
|
|
|
|
*
|
|
|
|
* @param name the plugin name for the containment, as given by
|
2007-10-28 21:04:38 +01:00
|
|
|
* KPluginInfo::pluginName(). If an empty string is passed in, the defalt
|
|
|
|
* containment plugin will be used (usually DesktopContainment). If the
|
|
|
|
* string literal "null" is passed in, then no plugin will be loaded and
|
|
|
|
* a simple Containment object will be created instead.
|
2007-09-18 23:25:15 +02:00
|
|
|
* @param args argument list to pass to the containment
|
|
|
|
* @param id to assign to this containment, or 0 to auto-assign it a new id
|
|
|
|
* @param geometry where to place the containment, or to auto-place it if an invalid
|
|
|
|
* is provided
|
|
|
|
*
|
|
|
|
* @return a pointer to the containment on success, or 0 on failure
|
|
|
|
*/
|
|
|
|
Containment* addContainment(const QString& name, const QVariantList& args = QVariantList(),
|
|
|
|
uint id = 0, bool delayInit = false);
|
|
|
|
|
2007-11-25 00:38:37 +01:00
|
|
|
/**
|
|
|
|
* Removes a given containment from the corona
|
|
|
|
*/
|
|
|
|
void destroyContainment(Containment *containment);
|
|
|
|
|
2007-09-18 23:25:15 +02:00
|
|
|
/**
|
|
|
|
* Returns the Containment, if any, for a given physical screen
|
|
|
|
*
|
|
|
|
* @param screen number of the physical screen to locate
|
|
|
|
*/
|
|
|
|
Containment* containmentForScreen(int screen) const;
|
2007-06-01 00:27:33 +02:00
|
|
|
|
2007-09-30 20:06:08 +02:00
|
|
|
/**
|
|
|
|
* Returns all containments on this Corona
|
|
|
|
*/
|
|
|
|
QList<Containment*> containments() const;
|
|
|
|
|
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-11-15 12:06:33 +01:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
2007-11-27 23:55:09 +01:00
|
|
|
* This signal indicates that a application launch was triggered
|
2007-11-15 12:06:33 +01:00
|
|
|
*/
|
|
|
|
void launchActivated();
|
|
|
|
|
2007-11-27 23:55:09 +01:00
|
|
|
/**
|
|
|
|
* This signal indicates that a new screen is being handled
|
|
|
|
* at runtime (e.g. after first creation)
|
|
|
|
*
|
|
|
|
* @param screen the xinerama number of the new screen
|
|
|
|
*/
|
|
|
|
void newScreen(int screen);
|
|
|
|
|
2007-06-01 00:27:33 +02:00
|
|
|
protected:
|
|
|
|
void dragEnterEvent(QGraphicsSceneDragDropEvent* event);
|
|
|
|
void dragLeaveEvent(QGraphicsSceneDragDropEvent* event);
|
|
|
|
void dragMoveEvent(QGraphicsSceneDragDropEvent* event);
|
2007-09-18 23:25:15 +02:00
|
|
|
//void contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent);
|
2007-06-01 00:27:33 +02:00
|
|
|
|
|
|
|
protected Q_SLOTS:
|
2007-09-18 23:25:15 +02:00
|
|
|
void containmentDestroyed(QObject*);
|
2007-11-09 01:44:35 +01:00
|
|
|
void screenResized(int);
|
2007-06-01 00:27:33 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private * const d;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|