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 00072 QList<Containment*> containments() const; 00073 00077 void clearContainments(); 00078 00082 KSharedConfig::Ptr config() const; 00083 00096 Containment *addContainment(const QString &name, const QVariantList &args = QVariantList()); 00097 00105 Containment *containmentForScreen(int screen, int desktop = -1) const; 00106 00119 Containment *containmentForScreen(int screen, int desktop, 00120 const QString &defaultPluginIfNonExistent, 00121 const QVariantList &defaultArgs = QVariantList()); 00128 void addOffscreenWidget(QGraphicsWidget *widget); 00129 00134 void removeOffscreenWidget(QGraphicsWidget *widget); 00135 00140 QList <QGraphicsWidget *> offscreenWidgets() const; 00141 00147 virtual int numScreens() const; 00148 00155 virtual QRect screenGeometry(int id) const; 00156 00165 virtual QRegion availableScreenRegion(int id) const; 00166 00174 QPoint popupPosition(const QGraphicsItem *item, const QSize &size); 00175 00185 QPoint popupPosition(const QGraphicsItem *item, const QSize &size, Qt::AlignmentFlag alignment); 00186 00193 QList<Plasma::Location> freeEdges(int screen) const; 00194 00198 QAction *action(QString name) const; 00199 00203 void addAction(QString name, QAction *action); 00204 00208 QList<QAction*> actions() const; 00209 00216 void enableAction(const QString &name, bool enable); 00217 00224 void updateShortcuts(); 00225 00232 void addShortcuts(KActionCollection *newShortcuts); 00233 00241 KAction* addAction(QString name); 00242 00247 void setContainmentActionsDefaults(Containment::Type containmentType, const ContainmentActionsPluginsConfig &config); 00248 00253 ContainmentActionsPluginsConfig containmentActionsDefaults(Containment::Type containmentType); 00254 00260 void setDialogManager(AbstractDialogManager *manager); 00261 00267 AbstractDialogManager *dialogManager(); 00268 00279 #ifndef KDE_NO_DEPRECATED 00280 KDE_DEPRECATED QList<Plasma::Containment *> importLayout(const KConfigBase &config); 00281 #endif 00282 00290 QString preferredToolBoxPlugin(const Containment::Type type) const; 00291 00301 QList<Plasma::Containment *> importLayout(const KConfigGroup &config); 00302 00310 void exportLayout(KConfigGroup &config, QList<Containment*> containments); 00311 00312 public Q_SLOTS: 00321 void initializeLayout(const QString &config = QString()); 00322 00330 void loadLayout(const QString &config = QString()); 00331 00336 void saveLayout(const QString &config = QString()) const; 00337 00341 ImmutabilityType immutability() const; 00342 00348 void setImmutability(const ImmutabilityType immutable); 00349 00354 void requestConfigSync(); 00355 00363 void requireConfigSync(); 00364 00371 void layoutContainments(); 00372 00373 Q_SIGNALS: 00378 void containmentAdded(Plasma::Containment *containment); 00379 00388 void screenOwnerChanged(int wasScreen, int isScreen, Plasma::Containment *containment); 00389 00396 void releaseVisualFocus(); 00397 00401 void configSynced(); 00402 00406 void availableScreenRegionChanged(); 00407 00414 void immutabilityChanged(Plasma::ImmutabilityType immutability); 00415 00424 void shortcutsChanged(); 00425 00426 protected: 00430 virtual void loadDefaultLayout(); 00431 00446 Containment *addContainmentDelayed(const QString &name, 00447 const QVariantList &args = QVariantList()); 00448 00456 void mapAnimation(Animator::Animation from, Animator::Animation to); 00457 00465 void mapAnimation(Animator::Animation from, const QString &to); 00466 00473 void setPreferredToolBoxPlugin(const Containment::Type type, const QString &plugin); 00474 00475 //Reimplemented from QGraphicsScene 00476 void dragEnterEvent(QGraphicsSceneDragDropEvent *event); 00477 void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); 00478 void dragMoveEvent(QGraphicsSceneDragDropEvent *event); 00479 00480 private: 00481 CoronaPrivate *const d; 00482 00483 Q_PRIVATE_SLOT(d, void containmentDestroyed(QObject*)) 00484 Q_PRIVATE_SLOT(d, void offscreenWidgetDestroyed(QObject *)) 00485 Q_PRIVATE_SLOT(d, void syncConfig()) 00486 Q_PRIVATE_SLOT(d, void toggleImmutability()) 00487 Q_PRIVATE_SLOT(d, void showShortcutConfig()) 00488 00489 friend class CoronaPrivate; 00490 friend class View; 00491 }; 00492 00493 } // namespace Plasma 00494 00495 #endif 00496
KDE 4.6 API Reference