author | simon <simon> | 2002-12-11 18:25:17 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 18:25:17 (UTC) |
commit | f3d21af83a2846d1c20fc845cf88329ff1f2b1a9 (patch) (unidiff) | |
tree | 2187152e0aa3c121c833d15060ab1aedcfae0a36 | |
parent | d9a6575f931b288086da701c3094b475c73d2efc (diff) | |
download | opie-f3d21af83a2846d1c20fc845cf88329ff1f2b1a9.zip opie-f3d21af83a2846d1c20fc845cf88329ff1f2b1a9.tar.gz opie-f3d21af83a2846d1c20fc845cf88329ff1f2b1a9.tar.bz2 |
QBusyBar::~QBusyBar ( )
{
+ delete [] m_fadecols;
-rw-r--r-- | noncore/unsupported/qpdf/qbusybar.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/qbusybar.cpp b/noncore/unsupported/qpdf/qbusybar.cpp index f5c62fa..ce7ab8e 100644 --- a/noncore/unsupported/qpdf/qbusybar.cpp +++ b/noncore/unsupported/qpdf/qbusybar.cpp | |||
@@ -1,132 +1,133 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qtimer.h> | 2 | #include <qtimer.h> |
3 | #include <qpainter.h> | 3 | #include <qpainter.h> |
4 | 4 | ||
5 | #include "qbusybar.h" | 5 | #include "qbusybar.h" |
6 | 6 | ||
7 | 7 | ||
8 | 8 | ||
9 | QBusyBar::QBusyBar ( QWidget *parent, const char *name, int flags ) : QWidget ( parent, name, flags | WRepaintNoErase ) | 9 | QBusyBar::QBusyBar ( QWidget *parent, const char *name, int flags ) : QWidget ( parent, name, flags | WRepaintNoErase ) |
10 | { | 10 | { |
11 | m_busy = 0; | 11 | m_busy = 0; |
12 | 12 | ||
13 | m_div = 0; | 13 | m_div = 0; |
14 | m_pos = 0; | 14 | m_pos = 0; |
15 | m_fade = 0; | 15 | m_fade = 0; |
16 | m_fadecols = 0; | 16 | m_fadecols = 0; |
17 | m_speed = 500; | 17 | m_speed = 500; |
18 | 18 | ||
19 | m_timer = new QTimer ( this ); | 19 | m_timer = new QTimer ( this ); |
20 | connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( slotTimeout ( ))); | 20 | connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( slotTimeout ( ))); |
21 | 21 | ||
22 | setParameters ( 12, 8, 200 ); | 22 | setParameters ( 12, 8, 200 ); |
23 | } | 23 | } |
24 | 24 | ||
25 | void QBusyBar::setParameters ( int d, int s, int v ) | 25 | void QBusyBar::setParameters ( int d, int s, int v ) |
26 | { | 26 | { |
27 | bool running = m_timer-> isActive ( ); | 27 | bool running = m_timer-> isActive ( ); |
28 | 28 | ||
29 | if ( running ) | 29 | if ( running ) |
30 | m_timer-> stop ( ); | 30 | m_timer-> stop ( ); |
31 | 31 | ||
32 | m_div = d; | 32 | m_div = d; |
33 | m_speed = v; | 33 | m_speed = v; |
34 | 34 | ||
35 | delete [] m_fadecols; | 35 | delete [] m_fadecols; |
36 | m_fade = s; | 36 | m_fade = s; |
37 | m_fadecols = new QColor [m_fade]; | 37 | m_fadecols = new QColor [m_fade]; |
38 | 38 | ||
39 | int rt, gt, bt; | 39 | int rt, gt, bt; |
40 | int rf, gf, bf; | 40 | int rf, gf, bf; |
41 | 41 | ||
42 | colorGroup ( ). color ( QColorGroup::Highlight ). rgb ( &rf, &gf, &bf ); | 42 | colorGroup ( ). color ( QColorGroup::Highlight ). rgb ( &rf, &gf, &bf ); |
43 | colorGroup ( ). color ( QColorGroup::Background ). rgb ( &rt, >, &bt ); | 43 | colorGroup ( ). color ( QColorGroup::Background ). rgb ( &rt, >, &bt ); |
44 | 44 | ||
45 | for ( int i = 0; i < s; i++ ) | 45 | for ( int i = 0; i < s; i++ ) |
46 | m_fadecols [i]. setRgb ( rf + ( rt - rf ) * i / s, gf + ( gt - gf ) * i / s, bf + ( bt - bf ) * i / s ); | 46 | m_fadecols [i]. setRgb ( rf + ( rt - rf ) * i / s, gf + ( gt - gf ) * i / s, bf + ( bt - bf ) * i / s ); |
47 | 47 | ||
48 | if ( running ) { | 48 | if ( running ) { |
49 | m_pos = 0; | 49 | m_pos = 0; |
50 | m_timer-> start ( m_speed ); | 50 | m_timer-> start ( m_speed ); |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | QBusyBar::~QBusyBar ( ) | 54 | QBusyBar::~QBusyBar ( ) |
55 | { | 55 | { |
56 | delete [] m_fadecols; | ||
56 | } | 57 | } |
57 | 58 | ||
58 | bool QBusyBar::isBusy ( ) const | 59 | bool QBusyBar::isBusy ( ) const |
59 | { | 60 | { |
60 | return m_busy; | 61 | return m_busy; |
61 | } | 62 | } |
62 | 63 | ||
63 | void QBusyBar::beginBusy ( ) | 64 | void QBusyBar::beginBusy ( ) |
64 | { | 65 | { |
65 | setBusy ( true ); | 66 | setBusy ( true ); |
66 | } | 67 | } |
67 | 68 | ||
68 | void QBusyBar::endBusy ( ) | 69 | void QBusyBar::endBusy ( ) |
69 | { | 70 | { |
70 | setBusy ( false ); | 71 | setBusy ( false ); |
71 | } | 72 | } |
72 | 73 | ||
73 | void QBusyBar::setBusy ( bool b ) | 74 | void QBusyBar::setBusy ( bool b ) |
74 | { | 75 | { |
75 | int busy = m_busy + ( b ? 1 : -1 ); | 76 | int busy = m_busy + ( b ? 1 : -1 ); |
76 | 77 | ||
77 | if ( busy < 0 ) | 78 | if ( busy < 0 ) |
78 | busy = 0; | 79 | busy = 0; |
79 | 80 | ||
80 | if (( m_busy == 0 ) && ( busy > 0 )) { // Changed stateto on | 81 | if (( m_busy == 0 ) && ( busy > 0 )) { // Changed stateto on |
81 | m_pos = 0; | 82 | m_pos = 0; |
82 | m_timer-> start ( m_speed ); | 83 | m_timer-> start ( m_speed ); |
83 | update ( ); | 84 | update ( ); |
84 | } | 85 | } |
85 | else if (( m_busy > 0 ) && ( busy == 0 )) { // Changed state to off | 86 | else if (( m_busy > 0 ) && ( busy == 0 )) { // Changed state to off |
86 | m_timer-> stop ( ); | 87 | m_timer-> stop ( ); |
87 | update ( ); | 88 | update ( ); |
88 | } | 89 | } |
89 | 90 | ||
90 | m_busy = busy; | 91 | m_busy = busy; |
91 | } | 92 | } |
92 | 93 | ||
93 | void QBusyBar::slotTimeout ( ) | 94 | void QBusyBar::slotTimeout ( ) |
94 | { | 95 | { |
95 | m_pos++; | 96 | m_pos++; |
96 | m_pos %= ( 2 * ( m_fade + m_div )); | 97 | m_pos %= ( 2 * ( m_fade + m_div )); |
97 | 98 | ||
98 | update ( ); | 99 | update ( ); |
99 | } | 100 | } |
100 | 101 | ||
101 | void QBusyBar::paintEvent ( QPaintEvent *e ) | 102 | void QBusyBar::paintEvent ( QPaintEvent *e ) |
102 | { | 103 | { |
103 | QPainter p ( this ); | 104 | QPainter p ( this ); |
104 | 105 | ||
105 | QRect clip = e-> rect ( ); | 106 | QRect clip = e-> rect ( ); |
106 | 107 | ||
107 | int x = 0; | 108 | int x = 0; |
108 | int dx = width ( ) / m_div; | 109 | int dx = width ( ) / m_div; |
109 | int y = clip. top ( ); | 110 | int y = clip. top ( ); |
110 | int dy = clip. height ( ); | 111 | int dy = clip. height ( ); |
111 | 112 | ||
112 | if ( m_busy ) { | 113 | if ( m_busy ) { |
113 | int dir = ( m_pos < ( m_fade + m_div )) ? 1 : -1; | 114 | int dir = ( m_pos < ( m_fade + m_div )) ? 1 : -1; |
114 | int pos = ( dir > 0 ) ? m_pos : ( 2 * ( m_div + m_fade )) - m_pos - m_fade - 1; | 115 | int pos = ( dir > 0 ) ? m_pos : ( 2 * ( m_div + m_fade )) - m_pos - m_fade - 1; |
115 | 116 | ||
116 | for ( int i = 0; i < m_div; i++ ) { | 117 | for ( int i = 0; i < m_div; i++ ) { |
117 | int ind = ( pos - i ) * dir; | 118 | int ind = ( pos - i ) * dir; |
118 | if (( ind < 0 ) || ( ind >= m_fade )) | 119 | if (( ind < 0 ) || ( ind >= m_fade )) |
119 | ind = m_fade - 1; | 120 | ind = m_fade - 1; |
120 | 121 | ||
121 | if ((( x + dx ) > clip. left ( )) || ( x < clip. right ( ))) | 122 | if ((( x + dx ) > clip. left ( )) || ( x < clip. right ( ))) |
122 | p. fillRect ( x, y, ( i < ( m_div - 1 )) ? dx : width ( ) - x, dy, m_fadecols [ind] ); | 123 | p. fillRect ( x, y, ( i < ( m_div - 1 )) ? dx : width ( ) - x, dy, m_fadecols [ind] ); |
123 | x += dx; | 124 | x += dx; |
124 | } | 125 | } |
125 | } | 126 | } |
126 | else { | 127 | else { |
127 | p. fillRect ( e-> rect ( ), m_fadecols [m_fade - 1] ); | 128 | p. fillRect ( e-> rect ( ), m_fadecols [m_fade - 1] ); |
128 | } | 129 | } |
129 | } | 130 | } |
130 | 131 | ||
131 | 132 | ||
132 | 133 | ||