7f974feef492c8c8d39da94d93668af052161854
[quick-widgets] / quickwidget.hpp
1 #ifndef QUICKWIDGET_HPP
2 #define QUICKWIDGET_HPP
3
4 #include <QtCore>
5 #include <QtGui>
6 #include <q-extras/qemaemo5dynamicwidgethelper.h>
7
8 class QDeclarativeView;
9 class QuickWidgetWrapper;
10
11
12 class QuickWidget : public QeMaemo5DynamicHomescreenWidget
13 {
14     Q_OBJECT
15
16 private:
17     void initView(const QString& fileName, const QSize& size=QSize(),
18                   bool rotate=false);
19     QSize size_;
20     QDeclarativeView* view_;
21     QuickWidgetWrapper* wrapper_;
22     bool landscape_;
23
24 protected:
25 //    void showSettingsDialog();
26     bool restoreWidgetState();
27     void errorWidget();
28     void paintEvent(QPaintEvent *event);
29
30 public slots:
31   void resizer(const QSize& size);
32   void rotateScreen(const QString& orientation);
33
34 public:
35     static QuickWidget *createAndShowNew(const QString& fileName, 
36                                          const QSize& size=QSize(),
37                                          bool rotate=false);
38
39     explicit QuickWidget(QWidget *parent = 0);
40     ~QuickWidget();
41
42 };
43
44 class QuickWidgetWrapper : public QObject
45 {
46     Q_OBJECT
47
48 Q_SIGNALS:
49     void onHomeScreenChanged();
50
51 public:
52     QuickWidgetWrapper(QuickWidget *owner) : m_owner(owner) {;}
53     Q_PROPERTY(bool isActiveWindow READ onHomeScreen NOTIFY onHomeScreenChanged);
54
55     bool onHomeScreen() const { return m_homeScreen; }
56
57 public slots:
58     void setOnHomeScreen(bool active)
59     {
60         if (active == m_homeScreen)
61             return;
62         m_homeScreen = active;
63         emit onHomeScreenChanged();
64     }
65
66 private:
67     QuickWidget *m_owner;
68     bool m_homeScreen;
69 };
70
71 #endif // QuickWidget_HPP