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"
-XdxfDictDownloadProgressDialog::XdxfDictDownloadProgressDialog(QString title, QWidget*parent):
+XdxfDictDownloadProgressDialog::XdxfDictDownloadProgressDialog(QWidget*parent):
QDialog(parent) {
+#ifndef Q_WS_MAEMO_5
+ view= new QDeclarativeView();
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/XdxfDictDownloader.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+ view->show();
+
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(view);
+ setLayout(mainLayout);
+ view->setWindowTitle(tr("Progres Dialog"));
+
+ QGraphicsObject *rootObject = view->rootObject();
+
+ connect(this, SIGNAL(setValue(QVariant)),
+ rootObject, SLOT(setValue(QVariant)));
+ connect(this, SIGNAL(setTextt(QVariant)),
+ rootObject, SLOT(setText(QVariant)));
+ connect(this, SIGNAL(setMaximumValue(QVariant)),
+ rootObject, SLOT(setMaximumValue(QVariant)));
+
+ connect(rootObject, SIGNAL(cancelDownloading()),
+ this, SIGNAL(cancelDownloading()));
+
+#else
verticalLayout = new QVBoxLayout(this);
setLayout(verticalLayout);
- setWindowTitle(title);
downloadProgressBar = new QProgressBar(this);
downloadProgressBar->setMinimum(0);
downloadProgressBar->setMaximum(0);
downloadProgressBar->setTextVisible(true);
- // cancelButton = new QPushButton(tr("Cancel"),this);
+ cancelButton = new QPushButton(tr("Cancel"),this);
+ connect(cancelButton, SIGNAL(clicked()),
+ this, SIGNAL(cancelDownloading()));
#ifndef Q_WS_MAEMO_5
downloadLabel = new QLabel(this);
- downloadLabel->setText(title);
verticalLayout->addWidget(downloadLabel, 0, Qt::AlignCenter);
#endif
verticalLayout->addWidget(downloadProgressBar);
- //erticalLayout->addWidget(cancelButton);
-
+ verticalLayout->addWidget(cancelButton);
setModal(true);
+
+ #ifndef Q_WS_MAEMO_5
+ setMinimumWidth(350);
+ #endif
+#endif
+}
+
+
+void XdxfDictDownloadProgressDialog::show() {
+#ifndef Q_WS_MAEMO_5
+ emit setMaximumValue(0);
+ maximumValue=0;
+#else
+ downloadProgressBar->setMaximum(0);
+ QDialog::show();
+#endif
+ QDialog::show();
+}
+
+
+void XdxfDictDownloadProgressDialog::setText(QString text) {
+#ifndef Q_WS_MAEMO_5
+ emit setTextt(text);
+#else
+ setWindowTitle(text);
+#endif
+}
+
+
+void XdxfDictDownloadProgressDialog::updateProgress(float progress) {
+#ifndef Q_WS_MAEMO_5
+ if(maximumValue == 0) {
+ emit setMaximumValue(100);
+ }
+ emit setValue((int)(progress*100));
+#else
+ if(downloadProgressBar->maximum() == 0) {
+ downloadProgressBar->setMaximum(100);
+ }
+ downloadProgressBar->setValue(progress*100);
+#endif
}
void XdxfDictDownloadProgressDialog::reject() {
- return;
+ #ifndef Q_WS_MAEMO_5
+ Q_EMIT cancelDownloading();
+ #else
+ return;
+ #endif
}