22 #include "waitingoverlay_p.h"
27 #include <KLocalizedString>
29 #include <QtCore/QEvent>
38 : QWidget( parent ? parent : baseWidget->window() ),
39 mBaseWidget( baseWidget )
41 Q_ASSERT( baseWidget );
42 Q_ASSERT( parentWidget() != baseWidget );
44 connect( baseWidget, SIGNAL(destroyed()), SLOT(deleteLater()) );
45 connect( job, SIGNAL(result(KJob*)), SLOT(deleteLater()) );
46 mPreviousState = mBaseWidget->isEnabled();
48 QBoxLayout *topLayout =
new QVBoxLayout(
this );
49 topLayout->addStretch();
50 QLabel *description =
new QLabel(
this );
51 description->setText( i18n(
"<p style=\"color: white;\"><b>Waiting for operation</b><br/></p>" ) );
52 description->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
53 topLayout->addWidget( description );
54 topLayout->addStretch();
56 QPalette p = palette();
57 p.setColor( backgroundRole(), QColor( 0, 0, 0, 128 ) );
59 setAutoFillBackground(
true );
61 mBaseWidget->installEventFilter(
this );
66 WaitingOverlay::~ WaitingOverlay()
69 mBaseWidget->setEnabled( mPreviousState );
73 void WaitingOverlay::reposition()
81 if ( parentWidget() != mBaseWidget->window() ) {
82 setParent( mBaseWidget->window() );
87 if ( !mBaseWidget->isVisible() ) {
94 const QPoint topLevelPos = mBaseWidget->mapTo( window(), QPoint( 0, 0 ) );
95 const QPoint parentPos = parentWidget()->mapFrom( window(), topLevelPos );
100 resize( mBaseWidget->size() );
103 bool WaitingOverlay::eventFilter(QObject *
object, QEvent * event)
105 if (
object == mBaseWidget &&
106 ( event->type() == QEvent::Move ||
event->type() == QEvent::Resize ||
107 event->type() == QEvent::Show ||
event->type() == QEvent::Hide ||
108 event->type() == QEvent::ParentChange ) ) {
111 return QWidget::eventFilter(
object, event );
WaitingOverlay(KJob *job, QWidget *baseWidget, QWidget *parent=0)
Create an overlay widget on baseWidget for job.