1.0.6 candidate
[qtmeetings] / src / UserInterface / Views / RoomStatusIndicatorWidget.cpp
index ebe2a90..2ee240e 100644 (file)
@@ -3,7 +3,8 @@
 #include <QLabel>
 #include <QFont>
 #include <QVBoxLayout>
-#include "DigitalTimeDisplayWidget.h"
+#include "BorderedBarWidget.h"
+
 #include "ToolBox.h"
 
 #include <QEvent>
@@ -15,68 +16,78 @@ 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 clockFont;
+       clockFont.setStyleHint( QFont::Helvetica );
+       clockFont.setBold( true );
+       clockFont.setPixelSize( 36 );
+
+       QFont textFont;
+       textFont.setStyleHint( QFont::Helvetica );
+       textFont.setBold( true );
+       textFont.setPixelSize( 48 );
 
-       QFont regularTextFont;
-       //regularTextFont.setBold( true );
-       regularTextFont.setPointSize( 12);
+       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 DigitalTimeDisplayWidget( QTime::currentTime(), iTimeFormat, this );
-       iTimeDisplay->setFrameVisible( false);
-       iTimeDisplay->setSize( 250, 120);
+       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(), importantTextFont);
-       iDefaultRoomLabel->setAlignment(Qt::AlignHCenter);
-       iDefaultRoomLabel->setHidden( true);
+                       = ToolBox::createLabel(aDefaultRoom->name(), textFont);
+       iDefaultRoomLabel->setAlignment( Qt::AlignHCenter );
+       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);
+       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) ), 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();
+                       = ToolBox::createLabel(tr( "until %1" ).arg(aUntil.toString(iTimeFormat) ), textFont);
+       iUntilTextLabel->setAlignment( Qt::AlignHCenter );
+       iUntilTextLabel->setHidden( true );
+
+       QHBoxLayout *topLayout = new QHBoxLayout;
        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);
+
+       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);
@@ -95,6 +106,9 @@ RoomStatusIndicatorWidget::~RoomStatusIndicatorWidget()
 {
        delete iTimeDisplay;
        iTimeDisplay = 0;
+
+       delete iStatusBar;
+       iStatusBar = 0;
 }
 
 QString RoomStatusIndicatorWidget::statusToText(const Room::Status aStatus)
@@ -116,7 +130,7 @@ QPalette RoomStatusIndicatorWidget::createPalette(Room::Status aStatus)
        int cropheight(pixmap.height() - yoffset);
 
        QBrush brush;
-       if (windowState() == Qt::WindowFullScreen)
+       if ( (pixmap.width() == rect().width()) && (pixmap.height() == rect().height()) )
        {
                // Use the full image in full screen mode
                brush.setTexture(pixmap);
@@ -130,16 +144,42 @@ QPalette RoomStatusIndicatorWidget::createPalette(Room::Status aStatus)
 
        QPalette palette;
        palette.setColor( QPalette::Window, Qt::white );
-       palette.setColor( QPalette::WindowText, Qt::darkGray );
+       palette.setColor( QPalette::WindowText, Qt::black );
        palette.setBrush( QPalette::Window, brush );
        return palette;
 }
 
-void RoomStatusIndicatorWidget::setCurrentTime(QTime aCurrentTime)
+void RoomStatusIndicatorWidget::setConnectionStatus( QDateTime aCurrentTime, bool aConnected,
+               QTime aLastUpdated, QString aError )
 {
-       iTimeDisplay->setTime(aCurrentTime);
+       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"), 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) ) );
@@ -164,11 +204,11 @@ bool RoomStatusIndicatorWidget::event(QEvent *event)
        switch (event->type())
        {
                case QEvent::Paint:
-                       qDebug() << "[RoomStatusIndicatorWidget::event] <Paint event>";
+                       //qDebug() << "[RoomStatusIndicatorWidget::event] <Paint event>";
                        break;
                case QEvent::PaletteChange:
-                       qDebug()
-                                       << "[RoomStatusIndicatorWidget::event] <Palette change event>";
+                       //qDebug()
+                       //              << "[RoomStatusIndicatorWidget::event] <Palette change event>";
                        break;
                default:
                        break;
@@ -179,24 +219,10 @@ bool RoomStatusIndicatorWidget::event(QEvent *event)
 
 void RoomStatusIndicatorWidget::connectionEstablished()
 {
-       if ( !connectedOnce)
-       { 
-               // Just got the required meetings for the first time              
-               qDebug() << "RoomStatusIndicatorWidget::connectionEstablished() first call";
-               iDefaultRoomLabel->setHidden( false);
-               iUntilTextLabel->setHidden( false);
-               iStatusLabel->setHidden( false);
-       }
-       else
-       {
-               qDebug() << "RoomStatusIndicatorWidget::connectionEstablished()";
-       }
        ViewBase::connectionEstablished();
-       iConnectionLabel->setHidden( true);
 }
 
 void RoomStatusIndicatorWidget::connectionLost()
 {
        ViewBase::connectionLost();
-       iConnectionLabel->setHidden( false);
 }