summaryrefslogtreecommitdiffstats
path: root/libk9copy/k9progress.cpp
blob: a1d83555d8945b7859bad8e232b97dbd2222acba (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//
// C++ Implementation:
//
// Description:
//
//
// Author: Jean-Michel PETIT <[email protected]>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//


#include "k9progress.h"
#include <kprogress.h>
#include <tqlabel.h>
#include <tqapplication.h>
#include <tqeventloop.h>
#include <tqimage.h>
#include <tqpainter.h>
#include <kstandarddirs.h>
#include <tqmovie.h>
#include <tqlayout.h>



k9Progress::k9Progress(TQWidget* parent, const char* name,const TQStringList &args)
        : Progress(parent,name,0) {
    m_process=new k9Process(this,0);
    m_wimage=new k9DrawImage(image,0);
    TQGridLayout *l=new TQGridLayout(image,1,1);
    l->addWidget(m_wimage,0,0);


}


k9Progress::~k9Progress() {
    delete m_process;
}


void k9Progress::setElapsed(const TQString _text) {
    lblElapsed->setText(_text);
}

void k9Progress::setTitle(const TQString _text) {
    lblTitle->setText(_text);
}


void k9Progress::setLabelText(const TQString _text) {
    LabelText->setText(_text);
}

void k9Progress::setProgress(long _position,long _total) {
    ProgressBar->setRange(0,_total);
    ProgressBar->setProgress(_position);
}

int k9Progress::execute() {
    if (! m_process->isRunning()) {
        if (!m_process->start(TDEProcess::NotifyOnExit,TDEProcess::All ))
            return -1;
    }

//   m_timer.start(200,FALSE);
    show();
    m_canceled=false;
    //the sync method allows to wait for the process end while receiving stdout.
    m_process->sync();

//   m_timer.stop();
    if (!m_canceled && m_process->normalExit())
        return 1;
    else
        return 0;
}


void k9Progress::bCancelClick() {
    m_process->kill();
    m_canceled=true;
}

k9Process* k9Progress::getProcess() const {
    return m_process;
}

/*$SPECIALIZATION$*/


void k9Progress::setImage(TQString _fileName) {
    m_wimage->setImage(_fileName);
}

void k9Progress::setImage(const TQImage &_image) {
    m_wimage->setImage(_image);
}


void k9Progress::setMovie(TQString _fileName) {
    image->setPaletteBackgroundColor(this->paletteBackgroundColor());
    TQMovie mv(_fileName,2048);
    mv.setBackgroundColor(this->paletteBackgroundColor());
    image->setMovie(mv);
    m_wimage->hide();
}


#include "k9progress.moc"


bool k9Progress::getCanceled() const {
    return m_canceled;
}