/* * Copyright 2007 Aaron Seigo * Copyright 2007 Matt Broadstone * * 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 CORONA_H #define CORONA_H #include #include #include #include namespace Plasma { class Containment; /** * @short A QGraphicsScene for Plasma::Applets */ class PLASMA_EXPORT Corona : public QGraphicsScene { Q_OBJECT //typedef QHash > layouts; public: explicit Corona(QObject * parent = 0); ~Corona(); /** * Sets the mimetype of Drag/Drop items. Default is * text/x-plasmoidservicename */ void setAppletMimeType(const QString &mimetype); /** * The current mime type of Drag/Drop items. */ QString appletMimeType(); /** * @return all containments on this Corona */ QList containments() const; /** * Clear the Corona from all applets. */ void clearContainments(); /** * Returns the the config file used to store the configuration for this Corona */ KSharedConfig::Ptr config() const; /** * 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 */ Containment* addContainment(const QString& name, const QVariantList& args = QVariantList()); public Q_SLOTS: /** * Load applet layout from a config file * * @param config the name of the config file to load from, * or the default config file if QString() */ void loadLayout(const QString &config = QString()); /** * Save applets layout to file * @arg config the file to save to, or the default config file if QString() */ void saveLayout(const QString &config = QString()) const; /** * Called when there have been changes made to configuration that should be saved * to disk at the next convenient moment */ void scheduleConfigSync() const; /** * Removes a given containment from the corona */ void destroyContainment(Containment *containment); /** * Returns the Containment, if any, for a given physical screen * * @param screen number of the physical screen to locate */ Containment* containmentForScreen(int screen) const; /** * @return The type of immutability of this Corona */ ImmutabilityType immutability() const; /** * Sets the immutability type for this Corona (not immutable, user immutable or system immutable) * @arg immutable the new immutability type of this applet */ void setImmutability(const ImmutabilityType immutable); Q_SIGNALS: /** * 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. * * @param wasScreen the screen it was associated with * @param isScreen the screen it is now associated with * @param containment the containment switching screens */ void screenOwnerChanged(int wasScreen, int isScreen, Plasma::Containment *containment); /** * 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. */ void launchActivated(); protected: /** * Loads the default (system wide) layout for this user **/ virtual void loadDefaultLayout(); //Reimplemented from QGraphicsScene void dragEnterEvent(QGraphicsSceneDragDropEvent* event); void dragLeaveEvent(QGraphicsSceneDragDropEvent* event); void dragMoveEvent(QGraphicsSceneDragDropEvent* event); private: class Private; Private * const d; Q_PRIVATE_SLOT(d, void containmentDestroyed(QObject*)) Q_PRIVATE_SLOT(d, void syncConfig()) }; } // namespace Plasma #endif