summaryrefslogtreecommitdiffstats
path: root/src/part/progressBox.cpp
blob: cd4f789f74e2a9daa86b1aab6a41332b8c33f830 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//Author:    Max Howell <[email protected]>, (C) 2003-4
//Copyright: See COPYING file that comes with this distribution

#include <kglobal.h>
#include <kglobalsettings.h>
#include <tdeio/job.h>
#include <klocale.h>

#include "scan.h"
#include "progressBox.h"


ProgressBox::ProgressBox( TQWidget *parent, TQObject *part )
   : TQLabel( parent, "ProgressBox" )
{
   hide();

   setAlignment( TQt::AlignCenter );
   setFont( TDEGlobalSettings::fixedFont() );
   setSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed );

   setText( 999999 );
   setMinimumWidth( sizeHint().width() );

   connect( &m_timer, TQT_SIGNAL(timeout()), TQT_SLOT(report()) );
   connect( part, TQT_SIGNAL(started( TDEIO::Job* )), TQT_SLOT(start()) );
   connect( part, TQT_SIGNAL(completed()), TQT_SLOT(stop()) );
   connect( part, TQT_SIGNAL(canceled( const TQString& )), TQT_SLOT(halt()) );
}

void
ProgressBox::start() //slot
{
   m_timer.start( 50 ); //20 times per second - very smooth
   report();
   show();
}

void
ProgressBox::report() //slot
{
   setText( Filelight::ScanManager::files() );
}

void
ProgressBox::stop()
{
   m_timer.stop();
}

void
ProgressBox::halt()
{
   // canceled by stop button
   m_timer.stop();
   TQTimer::singleShot( 2000, this, TQT_SLOT(hide()) );
}

void
ProgressBox::setText( int files )
{
   TQLabel::setText( i18n("%n File", "%n Files", files) );
}

#include "progressBox.moc"