• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • akonadi
  • contact
waitingoverlay.cpp
1 /*
2  This file is part of Akonadi Contact.
3 
4  Copyright (c) 2008 Volker Krause <vkrause@kde.org>
5 
6  This library is free software; you can redistribute it and/or modify it
7  under the terms of the GNU Library General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or (at your
9  option) any later version.
10 
11  This library is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14  License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to the
18  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301, USA.
20 */
21 
22 #include "waitingoverlay_p.h"
23 
24 #include <KDebug>
25 #include <KIcon>
26 #include <KJob>
27 #include <KLocalizedString>
28 
29 #include <QtCore/QEvent>
30 #include <QBoxLayout>
31 #include <QLabel>
32 #include <QPalette>
33 //#include <QProgressBar>
34 
35 //@cond PRIVATE
36 
37 WaitingOverlay::WaitingOverlay( KJob *job, QWidget *baseWidget, QWidget * parent )
38  : QWidget( parent ? parent : baseWidget->window() ),
39  mBaseWidget( baseWidget )
40 {
41  Q_ASSERT( baseWidget );
42  Q_ASSERT( parentWidget() != baseWidget );
43 
44  connect( baseWidget, SIGNAL(destroyed()), SLOT(deleteLater()) );
45  connect( job, SIGNAL(result(KJob*)), SLOT(deleteLater()) );
46  mPreviousState = mBaseWidget->isEnabled();
47 
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();
55 
56  QPalette p = palette();
57  p.setColor( backgroundRole(), QColor( 0, 0, 0, 128 ) );
58  setPalette( p );
59  setAutoFillBackground( true );
60 
61  mBaseWidget->installEventFilter( this );
62 
63  reposition();
64 }
65 
66 WaitingOverlay::~ WaitingOverlay()
67 {
68  if ( mBaseWidget ) {
69  mBaseWidget->setEnabled( mPreviousState );
70  }
71 }
72 
73 void WaitingOverlay::reposition()
74 {
75  if ( !mBaseWidget ) {
76  return;
77  }
78 
79  // reparent to the current top level widget of the base widget if needed
80  // needed eg. in dock widgets
81  if ( parentWidget() != mBaseWidget->window() ) {
82  setParent( mBaseWidget->window() );
83  }
84 
85  // follow base widget visibility
86  // needed eg. in tab widgets
87  if ( !mBaseWidget->isVisible() ) {
88  hide();
89  return;
90  }
91  show();
92 
93  // follow position changes
94  const QPoint topLevelPos = mBaseWidget->mapTo( window(), QPoint( 0, 0 ) );
95  const QPoint parentPos = parentWidget()->mapFrom( window(), topLevelPos );
96  move( parentPos );
97 
98  // follow size changes
99  // TODO: hide/scale icon if we don't have enough space
100  resize( mBaseWidget->size() );
101 }
102 
103 bool WaitingOverlay::eventFilter(QObject * object, QEvent * event)
104 {
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 ) ) {
109  reposition();
110  }
111  return QWidget::eventFilter( object, event );
112 }
113 
114 //@endcond
WaitingOverlay::WaitingOverlay
WaitingOverlay(KJob *job, QWidget *baseWidget, QWidget *parent=0)
Create an overlay widget on baseWidget for job.
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal