#include "hddStatus.h" HDDStatus::HDDStatus() { // Create the grid layout and the main layout. QGridLayout* hLayout = new QGridLayout; layout = new QVBoxLayout; // Create the labels for the text boxes. hddLabels[ESPEED] = new QLabel( tr( "Estimated Rec. Speed:" ) ); hddLabels[ASPEED] = new QLabel( tr( "Actual Rec. Speed:" ) ); hddLabels[TSPACE] = new QLabel( tr( "Total HDD Space:" ) ); hddLabels[FSPACE] = new QLabel( tr( "Free HDD Space:" ) ); hddLabels[RTIME] = new QLabel( tr( "Remaining Time:" ) ); progBarLabel = new QLabel( tr( "Last 2 Hours:" ) ); // Create the text boxes. for( int i = 0; i < numHDD; ++i ) { hddLines[i] = new QLineEdit( "-1" ); hddLines[i]->setReadOnly( true ); hddLines[i]->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); } // Create the bar graph to show the time remaining, when under 2 hours. pBar = new QProgressBar; pBar->setMinimum( 0 ); pBar->setMaximum( 120 ); pBar->setValue( 120 ); pBar->setStyleSheet( "QProgressBar::chunk { background-color: green; } QProgressBar { text-align: center; }" ); //pBar->setStyleSheet( "QProgressBar { text-align: center }" ); // Set the tooltips. hddLines[RTIME]->setToolTip( "Calculated using actual recording speed" ); pBar->setToolTip( "Full bar = 2 or more hours" ); // Place the objects into the grid layout. hLayout->addWidget( hddLabels[ESPEED], 1, 0 ); hLayout->addWidget( hddLines[ESPEED], 1, 1 ); hLayout->addWidget( hddLabels[ASPEED], 2, 0 ); hLayout->addWidget( hddLines[ASPEED], 2, 1 ); hLayout->addWidget( hddLabels[TSPACE], 3, 0 ); hLayout->addWidget( hddLines[TSPACE], 3, 1 ); hLayout->addWidget( hddLabels[FSPACE], 4, 0 ); hLayout->addWidget( hddLines[FSPACE], 4, 1 ); hLayout->addWidget( hddLabels[RTIME], 5, 0 ); hLayout->addWidget( hddLines[RTIME], 5, 1 ); hLayout->addWidget( progBarLabel, 6, 0 ); hLayout->addWidget( pBar, 6, 1 ); // Set the main layout. layout->addLayout( hLayout ); } HDDStatus::~HDDStatus() { } QGroupBox* HDDStatus::getGroupBox( QString title ) { // Create the group box, title it, and set the layout. hBox = new QGroupBox( tr( title.toStdString().c_str() ) ); hBox->setLayout( layout ); //hBox->setFixedHeight( 150 ); // Will comment out later when more status fields are added. return hBox; } void HDDStatus::setEstRec( QString msg ) { hddLines[ESPEED]->setText( msg ); } void HDDStatus::showWindow() { } void HDDStatus::setInfo( double aRec, double total, double free, int remaining ) { // Put the doubles into QStrings. QString aR, t, f, r, hour, sec; aR.setNum( aRec, 'f', 1 ); t.setNum( total, 'f', 1 ); f.setNum( free, 'f', 1 ); hour.setNum( (int)remaining / 60 ); sec.setNum( (int)remaining % 60 ); r = hour + ":" + sec; // Set the fields to use the strings. hddLines[ASPEED]->setText( aR ); hddLines[TSPACE]->setText( t ); hddLines[FSPACE]->setText( f ); hddLines[RTIME]->setText( r ); // Change the progress bar, if needed. if( remaining <= 120 ) { pBar->setValue( remaining ); if( ( remaining <= 60 ) && ( remaining > 30 ) ) { pBar->setStyleSheet( "QProgressBar::chunk { background-color: yellow; } QProgressBar { text-align: center; }" ); } else if( remaining <= 30 ) { pBar->setStyleSheet( "QProgressBar::chunk { background-color: red; } QProgressBar { text-align: center; }" ); } else { pBar->setStyleSheet( "QProgressBar::chunk { background-color: green; } QProgressBar { text-align: center; }" ); } } else { pBar->setValue( 120 ); pBar->setStyleSheet( "QProgressBar::chunk { background-color: green; } QProgressBar { text-align: center; }" ); } }