Copyright 2010 Comarch S.A.
*******************************************************************************/
+/*!
+ \file XdxfDictDownloadProgressDialog.cpp
+ \brief Shows downloading progress bar.
-//Created by Mateusz Półrola
+ \author Mateusz Półrola <mateusz.polrola@comarch.com>
+*/
#include "XdxfDictDownloadProgressDialog.h"
verticalLayout = new QVBoxLayout(this);
setLayout(verticalLayout);
- setWindowTitle(tr("Downloading dictionary, please wait"));
downloadProgressBar = new QProgressBar(this);
downloadProgressBar->setMinimum(0);
- downloadProgressBar->setMaximum(100);
+ downloadProgressBar->setMaximum(0);
downloadProgressBar->setTextVisible(true);
cancelButton = new QPushButton(tr("Cancel"),this);
-
- downloadTimeLabel = new QLabel(this);
- downloadTimeLabel->hide();
+ connect(cancelButton, SIGNAL(clicked()),
+ this, SIGNAL(cancelDownloading()));
#ifndef Q_WS_MAEMO_5
downloadLabel = new QLabel(this);
- downloadLabel->setText(tr("Downloading dictionary, please wait"));
verticalLayout->addWidget(downloadLabel, 0, Qt::AlignCenter);
#endif
-
- verticalLayout->addWidget(downloadTimeLabel);
verticalLayout->addWidget(downloadProgressBar);
verticalLayout->addWidget(cancelButton);
+ setModal(true);
- connect(cancelButton, SIGNAL(clicked()),
- this, SIGNAL(cancelDownloading()));
+ #ifndef Q_WS_MAEMO_5
+ setMinimumWidth(350);
+ #endif
+}
- time.start();
- setModal(true);
+void XdxfDictDownloadProgressDialog::show() {
+ downloadProgressBar->setMaximum(0);
+ QDialog::show();
}
-void XdxfDictDownloadProgressDialog::reject() {
- return;
+void XdxfDictDownloadProgressDialog::setText(QString text) {
+ setWindowTitle(text);
+ #ifndef Q_WS_MAEMO_5
+ downloadLabel->setText(text);
+ #endif
}
-void XdxfDictDownloadProgressDialog::updateDownloadProgress(int progress,
- int time) {
- if(!downloadTimeLabel->isVisible())
- downloadTimeLabel->show();
- int seconds = float((100 - progress)*time) / (5*1000);
+void XdxfDictDownloadProgressDialog::updateProgress(float progress) {
+ if(downloadProgressBar->maximum() == 0) {
+ downloadProgressBar->setMaximum(100);
+ }
+ downloadProgressBar->setValue(progress*100);
+}
- downloadTimeLabel->setText(tr("Estimated time left: ") +
- tr("%n second(s)", "", seconds));
- if(progress >= 100)
- this->accept();
+
+void XdxfDictDownloadProgressDialog::reject() {
+ #ifndef Q_WS_MAEMO_5
+ Q_EMIT cancelDownloading();
+ #else
+ return;
+ #endif
}