Commit ddada14e authored by Dennis Rassmann's avatar Dennis Rassmann

flasher: add extract progress bar

Signed-off-by: Dennis Rassmann's avatarshowp1984 <showp1984@gmail.com>
parent be2d7fbd
......@@ -24,6 +24,12 @@ flasher::flasher(QWidget *parent) :
ui->bar_flash->setMinimum(0);
ui->bar_flash->setMaximum(90);
ui->bar_flash->setValue(0);
ui->bar_extract->hide();
ui->bar_extract->setMinimum(0);
ui->bar_extract->setMaximum(100);
ui->bar_extract->setValue(0);
ui->txt_out->hide();
}
......@@ -123,6 +129,8 @@ void flasher::on_txt_out_textChanged()
bool flasher::extract_zip(const QString & filePath, const QString & extDirPath, const QString & singleFileName = QString(""))
{
ui->bar_extract->show();
QuaZip zip(filePath);
if (!zip.open(QuaZip::mdUnzip)) {
......@@ -147,6 +155,8 @@ bool flasher::extract_zip(const QString & filePath, const QString & extDirPath,
QStringList splitpath = QStringList() << "" << "" << "" << "" << "" << "" << "" << "" << "" << "" << "" << "" << "" << "";
QByteArray cnt;
QDir filedir;
int filenr = 0;
ui->bar_extract->setMaximum(zip.getEntriesCount());
for (bool more = zip.goToFirstFile(); more; more = zip.goToNextFile()) {
if (!zip.getCurrentFileInfo(&info)) {
qWarning("testRead(): getCurrentFileInfo(): %d\n", zip.getZipError());
......@@ -199,6 +209,8 @@ bool flasher::extract_zip(const QString & filePath, const QString & extDirPath,
qWarning("testRead(): file.close(): %d", file.getZipError());
return false;
}
ui->bar_extract->setValue(filenr);
filenr++;
}
zip.close();
if (zip.getZipError() != UNZ_OK) {
......@@ -297,8 +309,10 @@ int flasher::extract(void)
if (!xtr_return) {
ui->txt_out->append("Error! Could not extract zip file.");
return RELEASE_CONTROLS;
} else {
ui->txt_out->append("Successfully extracted zip file.");
}
ui->bar_extract->hide();
//QDir().rmdir(tmp_folder);
//ui->txt_out->append("Deleted temporary directory: " + tmp_folder);
//skip to detect
......
......@@ -187,6 +187,25 @@ p, li { white-space: pre-wrap; }
<bool>true</bool>
</property>
</widget>
<widget class="QProgressBar" name="bar_extract">
<property name="geometry">
<rect>
<x>200</x>
<y>440</y>
<width>421</width>
<height>23</height>
</rect>
</property>
<property name="value">
<number>0</number>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="format">
<string>Extracting... %p%</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
......
/********************************************************************************
** Form generated from reading UI file 'flasher.ui'
**
** Created: Mon Jul 2 01:03:12 2012
** Created: Mon Jul 2 04:54:39 2012
** by: Qt User Interface Compiler version 4.6.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
......@@ -42,6 +42,7 @@ public:
QTextEdit *txt_out;
QLabel *lbl_filepath;
QLineEdit *edt_filepath;
QProgressBar *bar_extract;
QMenuBar *menubar;
QMenu *menuFile;
QMenu *menuHelp;
......@@ -103,6 +104,11 @@ public:
edt_filepath->setSizePolicy(sizePolicy);
edt_filepath->setCursor(QCursor(Qt::IBeamCursor));
edt_filepath->setReadOnly(true);
bar_extract = new QProgressBar(centralwidget);
bar_extract->setObjectName(QString::fromUtf8("bar_extract"));
bar_extract->setGeometry(QRect(200, 440, 421, 23));
bar_extract->setValue(0);
bar_extract->setInvertedAppearance(false);
flasher->setCentralWidget(centralwidget);
menubar = new QMenuBar(flasher);
menubar->setObjectName(QString::fromUtf8("menubar"));
......@@ -143,6 +149,7 @@ public:
"</style></head><body style=\" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"></p></body></html>", 0, QApplication::UnicodeUTF8));
lbl_filepath->setText(QApplication::translate("flasher", "From:", 0, QApplication::UnicodeUTF8));
bar_extract->setFormat(QApplication::translate("flasher", "Extracting... %p%", 0, QApplication::UnicodeUTF8));
menuFile->setTitle(QApplication::translate("flasher", "File", 0, QApplication::UnicodeUTF8));
menuHelp->setTitle(QApplication::translate("flasher", "Help", 0, QApplication::UnicodeUTF8));
} // retranslateUi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment