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.
|
|
|
|
*/
|
|
|
|
|
2008-08-06 11:19:29 +02:00
|
|
|
#ifndef PLASMA_CORONA_H
|
|
|
|
#define PLASMA_CORONA_H
|
2007-06-01 00:27:33 +02:00
|
|
|
|
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
|
|
|
|
2008-08-02 13:48:56 +02:00
|
|
|
class QGraphicsGridLayout;
|
|
|
|
|
2007-06-01 00:27:33 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2007-09-18 23:25:15 +02:00
|
|
|
class Containment;
|
2008-07-01 20:56:43 +02:00
|
|
|
class CoronaPrivate;
|
2007-06-01 00:27:33 +02:00
|
|
|
|
|
|
|
/**
|
2008-08-25 19:47:48 +02:00
|
|
|
* @class Corona plasma/corona.h <Plasma/Corona>
|
|
|
|
*
|
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);
|
|
|
|
~Corona();
|
2007-06-23 00:07:13 +02:00
|
|
|
|
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();
|
|
|
|
|
2008-04-24 21:17:29 +02:00
|
|
|
/**
|
|
|
|
* @return all containments on this Corona
|
|
|
|
*/
|
|
|
|
QList<Containment*> containments() const;
|
|
|
|
|
2007-08-08 19:32:32 +02:00
|
|
|
/**
|
|
|
|
* Clear the Corona from all applets.
|
|
|
|
*/
|
2008-04-16 23:15:38 +02:00
|
|
|
void clearContainments();
|
2007-09-18 23:25:15 +02:00
|
|
|
|
2007-11-25 00:38:37 +01:00
|
|
|
/**
|
2008-09-25 17:05:22 +02:00
|
|
|
* Returns the config file used to store the configuration for this Corona
|
2007-11-25 00:38:37 +01:00
|
|
|
*/
|
2008-01-02 00:41:59 +01:00
|
|
|
KSharedConfig::Ptr config() const;
|
2007-11-25 00:38:37 +01:00
|
|
|
|
2008-04-25 19:15:14 +02:00
|
|
|
/**
|
|
|
|
* Adds a Containment to the Corona
|
|
|
|
*
|
|
|
|
* @param name the plugin name for the containment, as given by
|
|
|
|
* 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.
|
|
|
|
* @param args argument list to pass to the containment
|
|
|
|
*
|
|
|
|
* @return a pointer to the containment on success, or 0 on failure
|
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
Containment *addContainment(const QString &name, const QVariantList &args = QVariantList());
|
2008-04-25 19:15:14 +02:00
|
|
|
|
2008-04-29 03:24:00 +02:00
|
|
|
/**
|
|
|
|
* Returns the Containment, if any, for a given physical screen
|
|
|
|
*
|
|
|
|
* @param screen number of the physical screen to locate
|
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
Containment *containmentForScreen(int screen) const;
|
2008-04-29 03:24:00 +02:00
|
|
|
|
2008-08-02 13:48:56 +02:00
|
|
|
/**
|
|
|
|
* Adds a widget in the topleft quadrant in the scene. Widgets in the topleft quadrant are
|
|
|
|
* normally never shown unless you specifically aim a view at it, which makes it ideal for
|
|
|
|
* toplevel views etc.
|
|
|
|
* @param widget the widget to add.
|
|
|
|
*/
|
|
|
|
void addOffscreenWidget(QGraphicsWidget *widget);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a widget from the topleft quadrant in the scene.
|
|
|
|
* @param widget the widget to remove.
|
|
|
|
*/
|
|
|
|
void removeOffscreenWidget(QGraphicsWidget *widget);
|
|
|
|
|
2008-10-29 16:22:38 +01:00
|
|
|
/**
|
|
|
|
* Returns the number of screens available to plasma.
|
|
|
|
* Subclasses should override this method as the default
|
|
|
|
* implementation returns a meaningless value.
|
|
|
|
*/
|
|
|
|
virtual int numScreens() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the geometry of a given screen.
|
|
|
|
* Valid screen ids are 0 to numScreen()-1, or -1 for the full desktop geometry.
|
|
|
|
* Subclasses should override this method as the default
|
|
|
|
* implementation returns a meaningless value.
|
|
|
|
*/
|
|
|
|
virtual QRect screenGeometry(int id) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the available region for a given screen.
|
|
|
|
* The available region excludes panels and similar windows.
|
|
|
|
* Valid screen ids are 0 to numScreens()-1.
|
|
|
|
* By default this method returns a rectangular region
|
|
|
|
* equal to screenGeometry(id); subclasses that need another
|
|
|
|
* behavior should override this method.
|
|
|
|
*/
|
|
|
|
virtual QRegion availableScreenRegion(int id) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reccomended position for a popup window like a menu or a tooltip
|
|
|
|
* given its size
|
|
|
|
* @param s size of the popup
|
|
|
|
* @returns reccomended position
|
|
|
|
*/
|
|
|
|
QPoint popupPosition(const QGraphicsItem *item, const QSize &s);
|
|
|
|
|
2007-06-02 00:06:19 +02:00
|
|
|
public Q_SLOTS:
|
2007-08-06 00:44:07 +02:00
|
|
|
/**
|
2008-05-24 01:12:05 +02:00
|
|
|
* Initializes the layout from a config file. This will first clear any existing
|
|
|
|
* Containments, load a layout from the requested configuration file, request the
|
|
|
|
* default layout if needed and update immutability.
|
|
|
|
*
|
|
|
|
* @param config the name of the config file to load from,
|
|
|
|
* or the default config file if QString()
|
|
|
|
*/
|
|
|
|
void initializeLayout(const QString &config = QString());
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load applet layout from a config file. The results will be added to the
|
|
|
|
* current set of Containments.
|
2008-02-11 22:43:09 +01:00
|
|
|
*
|
|
|
|
* @param config the name of the config file to load from,
|
|
|
|
* or the default config file if QString()
|
2007-08-06 00:44:07 +02:00
|
|
|
*/
|
2008-04-24 21:04:15 +02:00
|
|
|
void loadLayout(const QString &config = QString());
|
2007-08-06 00:44:07 +02:00
|
|
|
|
2007-08-05 15:03:54 +02:00
|
|
|
/**
|
2008-04-24 21:04:15 +02:00
|
|
|
* Save applets layout to file
|
2008-02-11 22:43:09 +01:00
|
|
|
* @arg config the file to save to, or the default config file if QString()
|
2007-08-05 15:03:54 +02:00
|
|
|
*/
|
2008-04-24 21:04:15 +02:00
|
|
|
void saveLayout(const QString &config = QString()) const;
|
2007-08-05 15:03:54 +02:00
|
|
|
|
2007-06-04 02:25:44 +02:00
|
|
|
/**
|
2008-04-25 19:33:55 +02:00
|
|
|
* @return The type of immutability of this Corona
|
2007-06-04 02:25:44 +02:00
|
|
|
*/
|
2008-04-24 20:24:11 +02:00
|
|
|
ImmutabilityType immutability() const;
|
|
|
|
|
|
|
|
/**
|
2008-10-11 18:19:04 +02:00
|
|
|
* Sets the immutability type for this Corona (not immutable,
|
|
|
|
* user immutable or system immutable)
|
2008-04-24 20:24:11 +02:00
|
|
|
* @arg immutable the new immutability type of this applet
|
|
|
|
*/
|
|
|
|
void setImmutability(const ImmutabilityType immutable);
|
2007-06-01 23:32:03 +02:00
|
|
|
|
2008-06-14 03:31:53 +02:00
|
|
|
/**
|
|
|
|
* Schedules a flush-to-disk synchronization of the configuration state
|
|
|
|
* at the next convenient moment.
|
|
|
|
*/
|
|
|
|
void requestConfigSync();
|
|
|
|
|
2007-11-15 12:06:33 +01:00
|
|
|
Q_SIGNALS:
|
2007-11-27 23:55:09 +01:00
|
|
|
/**
|
2008-03-12 21:41:03 +01:00
|
|
|
* This signal indicates a new containment has been added to
|
|
|
|
* the Corona
|
|
|
|
*/
|
|
|
|
void containmentAdded(Plasma::Containment *containment);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This signal indicates that a containment has been newly
|
|
|
|
* associated (or dissociated) with a physical screen.
|
2007-11-27 23:55:09 +01:00
|
|
|
*
|
2008-03-12 21:41:03 +01:00
|
|
|
* @param wasScreen the screen it was associated with
|
|
|
|
* @param isScreen the screen it is now associated with
|
|
|
|
* @param containment the containment switching screens
|
2007-11-27 23:55:09 +01:00
|
|
|
*/
|
2008-03-12 21:41:03 +01:00
|
|
|
void screenOwnerChanged(int wasScreen, int isScreen, Plasma::Containment *containment);
|
2007-11-27 23:55:09 +01:00
|
|
|
|
2008-04-25 19:21:24 +02:00
|
|
|
/**
|
|
|
|
* This signal indicates that an application launch, window
|
|
|
|
* creation or window focus event was triggered. This is used, for instance,
|
|
|
|
* to ensure that the Dashboard view in Plasma hides when such an event is
|
|
|
|
* triggered by an item it is displaying.
|
|
|
|
*/
|
2008-04-29 04:28:35 +02:00
|
|
|
void releaseVisualFocus();
|
2008-04-25 19:21:24 +02:00
|
|
|
|
2008-06-14 03:31:53 +02:00
|
|
|
/**
|
|
|
|
* This signal indicates that the configuration file was flushed to disc.
|
|
|
|
*/
|
|
|
|
void configSynced();
|
|
|
|
|
2008-04-24 20:36:39 +02:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Loads the default (system wide) layout for this user
|
|
|
|
**/
|
|
|
|
virtual void loadDefaultLayout();
|
|
|
|
|
2008-07-07 04:16:08 +02:00
|
|
|
/**
|
|
|
|
* Loads a containment with delayed initialization, primarily useful
|
|
|
|
* for implementations of loadDefaultLayout. The caller is responsible
|
|
|
|
* for all initializating, saving and notification of a new containment.
|
|
|
|
*
|
|
|
|
* @param name the plugin name for the containment, as given by
|
|
|
|
* 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.
|
|
|
|
* @param args argument list to pass to the containment
|
|
|
|
*
|
|
|
|
* @return a pointer to the containment on success, or 0 on failure
|
|
|
|
**/
|
2008-10-11 18:19:04 +02:00
|
|
|
Containment *addContainmentDelayed(const QString &name,
|
|
|
|
const QVariantList &args = QVariantList());
|
2008-07-07 04:16:08 +02:00
|
|
|
|
2008-04-24 20:36:39 +02:00
|
|
|
//Reimplemented from QGraphicsScene
|
2008-10-11 18:19:04 +02:00
|
|
|
void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
|
|
|
|
void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
|
|
|
|
void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
|
2007-06-01 00:27:33 +02:00
|
|
|
|
|
|
|
private:
|
2008-10-11 18:19:04 +02:00
|
|
|
CoronaPrivate *const d;
|
2008-04-24 21:46:07 +02:00
|
|
|
|
|
|
|
Q_PRIVATE_SLOT(d, void containmentDestroyed(QObject*))
|
|
|
|
Q_PRIVATE_SLOT(d, void syncConfig())
|
2008-07-01 20:56:43 +02:00
|
|
|
|
|
|
|
friend class CoronaPrivate;
|
2007-06-01 00:27:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|