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 &, const QSize &) ), iCurrentView, SLOT( viewResized( const QSize &, 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 &, const QSize &) ), oldView, SLOT( viewResized(const QSize &, const QSize &) ) );
61 void WindowManager::showDialog(QDialog *aDialog, bool blocking, bool aSendSignal)
63 // Handle dialog displaying
64 if ( aSendSignal ) emit dialogActivated();
73 if ( aSendSignal ) emit dialogDeactivated();
76 void WindowManager::viewEventDetected()
79 if ( iCurrentView != 0 )
81 if ( iCurrentView->viewMode() == ViewBase::NormalView )
85 else if ( iCurrentView->viewMode() == ViewBase::ObservedView )
87 if ( !iViewList.isEmpty() )
89 ViewBase *previousView = static_cast<ViewBase *>( iViewList.pop() );
90 this->showView( previousView );
91 emit previousViewRestored();
98 bool WindowManager::event(QEvent *event)
100 if ( event->type() == QEvent::Resize )
102 if ( iCurrentView != 0 )
104 QSize currentSize = iCurrentView->size();
105 iCurrentView->setFixedSize( this->size() );
106 emit viewResized( this->size(), currentSize );
110 return QWidget::event( event );
113 void WindowManager::error( const QString &aErrorMessage )
115 qDebug() << "WindowManager::error ";
117 PopUpMessageBox *popup = PopUpMessageBox::error( 0, aErrorMessage );
120 showDialog( static_cast<QDialog *>( popup ), false );
124 void WindowManager::setFullscreen()
126 this->setWindowState( Qt::WindowFullScreen );
127 // Resize event handles the rest.