37 #include "hbgraphicsscene.h" |
37 #include "hbgraphicsscene.h" |
38 #include "hbmainwindow.h" |
38 #include "hbmainwindow.h" |
39 #include "hbmainwindow_p.h" |
39 #include "hbmainwindow_p.h" |
40 #include "hbnamespace.h" |
40 #include "hbnamespace.h" |
41 #include "hbnamespace_p.h" |
41 #include "hbnamespace_p.h" |
42 #include "hbsoftkey_p.h" |
|
43 #include "hbsoftkeygroup_p.h" |
|
44 #include "hbtitlebar_p.h" |
42 #include "hbtitlebar_p.h" |
45 #include "hbstatusbar_p.h" |
43 #include "hbstatusbar_p.h" |
46 #include "hbstyle.h" |
44 #include "hbstyle.h" |
47 #include "hbtitlepane_p.h" |
45 #include "hbtitlepane_p.h" |
48 #include "hbtoolbar.h" |
46 #include "hbtoolbar.h" |
59 #include "hbsplashscreen.h" |
57 #include "hbsplashscreen.h" |
60 #include "hbcontentwidget_p.h" |
58 #include "hbcontentwidget_p.h" |
61 #include "hbscreen_p.h" |
59 #include "hbscreen_p.h" |
62 #include "hbmainwindoworientation_p.h" |
60 #include "hbmainwindoworientation_p.h" |
63 #include "hbfeaturemanager_p.h" |
61 #include "hbfeaturemanager_p.h" |
|
62 #include "hboogmwatcher_p.h" |
64 |
63 |
65 #ifdef Q_OS_SYMBIAN |
64 #ifdef Q_OS_SYMBIAN |
66 #include <coecntrl.h> |
65 #include <coecntrl.h> |
67 #include "hbnativewindow_sym_p.h" |
66 #include "hbnativewindow_sym_p.h" |
68 #endif |
67 #endif |
69 |
68 |
70 /*! |
69 /*! |
71 @beta |
70 @stable |
72 @hbcore |
71 @hbcore |
73 \class HbMainWindow |
72 \class HbMainWindow |
74 |
73 |
75 \brief HbMainWindow is a GraphicsView instance, which can be initialized with S60 |
74 \brief HbMainWindow is a GraphicsView instance, which can be initialized with S60 |
76 style decorators. |
75 style decorators. |
138 |
137 |
139 /*! |
138 /*! |
140 \fn void HbMainWindow::orientationChanged() |
139 \fn void HbMainWindow::orientationChanged() |
141 |
140 |
142 This signal is emitted when animation related to orientation change has completed. |
141 This signal is emitted when animation related to orientation change has completed. |
143 */ |
|
144 |
|
145 /*! |
|
146 \deprecated HbMainWindow::currentViewIndexChanged(int) |
|
147 is deprecated. |
|
148 |
|
149 \fn void HbMainWindow::currentViewIndexChanged(int index) |
|
150 |
|
151 This signal is emitted when the current view index changes. |
|
152 */ |
142 */ |
153 |
143 |
154 /*! |
144 /*! |
155 \fn void HbMainWindow::aboutToChangeView(HbView *oldView, HbView *newView) |
145 \fn void HbMainWindow::aboutToChangeView(HbView *oldView, HbView *newView) |
156 |
146 |
265 } |
255 } |
266 |
256 |
267 #if defined(Q_WS_S60) || defined(HB_Q_WS_MAEMO) |
257 #if defined(Q_WS_S60) || defined(HB_Q_WS_MAEMO) |
268 setWindowState(Qt::WindowFullScreen); |
258 setWindowState(Qt::WindowFullScreen); |
269 #endif//Q_WS_S60 |
259 #endif//Q_WS_S60 |
|
260 |
270 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
261 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
271 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
262 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
272 setFrameShape(QFrame::NoFrame); |
263 setFrameShape(QFrame::NoFrame); |
273 |
264 |
274 // create scene and style |
265 // create scene and style |
298 // create content (stacked) widget |
289 // create content (stacked) widget |
299 d->mViewStackWidget = new HbContentWidget(this, d->mClippingItem); |
290 d->mViewStackWidget = new HbContentWidget(this, d->mClippingItem); |
300 d->mEffectItem = d->mViewStackWidget; |
291 d->mEffectItem = d->mViewStackWidget; |
301 d->mClippingItem->setStackWidget(d->mViewStackWidget); |
292 d->mClippingItem->setStackWidget(d->mViewStackWidget); |
302 connect(d->mViewStackWidget, SIGNAL(currentChanged(int)), |
293 connect(d->mViewStackWidget, SIGNAL(currentChanged(int)), |
303 this, SLOT(_q_viewChanged(int))); |
294 this, SLOT(_q_viewChanged())); |
304 connect(d->mViewStackWidget, SIGNAL(widgetRemoved(QGraphicsWidget*)), |
295 connect(d->mViewStackWidget, SIGNAL(widgetRemoved(QGraphicsWidget*)), |
305 this, SLOT(_q_viewRemoved(QGraphicsWidget*))); |
296 this, SLOT(_q_viewRemoved(QGraphicsWidget*))); |
306 |
297 |
307 // create Titlebar (container for indicators, titlepane and secondary softkey |
298 // create Titlebar (container for indicators, titlepane and secondary softkey |
308 d->mTitleBar = new HbTitleBar(this, d->mClippingItem); |
299 d->mTitleBar = new HbTitleBar(this, d->mClippingItem); |
318 QRectF rect(0,0,pSize.width(),pSize.height()); |
309 QRectF rect(0,0,pSize.width(),pSize.height()); |
319 resize(pSize); |
310 resize(pSize); |
320 d->mLayoutRect = rect; |
311 d->mLayoutRect = rect; |
321 d->mRootItem->setGeometry(rect); |
312 d->mRootItem->setGeometry(rect); |
322 d->mClippingItem->setGeometry(rect); |
313 d->mClippingItem->setGeometry(rect); |
323 |
|
324 setSceneRect(0, 0, pSize.width(), pSize.height()); |
314 setSceneRect(0, 0, pSize.width(), pSize.height()); |
325 |
|
326 setTransformationAnchor(QGraphicsView::AnchorViewCenter); |
315 setTransformationAnchor(QGraphicsView::AnchorViewCenter); |
327 |
316 |
328 // Rest of the initialization is done later, see paintEvent(). |
317 // Initialize common translations. This must be done before |
329 |
318 // creating any widget that can potentially use localized strings |
330 |
319 // and therefore cannot be delayed. |
|
320 d->initTranslations(); |
|
321 |
|
322 // Make sure the oogm watcher is initialized (so that wserv events |
|
323 // are routed to it properly). |
|
324 HbOogmWatcher::instance(); |
|
325 |
331 #ifdef HB_GESTURE_FW |
326 #ifdef HB_GESTURE_FW |
332 // @todo remove after view auto-subscribes to gestures |
327 // @todo remove after view auto-subscribes to gestures |
333 viewport()->grabGesture(Qt::TapGesture); |
328 viewport()->grabGesture(Qt::TapGesture); |
334 viewport()->grabGesture(Qt::TapAndHoldGesture); |
329 viewport()->grabGesture(Qt::TapAndHoldGesture); |
335 viewport()->grabGesture(Qt::PanGesture); |
330 viewport()->grabGesture(Qt::PanGesture); |
336 viewport()->grabGesture(Qt::SwipeGesture); |
331 viewport()->grabGesture(Qt::SwipeGesture); |
337 viewport()->grabGesture(Qt::PinchGesture); |
332 viewport()->grabGesture(Qt::PinchGesture); |
338 #endif |
333 #endif |
339 |
334 |
|
335 |
|
336 // Rest of the initialization is done later, see paintEvent(). |
|
337 |
340 } |
338 } |
341 |
339 |
342 /*! |
340 /*! |
343 Destructs the main window. |
341 Destructs the main window. |
344 */ |
342 */ |
478 } |
477 } |
479 } |
478 } |
480 } |
479 } |
481 |
480 |
482 /*! |
481 /*! |
483 \deprecated HbMainWindow::removeView(int) |
|
484 is deprecated. Use HbMainWindow::removeView(QGraphicsWidget *widget) instead! |
|
485 |
|
486 Removes a view from a given \a index from the HbMainWindow object. The view is not deleted but returned to caller. |
|
487 |
|
488 \return the removed widget. |
|
489 |
|
490 \sa addView insertView |
|
491 */ |
|
492 QGraphicsWidget *HbMainWindow::removeView(int index) |
|
493 { |
|
494 HB_DEPRECATED("HbMainWindow::removeView is deprecated. Use HbMainWindow::removeView(QGraphicsWidget *widget) instead!"); |
|
495 Q_D(HbMainWindow); |
|
496 return d->mViewStackWidget->removeAt(index); |
|
497 } |
|
498 |
|
499 /*! |
|
500 Returns the current view of the HbMainWindow object. |
482 Returns the current view of the HbMainWindow object. |
501 \return pointer to the current view object, or 0 if undefined. |
483 \return pointer to the current view object, or 0 if undefined. |
502 |
484 |
503 \sa setCurrentView |
485 \sa setCurrentView |
504 */ |
486 */ |
556 QMetaObject::invokeMethod(this, "_q_viewReady", Qt::QueuedConnection); |
538 QMetaObject::invokeMethod(this, "_q_viewReady", Qt::QueuedConnection); |
557 } |
539 } |
558 } |
540 } |
559 } |
541 } |
560 |
542 |
561 |
|
562 /*! |
|
563 \deprecated HbMainWindow::currentViewIndex() const |
|
564 is deprecated. Use HbMainWindow::currentView() instead! |
|
565 |
|
566 Returns the current index of the HbMainWindow object. |
|
567 \return current index, or -1 if undefined. |
|
568 |
|
569 \sa setCurrentViewIndex setCurrentView currentView |
|
570 */ |
|
571 int HbMainWindow::currentViewIndex() const |
|
572 { |
|
573 HB_DEPRECATED("HbMainWindow::currentViewIndex is deprecated. Use HbMainWindow::currentView() instead!"); |
|
574 Q_D(const HbMainWindow); |
|
575 return d->mViewStackWidget->currentIndex(); |
|
576 } |
|
577 |
|
578 /*! |
|
579 \deprecated HbMainWindow::viewCount() const |
|
580 is deprecated. Use HbMainWindow::views().count() instead! |
|
581 |
|
582 Returns the count of view objects of the HbMainWindow object. |
|
583 \return view object count. |
|
584 |
|
585 \sa addView insertView |
|
586 */ |
|
587 int HbMainWindow::viewCount() const |
|
588 { |
|
589 HB_DEPRECATED("HbMainWindow::viewCount is deprecated. Use HbMainWindow::views().count() instead!"); |
|
590 Q_D(const HbMainWindow); |
|
591 return d->mViewStackWidget->count(); |
|
592 } |
|
593 |
|
594 /*! |
|
595 \deprecated HbMainWindow::indexOfView(HbView*) const |
|
596 is deprecated. Use HbMainWindow::views().indexOf(view) instead! |
|
597 |
|
598 Returns the index for a given \a view object of the HbMainWindow object. |
|
599 \return index of a view object. |
|
600 |
|
601 \sa currentViewIndex currentView |
|
602 */ |
|
603 int HbMainWindow::indexOfView(HbView *view) const |
|
604 { |
|
605 HB_DEPRECATED("HbMainWindow::indexOfView is deprecated. Use HbMainWindow::views().indexOf(view) instead!"); |
|
606 Q_D(const HbMainWindow); |
|
607 return d->mViewStackWidget->indexOf(view); |
|
608 } |
|
609 |
|
610 /*! |
|
611 \deprecated HbMainWindow::viewAt(int) const |
|
612 is deprecated. Use HbMainWindow::views() instead! |
|
613 |
|
614 Returns \a view object for a given \a index of the HbMainWindow object. |
|
615 \return view object. |
|
616 |
|
617 \sa currentViewIndex currentView indexOfView |
|
618 */ |
|
619 HbView *HbMainWindow::viewAt(int index) const |
|
620 { |
|
621 HB_DEPRECATED("HbMainWindow::viewAt is deprecated. Use HbMainWindow::views() instead!"); |
|
622 Q_D(const HbMainWindow); |
|
623 return qobject_cast<HbView *>(d->mViewStackWidget->widgetAt(index)); |
|
624 } |
|
625 |
|
626 /*! |
543 /*! |
627 |
544 |
628 Returns list of all views. |
545 Returns list of all views. |
629 */ |
546 */ |
630 QList<HbView *> HbMainWindow::views() const |
547 QList<HbView *> HbMainWindow::views() const |
690 d->setTransformedOrientation(HbMainWindowOrientation::instance()->sensorOrientation(), animate); |
607 d->setTransformedOrientation(HbMainWindowOrientation::instance()->sensorOrientation(), animate); |
691 } |
608 } |
692 } |
609 } |
693 |
610 |
694 /*! |
611 /*! |
695 \deprecated HbMainWindow::showItems(QFlags<Hb::SceneItem>) |
|
696 is deprecated. Use HbView::showItems instead. |
|
697 |
|
698 Sets \a items to be visible in main window. |
|
699 |
|
700 \sa isItemVisible() setItemVisible() hideItems() visibleItems() |
|
701 */ |
|
702 void HbMainWindow::showItems(Hb::SceneItems items) |
|
703 { |
|
704 HB_DEPRECATED("HbMainWindow::showItems is deprecated! Use HbView::showItems instead."); |
|
705 Q_D(HbMainWindow); |
|
706 if (d->mVisibleItems ^ items) { |
|
707 d->mVisibleItems |= items; |
|
708 d->updateVisibleItems(); |
|
709 } |
|
710 } |
|
711 |
|
712 /*! |
|
713 \deprecated HbMainWindow::hideItems(QFlags<Hb::SceneItem>) |
|
714 is deprecated. Use HbView::hideItems instead. |
|
715 |
|
716 Sets \a items to be invisible in main window. |
|
717 |
|
718 \sa isItemVisible() setItemVisible() showItems() visibleItems() |
|
719 */ |
|
720 void HbMainWindow::hideItems(Hb::SceneItems items) |
|
721 { |
|
722 HB_DEPRECATED("HbMainWindow::hideItems is deprecated! Use HbView::hideItems instead."); |
|
723 Q_D(HbMainWindow); |
|
724 if (d->mVisibleItems & items) { |
|
725 d->mVisibleItems &= ~items; |
|
726 d->updateVisibleItems(); |
|
727 } |
|
728 } |
|
729 |
|
730 /*! |
|
731 \deprecated HbMainWindow::visibleItems() const |
|
732 is deprecated. Use HbView::visibleItems instead. |
|
733 |
|
734 Returns visible items. |
|
735 |
|
736 \sa isItemVisible() setItemVisible() hideItems() showItems() |
|
737 |
|
738 */ |
|
739 Hb::SceneItems HbMainWindow::visibleItems() const |
|
740 { |
|
741 HB_DEPRECATED("HbMainWindow::visibleItems is deprecated! Use HbView::visibleItems instead."); |
|
742 Q_D(const HbMainWindow); |
|
743 return d->mVisibleItems; |
|
744 } |
|
745 |
|
746 /*! |
|
747 \deprecated HbMainWindow::isItemVisible(Hb::SceneItem) const |
|
748 is deprecated. Use HbView::isItemVisible instead. |
|
749 |
|
750 Returns \c true if \a item is set to be visible. |
|
751 |
|
752 \sa setItemVisible() hideItems() showItems() visibleItems() |
|
753 |
|
754 */ |
|
755 bool HbMainWindow::isItemVisible(Hb::SceneItem item) const |
|
756 { |
|
757 HB_DEPRECATED("HbMainWindow::isItemVisible is deprecated! Use HbView::isItemVisible instead."); |
|
758 Q_D(const HbMainWindow); |
|
759 return d->mVisibleItems & item; |
|
760 } |
|
761 |
|
762 /*! |
|
763 \deprecated HbMainWindow::setItemVisible(Hb::SceneItem, bool) |
|
764 is deprecated. Use HbView::setItemVisible instead. |
|
765 |
|
766 Sets \a item to be \a visible in main window. |
|
767 |
|
768 \sa isItemVisible() hideItems() showItems() visibleItems() |
|
769 */ |
|
770 void HbMainWindow::setItemVisible(Hb::SceneItem item, bool visible) |
|
771 { |
|
772 HB_DEPRECATED("HbMainWindow::setItemVisible is deprecated! Use HbView::setItemVisible instead."); |
|
773 if (visible) { |
|
774 showItems(item); |
|
775 } else { |
|
776 hideItems(item); |
|
777 } |
|
778 } |
|
779 |
|
780 /*! |
|
781 Returns empty drawable window. |
612 Returns empty drawable window. |
782 |
613 |
783 Returned window is inherited from CCoeControl in Symbian platform |
614 Returned window is inherited from CCoeControl in Symbian platform |
784 and by default you don't have any surface attached to it. In other |
615 and by default you don't have any surface attached to it. In other |
785 platforms returns 0. |
616 platforms returns 0. |
837 QRectF HbMainWindow::layoutRect() const |
668 QRectF HbMainWindow::layoutRect() const |
838 { |
669 { |
839 Q_D(const HbMainWindow); |
670 Q_D(const HbMainWindow); |
840 return d->mLayoutRect; |
671 return d->mLayoutRect; |
841 } |
672 } |
842 /*! |
|
843 \deprecated HbMainWindow::setCurrentViewIndex(int) |
|
844 is deprecated. Use setCurrentView() instead. |
|
845 |
|
846 Sets the current view from a given \a index of the HbMainWindow object. |
|
847 |
|
848 \sa currentView currentViewIndex setCurrentView |
|
849 */ |
|
850 void HbMainWindow::setCurrentViewIndex(int index) |
|
851 { |
|
852 HB_DEPRECATED("HbMainWindow::setCurrentViewIndex is deprecated! Use setCurrentView() instead."); |
|
853 Q_D(HbMainWindow); |
|
854 QGraphicsWidget *widget = d->mViewStackWidget->widgetAt(index); |
|
855 setCurrentView(qobject_cast<HbView*>(widget)); |
|
856 } |
|
857 |
|
858 /*! |
|
859 \deprecated HbMainWindow::nextView() |
|
860 is deprecated. Use setCurrentView() instead. |
|
861 |
|
862 Switches to next view (view with bigger index). |
|
863 If current view is last view it does nothing. |
|
864 */ |
|
865 void HbMainWindow::nextView() |
|
866 { |
|
867 HB_DEPRECATED("HbMainWindow::nextView is deprecated! Use setCurrentView() instead."); |
|
868 int index = currentViewIndex()+1; |
|
869 if( index<viewCount() ) { |
|
870 setCurrentViewIndex(index); |
|
871 } |
|
872 } |
|
873 |
|
874 /*! |
|
875 \deprecated HbMainWindow::previousView() |
|
876 is deprecated. Use setCurrentView() instead. |
|
877 |
|
878 Switches to previous view (view with smaller index). |
|
879 If current view is first view it does nothing. |
|
880 */ |
|
881 void HbMainWindow::previousView() |
|
882 { |
|
883 HB_DEPRECATED("HbMainWindow::previousView is deprecated! Use setCurrentView() instead."); |
|
884 int index = currentViewIndex()-1; |
|
885 if( index>=0 ) { |
|
886 setCurrentViewIndex(index); |
|
887 } |
|
888 } |
|
889 |
673 |
890 /*! |
674 /*! |
891 Sets the \a name for the background image for the given \a orientation. If |
675 Sets the \a name for the background image for the given \a orientation. If |
892 the default image from the theme is suitable then there is no need to call |
676 the default image from the theme is suitable then there is no need to call |
893 this function. |
677 this function. |
910 */ |
694 */ |
911 QString HbMainWindow::backgroundImageName(Qt::Orientation orientation) const |
695 QString HbMainWindow::backgroundImageName(Qt::Orientation orientation) const |
912 { |
696 { |
913 Q_D(const HbMainWindow); |
697 Q_D(const HbMainWindow); |
914 return d->mBgItem ? d->mBgItem->imageName(orientation) : QString(); |
698 return d->mBgItem ? d->mBgItem->imageName(orientation) : QString(); |
|
699 } |
|
700 |
|
701 /*! |
|
702 Sets the animations enabled when the orientation is changed automatically. |
|
703 By default animations are enabled. |
|
704 |
|
705 \sa automaticOrientationEffectEnabled() |
|
706 */ |
|
707 |
|
708 void HbMainWindow::setAutomaticOrientationEffectEnabled(bool enabled) |
|
709 { |
|
710 Q_D(HbMainWindow); |
|
711 d->mAutomaticOrientationChangeAnimation = enabled; |
|
712 } |
|
713 |
|
714 /*! |
|
715 Returns boolean value to signify whether animations enabled/disabled during |
|
716 automatic orientation change. By default animations are enabled. |
|
717 |
|
718 \sa setAutomaticOrientationEffectEnabled() |
|
719 */ |
|
720 bool HbMainWindow::automaticOrientationEffectEnabled() const |
|
721 { |
|
722 Q_D(const HbMainWindow); |
|
723 return d->mAutomaticOrientationChangeAnimation; |
915 } |
724 } |
916 |
725 |
917 /*! |
726 /*! |
918 Reimplemented from QWidget::changeEvent(). |
727 Reimplemented from QWidget::changeEvent(). |
919 */ |
728 */ |