User interface and menu fixes
[qtmeetings] / src / UserInterface / Views / RoomStatusIndicatorWidget.cpp
index dbc2b07..be37768 100644 (file)
-#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
-       // 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
-\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
-\r
-       QVBoxLayout *topLayout = new QVBoxLayout;\r
-       topLayout->addStretch();\r
-       topLayout->addWidget( iTimeDisplay );\r
-       topLayout->addWidget( iDefaultRoomLabel );\r
-       topLayout->addWidget( iStatusLabel );\r
-       topLayout->addWidget( iUntilTextLabel );\r
-       topLayout->addStretch();\r
-\r
-       QHBoxLayout *mainLayout = new QHBoxLayout;\r
-       mainLayout->addLayout( topLayout );\r
-       mainLayout->addStretch();\r
-       mainLayout->setMargin( 65 );\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
-       // QPixmap pixmap( aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free" );\r
-       QString image = aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free";\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
-               brush.setTexture( QPixmap(image) );\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
-               brush.setTexture( QPixmap(image) );\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 "BorderedBarWidget.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 clockFont;
+       clockFont.setStyleHint( QFont::Helvetica );
+       clockFont.setBold( true );
+       clockFont.setPixelSize( 36 );
+
+       QFont textFont;
+       textFont.setStyleHint( QFont::Helvetica );
+       textFont.setBold( true );
+       textFont.setPixelSize( 48 );
+
+       QFont statusBarFont;
+       statusBarFont.setStyleHint( QFont::Helvetica );
+       statusBarFont.setPixelSize( 18 );
+
+       // display for current time
+       // Note: the time display receives current time info from Engine::clock()
+       iTimeDisplay = new BorderedBarWidget( this );
+       iTimeDisplay->setFaceColor( Qt::darkGray );
+       iTimeDisplay->setBackgroundColor( Qt::white );
+       iTimeDisplay->setBorderWidth( 6 );
+       iTimeDisplay->setFixedWidth( 170 );
+       iTimeDisplay->setFixedHeight( 50 );
+       iTimeDisplay->setFont( clockFont );
+
+       iStatusBar = new BorderedBarWidget( this );
+       iStatusBar->setFaceColor( Qt::darkGray );
+       iStatusBar->setBackgroundColor( Qt::white );
+       iStatusBar->setBorderWidth( 4 );
+       iStatusBar->setFont(statusBarFont);
+       iStatusBar->setFixedHeight( 36 );
+       iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign );
+
+       // Pegasus
+       iDefaultRoomLabel
+                       = ToolBox::createLabel(aDefaultRoom->name(), textFont);
+       iDefaultRoomLabel->setAlignment( Qt::AlignHCenter );
+       iDefaultRoomLabel->setHidden( true );
+
+       // is busy
+       iStatusLabel = ToolBox::createLabel(tr( "is %1" ).arg(statusToText(aStatus) ), textFont);
+       iStatusLabel->setAlignment( Qt::AlignHCenter );
+       iStatusLabel->setHidden( true );
+
+       // until 13:22
+       iUntilTextLabel
+                       = ToolBox::createLabel(tr( "until %1" ).arg(aUntil.toString(iTimeFormat) ), textFont);
+       iUntilTextLabel->setAlignment( Qt::AlignHCenter );
+       iUntilTextLabel->setHidden( true );
+
+       QHBoxLayout *topLayout = new QHBoxLayout;
+       topLayout->addWidget(iTimeDisplay);
+
+       QVBoxLayout *textLayout = new QVBoxLayout;
+       textLayout->addWidget(iDefaultRoomLabel);
+       textLayout->addWidget(iStatusLabel);
+       textLayout->addWidget(iUntilTextLabel);
+       textLayout->addSpacing( 250 );
+
+       QHBoxLayout *centerLayout = new QHBoxLayout;
+       centerLayout->addLayout( textLayout );
+       centerLayout->addSpacing( 250 );
+
+       QHBoxLayout *bottomLayout = new QHBoxLayout;
+       bottomLayout->addSpacing( 56 );
+       bottomLayout->addWidget( iStatusBar );
+       bottomLayout->addSpacing( 56 );
+
+       QVBoxLayout *mainLayout = new QVBoxLayout;
+       mainLayout->addLayout( topLayout );
+       mainLayout->addSpacing( 50 );
+       mainLayout->addLayout( centerLayout );
+       mainLayout->addLayout( bottomLayout );
+       setLayout(mainLayout);
+
+       statusChanged(aStatus, aUntil);
+
+       QPalette palette;
+       palette.setColor( QPalette::Window, Qt::white );
+       palette.setColor( QPalette::WindowText, Qt::darkGray );
+       setPalette( palette );
+
+       setAutoFillBackground( true );
+       setFocusPolicy(Qt::StrongFocus);
+       setEnabled( true); // enable mouse & key events
+}
+
+RoomStatusIndicatorWidget::~RoomStatusIndicatorWidget()
+{
+       delete iTimeDisplay;
+       iTimeDisplay = 0;
+
+       delete iStatusBar;
+       iStatusBar = 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 ( (pixmap.width() == rect().width()) && (pixmap.height() == rect().height()) )
+       {
+               // 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.setColor( QPalette::Window, Qt::white );
+       palette.setColor( QPalette::WindowText, Qt::black );
+       palette.setBrush( QPalette::Window, brush );
+       return palette;
+}
+
+void RoomStatusIndicatorWidget::setConnectionStatus( QDateTime aCurrentTime, bool aConnected,
+               QTime aLastUpdated, QString aError )
+{
+       iTimeDisplay->setText( aCurrentTime.toString( iTimeFormat ) );
+       if ( aLastUpdated.isNull() )
+               iStatusBar->setText( tr("Disconnected") , BorderedBarWidget::LeftAlign );
+       else
+       {
+               iDefaultRoomLabel->setHidden( false );
+               iUntilTextLabel->setHidden( false );
+               iStatusLabel->setHidden( false );
+
+               if (!aConnected)
+               {
+                       iStatusBar->setText( tr("Disconnected").arg(aLastUpdated.toString(iTimeFormat))
+                                       , BorderedBarWidget::LeftAlign );
+               }
+               else
+               {
+                       iStatusBar->setText( tr("Connected - Last update %1").arg(aLastUpdated.toString(iTimeFormat)) ,
+                                       BorderedBarWidget::LeftAlign );
+               }
+       }
+       showError( aError );
+}
+
+void RoomStatusIndicatorWidget::showError( QString aError )
+{
+       iStatusBar->setText( aError );
+}
+
+
+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);
+}
+
+void RoomStatusIndicatorWidget::connectionEstablished()
+{
+       ViewBase::connectionEstablished();
+}
+
+void RoomStatusIndicatorWidget::connectionLost()
+{
+       ViewBase::connectionLost();
 }
-\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