| 1 |
/* dvbcut |
| 2 |
Copyright (c) 2005 Sven Over <[email protected]> |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU General Public License as published by |
| 6 |
the Free Software Foundation; either version 2 of the License, or |
| 7 |
(at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program; if not, write to the Free Software |
| 16 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 |
*/ |
| 18 |
|
| 19 |
/* $Id$ */ |
| 20 |
|
| 21 |
#ifndef _GNU_SOURCE |
| 22 |
#define _GNU_SOURCE |
| 23 |
#endif |
| 24 |
|
| 25 |
#include <cstdio> |
| 26 |
#include <cstdarg> |
| 27 |
#include <cstdlib> |
| 28 |
#include <qstatusbar.h> |
| 29 |
#include <qprogressbar.h> |
| 30 |
#include <qapplication.h> |
| 31 |
#include <qpushbutton.h> |
| 32 |
#include <qlabel.h> |
| 33 |
#include <qsizepolicy.h> |
| 34 |
#include "progressstatusbar.h" |
| 35 |
|
| 36 |
progressstatusbar::progressstatusbar(QStatusBar *bar) |
| 37 |
: logoutput(), cancelwasclicked(false), statusbar(bar) |
| 38 |
{ |
| 39 |
label=new QLabel(statusbar); |
| 40 |
label->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum)); |
| 41 |
statusbar->addWidget(label,true); |
| 42 |
|
| 43 |
cancelbutton=new QPushButton(statusbar); |
| 44 |
cancelbutton->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); |
| 45 |
cancelbutton->setText(tr("cancel")); |
| 46 |
cancelbutton->setMaximumWidth(80); |
| 47 |
statusbar->addWidget(cancelbutton,true); |
| 48 |
|
| 49 |
progressbar=new QProgressBar(statusbar); |
| 50 |
progressbar->setMaximum(1000); |
| 51 |
progressbar->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum)); |
| 52 |
progressbar->setMinimumWidth(160); |
| 53 |
progressbar->setMaximumWidth(160); |
| 54 |
statusbar->addWidget(progressbar,true); |
| 55 |
|
| 56 |
connect(cancelbutton,SIGNAL(clicked()),SLOT(clickedcancel())); |
| 57 |
progressbar->show(); |
| 58 |
cancelbutton->show(); |
| 59 |
label->show(); |
| 60 |
qApp->processEvents(); |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
progressstatusbar::~progressstatusbar() |
| 65 |
{ |
| 66 |
delete progressbar; |
| 67 |
delete cancelbutton; |
| 68 |
delete label; |
| 69 |
statusbar->clearMessage(); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
void progressstatusbar::setprogress(int permille) |
| 74 |
{ |
| 75 |
if (permille==currentprogress) |
| 76 |
return; |
| 77 |
currentprogress=permille; |
| 78 |
progressbar->setValue(permille); |
| 79 |
qApp->processEvents(); |
| 80 |
} |
| 81 |
|
| 82 |
void progressstatusbar::finish() |
| 83 |
{ |
| 84 |
cancelbutton->setEnabled(false); |
| 85 |
} |
| 86 |
|
| 87 |
void progressstatusbar::clickedcancel() |
| 88 |
{ |
| 89 |
cancelwasclicked=true; |
| 90 |
cancelbutton->setEnabled(false); |
| 91 |
qApp->processEvents(); |
| 92 |
} |
| 93 |
|
| 94 |
void progressstatusbar::print(const QString &str) { |
| 95 |
label->setText(str); |
| 96 |
qApp->processEvents(); |
| 97 |
} |