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

akonadi

  • 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 <KJob>
26#include <KLocalizedString>
27
28#include <QtCore/QEvent>
29#include <QBoxLayout>
30#include <QLabel>
31#include <QPalette>
32//#include <QProgressBar>
33
34//@cond PRIVATE
35
36WaitingOverlay::WaitingOverlay( KJob *job, QWidget *baseWidget, QWidget * parent )
37 : QWidget( parent ? parent : baseWidget->window() ),
38 mBaseWidget( baseWidget )
39{
40 Q_ASSERT( baseWidget );
41 Q_ASSERT( parentWidget() != baseWidget );
42
43 connect( baseWidget, SIGNAL(destroyed()), SLOT(deleteLater()) );
44 connect( job, SIGNAL(result(KJob*)), SLOT(deleteLater()) );
45 mPreviousState = mBaseWidget->isEnabled();
46
47 QBoxLayout *topLayout = new QVBoxLayout( this );
48 topLayout->addStretch();
49 QLabel *description = new QLabel( this );
50 description->setText( i18n( "<p style=\"color: white;\"><b>Waiting for operation</b><br/></p>" ) );
51 description->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
52 topLayout->addWidget( description );
53 topLayout->addStretch();
54
55 QPalette p = palette();
56 p.setColor( backgroundRole(), QColor( 0, 0, 0, 128 ) );
57 setPalette( p );
58 setAutoFillBackground( true );
59
60 mBaseWidget->installEventFilter( this );
61
62 reposition();
63}
64
65WaitingOverlay::~ WaitingOverlay()
66{
67 if ( mBaseWidget ) {
68 mBaseWidget->setEnabled( mPreviousState );
69 }
70}
71
72void WaitingOverlay::reposition()
73{
74 if ( !mBaseWidget ) {
75 return;
76 }
77
78 // reparent to the current top level widget of the base widget if needed
79 // needed eg. in dock widgets
80 if ( parentWidget() != mBaseWidget->window() ) {
81 setParent( mBaseWidget->window() );
82 }
83
84 // follow base widget visibility
85 // needed eg. in tab widgets
86 if ( !mBaseWidget->isVisible() ) {
87 hide();
88 return;
89 }
90 show();
91
92 // follow position changes
93 const QPoint topLevelPos = mBaseWidget->mapTo( window(), QPoint( 0, 0 ) );
94 const QPoint parentPos = parentWidget()->mapFrom( window(), topLevelPos );
95 move( parentPos );
96
97 // follow size changes
98 // TODO: hide/scale icon if we don't have enough space
99 resize( mBaseWidget->size() );
100}
101
102bool WaitingOverlay::eventFilter(QObject * object, QEvent * event)
103{
104 if ( object == mBaseWidget &&
105 ( event->type() == QEvent::Move || event->type() == QEvent::Resize ||
106 event->type() == QEvent::Show || event->type() == QEvent::Hide ||
107 event->type() == QEvent::ParentChange ) ) {
108 reposition();
109 }
110 return QWidget::eventFilter( object, event );
111}
112
113//@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-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 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
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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