1 #include "WindowManager.h"
7 #include "PopUpMessageBox.h"
11 WindowManager::WindowManager( QWidget *aParent ) :
12 QMainWindow( aParent ),
13 iApplicationName( tr( "Qt Meetings" ) ),
16 this->setWindowTitle( iApplicationName );
17 settingsAction = new QAction(tr("&Settings"), this);
18 connect(settingsAction, SIGNAL(triggered()), this, SIGNAL(showSettingsClicked()));
19 menuBar()->addAction(settingsAction);
22 WindowManager::~WindowManager()
27 void WindowManager::showView( ViewBase *view )
29 // The views parent must be WindowManager when it is displayed trough this
30 QWidget *parent = static_cast<QWidget *>(view->parent());
33 view->setParent( this );
36 // Store the current view because it is hidden after the new view is shown
37 QWidget *oldView = iCurrentView;
39 // If the new view is observed view we store the current into stack
40 // from which it is restored when the new view receives event we are
42 if ( view->viewMode() == ViewBase::ObservedView )
44 iViewList.push( iCurrentView );
47 // Make the new view visible and handle connections
49 connect( iCurrentView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
50 connect( this, SIGNAL( viewResized(const QSize &, const QSize &) ), iCurrentView, SLOT( viewResized( const QSize &, const QSize & ) ) );
51 if (((QWidget*)view) != this)
55 view->resize(this->size());
59 // Disconnect old connections and hide the view
62 disconnect( oldView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
63 disconnect( this, SIGNAL( viewResized(const QSize &, const QSize &) ), oldView, SLOT( viewResized(const QSize &, const QSize &) ) );
69 void WindowManager::showDialog(QDialog *aDialog, bool blocking, bool aSendSignal)
71 // Handle dialog displaying
72 if ( aSendSignal ) emit dialogActivated();
81 if ( aSendSignal ) emit dialogDeactivated();
84 void WindowManager::viewEventDetected()
87 if ( iCurrentView != 0 )
89 if ( iCurrentView->viewMode() == ViewBase::NormalView )
93 else if ( iCurrentView->viewMode() == ViewBase::ObservedView )
95 if ( !iViewList.isEmpty() )
97 ViewBase *previousView = static_cast<ViewBase *>( iViewList.pop() );
98 this->showView( previousView );
99 emit previousViewRestored();
106 bool WindowManager::event(QEvent *event)
108 if ( event->type() == QEvent::Resize )
110 if ( iCurrentView != 0 )
112 QSize currentSize = iCurrentView->size();
113 iCurrentView->setFixedSize( this->size() );
114 emit viewResized( this->size(), currentSize );
118 return QWidget::event( event );
121 void WindowManager::error( const QString &aErrorMessage )
123 qDebug() << "WindowManager::error ";
125 PopUpMessageBox *popup = PopUpMessageBox::error( 0, aErrorMessage );
128 showDialog( static_cast<QDialog *>( popup ), false );
132 void WindowManager::setFullscreen()
134 this->setWindowState( Qt::WindowFullScreen );
135 // Resize event handles the rest.