-rw-r--r-- | noncore/applets/volumeapplet2/volumeapplet.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/applets/volumeapplet2/volumeapplet.cpp b/noncore/applets/volumeapplet2/volumeapplet.cpp index 2122007..946616f 100644 --- a/noncore/applets/volumeapplet2/volumeapplet.cpp +++ b/noncore/applets/volumeapplet2/volumeapplet.cpp | |||
@@ -110,104 +110,107 @@ void VolumeAppletControl::build() | |||
110 | } | 110 | } |
111 | 111 | ||
112 | } | 112 | } |
113 | 113 | ||
114 | 114 | ||
115 | VolumeAppletControl::~VolumeAppletControl() | 115 | VolumeAppletControl::~VolumeAppletControl() |
116 | { | 116 | { |
117 | } | 117 | } |
118 | 118 | ||
119 | int VolumeAppletControl::volPercent ( ) const | 119 | int VolumeAppletControl::volPercent ( ) const |
120 | { | 120 | { |
121 | return m_vol_percent; | 121 | return m_vol_percent; |
122 | } | 122 | } |
123 | 123 | ||
124 | bool VolumeAppletControl::volMuted ( ) const | 124 | bool VolumeAppletControl::volMuted ( ) const |
125 | { | 125 | { |
126 | return m_vol_muted; | 126 | return m_vol_muted; |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | void VolumeAppletControl::showEvent( QShowEvent* e ) | 130 | void VolumeAppletControl::showEvent( QShowEvent* e ) |
131 | { | 131 | { |
132 | odebug << "showEvent" << oendl; | 132 | odebug << "showEvent" << oendl; |
133 | QWidget::showEvent( e ); | 133 | QWidget::showEvent( e ); |
134 | } | 134 | } |
135 | 135 | ||
136 | 136 | ||
137 | void VolumeAppletControl::hideEvent( QHideEvent* e ) | 137 | void VolumeAppletControl::hideEvent( QHideEvent* e ) |
138 | { | 138 | { |
139 | odebug << "hideEvent" << oendl; | 139 | odebug << "hideEvent" << oendl; |
140 | QWidget::hideEvent( e ); | 140 | QWidget::hideEvent( e ); |
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
144 | QSize VolumeAppletControl::sizeHint() const | 144 | QSize VolumeAppletControl::sizeHint() const |
145 | { | 145 | { |
146 | int wd = QPEApplication::desktop()->width(); | 146 | int wd = QPEApplication::desktop()->width(); |
147 | return QSize( wd, 200 ); //QFrame::sizeHint(); | 147 | return QSize( wd, 200 ); //QFrame::sizeHint(); |
148 | } | 148 | } |
149 | 149 | ||
150 | 150 | ||
151 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 151 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
152 | :OTaskbarApplet( parent, name ) | 152 | :OTaskbarApplet( parent, name ) |
153 | { | 153 | { |
154 | setFixedHeight( AppLnk::smallIconSize() +4); | 154 | setFixedHeight( AppLnk::smallIconSize() +4); |
155 | setFixedWidth( AppLnk::smallIconSize() ); | 155 | setFixedWidth( AppLnk::smallIconSize() ); |
156 | _pixmap = new QPixmap (Opie::Core::OResource::loadPixmap( "volume", Opie::Core::OResource::SmallIcon )); | 156 | _pixmap = new QPixmap (Opie::Core::OResource::loadPixmap( "volume", Opie::Core::OResource::SmallIcon )); |
157 | _control = new VolumeAppletControl( this, "control" ); | 157 | _control = new VolumeAppletControl( this, "control" ); |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | VolumeApplet::~VolumeApplet() | 161 | VolumeApplet::~VolumeApplet() |
162 | { | 162 | { |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | int VolumeApplet::position() | 166 | int VolumeApplet::position() |
167 | { | 167 | { |
168 | return 4; | 168 | return 4; |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | void VolumeApplet::paintEvent( QPaintEvent* ) | 172 | void VolumeApplet::paintEvent( QPaintEvent* ) |
173 | { | 173 | { |
174 | QPainter p ( this ); | 174 | QPainter p(this); |
175 | p.drawPixmap(0, 2, _pixmap ); | ||
175 | 176 | ||
177 | /* | ||
176 | p. drawPixmap ( (width()- _pixmap->width())/2, QMAX( (height()-4-_pixmap->height() )/2, 1), *_pixmap ); | 178 | p. drawPixmap ( (width()- _pixmap->width())/2, QMAX( (height()-4-_pixmap->height() )/2, 1), *_pixmap ); |
177 | p. setPen ( darkGray ); | 179 | p. setPen ( darkGray ); |
178 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); | 180 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); |
179 | 181 | ||
180 | OMixerInterface* mixer = new OMixerInterface( this, "/dev/mixer" ); | 182 | OMixerInterface* mixer = new OMixerInterface( this, "/dev/mixer" ); |
181 | 183 | ||
182 | int volPercent = mixer->volume( "Vol" ) >> 8; | 184 | int volPercent = mixer->volume( "Vol" ) >> 8; |
183 | 185 | ||
184 | int pixelsWide = volPercent * ( width() - 4 ) / 100; | 186 | int pixelsWide = volPercent * ( width() - 4 ) / 100; |
185 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); | 187 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); |
186 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | 188 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); |
189 | */ | ||
187 | 190 | ||
188 | // if ( _control-> volMuted ( )) { | 191 | // if ( _control-> volMuted ( )) { |
189 | // p. setPen ( red ); | 192 | // p. setPen ( red ); |
190 | // p. drawLine ( 1, 2, width() - 2, height() - 5 ); | 193 | // p. drawLine ( 1, 2, width() - 2, height() - 5 ); |
191 | // p. drawLine ( 1, 3, width() - 2, height() - 4 ); | 194 | // p. drawLine ( 1, 3, width() - 2, height() - 4 ); |
192 | // p. drawLine ( width() - 2, 2, 1, height() - 5 ); | 195 | // p. drawLine ( width() - 2, 2, 1, height() - 5 ); |
193 | // p. drawLine ( width() - 2, 3, 1, height() - 4 ); | 196 | // p. drawLine ( width() - 2, 3, 1, height() - 4 ); |
194 | // } | 197 | // } |
195 | 198 | ||
196 | // QPainter p(this); | 199 | // QPainter p(this); |
197 | // p.drawPixmap(0, 2, _pixmap ); | 200 | // p.drawPixmap(0, 2, _pixmap ); |
198 | } | 201 | } |
199 | 202 | ||
200 | 203 | ||
201 | void VolumeApplet::mousePressEvent( QMouseEvent* ) | 204 | void VolumeApplet::mousePressEvent( QMouseEvent* ) |
202 | { | 205 | { |
203 | if ( !_control->isVisible() ) | 206 | if ( !_control->isVisible() ) |
204 | { | 207 | { |
205 | popup( _control ); | 208 | popup( _control ); |
206 | } | 209 | } |
207 | else | 210 | else |
208 | { | 211 | { |
209 | _control->hide(); | 212 | _control->hide(); |
210 | } | 213 | } |
211 | } | 214 | } |
212 | 215 | ||
213 | EXPORT_OPIE_APPLET_v1( VolumeApplet ) | 216 | EXPORT_OPIE_APPLET_v1( VolumeApplet ) |