2014-10-12 19:19:43 +00:00
|
|
|
#include "jcestatusbar.h"
|
|
|
|
|
|
|
|
jceStatusBar::jceStatusBar(QWidget *parent) :
|
2014-10-13 03:29:46 +00:00
|
|
|
QStatusBar(parent)
|
2014-10-12 19:19:43 +00:00
|
|
|
{
|
2014-10-13 03:29:46 +00:00
|
|
|
this->setStyleSheet("QStatusBar { border: 0px solid black };");
|
|
|
|
this->setFixedHeight(STATUS_ICON_HEIGH+5);
|
|
|
|
this->showMessage(tr("Ready"));
|
2014-10-12 19:19:43 +00:00
|
|
|
|
|
|
|
|
2014-10-13 03:29:46 +00:00
|
|
|
//Icon
|
|
|
|
iconButtomStatusLabel = new QLabel(this);
|
|
|
|
iconButtomStatusLabel->setAlignment(Qt::AlignHCenter);
|
2014-10-12 19:19:43 +00:00
|
|
|
|
2014-10-13 03:29:46 +00:00
|
|
|
//ProgressBar
|
|
|
|
progressBar = new QProgressBar(this);
|
|
|
|
connect(progressBar,SIGNAL(valueChanged(int)),this,SLOT(setProgressValue(int)));
|
|
|
|
connect(this,SIGNAL(progressHasPacket(int)),this,SLOT(addValueToProgressBar(int)));
|
2014-10-12 19:19:43 +00:00
|
|
|
|
2014-10-13 03:29:46 +00:00
|
|
|
progressBar->setFixedWidth(120);
|
|
|
|
progressBar->setFixedHeight(STATUS_ICON_HEIGH);
|
|
|
|
progressBar->setStyleSheet("QProgressBar {"
|
|
|
|
"border: 1px solid gray;"
|
|
|
|
"border-radius: 3px;"
|
|
|
|
"background: transparent;"
|
|
|
|
"padding: 1px;"
|
|
|
|
"}"
|
|
|
|
"QProgressBar::chunk {"
|
|
|
|
"background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #b4e391 , stop: 1 #61c419);"
|
|
|
|
"}");
|
|
|
|
progressBar->setRange(0,100);
|
|
|
|
progressBar->setValue(0);
|
|
|
|
progressBar->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
|
|
|
progressBar->setTextVisible(true);
|
|
|
|
progressBar->setFormat("%p%");
|
|
|
|
progressBar->setOrientation(Qt::Horizontal);
|
2014-10-12 19:19:43 +00:00
|
|
|
|
|
|
|
|
2014-10-13 03:29:46 +00:00
|
|
|
addPermanentWidget(progressBar,0);
|
|
|
|
addPermanentWidget(iconButtomStatusLabel,0);
|
2014-10-12 19:19:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void jceStatusBar::setIconConnectionStatus(jceProgressStatus update)
|
|
|
|
{
|
2014-10-13 03:29:46 +00:00
|
|
|
QPixmap iconPix;
|
|
|
|
switch (update)
|
2014-10-12 19:19:43 +00:00
|
|
|
{
|
2014-10-13 13:00:58 +00:00
|
|
|
case jceProgressStatus::Error:
|
2014-10-13 03:29:46 +00:00
|
|
|
setProgressValue(0);
|
|
|
|
iconPix.load(":/icons/redStatusIcon.png");
|
|
|
|
showMessage(tr("Error"));
|
|
|
|
break;
|
2014-10-12 19:19:43 +00:00
|
|
|
case jceProgressStatus::Disconnected:
|
2014-10-13 03:29:46 +00:00
|
|
|
setProgressValue(0);
|
|
|
|
iconPix.load(":/icons/redStatusIcon.png");
|
|
|
|
showMessage(tr("Disconnected"));
|
|
|
|
break;
|
2014-10-12 19:19:43 +00:00
|
|
|
case jceProgressStatus::Ready:
|
2014-10-13 03:29:46 +00:00
|
|
|
setProgressValue(0);
|
|
|
|
iconPix.load(":/icons/redStatusIcon.png");
|
|
|
|
showMessage(tr("Ready"));
|
|
|
|
break;
|
2014-10-12 19:19:43 +00:00
|
|
|
case jceProgressStatus::Connecting:
|
2014-10-13 03:29:46 +00:00
|
|
|
setProgressValue(5);
|
|
|
|
iconPix.load(":/icons/blueStatusIcon.png");
|
|
|
|
showMessage(tr("Connecting..."));
|
|
|
|
break;
|
2014-10-12 19:19:43 +00:00
|
|
|
case jceProgressStatus::Sending:
|
2014-10-13 03:29:46 +00:00
|
|
|
if (progressBar->value() < 10)
|
|
|
|
setProgressValue(10);
|
|
|
|
iconPix.load(":/icons/blueStatusIcon.png");
|
|
|
|
showMessage(tr("Sending..."));
|
|
|
|
break;
|
2014-10-12 19:19:43 +00:00
|
|
|
case jceProgressStatus::Recieving:
|
2014-10-13 03:29:46 +00:00
|
|
|
if (progressBar->value() < 15)
|
2014-10-12 22:59:57 +00:00
|
|
|
setProgressValue(15);
|
2014-10-13 03:29:46 +00:00
|
|
|
iconPix.load(":/icons/blueStatusIcon.png");
|
|
|
|
showMessage(tr("Recieving..."));
|
|
|
|
break;
|
|
|
|
case jceProgressStatus::Connected:
|
|
|
|
setProgressValue(30);
|
|
|
|
iconPix.load(":/icons/blueStatusIcon.png");
|
|
|
|
showMessage(tr("Connected"));
|
|
|
|
break;
|
2014-10-12 19:19:43 +00:00
|
|
|
case jceProgressStatus::Inserting:
|
2014-10-13 03:29:46 +00:00
|
|
|
setProgressValue(80);
|
|
|
|
iconPix.load(":/icons/blueStatusIcon.png");
|
|
|
|
showMessage(tr("Inserting"));
|
|
|
|
break;
|
2014-10-12 19:19:43 +00:00
|
|
|
case jceProgressStatus::LoggedIn:
|
2014-10-13 03:29:46 +00:00
|
|
|
setProgressValue(100);
|
|
|
|
iconPix.load(":/icons/greenStatusIcon.png");
|
|
|
|
showMessage(tr("Logged In."));
|
|
|
|
break;
|
2014-10-12 19:19:43 +00:00
|
|
|
case jceProgressStatus::Done:
|
2014-10-13 03:29:46 +00:00
|
|
|
setProgressValue(100);
|
|
|
|
iconPix.load(":/icons/greenStatusIcon.png");
|
|
|
|
showMessage(tr("Done"));
|
|
|
|
break;
|
|
|
|
|
2014-10-12 19:19:43 +00:00
|
|
|
}
|
2014-10-13 03:29:46 +00:00
|
|
|
iconButtomStatusLabel->setPixmap(iconPix);
|
2014-10-12 19:19:43 +00:00
|
|
|
|
2014-10-13 03:29:46 +00:00
|
|
|
repaint();
|
2014-10-12 19:19:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @brief Every time the value changes this method will be called
|
|
|
|
* @param value = the value of the progress Bar
|
|
|
|
*/
|
|
|
|
void jceStatusBar::setProgressValue(int value)
|
|
|
|
{
|
2014-10-13 03:29:46 +00:00
|
|
|
if (value == 0)
|
2014-10-12 19:19:43 +00:00
|
|
|
{
|
2014-10-13 03:29:46 +00:00
|
|
|
progressBar->setVisible(false);
|
|
|
|
progressBar->setValue(0);
|
2014-10-12 19:19:43 +00:00
|
|
|
}
|
2014-10-13 03:29:46 +00:00
|
|
|
else
|
2014-10-12 19:19:43 +00:00
|
|
|
{
|
2014-10-13 03:29:46 +00:00
|
|
|
progressBar->setValue(value);
|
|
|
|
progressBar->setVisible(true);
|
2014-10-12 19:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void jceStatusBar::addValueToProgressBar(int value)
|
|
|
|
{
|
2014-10-13 03:29:46 +00:00
|
|
|
progressBar->setValue(progressBar->value() + value);
|
2014-10-12 19:19:43 +00:00
|
|
|
|
|
|
|
}
|