-rw-r--r-- | libopie2/opieui/owait.cpp | 77 |
1 files changed, 47 insertions, 30 deletions
diff --git a/libopie2/opieui/owait.cpp b/libopie2/opieui/owait.cpp index 0fdf08d..8bb4ed6 100644 --- a/libopie2/opieui/owait.cpp +++ b/libopie2/opieui/owait.cpp | |||
@@ -1,93 +1,110 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* |
2 | Copyright (C) 2003 Maximilian Reiss (harlekin@handhelds.org) | 2 | This file is part of the Opie Project |
3 | 3 | Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> | |
4 | This library is free software; you can redistribute it and/or | 4 | =. |
5 | modify it under the terms of the GNU Library General Public | 5 | .=l. |
6 | License as published by the Free Software Foundation; either | 6 | .>+-= |
7 | version 2 of the License, or (at your option) any later version. | 7 | _;:, .> :=|. This program is free software; you can |
8 | 8 | .> <`_, > . <= redistribute it and/or modify it under | |
9 | This library is distributed in the hope that it will be useful, | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | Library General Public License for more details. | 12 | ._= =} : or (at your option) any later version. |
13 | 13 | .%`+i> _;_. | |
14 | You should have received a copy of the GNU Library General Public License | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
18 | */ | ||
19 | 28 | ||
20 | #include <qlabel.h> | 29 | */ |
21 | #include <qlayout.h> | ||
22 | #include <qtimer.h> | ||
23 | #include <qpe/qpeapplication.h> | ||
24 | #include <qpainter.h> | ||
25 | 30 | ||
26 | #include "owait.h" | 31 | #include "owait.h" |
27 | 32 | ||
33 | /* OPIE */ | ||
34 | #include <qpe/qpeapplication.h> | ||
28 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
29 | 36 | ||
37 | /* QT */ | ||
38 | #include <qlayout.h> | ||
39 | #include <qpainter.h> | ||
40 | |||
30 | static int frame = 0; | 41 | static int frame = 0; |
31 | 42 | ||
32 | /** | 43 | /** |
33 | * This will construct a modal dialog. | 44 | * This will construct a modal dialog. |
34 | * | 45 | * |
35 | * The default timer length is 10. | 46 | * The default timer length is 10. |
36 | * | 47 | * |
37 | * @param parent The parent of the widget | 48 | * @param parent The parent of the widget |
38 | * @param msg The name of the object | 49 | * @param msg The name of the object |
39 | * @param dispIcon Display Icon? | 50 | * @param dispIcon Display Icon? |
40 | */ | 51 | */ |
41 | OWait::OWait(QWidget *parent, const char* msg, bool dispIcon ) | 52 | OWait::OWait(QWidget *parent, const char* msg, bool dispIcon ) |
42 | :QDialog(parent, msg, TRUE,WStyle_Customize) { | 53 | :QDialog( parent, msg, TRUE, WStyle_Customize ) |
54 | { | ||
43 | 55 | ||
44 | 56 | ||
45 | QHBoxLayout *hbox = new QHBoxLayout( this ); | 57 | QHBoxLayout *hbox = new QHBoxLayout( this ); |
46 | 58 | ||
47 | m_lb = new QLabel( this ); | 59 | m_lb = new QLabel( this ); |
48 | m_lb->setBackgroundMode ( NoBackground ); | 60 | m_lb->setBackgroundMode ( NoBackground ); |
49 | 61 | ||
50 | hbox->addWidget( m_lb ); | 62 | hbox->addWidget( m_lb ); |
51 | hbox->activate(); | 63 | hbox->activate(); |
52 | 64 | ||
53 | m_pix = Resource::loadPixmap( "BigBusy" ); | 65 | m_pix = Resource::loadPixmap( "BigBusy" ); |
54 | m_aniSize = m_pix.height(); | 66 | m_aniSize = m_pix.height(); |
55 | resize( m_aniSize, m_aniSize ); | 67 | resize( m_aniSize, m_aniSize ); |
56 | 68 | ||
57 | m_timerLength = 10; | 69 | m_timerLength = 10; |
58 | 70 | ||
59 | m_waitTimer = new QTimer( this ); | 71 | m_waitTimer = new QTimer( this ); |
60 | connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) ); | 72 | connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) ); |
61 | } | 73 | } |
62 | 74 | ||
63 | void OWait::timerEvent( QTimerEvent * ) { | 75 | void OWait::timerEvent( QTimerEvent * ) |
76 | { | ||
64 | frame = (++frame) % 4; | 77 | frame = (++frame) % 4; |
65 | repaint(); | 78 | repaint(); |
66 | } | 79 | } |
67 | 80 | ||
68 | void OWait::paintEvent( QPaintEvent * ) { | 81 | void OWait::paintEvent( QPaintEvent * ) |
82 | { | ||
69 | QPainter p( m_lb ); | 83 | QPainter p( m_lb ); |
70 | p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize ); | 84 | p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize ); |
71 | } | 85 | } |
72 | 86 | ||
73 | void OWait::show() { | 87 | void OWait::show() |
88 | { | ||
74 | 89 | ||
75 | move( ( ( qApp->desktop()->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop()->height() ) / 2 ) - ( m_aniSize / 2 ) ); | 90 | move( ( ( qApp->desktop()->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop()->height() ) / 2 ) - ( m_aniSize / 2 ) ); |
76 | startTimer( 300 ); | 91 | startTimer( 300 ); |
77 | m_waitTimer->start( m_timerLength * 1000, true ); | 92 | m_waitTimer->start( m_timerLength * 1000, true ); |
78 | QDialog::show(); | 93 | QDialog::show(); |
79 | } | 94 | } |
80 | 95 | ||
81 | void OWait::hide() { | 96 | void OWait::hide() |
97 | { | ||
82 | killTimers(); | 98 | killTimers(); |
83 | m_waitTimer->stop(); | 99 | m_waitTimer->stop(); |
84 | frame = 0; | 100 | frame = 0; |
85 | QDialog::hide(); | 101 | QDialog::hide(); |
86 | } | 102 | } |
87 | 103 | ||
88 | void OWait::setTimerLength( int length ) { | 104 | void OWait::setTimerLength( int length ) |
105 | { | ||
89 | m_timerLength = length; | 106 | m_timerLength = length; |
90 | } | 107 | } |
91 | 108 | ||
92 | OWait::~OWait() { | 109 | OWait::~OWait() |
93 | } | 110 | {} |