Plasma
corona.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2007 Aaron Seigo <aseigo@kde.org> 00003 * Copyright 2007 Matt Broadstone <mbroadst@gmail.com> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Library General Public License as 00007 * published by the Free Software Foundation; either version 2, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details 00014 * 00015 * You should have received a copy of the GNU Library General Public 00016 * License along with this program; if not, write to the 00017 * Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef PLASMA_CORONA_H 00022 #define PLASMA_CORONA_H 00023 00024 #include <QtGui/QGraphicsScene> 00025 00026 #include <plasma/applet.h> 00027 #include <plasma/containment.h> 00028 #include <plasma/plasma.h> 00029 #include <plasma/plasma_export.h> 00030 00031 class QGraphicsGridLayout; 00032 class QAction; 00033 00034 class KAction; 00035 00036 namespace Plasma 00037 { 00038 00039 class CoronaPrivate; 00040 class ContainmentActionsPluginsConfig; 00041 class AbstractDialogManager; 00042 00048 class PLASMA_EXPORT Corona : public QGraphicsScene 00049 { 00050 Q_OBJECT 00051 00052 //typedef QHash<QString, QList<Plasma::Applet*> > layouts; 00053 00054 public: 00055 explicit Corona(QObject * parent = 0); 00056 ~Corona(); 00057 00062 void setAppletMimeType(const QString &mimetype); 00063 00067 QString appletMimeType(); 00068 00073 QString defaultContainmentPlugin() const; 00074 00078 QList<Containment*> containments() const; 00079 00083 void clearContainments(); 00084 00088 KSharedConfig::Ptr config() const; 00089 00105 Containment *addContainment(const QString &name, const QVariantList &args = QVariantList()); 00106 00114 Containment *containmentForScreen(int screen, int desktop = -1) const; 00115 00128 Containment *containmentForScreen(int screen, int desktop, 00129 const QString &defaultPluginIfNonExistent, 00130 const QVariantList &defaultArgs = QVariantList()); 00137 void addOffscreenWidget(QGraphicsWidget *widget); 00138 00143 void removeOffscreenWidget(QGraphicsWidget *widget); 00144 00149 QList <QGraphicsWidget *> offscreenWidgets() const; 00150 00156 virtual int numScreens() const; 00157 00164 virtual QRect screenGeometry(int id) const; 00165 00174 virtual QRegion availableScreenRegion(int id) const; 00175 00183 QPoint popupPosition(const QGraphicsItem *item, const QSize &size); 00184 00194 QPoint popupPosition(const QGraphicsItem *item, const QSize &size, Qt::AlignmentFlag alignment); 00195 00202 QList<Plasma::Location> freeEdges(int screen) const; 00203 00207 QAction *action(QString name) const; 00208 00212 void addAction(QString name, QAction *action); 00213 00217 QList<QAction*> actions() const; 00218 00225 void enableAction(const QString &name, bool enable); 00226 00233 void updateShortcuts(); 00234 00241 void addShortcuts(KActionCollection *newShortcuts); 00242 00250 KAction* addAction(QString name); 00251 00256 void setContainmentActionsDefaults(Containment::Type containmentType, const ContainmentActionsPluginsConfig &config); 00257 00262 ContainmentActionsPluginsConfig containmentActionsDefaults(Containment::Type containmentType); 00263 00269 void setDialogManager(AbstractDialogManager *manager); 00270 00276 AbstractDialogManager *dialogManager(); 00277 00288 #ifndef KDE_NO_DEPRECATED 00289 KDE_DEPRECATED QList<Plasma::Containment *> importLayout(const KConfigBase &config); 00290 #endif 00291 00299 QString preferredToolBoxPlugin(const Containment::Type type) const; 00300 00310 QList<Plasma::Containment *> importLayout(const KConfigGroup &config); 00311 00319 void exportLayout(KConfigGroup &config, QList<Containment*> containments); 00320 00321 public Q_SLOTS: 00330 void initializeLayout(const QString &config = QString()); 00331 00339 void loadLayout(const QString &config = QString()); 00340 00345 void saveLayout(const QString &config = QString()) const; 00346 00350 ImmutabilityType immutability() const; 00351 00357 void setImmutability(const ImmutabilityType immutable); 00358 00363 void requestConfigSync(); 00364 00372 void requireConfigSync(); 00373 00380 void layoutContainments(); 00381 00382 Q_SIGNALS: 00387 void containmentAdded(Plasma::Containment *containment); 00388 00397 void screenOwnerChanged(int wasScreen, int isScreen, Plasma::Containment *containment); 00398 00405 void releaseVisualFocus(); 00406 00410 void configSynced(); 00411 00415 void availableScreenRegionChanged(); 00416 00423 void immutabilityChanged(Plasma::ImmutabilityType immutability); 00424 00433 void shortcutsChanged(); 00434 00435 protected: 00439 virtual void loadDefaultLayout(); 00440 00459 Containment *addContainmentDelayed(const QString &name, 00460 const QVariantList &args = QVariantList()); 00461 00469 void mapAnimation(Animator::Animation from, Animator::Animation to); 00470 00478 void mapAnimation(Animator::Animation from, const QString &to); 00479 00486 void setPreferredToolBoxPlugin(const Containment::Type type, const QString &plugin); 00487 00492 void setDefaultContainmentPlugin(const QString &name); 00493 00494 //Reimplemented from QGraphicsScene 00495 void dragEnterEvent(QGraphicsSceneDragDropEvent *event); 00496 void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); 00497 void dragMoveEvent(QGraphicsSceneDragDropEvent *event); 00498 00499 private: 00500 CoronaPrivate *const d; 00501 00502 Q_PRIVATE_SLOT(d, void containmentDestroyed(QObject*)) 00503 Q_PRIVATE_SLOT(d, void offscreenWidgetDestroyed(QObject *)) 00504 Q_PRIVATE_SLOT(d, void syncConfig()) 00505 Q_PRIVATE_SLOT(d, void toggleImmutability()) 00506 Q_PRIVATE_SLOT(d, void showShortcutConfig()) 00507 00508 friend class CoronaPrivate; 00509 friend class View; 00510 }; 00511 00512 } // namespace Plasma 00513 00514 #endif 00515
KDE 4.7 API Reference