Fluid Tabs

ftabarea.h

00001 #ifndef FTABAREA_H
00002 #define FTABAREA_H
00003 
00004 #include <QDeclarativeItem>
00005 #include <QQueue>
00006 #include "ftabbar.h"
00007 
00008 class FTabView;
00009 class FTabArea;
00010 
00011 class FTabTransition : public QObject
00012 {
00013     Q_OBJECT
00014 
00015 public:
00016     explicit FTabTransition(QObject *parent = 0);
00017     virtual ~FTabTransition() {}
00018 
00019     void setSourceView(FTabView *view);
00020     void setTargetView(FTabView *view);
00021 
00022     virtual void start();
00023 
00024 signals:
00025     void complete();
00026 
00027 protected:
00028     FTabView *m_sourceView;
00029     FTabView *m_targetView;
00030 };
00031 
00032 class FTabAnimatedTransition : public FTabTransition
00033 {
00034     Q_OBJECT
00035     Q_PROPERTY(qreal progress WRITE setProgress READ progress NOTIFY progressChanged)
00036     Q_PROPERTY(int duration WRITE setDuration READ duration)
00037 
00038 public:
00039     FTabAnimatedTransition(QObject *parent = 0);
00040     virtual ~FTabAnimatedTransition() {}
00041 
00042     void setProgress(qreal progress);
00043     qreal progress() const;
00044     void setDuration(int duration);
00045     int duration() const;
00046 
00047     void start();
00048 
00049 protected slots:
00050     void updateValue(const QVariant &value) { updateCurrent(value.toReal()); }
00051 
00052 protected:
00053     virtual void updateCurrent(qreal value) = 0;
00054 
00055 signals:
00056     void progressChanged();
00057 
00058 private:
00059     qreal m_progress;
00060     int   m_duration;
00061 };
00062 
00063 class FTabSlideTransition : public FTabAnimatedTransition
00064 {
00065     Q_OBJECT
00066     Q_ENUMS(SlideType)
00067     Q_PROPERTY(SlideType effect WRITE setTransitionType READ transitionType)
00068 
00069 public:
00070     enum SlideType {
00071         SlideLeftToRight,
00072         SlideRightToLeft,
00073         SlideTopToBottom,
00074         SlideBottomToTop,
00075         Random
00076     };
00077 
00078     explicit FTabSlideTransition(QObject *parent = 0);
00079     ~FTabSlideTransition() {}
00080 
00081     void setTransitionType(SlideType type);
00082     SlideType transitionType() const;
00083 
00084 protected:
00085     void updateCurrent(qreal value);
00086 
00087 private:
00088     SlideType m_type;
00089 };
00090 
00091 class FTabView : public QDeclarativeItem
00092 {
00093     Q_OBJECT
00094 
00095 public:
00096     explicit FTabView(QDeclarativeItem *parent = 0);
00097     ~FTabView() {}
00098 
00099 protected slots:
00100     void show() { setProperty("visible", true); }
00101     void hide() { setProperty("visible", false); }
00102 };
00103 
00104 class FTabArea : public QDeclarativeItem
00105 {
00106     Q_OBJECT
00107     Q_PROPERTY(QDeclarativeComponent *transition WRITE setTransition READ transition)
00108 
00109 public:
00110     explicit FTabArea(QDeclarativeItem *parent = 0);
00111     ~FTabArea() {}
00112 
00113     void setTransition(QDeclarativeComponent *transition);
00114     QDeclarativeComponent *transition() const;
00115 
00116     void componentComplete();
00117 
00118 protected slots:
00119     void switchTabView(int i);
00120     void processQueue();
00121 
00122 private:
00123     QDeclarativeComponent   *m_transition;
00124     FTabView                *m_current;
00125     QList<FTabView *>        m_views;
00126     QQueue<FTabTransition *> m_transitions;
00127     bool                     m_progress;
00128 };
00129 
00130 #endif // FTABAREA_H
 All Classes Functions Properties