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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
/***************************************************************************
* Copyright (C) 2005 by Jean-Michel Petit *
* jm_petit@laposte.net *
* *
* 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. *
***************************************************************************/
#include "k9backupdlg.h"
#include "ac.h"
#include <tqtimer.h>
#include <tqdatetime.h>
#include <tqapplication.h>
#include <tqprogressbar.h>
#include <tqlabel.h>
#include <kiconloader.h>
#include <kpushbutton.h>
#include <kstdguiitem.h>
#include <kguiitem.h>
#include <tqlabel.h>
#include <tqpainter.h>
#include <tqlayout.h>
#include "k9drawimage.h"
k9BackupDlg::k9BackupDlg(TQWidget* parent, const char* name, bool modal, WFlags fl)
: backupDlg(parent,name, modal,fl) {
Abort=false;
timer = new TQTimer( this );
time = new TQTime(0,0);
time->start();
connect( timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(timerDone()) );
timer->start(500, 0 );
bAbort->setIconSet(KStdGuiItem::cancel().iconSet());
bPlay->setIconSet(SmallIcon("player_play"));
totalCopied=0;
m_progressTotal=0;
m_progressLabel="";
m_totalSteps=0;
m_factor="";
m_progress=0;
connect(&m_decoder, TQT_SIGNAL(pixmapReady(TQImage *)), this, TQT_SLOT(drawPixmap(TQImage *)));
m_stop=false;
m_playmovie=true;
m_cpt=0;
m_wimage=new k9DrawImage(image,0);
TQGridLayout *l=new TQGridLayout(image,1,1);
l->addWidget(m_wimage,0,0);
m_data=NULL;
m_dataSize=0;
}
void k9BackupDlg::drawPixmap(TQImage *_image) {
m_count++;
if (m_count ==4) {
m_wimage->setImage(*_image);
m_stop=true;
}
}
void k9BackupDlg::bPlayToggled( bool state) {
m_playmovie=bPlay->isOn();
}
void k9BackupDlg::playMovie(uchar *_data,uint32_t _size) {
if (!m_playmovie || m_dataSize)
return;
m_count=0;
m_dataSize=_size;
m_data=(uchar*)malloc(_size);
tc_memcpy(m_data,_data,_size);
}
k9BackupDlg::~k9BackupDlg() {
delete timer;
delete time;
if (m_data)
free(m_data);
}
void k9BackupDlg::update(){
lblStep->setText(m_progressLabel);
pbTotal->setProgress(m_progressTotal);
pbStep->setTotalSteps(m_totalSteps);
lblFactor->setText(m_factor);
pbStep->setProgress(m_progress);
if (m_data) {
if (m_stop)
m_decoder.start();
m_stop=false;
for (uint32_t i=0;i<m_dataSize-2048;i+=2048) {
if (m_stop) {
m_decoder.stop();
break;
}
m_decoder.decode(m_data +i ,m_data+i+2048,0);
}
free(m_data);
m_data=NULL;
m_dataSize=0;
m_playmovie=false;
}
}
void k9BackupDlg::timerDone() {
m_cpt++;
if (m_cpt==10) {
m_cpt=0;
m_playmovie=bPlay->isOn();
}
TQTime time2(0,0);
time2=time2.addMSecs(time->elapsed());
TQString remain("--:--:--");
if (m_progressTotal>0) {
TQTime time3(0,0);
time3=time3.addMSecs((time->elapsed()/m_progressTotal)*pbTotal->totalSteps());
remain=time3.toString("hh:mm:ss");
}
lblTime->setText(time2.toString("hh:mm:ss") +" / " +remain);
update();
}
void k9BackupDlg::setTotalSteps(uint32_t _totalSteps) {
m_totalSteps=_totalSteps;
}
void k9BackupDlg::setProgress(uint32_t _position) {
m_progress=_position;
}
void k9BackupDlg::setTotalMax(uint32_t _max) {
pbTotal->setTotalSteps(_max);
}
void k9BackupDlg::setProgressTotal(uint32_t _position) {
totalCopied+=_position;
uint64_t total=totalCopied*2048;
total/=(1024*1024);
m_progressTotal=total;
}
void k9BackupDlg::setProgressLabel(TQString _text) {
m_progressLabel=_text;
update();
}
bool k9BackupDlg::getAbort() {
return Abort;
}
void k9BackupDlg::bAbortClick() {
Abort=true;
reject();
}
void k9BackupDlg::setFactor(TQString _factor) {
m_factor=_factor;
}
/*$SPECIALIZATION$*/
#include "k9backupdlg.moc"
|