New relase with auto-rotaion and fixed setting dialog in portrait mode.
[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
29 public slots:
30   void resizer(QSize size);
31   void rotateScreen(const QString& orientation);
32
33 public:
34     static QuickWidget *createAndShowNew(const QString& fileName, 
35                                          const QSize& size=QSize(),
36                                          bool rotate=false);
37
38     explicit QuickWidget(QWidget *parent = 0);
39     ~QuickWidget();
40
41 };
42
43 class QuickWidgetWrapper : public QObject
44 {
45     Q_OBJECT
46
47 Q_SIGNALS:
48     void onHomeScreenChanged();
49
50 public:
51     QuickWidgetWrapper(QuickWidget *owner) : m_owner(owner) {;}
52     Q_PROPERTY(bool isActiveWindow READ onHomeScreen NOTIFY onHomeScreenChanged);
53
54     bool onHomeScreen() const { return m_homeScreen; }
55
56 public slots:
57     void setOnHomeScreen(bool active)
58     {
59         if (active == m_homeScreen)
60             return;
61         m_homeScreen = active;
62         emit onHomeScreenChanged();
63     }
64
65 private:
66     QuickWidget *m_owner;
67     bool m_homeScreen;
68 };
69
70 #endif // QuickWidget_HPP