1 #include "WindowManager.h"
9 const int IDLE_TIME_MULTIPLIER = 60000; // Multiplies milliseconds to minutes
11 WindowManager::WindowManager( QWidget *aParent ) :
13 iApplicationName( tr( "Qt Meetings" ) ),
16 this->setWindowTitle( iApplicationName );
19 WindowManager::~WindowManager()
24 void WindowManager::showView( ViewBase *view )
26 // The views parent must be WindowManager when it is displayed trough this
27 QWidget *parent = static_cast<QWidget *>(view->parent());
30 view->setParent( this );
33 // Store the current view because it is hidden after the new view is shown
34 QWidget *oldView = iCurrentView;
36 // If the new view is observed view we store the current into stack
37 // from which it is restored when the new view receives event we are
39 if ( view->viewMode() == ViewBase::ObservedView )
41 iViewList.push( iCurrentView );
44 // Make the new view visible and handle connections
46 connect( iCurrentView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
47 connect( this, SIGNAL( viewResized(const QSize &) ), iCurrentView, SLOT( viewResized( const QSize & ) ) );
48 view->resize( this->size() );
52 // Disconnect old connections and hide the view
55 disconnect( oldView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
56 disconnect( this, SIGNAL( viewResized(const QSize &) ), oldView, SLOT( viewResized(const QSize &) ) );
62 void WindowManager::showDialog(QDialog *dialog)
64 // Handle dialog displaying
65 emit dialogActivated();
67 emit dialogDeactivated();
70 void WindowManager::viewEventDetected()
73 if ( iCurrentView != 0 )
75 if ( iCurrentView->viewMode() == ViewBase::NormalView )
79 else if ( iCurrentView->viewMode() == ViewBase::ObservedView )
81 if ( !iViewList.isEmpty() )
83 ViewBase *previousView = static_cast<ViewBase *>( iViewList.pop() );
84 this->showView( previousView );
85 emit previousViewRestored();
92 bool WindowManager::event(QEvent *event)
94 if ( event->type() == QEvent::Resize )
96 if ( iCurrentView != 0 )
98 iCurrentView->setFixedSize( this->size() );
99 emit viewResized( this->size() );
103 return QWidget::event( event );
106 void WindowManager::setFullscreen()
108 this->setWindowState( Qt::WindowFullScreen );
109 // Resize event handles the rest.