Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / libs / plasma / corona.h
blobf9308d15b87e6086bd19feb0831b9797454f2843
1 /*
2 * Copyright 2007 Aaron Seigo <aseigo@kde.org>
3 * Copyright 2007 Matt Broadstone <mbroadst@gmail.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Library General Public License as
7 * published by the Free Software Foundation; either version 2, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details
15 * You should have received a copy of the GNU Library General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef CORONA_H
22 #define CORONA_H
24 #include <QtGui/QGraphicsScene>
26 #include <plasma/applet.h>
27 #include <plasma/plasma.h>
28 #include <plasma/plasma_export.h>
30 namespace Plasma
33 class Containment;
35 /**
36 * @short A QGraphicsScene for Plasma::Applets
38 class PLASMA_EXPORT Corona : public QGraphicsScene
40 Q_OBJECT
42 //typedef QHash<QString, QList<Plasma::Applet*> > layouts;
44 public:
45 explicit Corona(QObject * parent = 0);
46 explicit Corona(const QRectF & sceneRect, QObject * parent = 0);
47 Corona(qreal x, qreal y, qreal width, qreal height, QObject * parent = 0);
48 ~Corona();
50 /**
51 * The applets and Corona surface are changeable or not
52 **/
53 bool isImmutable() const;
55 /**
56 * @return true if this Corona is immutable due to Kiosk settings
58 bool isKioskImmutable() const;
60 /**
61 * A rect containing the maximum size a plasmoid on this corona should
62 * consider being.
63 **/
64 QRectF maxSizeHint() const;
66 /**
67 * Sets the mimetype of Drag/Drop items. Default is
68 * text/x-plasmoidservicename
70 void setAppletMimeType(const QString &mimetype);
72 /**
73 * The current mime type of Drag/Drop items.
75 QString appletMimeType();
77 /**
78 * Loads the default (system wide) layout for this user
79 **/
80 virtual void loadDefaultSetup();
82 /**
83 * Clear the Corona from all applets.
85 void clearApplets();
87 /**
88 * Returns the the config file used to store the configuration for this Corona
90 KSharedConfig::Ptr config() const;
92 /**
93 * Updates all of the corona's containments with reguards to their tool box position..
95 void updateToolboxPositions();
97 public Q_SLOTS:
98 /**
99 * Load applet layout from a config file
101 * @param config the name of the config file to load from,
102 * or the default config file if QString()
104 void loadApplets(const QString &config = QString());
107 * Save applets to file
108 * @arg config the file to save to, or the default config file if QString()
110 void saveApplets(const QString &config = QString()) const;
113 * Called when there have been changes made to configuration that should be saved
114 * to disk at the next convenient moment
116 void scheduleConfigSync() const;
119 * Adds a Containment to the Corona
121 * @param name the plugin name for the containment, as given by
122 * KPluginInfo::pluginName(). If an empty string is passed in, the defalt
123 * containment plugin will be used (usually DesktopContainment). If the
124 * string literal "null" is passed in, then no plugin will be loaded and
125 * a simple Containment object will be created instead.
126 * @param args argument list to pass to the containment
127 * @param id to assign to this containment, or 0 to auto-assign it a new id
128 * @param geometry where to place the containment, or to auto-place it if an invalid
129 * is provided
131 * @return a pointer to the containment on success, or 0 on failure
133 Containment* addContainment(const QString& name, const QVariantList& args = QVariantList(),
134 uint id = 0, bool delayInit = false);
137 * Removes a given containment from the corona
139 void destroyContainment(Containment *containment);
142 * Returns the Containment, if any, for a given physical screen
144 * @param screen number of the physical screen to locate
146 Containment* containmentForScreen(int screen) const;
149 * Returns all containments on this Corona
151 QList<Containment*> containments() const;
154 * Sets if the applets are Immutable
156 void setImmutable(bool immutable_);
158 Q_SIGNALS:
160 * This signal indicates that a application launch was triggered
162 void launchActivated();
165 * This signal indicates that a new screen is being handled
166 * at runtime (e.g. after first creation)
168 * @param screen the xinerama number of the new screen
170 void newScreen(int screen);
172 protected:
173 void dragEnterEvent(QGraphicsSceneDragDropEvent* event);
174 void dragLeaveEvent(QGraphicsSceneDragDropEvent* event);
175 void dragMoveEvent(QGraphicsSceneDragDropEvent* event);
176 //void contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent);
178 protected Q_SLOTS:
179 void containmentDestroyed(QObject*);
180 void screenResized(int);
181 void syncConfig();
183 private:
184 class Private;
185 Private * const d;
188 } // namespace Plasma
190 #endif