From d2eac1cb69f359e28330fa1c434aa4ad1cc31d06 Mon Sep 17 00:00:00 2001 From: ruglory Date: Tue, 27 Jan 2009 01:14:48 +0000 Subject: [PATCH] Estimated and elapsed time updated on progress dialog git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@19 cac9541e-1b8d-4bfa-827e-589bba606050 --- NEWS | 6 +++--- src/qdialogprint.cpp | 20 ++++++++++++++++++ src/qdialogprint.h | 20 ++++++++++++++++++ src/qdialogprogress.cpp | 47 +++++++++++++++++++++++++++++++++++++++-- src/qdialogprogress.h | 25 ++++++++++++++++++++++ src/qdialogprogress.ui | 11 +++++++++- src/qlscribe.pro | 1 + 7 files changed, 124 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index ba912ef..64bb88b 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ NEWS - list of user-visible changes between releases of qlscribe -New in 0.1: -* First release of qlscribe -* * +New in 0.1: + Open/save as implemented. Text, round text and image items can be inserted and edited + Print preview and print is working (no exclusive lock or tray lock on printing yet) diff --git a/src/qdialogprint.cpp b/src/qdialogprint.cpp index f785876..9d030e4 100644 --- a/src/qdialogprint.cpp +++ b/src/qdialogprint.cpp @@ -1,3 +1,23 @@ +/* qlscribe - Qt based application to print lightScribe discs + + Copyright (C) 2009 Vyacheslav Kononenko + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + $Id$ */ + #include "qdialogprint.h" #include "ui_qdialogprint.h" diff --git a/src/qdialogprint.h b/src/qdialogprint.h index 92364ae..a0ef102 100644 --- a/src/qdialogprint.h +++ b/src/qdialogprint.h @@ -1,3 +1,23 @@ +/* qlscribe - Qt based application to print lightScribe discs + + Copyright (C) 2009 Vyacheslav Kononenko + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + $Id$ */ + #ifndef QDIALOGPRINT_H #define QDIALOGPRINT_H diff --git a/src/qdialogprogress.cpp b/src/qdialogprogress.cpp index e3c02ac..e141a6b 100644 --- a/src/qdialogprogress.cpp +++ b/src/qdialogprogress.cpp @@ -1,3 +1,23 @@ +/* qlscribe - Qt based application to print lightScribe discs + + Copyright (C) 2009 Vyacheslav Kononenko + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + $Id$ */ + #include "qdialogprogress.h" #include "ui_qdialogprogress.h" #include "qlightscribe.h" @@ -5,17 +25,26 @@ #include #include +#include +#include QDialogProgress::QDialogProgress(QWidget *parent) : QDialog(parent), - m_ui(new Ui::QDialogProgress) + m_ui(new Ui::QDialogProgress), + m_start( new QTime ), + m_timer( new QTimer( this ) ) { m_ui->setupUi(this); + m_start->start(); + connect( m_timer, SIGNAL(timeout()), this, SLOT(onTimeout()) ); + m_timer->start( 500 ); } QDialogProgress::~QDialogProgress() { - delete m_ui; + delete m_start; + delete m_timer; + delete m_ui; } void QDialogProgress::changeEvent(QEvent *e) @@ -75,14 +104,28 @@ void QDialogProgress::onLabelProgress( long current, long final ) { m_ui->progressPrinting->setMaximum( final ); m_ui->progressPrinting->setValue( current ); + + if( current && double( current ) / final > 0.1 ) { + int elapsed = m_start->elapsed(); + int estimate = double( elapsed ) / current * final; + m_ui->timeEstimated->setTime( QTime().addMSecs( estimate ) ); + } } void QDialogProgress::onTimeEstimate( long time ) { + m_ui->timeEstimated->setTime( QTime().addSecs( time ) ); } void QDialogProgress::onFinished(int status ) { + m_timer->stop(); + m_ui->progressPrinting->setValue( m_ui->progressPrinting->maximum() ); m_ui->lineResult->setText( status ? tr( "Failed - error code: 0x" ) + QString::number( status, 16 ) : tr( "Success" ) ); m_ui->buttonBox->setStandardButtons( QDialogButtonBox::Close ); } + +void QDialogProgress::onTimeout() +{ + m_ui->timeElapsed->setTime( QTime().addMSecs( m_start->elapsed() ) ); +} diff --git a/src/qdialogprogress.h b/src/qdialogprogress.h index f5179bf..bf4ce93 100644 --- a/src/qdialogprogress.h +++ b/src/qdialogprogress.h @@ -1,3 +1,23 @@ +/* qlscribe - Qt based application to print lightScribe discs + + Copyright (C) 2009 Vyacheslav Kononenko + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + $Id$ */ + #ifndef QDIALOGPROGRESS_H #define QDIALOGPROGRESS_H @@ -9,6 +29,8 @@ namespace Ui { class QCDScene; class QAbstractButton; +class QTime; +class QTimer; class QDialogProgress : public QDialog { Q_OBJECT @@ -22,6 +44,7 @@ protected slots: void onLabelProgress( long current, long final ); void onTimeEstimate( long time ); void onFinished(int status ); + void onTimeout(); protected: virtual void changeEvent(QEvent *e); @@ -31,6 +54,8 @@ private: virtual ~QDialogProgress(); Ui::QDialogProgress *m_ui; + QTime *m_start; + QTimer *m_timer; }; #endif // QDIALOGPROGRESS_H diff --git a/src/qdialogprogress.ui b/src/qdialogprogress.ui index e191035..4aa249b 100644 --- a/src/qdialogprogress.ui +++ b/src/qdialogprogress.ui @@ -10,7 +10,7 @@ - Dialog + Print progress @@ -85,6 +85,9 @@ hh:mm:ss + + 0 + @@ -172,6 +175,12 @@ + + buttonBox + lineResult + timeEstimated + timeElapsed + diff --git a/src/qlscribe.pro b/src/qlscribe.pro index 2b183ac..04d7238 100644 --- a/src/qlscribe.pro +++ b/src/qlscribe.pro @@ -1,6 +1,7 @@ TEMPLATE = app LANGUAGE = C++ CONFIG += qt +INCLUDEPATH += ../build/src QMAKE_CXXFLAGS += -m32 QMAKE_LFLAGS += -m32 QMAKE_LIBDIR = /usr/lib32