Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef KLFSIDEWIDGET_H
00025 #define KLFSIDEWIDGET_H
00026
00027
00028 #include <QObject>
00029 #include <QWidget>
00030 #include <QPointer>
00031
00032 #include <klfdefs.h>
00033 #include <klffactory.h>
00034
00035
00036 struct KLFSideWidgetManagerBasePrivate;
00037
00039
00065 class KLF_EXPORT KLFSideWidgetManagerBase : public QObject
00066 {
00067 Q_OBJECT
00068 public:
00074 KLFSideWidgetManagerBase(QWidget *parentWidget = NULL, QWidget *sideWidget = NULL,
00075 bool requireSideWidgetParentConsistency = false, QObject *managerParent = NULL);
00076 virtual ~KLFSideWidgetManagerBase();
00077
00079 virtual QWidget * sideWidget() const;
00081 virtual QWidget * ourParentWidget() const;
00082
00087 void setSideWidget(QWidget *widget);
00090 void setOurParentWidget(QWidget *widget);
00091
00093
00096 virtual bool sideWidgetVisible() const = 0;
00097
00098 signals:
00103 void sideWidgetShown(bool shown);
00104
00105 public slots:
00107
00113 virtual void showSideWidget(bool show) = 0;
00114
00116 void showSideWidget() { showSideWidget(true); }
00118 void hideSideWidget(bool hide = true) { showSideWidget(!hide); }
00121 void toggleSideWidget() { showSideWidget(!sideWidgetVisible()); }
00122
00130 virtual void waitForShowHideActionFinished(int timeout_ms = 2000);
00131
00132 protected:
00134 virtual void newSideWidgetSet(QWidget *oldSideWidget, QWidget *newSideWidget)
00135 { Q_UNUSED(oldSideWidget); Q_UNUSED(newSideWidget); }
00137 virtual void newParentWidgetSet(QWidget *oldParentWidget, QWidget *newParentWidget)
00138 { Q_UNUSED(oldParentWidget); Q_UNUSED(newParentWidget); }
00139
00146 virtual bool showHideIsAnimating() { return false; }
00147
00148 private:
00149 KLF_DECLARE_PRIVATE(KLFSideWidgetManagerBase);
00150 };
00151
00152
00153
00154
00155
00156 struct KLFShowHideSideWidgetManagerPrivate;
00157
00159
00168 class KLF_EXPORT KLFShowHideSideWidgetManager : public KLFSideWidgetManagerBase
00169 {
00170 Q_OBJECT
00171
00172 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) ;
00173 Q_PROPERTY(int calcSpacing READ calcSpacing WRITE setCalcSpacing) ;
00174 public:
00175 KLFShowHideSideWidgetManager(QWidget *parentWidget = NULL, QWidget *sideWidget = NULL,
00176 QObject *managerParent = NULL);
00177 virtual ~KLFShowHideSideWidgetManager();
00178
00179 Qt::Orientation orientation() const;
00180 int calcSpacing() const;
00181
00182 virtual bool eventFilter(QObject *obj, QEvent *event);
00183
00184 virtual bool sideWidgetVisible() const;
00185
00186 public slots:
00187 virtual void showSideWidget(bool show);
00188 void setOrientation(Qt::Orientation o);
00189 void setCalcSpacing(int cs);
00190
00191 protected:
00192 virtual bool event(QEvent *event);
00193
00194 virtual void newSideWidgetSet(QWidget *oldSideWidget, QWidget *newSideWidget);
00195 virtual void newParentWidgetSet(QWidget *oldParentWidget, QWidget *newParentWidget);
00196
00197 private slots:
00198 void resizeParentWidget(const QSize& size);
00199
00200 private:
00201 KLF_DECLARE_PRIVATE(KLFShowHideSideWidgetManager);
00202 };
00203
00204
00205
00206
00207 struct KLFContainerSideWidgetManagerPrivate;
00208
00210
00223 class KLFContainerSideWidgetManager : public KLFSideWidgetManagerBase
00224 {
00225 Q_OBJECT
00226
00227 public:
00228 KLFContainerSideWidgetManager(QWidget *parentWidget = NULL, QWidget *sideWidget = NULL,
00229 QObject *managerParent = NULL);
00230 virtual ~KLFContainerSideWidgetManager();
00231
00232 virtual bool sideWidgetVisible() const;
00233
00234 bool eventFilter(QObject *obj, QEvent *event);
00235
00236 public slots:
00237 virtual void showSideWidget(bool show);
00238
00239 protected:
00241 void init();
00242
00244 virtual QWidget * createContainerWidget(QWidget * pw) = 0;
00245
00246 virtual QWidget * containerWidget() const;
00247
00248 virtual void newSideWidgetSet(QWidget *oldSideWidget, QWidget *newSideWidget);
00249 virtual void newParentWidgetSet(QWidget *oldWidget, QWidget *newWidget);
00250
00251 private slots:
00252 void aWidgetDestroyed(QObject *);
00253
00254 private:
00255 KLF_DECLARE_PRIVATE(KLFContainerSideWidgetManager) ;
00256 };
00257
00258
00259
00260
00261
00262
00263 struct KLFFloatSideWidgetManagerPrivate;
00264
00266
00272 class KLF_EXPORT KLFFloatSideWidgetManager : public KLFContainerSideWidgetManager
00273 {
00274 Q_OBJECT
00275
00276 Q_PROPERTY(Qt::WindowFlags wflags READ wflags WRITE setWFlags) ;
00277 public:
00278 KLFFloatSideWidgetManager(QWidget *parentWidget = NULL, QWidget *sideWidget = NULL,
00279 QObject *managerParent = NULL);
00280 virtual ~KLFFloatSideWidgetManager();
00281
00282 Qt::WindowFlags wflags() const;
00283
00284 virtual bool sideWidgetVisible() const;
00285
00286 public slots:
00287 virtual void showSideWidget(bool show);
00288 void setWFlags(Qt::WindowFlags wflags);
00289
00290 protected:
00291 void newSideWidgetSet(QWidget *oldw, QWidget *w);
00292
00293 virtual QWidget * createContainerWidget(QWidget * pw);
00294
00295 private:
00296 KLF_DECLARE_PRIVATE(KLFFloatSideWidgetManager) ;
00297 };
00298
00299
00300
00301
00302
00303
00313 class KLF_EXPORT KLFSideWidgetManagerFactory : public KLFFactoryBase
00314 {
00315 public:
00316 KLFSideWidgetManagerFactory();
00317 virtual ~KLFSideWidgetManagerFactory();
00318
00319 virtual QStringList supportedTypes() const;
00321 virtual QString getTitleFor(const QString& type) const;
00322 virtual KLFSideWidgetManagerBase * createSideWidgetManager(const QString& type, QWidget *parentWidget,
00323 QWidget *sideWidget, QObject *parent);
00324
00325 static QStringList allSupportedTypes();
00326 static KLFSideWidgetManagerBase * findCreateSideWidgetManager(const QString& type, QWidget *parentWidget,
00327 QWidget *sideWidget, QObject *parent);
00328 static KLFSideWidgetManagerFactory * findFactoryFor(const QString& managertype);
00329
00330 private:
00331 static KLFFactoryManager pFactoryManager;
00332 };
00333
00334
00335
00336
00337
00338
00339
00340
00341 struct KLFSideWidgetPrivate;
00342
00344
00373 class KLF_EXPORT KLFSideWidget : public QWidget
00374 {
00375 Q_OBJECT
00376
00377 Q_PROPERTY(QString sideWidgetManagerType READ sideWidgetManagerType WRITE setSideWidgetManager) ;
00378 public:
00379 enum SideWidgetManager { ShowHide = 1, Float, Drawer } ;
00380
00381
00382
00383 KLFSideWidget(QWidget *parent = NULL);
00384 virtual ~KLFSideWidget();
00385
00390 bool sideWidgetVisible() const;
00391
00400 QString sideWidgetManagerType() const;
00401
00406 KLFSideWidgetManagerBase * sideWidgetManager();
00407
00408 signals:
00412 void sideWidgetShown(bool shown);
00417 void sideWidgetManagerTypeChanged(const QString& managerType);
00418
00419 public slots:
00426 void showSideWidget(bool show = true);
00431 void hideSideWidget(bool hide = true) { showSideWidget(!hide); }
00436 void toggleSideWidget() { showSideWidget(!sideWidgetVisible()); }
00437
00439 void setSideWidgetManager(SideWidgetManager mtype);
00443 void setSideWidgetManager(const QString& mtype);
00444
00449 void debug_unlock_qtdesigner();
00450
00451 private:
00452
00453 KLF_DECLARE_PRIVATE(KLFSideWidget) ;
00454
00455 friend class KLFSideWidgetDesPlugin;
00456 bool _inqtdesigner;
00457 };
00458
00459
00460
00461
00462 #endif