author | zecke <zecke> | 2004-02-21 11:36:36 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-02-21 11:36:36 (UTC) |
commit | a570c2824fcecaf1c278e1b5a592fa14cc0647f8 (patch) (unidiff) | |
tree | 019f96b57b57589409192258e3b6f1ca2ffdbb7f /libopie2 | |
parent | f80b38b2e348b588bf7560161d7551e6bd4939c0 (diff) | |
download | opie-a570c2824fcecaf1c278e1b5a592fa14cc0647f8.zip opie-a570c2824fcecaf1c278e1b5a592fa14cc0647f8.tar.gz opie-a570c2824fcecaf1c278e1b5a592fa14cc0647f8.tar.bz2 |
Install OWait as well.
If the API is considered too bad ( I remember the talk about OWait wait;
on the stack ) we will have to sort it out
-rw-r--r-- | libopie2/opieui/opieui.pro | 6 | ||||
-rw-r--r-- | libopie2/opieui/owait.cpp | 93 | ||||
-rw-r--r-- | libopie2/opieui/owait.h | 77 |
3 files changed, 174 insertions, 2 deletions
diff --git a/libopie2/opieui/opieui.pro b/libopie2/opieui/opieui.pro index 708b1fe..8506794 100644 --- a/libopie2/opieui/opieui.pro +++ b/libopie2/opieui/opieui.pro | |||
@@ -20,5 +20,6 @@ HEADERS = oclickablelabel.h \ | |||
20 | oresource.h \ | 20 | oresource.h \ |
21 | otaskbarapplet.h \ | 21 | otaskbarapplet.h \ |
22 | oseparator.h | 22 | oseparator.h \ |
23 | owait.h | ||
23 | 24 | ||
24 | SOURCES = oclickablelabel.cpp \ | 25 | SOURCES = oclickablelabel.cpp \ |
@@ -38,5 +39,6 @@ SOURCES = oclickablelabel.cpp \ | |||
38 | oresource.cpp \ | 39 | oresource.cpp \ |
39 | otaskbarapplet.cpp \ | 40 | otaskbarapplet.cpp \ |
40 | oseparator.cpp | 41 | oseparator.cpp \ |
42 | owait.cpp | ||
41 | 43 | ||
42 | include ( big-screen/big-screen.pro ) | 44 | include ( big-screen/big-screen.pro ) |
diff --git a/libopie2/opieui/owait.cpp b/libopie2/opieui/owait.cpp new file mode 100644 index 0000000..0fdf08d --- a/dev/null +++ b/libopie2/opieui/owait.cpp | |||
@@ -0,0 +1,93 @@ | |||
1 | /* This file is part of the OPIE libraries | ||
2 | Copyright (C) 2003 Maximilian Reiss (harlekin@handhelds.org) | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Library General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. | ||
18 | */ | ||
19 | |||
20 | #include <qlabel.h> | ||
21 | #include <qlayout.h> | ||
22 | #include <qtimer.h> | ||
23 | #include <qpe/qpeapplication.h> | ||
24 | #include <qpainter.h> | ||
25 | |||
26 | #include "owait.h" | ||
27 | |||
28 | #include <qpe/resource.h> | ||
29 | |||
30 | static int frame = 0; | ||
31 | |||
32 | /** | ||
33 | * This will construct a modal dialog. | ||
34 | * | ||
35 | * The default timer length is 10. | ||
36 | * | ||
37 | * @param parent The parent of the widget | ||
38 | * @param msg The name of the object | ||
39 | * @param dispIcon Display Icon? | ||
40 | */ | ||
41 | OWait::OWait(QWidget *parent, const char* msg, bool dispIcon ) | ||
42 | :QDialog(parent, msg, TRUE,WStyle_Customize) { | ||
43 | |||
44 | |||
45 | QHBoxLayout *hbox = new QHBoxLayout( this ); | ||
46 | |||
47 | m_lb = new QLabel( this ); | ||
48 | m_lb->setBackgroundMode ( NoBackground ); | ||
49 | |||
50 | hbox->addWidget( m_lb ); | ||
51 | hbox->activate(); | ||
52 | |||
53 | m_pix = Resource::loadPixmap( "BigBusy" ); | ||
54 | m_aniSize = m_pix.height(); | ||
55 | resize( m_aniSize, m_aniSize ); | ||
56 | |||
57 | m_timerLength = 10; | ||
58 | |||
59 | m_waitTimer = new QTimer( this ); | ||
60 | connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) ); | ||
61 | } | ||
62 | |||
63 | void OWait::timerEvent( QTimerEvent * ) { | ||
64 | frame = (++frame) % 4; | ||
65 | repaint(); | ||
66 | } | ||
67 | |||
68 | void OWait::paintEvent( QPaintEvent * ) { | ||
69 | QPainter p( m_lb ); | ||
70 | p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize ); | ||
71 | } | ||
72 | |||
73 | void OWait::show() { | ||
74 | |||
75 | move( ( ( qApp->desktop()->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop()->height() ) / 2 ) - ( m_aniSize / 2 ) ); | ||
76 | startTimer( 300 ); | ||
77 | m_waitTimer->start( m_timerLength * 1000, true ); | ||
78 | QDialog::show(); | ||
79 | } | ||
80 | |||
81 | void OWait::hide() { | ||
82 | killTimers(); | ||
83 | m_waitTimer->stop(); | ||
84 | frame = 0; | ||
85 | QDialog::hide(); | ||
86 | } | ||
87 | |||
88 | void OWait::setTimerLength( int length ) { | ||
89 | m_timerLength = length; | ||
90 | } | ||
91 | |||
92 | OWait::~OWait() { | ||
93 | } | ||
diff --git a/libopie2/opieui/owait.h b/libopie2/opieui/owait.h new file mode 100644 index 0000000..cbfc8d6 --- a/dev/null +++ b/libopie2/opieui/owait.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /* This file is part of the OPIE libraries | ||
2 | Copyright (C) 2003 Maximilian Reiss (harlekin@handhelds.org) | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Library General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. | ||
18 | */ | ||
19 | |||
20 | |||
21 | |||
22 | #ifndef WAITPOPUP_H | ||
23 | #define WAITPOPUP_H | ||
24 | |||
25 | #include <qdialog.h> | ||
26 | #include <qpixmap.h> | ||
27 | #include <qlabel.h> | ||
28 | #include <qtimer.h> | ||
29 | |||
30 | /** | ||
31 | * This class displays a animated waiting icon in the middle of the screen. | ||
32 | * | ||
33 | * @short modal hour glass dialog | ||
34 | * @see QDialog | ||
35 | * @author Maximilian Reiß | ||
36 | */ | ||
37 | class OWait : public QDialog { | ||
38 | |||
39 | Q_OBJECT | ||
40 | |||
41 | public: | ||
42 | // FIXME Wflags -zecke? | ||
43 | OWait(QWidget *parent=0,const char* name=0, bool dispIcon=TRUE); | ||
44 | ~OWait(); | ||
45 | |||
46 | /** | ||
47 | * reimplemented for control reasons | ||
48 | */ | ||
49 | void show(); | ||
50 | |||
51 | /** | ||
52 | * Set the time before the icon will be automaticly hidden | ||
53 | * The timer will be started once the widget will be shown. | ||
54 | * @param length - time in seconds | ||
55 | */ | ||
56 | void setTimerLength( int length ); | ||
57 | |||
58 | public slots: | ||
59 | /** | ||
60 | * reimplemented for control reasons | ||
61 | */ | ||
62 | void hide(); | ||
63 | |||
64 | private: | ||
65 | void timerEvent( QTimerEvent * ) ; | ||
66 | void paintEvent( QPaintEvent * ); | ||
67 | |||
68 | QPixmap m_pix; | ||
69 | QLabel *m_lb; | ||
70 | QTimer *m_waitTimer; | ||
71 | int m_timerLength; | ||
72 | int m_aniSize; | ||
73 | class Private; | ||
74 | Private *d; | ||
75 | }; | ||
76 | |||
77 | #endif | ||