25 #include <tqpainter.h>
29 #include <tqpushbutton.h>
35 #include "kprogress.h"
37 #include <tdeapplication.h>
42 : TQProgressBar(parent, name, f),
49 : TQProgressBar(totalSteps, parent, name, f),
104 setPercentageVisible(enable);
109 return percentageVisible();
115 if (mFormat !=
"%p%")
116 setCenterIndicator(
true);
130 bool KProgress::setIndicator(TQString &indicator,
int progress,
int totalSteps)
134 TQString newString(mFormat);
135 newString.replace(TQString::fromLatin1(
"%v"),
136 TQString::number(progress));
137 newString.replace(TQString::fromLatin1(
"%m"),
138 TQString::number(totalSteps));
140 if (totalSteps > INT_MAX / 1000) {
145 newString.replace(TQString::fromLatin1(
"%p"),
146 TQString::number((progress * 100) / totalSteps));
148 if (newString != indicator)
150 indicator = newString;
157 struct KProgressDialog::KProgressDialogPrivate
159 KProgressDialogPrivate() : cancelButtonShown(true)
163 bool cancelButtonShown;
170 const TQString& caption,
const TQString& text,
180 d(new KProgressDialogPrivate)
185 mShowTimer =
new TQTimer(
this);
191 TQVBoxLayout* layout =
new TQVBoxLayout(mainWidget, 10);
193 mLabel =
new TQLabel(text, mainWidget);
194 layout->addWidget(mLabel);
196 mProgressBar =
new KProgress(mainWidget);
197 layout->addWidget(mProgressBar);
199 connect(mProgressBar, TQT_SIGNAL(percentageChanged(
int)),
200 this, TQT_SLOT(slotAutoActions(
int)));
201 connect(mShowTimer, TQT_SIGNAL(timeout()),
this, TQT_SLOT(slotAutoShow()));
202 mShowTimer->start(mMinDuration,
true);
210 void KProgressDialog::slotAutoShow()
212 if (mShown || mCancelled)
218 kapp->processEvents();
221 void KProgressDialog::slotCancel()
252 mShowTimer->start(mMinDuration,
true);
295 mLabel->setText(text);
301 return mLabel->text();
306 return mLabel->text();
363 void KProgressDialog::slotAutoActions(
int percentage)
365 if (percentage < 100)
367 if (!d->cancelButtonShown)
370 d->cancelButtonShown =
true;
385 d->cancelButtonShown =
false;
408 void KProgress::virtual_hook(
int,
void* )
411 void KProgressDialog::virtual_hook(
int id,
void* data )
412 { KDialogBase::virtual_hook(
id, data ); }
414 #include "kprogress.moc"