19 |
19 |
20 #include <QDebug> |
20 #include <QDebug> |
21 #include <QTime> |
21 #include <QTime> |
22 #include <QGraphicsLinearLayout> |
22 #include <QGraphicsLinearLayout> |
23 |
23 |
24 #include <hblabel.h> |
24 #include <HbExtendedLocale> |
25 #include <hbextendedlocale.h> |
25 #include <HbMainWindow> |
26 |
26 |
27 #include "snsranalogclockwidget.h" |
27 #include "snsranalogclockwidget.h" |
28 #include "snsrindicatorwidget.h" |
28 #include "snsrindicatorwidget.h" |
29 #include "snsrswipewidget.h" |
29 #include "snsrswipewidget.h" |
|
30 #include "snsrlabel.h" |
30 |
31 |
31 /*! |
32 /*! |
32 \class SnsrAnalogClockContainer |
33 \class SnsrAnalogClockContainer |
33 \ingroup group_snsrbigclockscreensaverplugin |
34 \ingroup group_snsrbigclockscreensaverplugin |
34 \brief Container used for preparing layout for analog clock. |
35 \brief Container used for preparing layout for analog clock. |
59 SnsrAnalogClockContainer::SnsrAnalogClockContainer() : |
60 SnsrAnalogClockContainer::SnsrAnalogClockContainer() : |
60 SnsrBigClockContainer(), |
61 SnsrBigClockContainer(), |
61 mDateLabel(0), |
62 mDateLabel(0), |
62 mAnalogClockWidget(0)/*, |
63 mAnalogClockWidget(0)/*, |
63 mSwipeWidget(0)*/ |
64 mSwipeWidget(0)*/ |
64 { |
65 { |
65 SCREENSAVER_TEST_FUNC_ENTRY("SnsrAnalogClockContainer::SnsrAnalogClockContainer") |
66 SCREENSAVER_TEST_FUNC_ENTRY("SnsrAnalogClockContainer::SnsrAnalogClockContainer") |
66 |
|
67 bool ok(true); |
|
68 |
|
69 // load analog clock |
|
70 qDebug() << gAnalogLayoutDocml; |
|
71 mDocumentObjects = mDocumentLoader.load(gAnalogLayoutDocml, &ok); |
|
72 Q_ASSERT_X(ok, gAnalogLayoutDocml, "Invalid DocML file."); |
|
73 if (ok) { |
|
74 mMainView = mDocumentLoader.findWidget(gMainViewName); |
|
75 mDateLabel = qobject_cast<HbLabel *>( |
|
76 mDocumentLoader.findWidget(gDateLabelName)); |
|
77 mAnalogClockWidget = qobject_cast<SnsrAnalogClockWidget *>( |
|
78 mDocumentLoader.findWidget(gAnalogClockWidgetName)); |
|
79 mIndicatorWidget = qobject_cast<SnsrIndicatorWidget *>( |
|
80 mDocumentLoader.findWidget(gIndicatorWidgetName)); |
|
81 //We don't implement swipe widget at this poin |
|
82 /*mSwipeWidget = qobject_cast<SnsrSwipeWidget *>( |
|
83 mDocumentLoader.findWidget(gSwipeWidgetName));*/ |
|
84 |
|
85 Q_ASSERT_X( |
|
86 mMainView && mDateLabel && mAnalogClockWidget && |
|
87 mIndicatorWidget /*&& mSwipeWidget*/, |
|
88 gAnalogLayoutDocml, "Objects not found in DocML file." |
|
89 ); |
|
90 |
|
91 //connect( mSwipeWidget, SIGNAL(swipeDownDetected()), SIGNAL(unlockRequested()) ); |
|
92 |
|
93 mIndicatorWidget->setLayoutType(SnsrIndicatorWidget::IndicatorsCentered); |
|
94 |
|
95 mBackgroundContainerLayout->addItem(mMainView); |
|
96 // mSwipeWidget->start(); |
|
97 } |
|
98 |
|
99 SCREENSAVER_TEST_FUNC_EXIT("SnsrAnalogClockContainer::SnsrAnalogClockContainer") |
67 SCREENSAVER_TEST_FUNC_EXIT("SnsrAnalogClockContainer::SnsrAnalogClockContainer") |
100 } |
68 } |
101 |
69 |
102 /*! |
70 /*! |
103 Destructs the class. |
71 Destructs the class. |
104 */ |
72 */ |
105 SnsrAnalogClockContainer::~SnsrAnalogClockContainer() |
73 SnsrAnalogClockContainer::~SnsrAnalogClockContainer() |
106 { |
74 { |
|
75 resetIndicatorConnections(); |
107 //mDateLabel, mAnalogClockWidget - deleted by the parent |
76 //mDateLabel, mAnalogClockWidget - deleted by the parent |
108 } |
77 } |
109 |
78 |
110 /*! |
79 /*! |
111 Updates displayed time and date. |
80 Updates displayed time and date. |
129 } |
98 } |
130 |
99 |
131 SCREENSAVER_TEST_FUNC_EXIT("SnsrAnalogClockContainer::update") |
100 SCREENSAVER_TEST_FUNC_EXIT("SnsrAnalogClockContainer::update") |
132 } |
101 } |
133 |
102 |
134 /*! |
|
135 Changes screensaver layout basing on orientation changes. |
|
136 \param orientation Current orientation. |
|
137 */ |
|
138 void SnsrAnalogClockContainer::changeLayout(Qt::Orientation orientation) |
|
139 { |
|
140 SCREENSAVER_TEST_FUNC_ENTRY("SnsrAnalogClockContainer::changeLayout") |
|
141 |
|
142 bool ok(false); |
|
143 if (mCurrentOrientation != orientation) { |
|
144 mCurrentOrientation = orientation; |
|
145 |
|
146 // hide controls to avoid screen flickering |
|
147 mMainView->hide(); |
|
148 |
|
149 QString sectionToLoad(""); |
|
150 if (mCurrentOrientation == Qt::Horizontal) { |
|
151 sectionToLoad = gLandscapeSectionName; |
|
152 } |
|
153 qDebug() << "loading: " << gAnalogLayoutDocml << ", section: " << sectionToLoad; |
|
154 mDocumentLoader.load(gAnalogLayoutDocml, sectionToLoad, &ok); |
|
155 // view is rebuilt and ready to show |
|
156 update(); |
|
157 mMainView->show(); |
|
158 Q_ASSERT_X(ok, gAnalogLayoutDocml, "Invalid section in DocML file."); |
|
159 } |
|
160 // update anyway - this is needed in situations when screensaver goes to |
|
161 // foreground but layout change did not occur |
|
162 if (!ok) { |
|
163 update(); |
|
164 } |
|
165 |
|
166 SCREENSAVER_TEST_FUNC_EXIT("SnsrAnalogClockContainer::changeLayout") |
|
167 } |
|
168 |
|
169 int SnsrAnalogClockContainer::updateIntervalInMilliseconds() |
103 int SnsrAnalogClockContainer::updateIntervalInMilliseconds() |
170 { |
104 { |
171 return 1000; |
105 return 1000; |
172 } |
106 } |
173 |
107 |
|
108 void SnsrAnalogClockContainer::loadWidgets() |
|
109 { |
|
110 bool ok(true); |
|
111 |
|
112 // reset widget pointers, any previous widgets are already deleted by now |
|
113 mMainView = 0; |
|
114 mDateLabel = 0; |
|
115 mAnalogClockWidget = 0; |
|
116 mIndicatorWidget = 0; |
|
117 |
|
118 // load widgets from docml |
|
119 qDebug() << gAnalogLayoutDocml; |
|
120 mDocumentObjects = mDocumentLoader.load(gAnalogLayoutDocml, &ok); |
|
121 Q_ASSERT_X(ok, gAnalogLayoutDocml, "Invalid DocML file."); |
|
122 if (ok) { |
|
123 mMainView = mDocumentLoader.findWidget(gMainViewName); |
|
124 mDateLabel = qobject_cast<SnsrLabel *>( |
|
125 mDocumentLoader.findWidget(gDateLabelName)); |
|
126 mAnalogClockWidget = qobject_cast<SnsrAnalogClockWidget *>( |
|
127 mDocumentLoader.findWidget(gAnalogClockWidgetName)); |
|
128 mIndicatorWidget = qobject_cast<SnsrIndicatorWidget *>( |
|
129 mDocumentLoader.findWidget(gIndicatorWidgetName)); |
|
130 //We don't implement swipe widget at this poin |
|
131 /*mSwipeWidget = qobject_cast<SnsrSwipeWidget *>( |
|
132 mDocumentLoader.findWidget(gSwipeWidgetName));*/ |
|
133 |
|
134 Q_ASSERT_X( |
|
135 mMainView && mDateLabel && mAnalogClockWidget && |
|
136 mIndicatorWidget /*&& mSwipeWidget*/, |
|
137 gAnalogLayoutDocml, "Objects not found in DocML file." |
|
138 ); |
|
139 |
|
140 // In case of landscape layout, read also the landscape delta section |
|
141 if ( mCurrentOrientation == Qt::Horizontal ) { |
|
142 qDebug() << "loading: " << gAnalogLayoutDocml << ", section: " << gLandscapeSectionName; |
|
143 mDocumentLoader.load(gAnalogLayoutDocml, gLandscapeSectionName, &ok); |
|
144 Q_ASSERT_X(ok, gAnalogLayoutDocml, "Invalid section in DocML file."); |
|
145 } |
|
146 |
|
147 initIndicatorWidget(); |
|
148 mIndicatorWidget->setLayoutType(SnsrIndicatorWidget::IndicatorsCentered); |
|
149 |
|
150 mBackgroundContainerLayout->addItem(mMainView); |
|
151 |
|
152 //connect( mSwipeWidget, SIGNAL(swipeDownDetected()), SIGNAL(unlockRequested()) ); |
|
153 //mSwipeWidget->start(); |
|
154 } |
|
155 } |
|
156 |