-#include "RoomStatusIndicatorWidget.h"\r
-\r
-#include <QLabel>\r
-#include <QFont>\r
-#include <QVBoxLayout>\r
-#include "DigitalTimeDisplayWidget.h"\r
-#include "ToolBox.h"\r
-\r
-#include <QEvent>\r
-\r
-#include <QtDebug>\r
-\r
-QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0 );\r
-\r
-RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent ) :\r
- ViewBase( ViewBase::ObservedView, aParent ), iTimeFormat( aTimeFormat )\r
-{\r
- QFont importantTextFont;\r
- //importantTextFont.setBold( true );\r
- importantTextFont.setPointSize( 20 );\r
-\r
- QFont regularTextFont;\r
- //regularTextFont.setBold( true );\r
- regularTextFont.setPointSize( 12 );\r
-\r
- // display for current time\r
- // Note: the time display receives current time info from Engine::clock()\r
- iTimeDisplay = new DigitalTimeDisplayWidget( QTime::currentTime(), iTimeFormat, this );\r
- iTimeDisplay->setFrameVisible( false );\r
- iTimeDisplay->setSize( 250, 120 );\r
-\r
- // Pegasus\r
- iDefaultRoomLabel = ToolBox::createLabel( aDefaultRoom->name(), importantTextFont );\r
- iDefaultRoomLabel->setAlignment( Qt::AlignHCenter );\r
- iDefaultRoomLabel->setStyleSheet( "background-color: transparent" );\r
- iDefaultRoomLabel->setHidden( true );\r
- \r
- // is busy\r
- iStatusLabel = ToolBox::createLabel( tr( "is %1" ).arg( statusToText( aStatus ) ), importantTextFont );\r
- iStatusLabel->setAlignment( Qt::AlignHCenter );\r
- iStatusLabel->setStyleSheet( "background-color: transparent" );\r
- iStatusLabel->setHidden( true );\r
-\r
- // until 13:22\r
- iUntilTextLabel = ToolBox::createLabel( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ), importantTextFont );\r
- iUntilTextLabel->setAlignment( Qt::AlignHCenter );\r
- iUntilTextLabel->setStyleSheet( "background-color: transparent" );\r
- iUntilTextLabel->setHidden( true );\r
- \r
- // No connection to server note\r
- qDebug() << "RoomStatusIndicatorWidget::RoomStatusIndicatorWidget() creating connection label";\r
- QFrame* connectionLabelFrame = new QFrame( this );\r
- iConnectionLabel = new QLabel( tr( "No connection to server" ), connectionLabelFrame );\r
- iConnectionLabel->setFont( importantTextFont ); \r
- iConnectionLabel->setAlignment( Qt::AlignHCenter );\r
- iConnectionLabel->setWordWrap( true );\r
- iConnectionLabel->setStyleSheet( "background-color: transparent; color: red; text-decoration:blink; max-width: 250px" );\r
- connectionLabelFrame->setFixedSize( iConnectionLabel->sizeHint() );\r
- if( connectedOnce && !connectionError ) iConnectionLabel->setHidden( true );\r
- \r
-\r
- QVBoxLayout *topLayout = new QVBoxLayout;\r
- topLayout->addStretch();\r
- topLayout->addWidget( iTimeDisplay );\r
- topLayout->addSpacing( 28 );\r
- topLayout->addWidget( iDefaultRoomLabel );\r
- topLayout->addWidget( iStatusLabel );\r
- topLayout->addWidget( iUntilTextLabel );\r
- topLayout->addSpacing( 28 );\r
- topLayout->addWidget( connectionLabelFrame );\r
- topLayout->addStretch();\r
-\r
- QHBoxLayout *mainLayout = new QHBoxLayout;\r
- mainLayout->addLayout( topLayout );\r
- mainLayout->addStretch();\r
- //mainLayout->setMargin( 65 );\r
- mainLayout->setContentsMargins( 65, 65, 65, 0 );\r
- setLayout( mainLayout );\r
-\r
- statusChanged( aStatus, aUntil );\r
-\r
- setFocusPolicy( Qt::StrongFocus );\r
- setEnabled( true ); // enable mouse & key events\r
-}\r
-\r
-RoomStatusIndicatorWidget::~RoomStatusIndicatorWidget()\r
-{\r
- delete iTimeDisplay;\r
- iTimeDisplay = 0;\r
-}\r
-\r
-QString RoomStatusIndicatorWidget::statusToText( const Room::Status aStatus )\r
-{\r
- return ( aStatus == Room::BusyStatus ) ? tr( "busy" ) : tr( "free" );\r
-}\r
-\r
-QPalette RoomStatusIndicatorWidget::createPalette( Room::Status aStatus )\r
-{\r
- QString image = aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free";\r
- QPixmap pixmap( image );\r
-\r
- // The image needs to be moved in normal mode so the traffic light not partly outside the screen\r
- const int xoffset( 60 );\r
- const int yoffset( 19 );\r
- int cropwidth( pixmap.width() - xoffset );\r
- int cropheight( pixmap.height() - yoffset );\r
- \r
- QBrush brush;\r
- if ( windowState() == Qt::WindowFullScreen )\r
- {\r
- // Use the full image in full screen mode\r
- brush.setTexture( pixmap );\r
- }\r
- else\r
- {\r
- // Take part of the image so the traffic lights are moved xoffset poxels to left \r
- // and yoffset pixels to up\r
- brush.setTexture( pixmap.copy( xoffset, yoffset, cropwidth, cropheight ) );\r
- }\r
-\r
- QPalette palette;\r
- palette.setBrush( QPalette::Window, brush );\r
- return palette;\r
-}\r
-\r
-void RoomStatusIndicatorWidget::setCurrentTime( QTime aCurrentTime )\r
-{\r
- iTimeDisplay->setTime( aCurrentTime );\r
-}\r
-\r
-void RoomStatusIndicatorWidget::statusChanged( const Room::Status aStatus, const QTime aUntil )\r
-{\r
- iStatusLabel->setText( tr( "is %1" ).arg( statusToText( aStatus ) ) );\r
- if ( aUntil == RoomStatusIndicatorWidget::endOfTheDay )\r
- {\r
- iUntilTextLabel->setText( tr( "whole day." ) );\r
- }\r
- else\r
- {\r
- iUntilTextLabel->setText( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ) );\r
- }\r
- setPalette( createPalette( aStatus ) );\r
+#include "RoomStatusIndicatorWidget.h"
+
+#include <QLabel>
+#include <QFont>
+#include <QVBoxLayout>
+#include "DigitalTimeDisplayWidget.h"
+#include "ToolBox.h"
+
+#include <QEvent>
+
+#include <QtDebug>
+
+QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0 );
+
+RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent ) :
+ ViewBase( ViewBase::ObservedView, aParent ), iTimeFormat( aTimeFormat )
+{
+ QFont importantTextFont;
+ //importantTextFont.setBold( true );
+ importantTextFont.setPointSize( 20 );
+
+ QFont regularTextFont;
+ //regularTextFont.setBold( true );
+ regularTextFont.setPointSize( 12 );
+
+ // display for current time
+ // Note: the time display receives current time info from Engine::clock()
+ iTimeDisplay = new DigitalTimeDisplayWidget( QTime::currentTime(), iTimeFormat, this );
+ iTimeDisplay->setFrameVisible( false );
+ iTimeDisplay->setSize( 250, 120 );
+
+ // Pegasus
+ iDefaultRoomLabel = ToolBox::createLabel( aDefaultRoom->name(), importantTextFont );
+ iDefaultRoomLabel->setAlignment( Qt::AlignHCenter );
+ iDefaultRoomLabel->setStyleSheet( "background-color: transparent" );
+ iDefaultRoomLabel->setHidden( true );
+
+ // is busy
+ iStatusLabel = ToolBox::createLabel( tr( "is %1" ).arg( statusToText( aStatus ) ), importantTextFont );
+ iStatusLabel->setAlignment( Qt::AlignHCenter );
+ iStatusLabel->setStyleSheet( "background-color: transparent" );
+ iStatusLabel->setHidden( true );
+
+ // until 13:22
+ iUntilTextLabel = ToolBox::createLabel( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ), importantTextFont );
+ iUntilTextLabel->setAlignment( Qt::AlignHCenter );
+ iUntilTextLabel->setStyleSheet( "background-color: transparent" );
+ iUntilTextLabel->setHidden( true );
+
+ // No connection to server note
+ qDebug() << "RoomStatusIndicatorWidget::RoomStatusIndicatorWidget() creating connection label";
+ QFrame* connectionLabelFrame = new QFrame( this );
+ iConnectionLabel = new QLabel( tr( "No connection to server" ), connectionLabelFrame );
+ iConnectionLabel->setFont( importantTextFont );
+ iConnectionLabel->setAlignment( Qt::AlignHCenter );
+ iConnectionLabel->setWordWrap( true );
+ iConnectionLabel->setStyleSheet( "background-color: transparent; color: red; text-decoration:blink; max-width: 250px" );
+ connectionLabelFrame->setFixedSize( iConnectionLabel->sizeHint() );
+ if( connectedOnce && !connectionError ) iConnectionLabel->setHidden( true );
+
+
+ QVBoxLayout *topLayout = new QVBoxLayout;
+ topLayout->addStretch();
+ topLayout->addWidget( iTimeDisplay );
+ topLayout->addSpacing( 28 );
+ topLayout->addWidget( iDefaultRoomLabel );
+ topLayout->addWidget( iStatusLabel );
+ topLayout->addWidget( iUntilTextLabel );
+ topLayout->addSpacing( 28 );
+ topLayout->addWidget( connectionLabelFrame );
+ topLayout->addStretch();
+
+ QHBoxLayout *mainLayout = new QHBoxLayout;
+ mainLayout->addLayout( topLayout );
+ mainLayout->addStretch();
+ //mainLayout->setMargin( 65 );
+ mainLayout->setContentsMargins( 65, 65, 65, 0 );
+ setLayout( mainLayout );
+
+ statusChanged( aStatus, aUntil );
+
+ setFocusPolicy( Qt::StrongFocus );
+ setEnabled( true ); // enable mouse & key events
+}
+
+RoomStatusIndicatorWidget::~RoomStatusIndicatorWidget()
+{
+ delete iTimeDisplay;
+ iTimeDisplay = 0;
+}
+
+QString RoomStatusIndicatorWidget::statusToText( const Room::Status aStatus )
+{
+ return ( aStatus == Room::BusyStatus ) ? tr( "busy" ) : tr( "free" );
+}
+
+QPalette RoomStatusIndicatorWidget::createPalette( Room::Status aStatus )
+{
+ QString image = aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free";
+ QPixmap pixmap( image );
+
+ // The image needs to be moved in normal mode so the traffic light not partly outside the screen
+ const int xoffset( 60 );
+ const int yoffset( 19 );
+ int cropwidth( pixmap.width() - xoffset );
+ int cropheight( pixmap.height() - yoffset );
+
+ QBrush brush;
+ if ( windowState() == Qt::WindowFullScreen )
+ {
+ // Use the full image in full screen mode
+ brush.setTexture( pixmap );
+ }
+ else
+ {
+ // Take part of the image so the traffic lights are moved xoffset poxels to left
+ // and yoffset pixels to up
+ brush.setTexture( pixmap.copy( xoffset, yoffset, cropwidth, cropheight ) );
+ }
+
+ QPalette palette;
+ palette.setBrush( QPalette::Window, brush );
+ return palette;
+}
+
+void RoomStatusIndicatorWidget::setCurrentTime( QTime aCurrentTime )
+{
+ iTimeDisplay->setTime( aCurrentTime );
+}
+
+void RoomStatusIndicatorWidget::statusChanged( const Room::Status aStatus, const QTime aUntil )
+{
+ iStatusLabel->setText( tr( "is %1" ).arg( statusToText( aStatus ) ) );
+ if ( aUntil == RoomStatusIndicatorWidget::endOfTheDay )
+ {
+ iUntilTextLabel->setText( tr( "whole day." ) );
+ }
+ else
+ {
+ iUntilTextLabel->setText( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ) );
+ }
+ setPalette( createPalette( aStatus ) );
+}
+
+void RoomStatusIndicatorWidget::currentRoomChanged( Room *aRoom )
+{
+ iDefaultRoomLabel->setText( aRoom->name() );
+}
+
+bool RoomStatusIndicatorWidget::event(QEvent *event)
+{
+ switch(event->type())
+ {
+ case QEvent::Paint:
+ qDebug() << "[RoomStatusIndicatorWidget::event] <Paint event>";
+ break;
+ case QEvent::PaletteChange:
+ qDebug() << "[RoomStatusIndicatorWidget::event] <Palette change event>";
+ break;
+ default:
+ break;
+ }
+
+ return ViewBase::event( event );
}
-\r
-void RoomStatusIndicatorWidget::currentRoomChanged( Room *aRoom )\r
-{\r
- iDefaultRoomLabel->setText( aRoom->name() );\r
-}\r
-\r
-bool RoomStatusIndicatorWidget::event(QEvent *event)\r
-{\r
- switch(event->type())\r
- {\r
- case QEvent::Paint:\r
- qDebug() << "[RoomStatusIndicatorWidget::event] <Paint event>";\r
- break;\r
- case QEvent::PaletteChange:\r
- qDebug() << "[RoomStatusIndicatorWidget::event] <Palette change event>";\r
- break;\r
- default:\r
- break;\r
- }\r
- \r
- return ViewBase::event( event );\r
-}\r
-\r
-void RoomStatusIndicatorWidget::connectionEstablished()\r
-{\r
- \r
- if( !connectedOnce )\r
- {\r
- // Just got the required meetings for the first time\r
- qDebug() << "RoomStatusIndicatorWidget::connectionEstablished() first call";\r
- iDefaultRoomLabel->setHidden( false );\r
- iUntilTextLabel->setHidden( false );\r
- iStatusLabel->setHidden( false );\r
- }\r
- else qDebug() << "RoomStatusIndicatorWidget::connectionEstablished()";\r
- ViewBase::connectionEstablished();\r
- iConnectionLabel->setHidden( true );\r
-}\r
-\r
-void RoomStatusIndicatorWidget::connectionLost()\r
-{\r
- ViewBase::connectionLost();\r
- iConnectionLabel->setHidden( false );\r
-}\r
-\r