1 #include "WindowManager.h"
6 #include "PopUpMessageBox.h"
10 WindowManager::WindowManager( QWidget *aParent ) :
12 iApplicationName( tr( "Qt Meetings" ) ),
15 this->setWindowTitle( iApplicationName );
18 WindowManager::~WindowManager()
23 void WindowManager::showView( ViewBase *view )
25 // The views parent must be WindowManager when it is displayed trough this
26 QWidget *parent = static_cast<QWidget *>(view->parent());
29 view->setParent( this );
32 // Store the current view because it is hidden after the new view is shown
33 QWidget *oldView = iCurrentView;
35 // If the new view is observed view we store the current into stack
36 // from which it is restored when the new view receives event we are
38 if ( view->viewMode() == ViewBase::ObservedView )
40 iViewList.push( iCurrentView );
43 // Make the new view visible and handle connections
45 connect( iCurrentView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
46 connect( this, SIGNAL( viewResized(const QSize &) ), iCurrentView, SLOT( viewResized( const QSize & ) ) );
47 view->resize( this->size() );
51 // Disconnect old connections and hide the view
54 disconnect( oldView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
55 disconnect( this, SIGNAL( viewResized(const QSize &) ), oldView, SLOT( viewResized(const QSize &) ) );
61 void WindowManager::showDialog(QDialog *dialog)
63 // Handle dialog displaying
64 emit dialogActivated();
66 emit dialogDeactivated();
69 void WindowManager::viewEventDetected()
72 if ( iCurrentView != 0 )
74 if ( iCurrentView->viewMode() == ViewBase::NormalView )
78 else if ( iCurrentView->viewMode() == ViewBase::ObservedView )
80 if ( !iViewList.isEmpty() )
82 ViewBase *previousView = static_cast<ViewBase *>( iViewList.pop() );
83 this->showView( previousView );
84 emit previousViewRestored();
91 bool WindowManager::event(QEvent *event)
93 if ( event->type() == QEvent::Resize )
95 if ( iCurrentView != 0 )
97 iCurrentView->setFixedSize( this->size() );
98 emit viewResized( this->size() );
102 return QWidget::event( event );
105 void WindowManager::error( const QString &aErrorMessage )
107 qDebug() << "WindowManager::showErrorPopup";
109 showDialog( static_cast<QDialog *>( PopUpMessageBox::error( 0, aErrorMessage ) ) );
112 void WindowManager::setFullscreen()
114 this->setWindowState( Qt::WindowFullScreen );
115 // Resize event handles the rest.