From cb696906f4903619f294196d8b15287cf3f8ef4a Mon Sep 17 00:00:00 2001 From: liranbg Date: Mon, 13 Oct 2014 06:29:46 +0300 Subject: [PATCH] fixed progress bar on login session --- main/LoginTab/loginhandler.cpp | 1 - main/jceWidgets/jcestatusbar.cpp | 173 ++++++++++++++++--------------- 2 files changed, 87 insertions(+), 87 deletions(-) diff --git a/main/LoginTab/loginhandler.cpp b/main/LoginTab/loginhandler.cpp index be98d0a..c1f0108 100644 --- a/main/LoginTab/loginhandler.cpp +++ b/main/LoginTab/loginhandler.cpp @@ -59,7 +59,6 @@ bool loginHandler::makeConnection() { case jceLogin::JCE_YOU_ARE_IN: { - statusBar->setIconConnectionStatus(jceStatusBar::LoggedIn); logggedInFlag = true; return logggedInFlag; } diff --git a/main/jceWidgets/jcestatusbar.cpp b/main/jceWidgets/jcestatusbar.cpp index 45c978d..0127f2c 100644 --- a/main/jceWidgets/jcestatusbar.cpp +++ b/main/jceWidgets/jcestatusbar.cpp @@ -1,107 +1,108 @@ #include "jcestatusbar.h" jceStatusBar::jceStatusBar(QWidget *parent) : - QStatusBar(parent) + QStatusBar(parent) { - this->setStyleSheet("QStatusBar { border: 0px solid black };"); - this->setFixedHeight(STATUS_ICON_HEIGH+5); - this->showMessage(tr("Ready")); + this->setStyleSheet("QStatusBar { border: 0px solid black };"); + this->setFixedHeight(STATUS_ICON_HEIGH+5); + this->showMessage(tr("Ready")); - //Icon - iconButtomStatusLabel = new QLabel(this); - iconButtomStatusLabel->setAlignment(Qt::AlignHCenter); + //Icon + iconButtomStatusLabel = new QLabel(this); + iconButtomStatusLabel->setAlignment(Qt::AlignHCenter); - //ProgressBar - progressBar = new QProgressBar(this); - connect(progressBar,SIGNAL(valueChanged(int)),this,SLOT(setProgressValue(int))); - connect(this,SIGNAL(progressHasPacket(int)),this,SLOT(addValueToProgressBar(int))); + //ProgressBar + progressBar = new QProgressBar(this); + connect(progressBar,SIGNAL(valueChanged(int)),this,SLOT(setProgressValue(int))); + connect(this,SIGNAL(progressHasPacket(int)),this,SLOT(addValueToProgressBar(int))); - 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); + 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); - addPermanentWidget(progressBar,0); - addPermanentWidget(iconButtomStatusLabel,0); + addPermanentWidget(progressBar,0); + addPermanentWidget(iconButtomStatusLabel,0); } void jceStatusBar::setIconConnectionStatus(jceProgressStatus update) { - QPixmap iconPix; - switch (update) + QPixmap iconPix; + switch (update) { case jceProgressStatus::ERROR: - setProgressValue(0); - iconPix.load(":/icons/redStatusIcon.png"); - showMessage(tr("Error")); - break; + setProgressValue(0); + iconPix.load(":/icons/redStatusIcon.png"); + showMessage(tr("Error")); + break; case jceProgressStatus::Disconnected: - setProgressValue(0); - iconPix.load(":/icons/redStatusIcon.png"); - showMessage(tr("Disconnected")); - break; + setProgressValue(0); + iconPix.load(":/icons/redStatusIcon.png"); + showMessage(tr("Disconnected")); + break; case jceProgressStatus::Ready: - setProgressValue(0); - iconPix.load(":/icons/redStatusIcon.png"); - showMessage(tr("Ready")); - break; + setProgressValue(0); + iconPix.load(":/icons/redStatusIcon.png"); + showMessage(tr("Ready")); + break; case jceProgressStatus::Connecting: - setProgressValue(5); - iconPix.load(":/icons/blueStatusIcon.png"); - showMessage(tr("Connecting...")); - break; + setProgressValue(5); + iconPix.load(":/icons/blueStatusIcon.png"); + showMessage(tr("Connecting...")); + break; case jceProgressStatus::Sending: - if (progressBar->value() < 10) - setProgressValue(10); - iconPix.load(":/icons/blueStatusIcon.png"); - showMessage(tr("Sending...")); - break; + if (progressBar->value() < 10) + setProgressValue(10); + iconPix.load(":/icons/blueStatusIcon.png"); + showMessage(tr("Sending...")); + break; case jceProgressStatus::Recieving: - if (progressBar->value() < 15) + if (progressBar->value() < 15) setProgressValue(15); - iconPix.load(":/icons/blueStatusIcon.png"); - showMessage(tr("Recieving...")); - break; - case jceProgressStatus::Inserting: - setProgressValue(80); - iconPix.load(":/icons/blueStatusIcon.png"); - showMessage(tr("Inserting")); - break; - case jceProgressStatus::LoggedIn: - setProgressValue(100); - iconPix.load(":/icons/greenStatusIcon.png"); - showMessage(tr("Logged In.")); - break; - case jceProgressStatus::Done: - setProgressValue(100); - iconPix.load(":/icons/greenStatusIcon.png"); - showMessage(tr("Done")); - break; + iconPix.load(":/icons/blueStatusIcon.png"); + showMessage(tr("Recieving...")); + break; case jceProgressStatus::Connected: - setProgressValue(100); - iconPix.load(":/icons/greenStatusIcon.png"); - showMessage(tr("Connected")); - break; - } - iconButtomStatusLabel->setPixmap(iconPix); + setProgressValue(30); + iconPix.load(":/icons/blueStatusIcon.png"); + showMessage(tr("Connected")); + break; + case jceProgressStatus::Inserting: + setProgressValue(80); + iconPix.load(":/icons/blueStatusIcon.png"); + showMessage(tr("Inserting")); + break; + case jceProgressStatus::LoggedIn: + setProgressValue(100); + iconPix.load(":/icons/greenStatusIcon.png"); + showMessage(tr("Logged In.")); + break; + case jceProgressStatus::Done: + setProgressValue(100); + iconPix.load(":/icons/greenStatusIcon.png"); + showMessage(tr("Done")); + break; - repaint(); + } + iconButtomStatusLabel->setPixmap(iconPix); + + repaint(); } /** @@ -110,21 +111,21 @@ void jceStatusBar::setIconConnectionStatus(jceProgressStatus update) */ void jceStatusBar::setProgressValue(int value) { - if (value == 0) + if (value == 0) { - progressBar->setVisible(false); - progressBar->setValue(0); + progressBar->setVisible(false); + progressBar->setValue(0); } - else + else { - progressBar->setValue(value); - progressBar->setVisible(true); + progressBar->setValue(value); + progressBar->setVisible(true); } } void jceStatusBar::addValueToProgressBar(int value) { - progressBar->setValue(progressBar->value() + value); + progressBar->setValue(progressBar->value() + value); }