//------------------------------------------------------------------------- IoProgressDialog::IoProgressDialog( QWidget *parent /*= 0*/ ) :QDialog(parent),_parent(parent) { ui.setupUi(this); setSizeAndPosition( _parent); Qt::WindowFlags flags; ui.label->setOpenExternalLinks( true ); ui.msgLabel->setOpenExternalLinks( true ); #ifdef Q_OS_OSX flags = Qt::Sheet; #else flags = Qt::SplashScreen; ui.progressBar->setFormat("%v/%m"); ui.progressBar->setTextVisible(true); #endif this->setWindowOpacity(0.8); flags ^= Qt::NoDropShadowWindowHint; setWindowFlags(flags); setWindowModality(Qt::WindowModal); setModal(true); this->setWindowIcon(QIcon(":/images/res/dcpm_256x256x32.png")); _s = size(); setIoHealth( 0 ); }
bool MessageOverlay::eventFilter(QObject *o, QEvent *e) { if (o==parentWidget() && isVisible() && QEvent::Resize==e->type()) { setSizeAndPosition(); } return QObject::eventFilter(o, e); }
//------------------------------------------------------------------------- void IoProgressDialog::reset() { setProgress(0); ui.progressBar->setVisible( true ); ui.progressBar->setTextVisible(false); ui.progressBar->reset(); ui.pushButton->setText( "Cancel" ); ui.label->clear(); _hasCancled = false; ui.msgLabel->clear(); ui.pushButton->show(); setIoHealth( 0 ); resize( 10,10 ); setSizeAndPosition( _parent ); adjustPosition( _parent ); }
void MessageOverlay::setText(const QString &txt, int timeout, bool allowCancel) { if (txt==text) { return; } text=txt; cancelButton->setVisible(allowCancel); setAttribute(Qt::WA_TransparentForMouseEvents, !allowCancel); setVisible(!text.isEmpty()); if (!text.isEmpty()) { setSizeAndPosition(); update(); if (-1!=timeout) { if (!timer) { timer=new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(timeout())); } timer->start(timeout); } } }