changeset 34 | ed14f46c0e55 |
parent 6 | c3690ec91ef8 |
31:7516d6d86cf5 | 34:ed14f46c0e55 |
---|---|
36 #include "hbtitlebar_p.h" |
36 #include "hbtitlebar_p.h" |
37 #include "hbstatusbar_p.h" |
37 #include "hbstatusbar_p.h" |
38 #include "hbscreen_p.h" |
38 #include "hbscreen_p.h" |
39 #include "hbviewactionmanager_p.h" |
39 #include "hbviewactionmanager_p.h" |
40 #include "hbglobal_p.h" |
40 #include "hbglobal_p.h" |
41 #include "hbevent.h" |
|
41 #include <QPointer> |
42 #include <QPointer> |
42 |
43 |
43 /*! |
44 /*! |
44 @stable |
45 @stable |
45 @hbcore |
46 @hbcore |
269 delete toolBar; |
270 delete toolBar; |
270 delete dockWidget; |
271 delete dockWidget; |
271 } |
272 } |
272 |
273 |
273 /*! |
274 /*! |
275 \internal |
|
276 */ |
|
277 void HbViewPrivate::delayedConstruction() |
|
278 { |
|
279 //view content is drawn already on screen.Try to |
|
280 //create the content of options menu now. |
|
281 if (menu) { |
|
282 HbMenuPrivate::d_ptr(menu)->delayedLayout(); |
|
283 } |
|
284 } |
|
285 |
|
286 /*! |
|
274 Constructs a view with the given \a parent. |
287 Constructs a view with the given \a parent. |
275 */ |
288 */ |
276 HbView::HbView(QGraphicsItem *parent) : |
289 HbView::HbView(QGraphicsItem *parent) : |
277 HbWidget(*new HbViewPrivate, parent) |
290 HbWidget(*new HbViewPrivate, parent) |
278 { |
291 { |
406 */ |
419 */ |
407 HbToolBar *HbView::toolBar() const |
420 HbToolBar *HbView::toolBar() const |
408 { |
421 { |
409 Q_D(const HbView); |
422 Q_D(const HbView); |
410 if (!d->toolBar) { |
423 if (!d->toolBar) { |
411 HbView *that = const_cast<HbView *>(this); |
424 HbViewPrivate* p = const_cast<HbViewPrivate*>(d); |
412 that->setToolBar(new HbToolBar); |
425 p->toolBar = new HbToolBar; |
426 // duplicates functionality of HbMainWindowPrivate::_q_viewToolBarChanged as a perf optimisation |
|
427 if ( mainWindow() && mainWindow()->currentView() == this ) { |
|
428 HbMainWindowPrivate::d_ptr(mainWindow())->addToolBarToLayout(p->toolBar); |
|
429 } |
|
430 |
|
413 } |
431 } |
414 return d->toolBar; |
432 return d->toolBar; |
415 } |
433 } |
416 |
434 |
417 /*! |
435 /*! |
532 // "setLayout( 0 )" deletes the existing layout. |
550 // "setLayout( 0 )" deletes the existing layout. |
533 setLayout(0); |
551 setLayout(0); |
534 d->mLayout = 0; |
552 d->mLayout = 0; |
535 } |
553 } |
536 } |
554 } |
555 // remove view switch effects the item might be part of |
|
556 HbEffect::cancel(this); |
|
557 |
|
537 delete d->widget; |
558 delete d->widget; |
538 d->widget = widget; |
559 d->widget = widget; |
539 } |
560 } |
540 } |
561 } |
541 |
562 |
721 } |
742 } |
722 Q_D(HbView); |
743 Q_D(HbView); |
723 HbView::HbViewFlags originalFlags(d->mViewFlags); |
744 HbView::HbViewFlags originalFlags(d->mViewFlags); |
724 d->mViewFlags = flags; |
745 d->mViewFlags = flags; |
725 if (mainWindow()) { |
746 if (mainWindow()) { |
726 |
747 bool isCurrentView(mainWindow()->currentView() == this); |
727 // Statusbar-animation |
748 if (isCurrentView) { |
728 bool statusBarAnimating = false; |
749 // Statusbar-animation |
729 HbStatusBar *statusBar = HbMainWindowPrivate::d_ptr(mainWindow())->mStatusBar; |
750 bool statusBarAnimating = false; |
730 if ((d->mViewFlags & HbView::ViewStatusBarHidden) && !(originalFlags & HbView::ViewStatusBarHidden)) { |
751 HbStatusBar *statusBar = HbMainWindowPrivate::d_ptr(mainWindow())->mStatusBar; |
752 if ((d->mViewFlags & HbView::ViewStatusBarHidden) && !(originalFlags & HbView::ViewStatusBarHidden)) { |
|
731 #ifdef HB_EFFECTS |
753 #ifdef HB_EFFECTS |
732 HbEffect::start(statusBar, "statusbar", "disappear", this, "statusBarEffectFinished"); |
754 HbEffect::start(statusBar, "statusbar", "disappear", this, "statusBarEffectFinished"); |
733 #endif // HB_EFFECTS |
755 #endif // HB_EFFECTS |
734 statusBarAnimating = true; |
756 statusBarAnimating = true; |
735 } else if (!(d->mViewFlags & HbView::ViewStatusBarHidden) && (originalFlags & HbView::ViewStatusBarHidden)) { |
757 } else if (!(d->mViewFlags & HbView::ViewStatusBarHidden) && (originalFlags & HbView::ViewStatusBarHidden)) { |
736 #ifdef HB_EFFECTS |
758 #ifdef HB_EFFECTS |
759 statusBar->setVisible(true); |
|
737 HbEffect::start(statusBar, "statusbar", "appear", this, "statusBarEffectFinished"); |
760 HbEffect::start(statusBar, "statusbar", "appear", this, "statusBarEffectFinished"); |
738 #endif // HB_EFFECTS |
761 #endif // HB_EFFECTS |
739 statusBarAnimating = true; |
762 statusBarAnimating = true; |
740 } |
763 } |
741 |
764 |
742 // Titlebar-animation |
765 // Titlebar-animation |
743 bool titleBarAnimating = false; |
766 bool titleBarAnimating = false; |
744 HbTitleBar *titleBar = HbMainWindowPrivate::d_ptr(mainWindow())->mTitleBar; |
767 HbTitleBar *titleBar = HbMainWindowPrivate::d_ptr(mainWindow())->mTitleBar; |
745 if ((d->mViewFlags & HbView::ViewTitleBarHidden) && !(originalFlags & HbView::ViewTitleBarHidden)) { |
768 if ((d->mViewFlags & HbView::ViewTitleBarHidden) && !(originalFlags & HbView::ViewTitleBarHidden)) { |
746 #ifdef HB_EFFECTS |
769 #ifdef HB_EFFECTS |
747 HbEffect::start(titleBar, "titlebar", "disappear", this, "titleBarEffectFinished"); |
770 HbEffect::start(titleBar, "titlebar", "disappear", this, "titleBarEffectFinished"); |
748 #endif // HB_EFFECTS |
771 #endif // HB_EFFECTS |
749 titleBarAnimating = true; |
772 titleBarAnimating = true; |
750 } else if (!(d->mViewFlags & HbView::ViewTitleBarHidden) && (originalFlags & HbView::ViewTitleBarHidden)) { |
773 } else if (!(d->mViewFlags & HbView::ViewTitleBarHidden) && (originalFlags & HbView::ViewTitleBarHidden)) { |
751 #ifdef HB_EFFECTS |
774 #ifdef HB_EFFECTS |
752 HbEffect::start(titleBar, "titlebar", "appear", this, "titleBarEffectFinished"); |
775 titleBar->setVisible(true); |
776 HbEffect::start(titleBar, "titlebar", "appear", this, "titleBarEffectFinished"); |
|
753 #endif // HB_EFFECTS |
777 #endif // HB_EFFECTS |
754 titleBarAnimating = true; |
778 titleBarAnimating = true; |
755 } |
|
756 |
|
757 if (!statusBarAnimating) { |
|
758 statusBar->setVisible(!(d->mViewFlags & HbView::ViewStatusBarHidden)); |
|
759 statusBar->propertiesChanged(); |
|
760 } |
|
761 if (!titleBarAnimating) { |
|
762 titleBar->setVisible(!(d->mViewFlags & HbView::ViewTitleBarHidden)); |
|
763 if (d->mNavigationActionSet) { |
|
764 titleBar->setNavigationAction(d->mNavigationAction); |
|
765 } else { |
|
766 titleBar->setDefaultNavigationAction(); |
|
767 } |
779 } |
768 titleBar->propertiesChanged(); |
780 |
781 if (!statusBarAnimating && !titleBarAnimating) { |
|
782 statusBar->setVisible(!(d->mViewFlags & HbView::ViewStatusBarHidden)); |
|
783 statusBar->propertiesChanged(); |
|
784 } |
|
785 if (!titleBarAnimating && !statusBarAnimating) { |
|
786 titleBar->setVisible(!(d->mViewFlags & HbView::ViewTitleBarHidden)); |
|
787 if (d->mNavigationActionSet) { |
|
788 titleBar->setNavigationAction(d->mNavigationAction); |
|
789 } else { |
|
790 titleBar->setDefaultNavigationAction(); |
|
791 } |
|
792 titleBar->propertiesChanged(); |
|
793 } |
|
769 } |
794 } |
770 if (d->toolBar) { |
795 if (d->toolBar) { |
771 d->toolBar->updatePrimitives(); |
796 d->toolBar->updatePrimitives(); |
772 } |
797 } |
773 |
798 |
791 |
816 |
792 // Repolish the screen if needed |
817 // Repolish the screen if needed |
793 int visibilityFlags = HbView::ViewTitleBarMinimized | HbView::ViewTitleBarFloating |
818 int visibilityFlags = HbView::ViewTitleBarMinimized | HbView::ViewTitleBarFloating |
794 | HbView::ViewTitleBarMinimizable | HbView::ViewStatusBarHidden | HbView::ViewStatusBarFloating |
819 | HbView::ViewTitleBarMinimizable | HbView::ViewStatusBarHidden | HbView::ViewStatusBarFloating |
795 | HbView::ViewTitleBarHidden | HbView::ViewDisableRelayout; |
820 | HbView::ViewTitleBarHidden | HbView::ViewDisableRelayout; |
796 if ((d->mViewFlags & visibilityFlags) != (originalFlags & visibilityFlags)) { |
821 if (isCurrentView && (d->mViewFlags & visibilityFlags) != (originalFlags & visibilityFlags)) { |
797 HbMainWindowPrivate::d_ptr(mainWindow())->mClippingItem->decoratorVisibilityChanged(); |
822 HbMainWindowPrivate::d_ptr(mainWindow())->mClippingItem->decoratorVisibilityChanged(); |
798 } |
823 } |
799 } |
824 } |
800 } |
825 } |
801 |
826 |
808 \sa setViewFlags() |
833 \sa setViewFlags() |
809 */ |
834 */ |
810 void HbView::setTitleBarVisible(bool visible) |
835 void HbView::setTitleBarVisible(bool visible) |
811 { |
836 { |
812 Q_D(HbView); |
837 Q_D(HbView); |
813 if (visible) { |
838 |
814 setViewFlags(d->mViewFlags &~ HbView::ViewTitleBarHidden); |
839 if (visible) { |
840 setViewFlags(d->mViewFlags &~ HbView::ViewTitleBarHidden); |
|
815 } else { |
841 } else { |
816 setViewFlags(d->mViewFlags | HbView::ViewTitleBarHidden); |
842 setViewFlags(d->mViewFlags | HbView::ViewTitleBarHidden); |
817 } |
843 } |
818 } |
844 } |
819 |
845 |
889 /*! |
915 /*! |
890 \reimp |
916 \reimp |
891 */ |
917 */ |
892 void HbView::changeEvent(QEvent *event) |
918 void HbView::changeEvent(QEvent *event) |
893 { |
919 { |
920 Q_D(const HbView); |
|
894 |
921 |
895 // We're listening for layout direction changes, because the screen needs to be |
922 // We're listening for layout direction changes, because the screen needs to be |
896 // repolished, if the layout direction changes and the titlebar is minimizable. |
923 // repolished, if the layout direction changes and the titlebar is minimizable. |
897 // We have to listen to the event here(and not in the titlebar), cause the layout |
924 // We have to listen to the event here(and not in the titlebar), cause the layout |
898 // direction change event is delivered to the titlebar (cause it does not mirror) |
925 // direction change event is delivered to the titlebar (cause it does not mirror) |
901 && (viewFlags() & ViewTitleBarMinimizable)) { |
928 && (viewFlags() & ViewTitleBarMinimizable)) { |
902 HbMainWindow *mw = mainWindow(); |
929 HbMainWindow *mw = mainWindow(); |
903 if (mw && mw->currentView() == this) { |
930 if (mw && mw->currentView() == this) { |
904 HbMainWindowPrivate::d_ptr(mw)->mClippingItem->decoratorVisibilityChanged(); |
931 HbMainWindowPrivate::d_ptr(mw)->mClippingItem->decoratorVisibilityChanged(); |
905 } |
932 } |
933 } else if(event->type() == HbEvent::ThemeChanged) { |
|
934 HbMainWindow *mw = mainWindow(); |
|
935 if (d->toolBar && mw && mw->currentView() != this) { |
|
936 d->toolBar->changeEvent(event); |
|
937 } |
|
906 } |
938 } |
907 |
939 |
908 HbWidget::changeEvent(event); |
940 HbWidget::changeEvent(event); |
909 } |
941 } |
910 |
942 |
1027 If you set the \a action to 0, the previous navigation action is |
1059 If you set the \a action to 0, the previous navigation action is |
1028 unset and no new one will be set. |
1060 unset and no new one will be set. |
1029 |
1061 |
1030 Ownership of \a action is not taken. |
1062 Ownership of \a action is not taken. |
1031 |
1063 |
1064 \note The navigation button will not display text that is assigned to the |
|
1065 action. |
|
1066 |
|
1032 \sa navigationAction() |
1067 \sa navigationAction() |
1033 */ |
1068 */ |
1034 void HbView::setNavigationAction(HbAction *action) |
1069 void HbView::setNavigationAction(HbAction *action) |
1035 { |
1070 { |
1036 Q_D(HbView); |
1071 Q_D(HbView); |