1 #include "WindowManager.h"
9 WindowManager::WindowManager( QWidget *aParent ) :
11 iApplicationName( tr( "Qt Meetings" ) ),
14 this->setWindowTitle( iApplicationName );
17 WindowManager::~WindowManager()
22 void WindowManager::showView( ViewBase *view )
24 // The views parent must be WindowManager when it is displayed trough this
25 QWidget *parent = static_cast<QWidget *>(view->parent());
28 view->setParent( this );
31 // Store the current view because it is hidden after the new view is shown
32 QWidget *oldView = iCurrentView;
34 // If the new view is observed view we store the current into stack
35 // from which it is restored when the new view receives event we are
37 if ( view->viewMode() == ViewBase::ObservedView )
39 iViewList.push( iCurrentView );
42 // Make the new view visible and handle connections
44 connect( iCurrentView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
45 connect( this, SIGNAL( viewResized(const QSize &) ), iCurrentView, SLOT( viewResized( const QSize & ) ) );
46 view->resize( this->size() );
50 // Disconnect old connections and hide the view
53 disconnect( oldView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
54 disconnect( this, SIGNAL( viewResized(const QSize &) ), oldView, SLOT( viewResized(const QSize &) ) );
60 void WindowManager::showDialog(QDialog *dialog)
62 // Handle dialog displaying
63 emit dialogActivated();
65 emit dialogDeactivated();
68 void WindowManager::viewEventDetected()
71 if ( iCurrentView != 0 )
73 if ( iCurrentView->viewMode() == ViewBase::NormalView )
77 else if ( iCurrentView->viewMode() == ViewBase::ObservedView )
79 if ( !iViewList.isEmpty() )
81 ViewBase *previousView = static_cast<ViewBase *>( iViewList.pop() );
82 this->showView( previousView );
83 emit previousViewRestored();
90 bool WindowManager::event(QEvent *event)
92 if ( event->type() == QEvent::Resize )
94 if ( iCurrentView != 0 )
96 iCurrentView->setFixedSize( this->size() );
97 emit viewResized( this->size() );
101 return QWidget::event( event );
104 void WindowManager::error( const QString &aErrorMessage )
106 qDebug() << "WindowManager::showErrorPopup";
108 // PopUpMessageBox::error( 0, aErrorMessage );
111 void WindowManager::setFullscreen()
113 this->setWindowState( Qt::WindowFullScreen );
114 // Resize event handles the rest.