19 #include <tqtooltip.h>
21 #include <tqwidgetstack.h>
22 #include <tqpushbutton.h>
25 #include <tdeapplication.h>
26 #include <tdelocale.h>
28 #include <kprogress.h>
30 #include "jobclasses.h"
31 #include "statusbarprogress.h"
38 m_bShowButton = button;
43 setStopOnClose(
false);
45 int w = fontMetrics().width(
" 999.9 kB/s 00:00:01 " ) + 8;
46 box =
new TQHBoxLayout(
this, 0, 0 );
48 m_pButton =
new TQPushButton(
"X",
this );
49 box->addWidget( m_pButton );
50 stack =
new TQWidgetStack(
this );
51 box->addWidget( stack );
52 connect( m_pButton, TQT_SIGNAL( clicked() ),
this, TQT_SLOT(
slotStop() ) );
54 m_pProgressBar =
new KProgress(
this );
55 m_pProgressBar->setFrameStyle( TQFrame::Box | TQFrame::Raised );
56 m_pProgressBar->setLineWidth( 1 );
57 m_pProgressBar->setBackgroundMode( TQWidget::PaletteBackground );
58 m_pProgressBar->installEventFilter(
this );
59 m_pProgressBar->setMinimumWidth( w );
60 stack->addWidget( m_pProgressBar, 1 );
62 m_pLabel =
new TQLabel(
"",
this );
63 m_pLabel->setAlignment( AlignHCenter | AlignVCenter );
64 m_pLabel->installEventFilter(
this );
65 m_pLabel->setMinimumWidth( w );
66 stack->addWidget( m_pLabel, 2 );
67 setMinimumSize( sizeHint() );
83 void StatusbarProgress::setMode() {
86 if ( m_bShowButton ) {
93 if ( m_bShowButton ) {
97 stack->raiseWidget( m_pLabel );
101 if ( m_bShowButton ) {
105 stack->raiseWidget( m_pProgressBar );
111 void StatusbarProgress::slotClean() {
113 m_pProgressBar->setValue( 0 );
125 void StatusbarProgress::slotPercent(
TDEIO::Job*,
unsigned long percent ) {
126 m_pProgressBar->setValue( percent );
130 void StatusbarProgress::slotSpeed(
TDEIO::Job*,
unsigned long speed ) {
132 m_pLabel->setText( i18n(
" Stalled ") );
139 bool StatusbarProgress::eventFilter( TQObject *, TQEvent *ev ) {
144 if ( ev->type() == TQEvent::MouseButtonPress ) {
145 TQMouseEvent *e = (TQMouseEvent*)ev;
147 if ( e->button() == Qt::LeftButton ) {
148 if ( mode == Label ) {
150 }
else if ( mode == Progress ) {
162 void StatusbarProgress::virtual_hook(
int id,
void* data )
163 { ProgressBase::virtual_hook(
id, data ); }
166 #include "statusbarprogress.moc"
TDEIO_EXPORT TQString convertSize(TDEIO::filesize_t size)
Converts size from bytes to the string representation.
This class does all initialization stuff for progress, like connecting signals to slots...
TQ_ULLONG filesize_t
64-bit file size
StatusbarProgress(TQWidget *parent, bool button=true)
Creates a new StatusbarProgress.
A namespace for TDEIO globals.
void setJob(TDEIO::Job *job)
Sets the job to monitor.
The base class for all jobs.
void setOnlyClean(bool onlyClean)
This controls whether the dialog should be deleted or only cleaned when the TDEIO::Job is finished (o...
void slotStop()
This method should be called for correct cancellation of IO operation Connect this to the progress wi...
void setJob(TDEIO::Job *job)
Assign a TDEIO::Job to this progress dialog.