44 graphics items excluding the background. |
44 graphics items excluding the background. |
45 |
45 |
46 \internal |
46 \internal |
47 */ |
47 */ |
48 |
48 |
49 HbScreen::HbScreen() : |
49 HbScreen::HbScreen() : |
50 HbWidget(), |
50 HbWidget(), |
51 mStack(0), |
51 mStack(0), |
52 mTb(0), |
52 mTb(0), |
53 mDock(0), |
53 mDock(0), |
54 mToolBarOrientation(0), |
54 mToolBarOrientation(0), |
55 mDelayedConstructionHandled(false), |
55 mDelayedConstructionHandled(false), |
56 mScreenPolished(false) |
56 mScreenPolished(false) |
57 { |
57 { |
58 } |
58 } |
59 |
59 |
60 void HbScreen::setStackWidget(HbContentWidget *stack) |
60 void HbScreen::setStackWidget(HbContentWidget *stack) |
61 { |
61 { |
62 if (mStack != stack) { |
62 if (mStack != stack) { |
63 if (mStack) { |
63 if (mStack) { |
64 HbStyle::setItemName(mTb, QString()); |
64 HbStyle::setItemName(mTb, QString()); |
65 HbStyle::setItemName(mDock, QString()); |
65 HbStyle::setItemName(mDock, QString()); |
66 } |
66 } |
67 mStack = stack; |
67 mStack = stack; |
68 } |
68 } |
69 } |
69 } |
70 |
70 |
71 void HbScreen::setToolBar(HbToolBar *tb) |
71 void HbScreen::setToolBar(HbToolBar *tb) |
72 { |
72 { |
73 if (mTb != tb) { |
73 if (mTb != tb) { |
74 if (mTb) { |
74 if (mTb) { |
75 disconnect(&HbToolBarPrivate::d_ptr(mTb)->core, 0, this, 0); |
75 disconnect(&HbToolBarPrivate::d_ptr(mTb)->core, 0, this, 0); |
76 HbStyle::setItemName(mTb, QString()); |
76 HbStyle::setItemName(mTb, QString()); |
77 } |
77 } |
78 mTb = tb; |
78 mTb = tb; |
79 if (mTb) { |
79 if (mTb) { |
80 setToolBarOrientation(mTb->orientation()); |
80 setToolBarOrientation(mTb->orientation()); |
81 if (mDelayedConstructionHandled){ |
81 if (mDelayedConstructionHandled) { |
82 connect(&HbToolBarPrivate::d_ptr(mTb)->core, SIGNAL(orientationChanged()), this, SLOT(toolBarOrientationChanged())); |
82 connect(&HbToolBarPrivate::d_ptr(mTb)->core, SIGNAL(orientationChanged()), this, SLOT(toolBarOrientationChanged())); |
83 connect(&HbToolBarPrivate::d_ptr(mTb)->core, SIGNAL(visibilityChanged()), this, SLOT(decoratorVisibilityChanged())); |
83 connect(&HbToolBarPrivate::d_ptr(mTb)->core, SIGNAL(visibilityChanged()), this, SLOT(decoratorVisibilityChanged())); |
84 } |
84 } |
85 } else { |
85 } else { |
86 mToolBarOrientation = 0; |
86 mToolBarOrientation = 0; |
93 if (mDock != dock) { |
93 if (mDock != dock) { |
94 if (mDock) { |
94 if (mDock) { |
95 disconnect(&HbDockWidgetPrivate::d_ptr(mDock)->core, 0, this, 0); |
95 disconnect(&HbDockWidgetPrivate::d_ptr(mDock)->core, 0, this, 0); |
96 HbStyle::setItemName(mDock, QString()); |
96 HbStyle::setItemName(mDock, QString()); |
97 } |
97 } |
98 mDock = dock; |
98 mDock = dock; |
99 if (mDock && mDelayedConstructionHandled) { |
99 if (mDock && mDelayedConstructionHandled) { |
100 connect(&HbDockWidgetPrivate::d_ptr(mDock)->core, SIGNAL(visibilityChanged()), this, SLOT(decoratorVisibilityChanged())); |
100 connect(&HbDockWidgetPrivate::d_ptr(mDock)->core, SIGNAL(visibilityChanged()), this, SLOT(decoratorVisibilityChanged())); |
101 } |
101 } |
102 } |
102 } |
103 } |
103 } |
115 { |
115 { |
116 //we handle toolbar as a special case to |
116 //we handle toolbar as a special case to |
117 //avoid unnecessary complications in setName function. |
117 //avoid unnecessary complications in setName function. |
118 if ((mTb->isVisible() || forced) && mTb->actions().count()) { |
118 if ((mTb->isVisible() || forced) && mTb->actions().count()) { |
119 HbStyle::setItemName(mTb, "toolbar"); |
119 HbStyle::setItemName(mTb, "toolbar"); |
120 } |
120 } else { |
121 else { |
|
122 HbStyle::setItemName(mTb, QString()); |
121 HbStyle::setItemName(mTb, QString()); |
123 } |
122 } |
124 } |
123 } |
125 |
124 |
126 void HbScreen::polish(HbStyleParameters& params) |
125 void HbScreen::polish(HbStyleParameters ¶ms) |
127 { |
126 { |
128 if (!mScreenPolished) { |
127 if (!mScreenPolished) { |
129 mScreenOrientation = mainWindow()->orientation(); |
128 mScreenOrientation = mainWindow()->orientation(); |
130 connect(mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(screenOrientationChanged(Qt::Orientation))); |
129 connect(mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(screenOrientationChanged(Qt::Orientation))); |
131 } |
130 } |
132 |
131 |
133 if (mStack) { |
132 if (mStack) { |
134 HbView *currentView = qobject_cast<HbView*>(mStack->currentWidget()); |
133 HbView *currentView = qobject_cast<HbView *>(mStack->currentWidget()); |
135 if (currentView && currentView->isContentFullScreen()) { |
134 if (currentView && currentView->isContentFullScreen()) { |
136 setName(mStack, "mainfull"); |
135 setName(mStack, "mainfull"); |
137 } else { |
136 } else { |
138 setName(mStack, "main"); |
137 setName(mStack, "main"); |
139 } |
138 } |
140 } |
139 } |
141 |
140 |
142 if (mTb) { |
141 if (mTb) { |
143 bool hiddenForEffects = HbToolBarPrivate::d_ptr(mTb)->mOrientationEffectsRunning; |
142 bool hiddenForEffects = HbToolBarPrivate::d_ptr(mTb)->mOrientationEffectsRunning; |
144 setToolBarName(hiddenForEffects); |
143 setToolBarName(hiddenForEffects); |
145 } |
144 } |
146 |
145 |
147 if (mDock) { |
146 if (mDock) { |
148 setName(mDock,"dock"); |
147 setName(mDock, "dock"); |
149 } |
148 } |
150 |
149 |
151 mScreenPolished = true; |
150 mScreenPolished = true; |
152 HbWidget::polish(params); |
151 HbWidget::polish(params); |
153 |
152 |
156 } |
155 } |
157 if (layout()) { |
156 if (layout()) { |
158 layout()->activate(); |
157 layout()->activate(); |
159 } |
158 } |
160 HbMainWindow *w = mainWindow(); |
159 HbMainWindow *w = mainWindow(); |
161 HbMainWindowPrivate::d_ptr(w)->postIdleEvent(HbMainWindowPrivate::IdleOrientationEvent); |
160 HbMainWindowPrivate::d_ptr(w)->postIdleEvent(HbMainWindowPrivate::IdleOrientationEvent); |
162 } |
161 } |
163 |
162 |
164 void HbScreen::delayedConstruction() |
163 void HbScreen::delayedConstruction() |
165 { |
164 { |
166 if (mDelayedConstructionHandled) |
165 if (mDelayedConstructionHandled) { |
167 return; |
166 return; |
|
167 } |
168 mDelayedConstructionHandled = true; |
168 mDelayedConstructionHandled = true; |
169 if (mTb) { |
169 if (mTb) { |
170 connect( &HbToolBarPrivate::d_ptr ( mTb )->core, SIGNAL(orientationChanged()), this, SLOT(toolBarOrientationChanged())); |
170 connect(&HbToolBarPrivate::d_ptr(mTb)->core, SIGNAL(orientationChanged()), this, SLOT(toolBarOrientationChanged())); |
171 connect( &HbToolBarPrivate::d_ptr ( mTb )->core, SIGNAL(visibilityChanged()), this, SLOT(decoratorVisibilityChanged())); |
171 connect(&HbToolBarPrivate::d_ptr(mTb)->core, SIGNAL(visibilityChanged()), this, SLOT(decoratorVisibilityChanged())); |
172 HbToolBarPrivate::d_ptr(mTb)->delayedConstruction(); |
172 HbToolBarPrivate::d_ptr(mTb)->delayedConstruction(); |
173 } |
173 } |
174 if (mDock) { |
174 if (mDock) { |
175 connect(&HbDockWidgetPrivate::d_ptr(mDock)->core, SIGNAL(visibilityChanged()), this, SLOT(decoratorVisibilityChanged())); |
175 connect(&HbDockWidgetPrivate::d_ptr(mDock)->core, SIGNAL(visibilityChanged()), this, SLOT(decoratorVisibilityChanged())); |
176 } |
176 } |
177 } |
177 } |
178 |
178 |
179 void HbScreen::setGeometry (const QRectF & rect) |
179 void HbScreen::setGeometry(const QRectF &rect) |
180 { |
180 { |
181 prepareGeometryChange(); |
181 prepareGeometryChange(); |
182 HbWidget::setGeometry(rect); |
182 HbWidget::setGeometry(rect); |
183 } |
183 } |
184 |
184 |
195 |
195 |
196 bool HbScreen::contentUnderTitleBar() const |
196 bool HbScreen::contentUnderTitleBar() const |
197 { |
197 { |
198 bool contentUnderTitleBar = false; |
198 bool contentUnderTitleBar = false; |
199 if (mStack) { |
199 if (mStack) { |
200 HbView *currentView = qobject_cast<HbView*>(mStack->currentWidget()); |
200 HbView *currentView = qobject_cast<HbView *>(mStack->currentWidget()); |
201 if (currentView && (currentView->viewFlags() |
201 if (currentView && !(currentView->viewFlags() & HbView::ViewDisableRelayout)) { |
202 & (HbView::ViewTitleBarMinimized | HbView::ViewTitleBarFloating |
202 if (currentView->viewFlags() & (HbView::ViewTitleBarMinimized |
203 | HbView::ViewTitleBarHidden))) { |
203 | HbView::ViewTitleBarFloating | HbView::ViewTitleBarHidden)) { |
204 contentUnderTitleBar = true; |
204 contentUnderTitleBar = true; |
|
205 } |
205 } |
206 } |
206 } |
207 } |
207 return contentUnderTitleBar; |
208 return contentUnderTitleBar; |
208 } |
209 } |
209 |
210 |
210 bool HbScreen::contentUnderStatusBar() const |
211 bool HbScreen::contentUnderStatusBar() const |
211 { |
212 { |
212 bool contentUnderStatusBar = false; |
213 bool contentUnderStatusBar = false; |
213 if (mStack) { |
214 if (mStack) { |
214 HbView *currentView = qobject_cast<HbView*>(mStack->currentWidget()); |
215 HbView *currentView = qobject_cast<HbView *>(mStack->currentWidget()); |
215 if (currentView && (currentView->viewFlags() |
216 if (currentView && !(currentView->viewFlags() & HbView::ViewDisableRelayout)) { |
216 & (HbView::ViewStatusBarFloating | HbView::ViewStatusBarHidden))) { |
217 if (currentView->viewFlags() & (HbView::ViewStatusBarFloating |
217 contentUnderStatusBar = true; |
218 | HbView::ViewStatusBarHidden)) { |
|
219 contentUnderStatusBar = true; |
|
220 } |
218 } |
221 } |
219 } |
222 } |
220 return contentUnderStatusBar; |
223 return contentUnderStatusBar; |
221 } |
224 } |
222 |
225 |
223 bool HbScreen::titleBarMinimizable() const |
226 bool HbScreen::titleBarMinimizable() const |
224 { |
227 { |
225 bool titleBarMinimizable = false; |
228 bool titleBarMinimizable = false; |
226 if (mStack) { |
229 if (mStack) { |
227 HbView *currentView = qobject_cast<HbView*>(mStack->currentWidget()); |
230 HbView *currentView = qobject_cast<HbView *>(mStack->currentWidget()); |
228 if (currentView && (currentView->viewFlags() & (HbView::ViewTitleBarMinimizable))) { |
231 if (currentView && (currentView->viewFlags() & (HbView::ViewTitleBarMinimizable))) { |
229 titleBarMinimizable = true; |
232 titleBarMinimizable = true; |
230 } |
233 } |
231 } |
234 } |
232 return titleBarMinimizable; |
235 return titleBarMinimizable; |
247 } |
250 } |
248 |
251 |
249 void HbScreen::setToolBarOrientation(Qt::Orientation orientation) |
252 void HbScreen::setToolBarOrientation(Qt::Orientation orientation) |
250 { |
253 { |
251 if (orientation != mToolBarOrientation) { |
254 if (orientation != mToolBarOrientation) { |
252 if (mTb){ |
255 if (mTb) { |
253 HbToolBarPrivate::d_ptr(mTb)->mDoLayout = false; |
256 HbToolBarPrivate::d_ptr(mTb)->mDoLayout = false; |
254 repolish(); |
257 repolish(); |
255 } |
258 } |
256 mToolBarOrientation = orientation; |
259 mToolBarOrientation = orientation; |
257 } |
260 } |
258 } |
261 } |
259 |
262 |
260 void HbScreen::decoratorVisibilityChanged() |
263 void HbScreen::decoratorVisibilityChanged() |
261 { |
264 { |
|
265 HbMainWindow *window = mainWindow(); |
|
266 // Do not repolish if orientation is about to change |
|
267 if (window && HbMainWindowPrivate::d_ptr(window)->mOrientationChangeOngoing |
|
268 && mScreenOrientation != HbMainWindowPrivate::d_ptr(window)->mOrientation) { |
|
269 return; |
|
270 } |
262 if (mTb) { |
271 if (mTb) { |
263 HbToolBarPrivate::d_ptr(mTb)->mDoLayout = false; |
272 HbToolBarPrivate::d_ptr(mTb)->mDoLayout = false; |
264 } |
273 } |
265 repolish(); |
274 repolish(); |
266 QCoreApplication::sendPostedEvents(this, QEvent::Polish); |
275 QCoreApplication::sendPostedEvents(this, QEvent::Polish); |
267 } |
276 } |
268 |
277 |
269 void HbScreen::currentViewChanged(HbView* view) |
278 void HbScreen::currentViewChanged(HbView *view) |
270 { |
279 { |
271 Q_UNUSED(view); |
280 Q_UNUSED(view); |
272 repolish(); |
281 repolish(); |
273 } |
282 } |
274 |
283 |
275 bool HbScreen::event(QEvent *e) |
284 bool HbScreen::event(QEvent *e) |
276 { |
285 { |
277 if (e->type() == HbEvent::DeviceProfileChanged) { |
286 if (e->type() == HbEvent::DeviceProfileChanged) { |
278 // supress polishEvent() [which is called in HbWidget::event()] into repolish() |
287 // suppress polishEvent() [which is called in HbWidget::event()] into repolish() |
279 repolish(); |
288 repolish(); |
280 return QGraphicsWidget::event(e); |
289 return QGraphicsWidget::event(e); |
281 } else { |
290 } else { |
282 return HbWidget::event(e); |
291 return HbWidget::event(e); |
283 } |
292 } |