summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2005-08-12 06:29:54 (UTC)
committer llornkcor <llornkcor>2005-08-12 06:29:54 (UTC)
commit6ee18e3d11d5204ca6c8e885bc563ab34befdaec (patch) (unidiff)
tree02e437a5f232e99ac87c72c8ebacb301275ef962
parent374d60dacd347a947d5833b21cd73793ffb057ca (diff)
downloadopie-6ee18e3d11d5204ca6c8e885bc563ab34befdaec.zip
opie-6ee18e3d11d5204ca6c8e885bc563ab34befdaec.tar.gz
opie-6ee18e3d11d5204ca6c8e885bc563ab34befdaec.tar.bz2
revert
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/volumeapplet2/volumeapplet.cpp3
-rw-r--r--noncore/applets/volumeapplet2/volumeapplet.h2
2 files changed, 3 insertions, 2 deletions
diff --git a/noncore/applets/volumeapplet2/volumeapplet.cpp b/noncore/applets/volumeapplet2/volumeapplet.cpp
index 946616f..fad8e42 100644
--- a/noncore/applets/volumeapplet2/volumeapplet.cpp
+++ b/noncore/applets/volumeapplet2/volumeapplet.cpp
@@ -1,216 +1,217 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 4 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7_;:, .> :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21: = ...= . :.=- 21: = ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#include "volumeapplet.h" 31#include "volumeapplet.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35#include <opie2/otaskbarapplet.h> 35#include <opie2/otaskbarapplet.h>
36#include <opie2/osoundsystem.h> 36#include <opie2/osoundsystem.h>
37#include <opie2/oledbox.h> 37#include <opie2/oledbox.h>
38#include <opie2/oresource.h> 38#include <opie2/oresource.h>
39 39
40#include <qpe/applnk.h> 40#include <qpe/applnk.h>
41#include <qpe/qpeapplication.h> 41#include <qpe/qpeapplication.h>
42 42
43using namespace Opie::Core; 43using namespace Opie::Core;
44using namespace Opie::MM; 44using namespace Opie::MM;
45using namespace Opie::Ui; 45using namespace Opie::Ui;
46 46
47/* QT */ 47/* QT */
48#include <qpainter.h> 48#include <qpainter.h>
49#include <qlabel.h> 49#include <qlabel.h>
50#include <qlayout.h> 50#include <qlayout.h>
51#include <qslider.h> 51#include <qslider.h>
52 52
53/* STD */ 53/* STD */
54#include <assert.h> 54#include <assert.h>
55 55
56Channel::Channel( OMixerInterface* mixer, QWidget* parent, const char* name ) 56Channel::Channel( OMixerInterface* mixer, QWidget* parent, const char* name )
57 :QVBox( parent, name ) 57 :QVBox( parent, name )
58{ 58{
59 _name = new QLabel( name, this ); 59 _name = new QLabel( name, this );
60 _name->setFont( QFont( "Vera", 8 ) ); 60 _name->setFont( QFont( "Vera", 8 ) );
61 _volume = new QSlider( 0, 100, 10, mixer->volume( name ) & 0xff, QSlider::Vertical, this ); 61 _volume = new QSlider( 0, 100, 10, mixer->volume( name ) & 0xff, QSlider::Vertical, this );
62 _volume->setTickmarks( QSlider::Both ); 62 _volume->setTickmarks( QSlider::Both );
63 _volume->setTickInterval( 20 ); 63 _volume->setTickInterval( 20 );
64 _mute = new OLedBox( green, this ); 64 _mute = new OLedBox( green, this );
65 _mute->setFocusPolicy( QWidget::NoFocus ); 65 _mute->setFocusPolicy( QWidget::NoFocus );
66 _mute->setFixedSize( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 66 _mute->setFixedSize( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
67 _name->show(); 67 _name->show();
68 _volume->show(); 68 _volume->show();
69 _mute->show(); 69 _mute->show();
70} 70}
71 71
72 72
73Channel::~Channel() 73Channel::~Channel()
74{ 74{
75} 75}
76 76
77 77
78VolumeAppletControl::VolumeAppletControl( OTaskbarApplet* parent, const char* name ) 78VolumeAppletControl::VolumeAppletControl( OTaskbarApplet* parent, const char* name )
79 :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), l(0) 79 :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), l(0)
80{ 80{
81 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 81 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
82 l = new QGridLayout( this ); 82 l = new QGridLayout( this );
83 build(); 83 build();
84} 84}
85 85
86 86
87void VolumeAppletControl::build() 87void VolumeAppletControl::build()
88{ 88{
89 OSoundSystem* sound = OSoundSystem::instance(); 89 OSoundSystem* sound = OSoundSystem::instance();
90 OSoundSystem::CardIterator it = sound->iterator(); 90 OSoundSystem::CardIterator it = sound->iterator();
91 91
92// OMixerInterface* 92// OMixerInterface*
93 mixer = new OMixerInterface( this, "/dev/mixer" ); 93 mixer = new OMixerInterface( this, "/dev/mixer" );
94 94
95 QStringList channels = mixer->allChannels(); 95 QStringList channels = mixer->allChannels();
96 96
97 int x = 0; 97 int x = 0;
98 // int y = 0; 98 // int y = 0;
99 99
100 for ( QStringList::Iterator it = channels.begin(); it != channels.end(); ++it ) 100 for ( QStringList::Iterator it = channels.begin(); it != channels.end(); ++it )
101 { 101 {
102 if((*it) == mixer->volume( "Vol")) { 102 if((*it) == mixer->volume( "Vol")) {
103 m_vol_percent=mixer->volume( *it ) >> 8; 103 m_vol_percent=mixer->volume( *it ) >> 8;
104 } 104 }
105 owarn << "OSSDEMO: Mixer has channel " << *it << "" << oendl; 105 owarn << "OSSDEMO: Mixer has channel " << *it << "" << oendl;
106 owarn << "OSSDEMO: +--- volume " << ( mixer->volume( *it ) & 0xff ) 106 owarn << "OSSDEMO: +--- volume " << ( mixer->volume( *it ) & 0xff )
107 << " (left) | " << ( mixer->volume( *it ) >> 8 ) << " (right)" << oendl; 107 << " (left) | " << ( mixer->volume( *it ) >> 8 ) << " (right)" << oendl;
108 108
109 l->addWidget( new Channel( mixer, this, *it ), 0, x++, AlignCenter ); 109 l->addWidget( new Channel( mixer, this, *it ), 0, x++, AlignCenter );
110 } 110 }
111 111
112} 112}
113 113
114 114
115VolumeAppletControl::~VolumeAppletControl() 115VolumeAppletControl::~VolumeAppletControl()
116{ 116{
117} 117}
118 118
119int VolumeAppletControl::volPercent ( ) const 119int VolumeAppletControl::volPercent ( ) const
120{ 120{
121 return m_vol_percent; 121 return m_vol_percent;
122} 122}
123 123
124bool VolumeAppletControl::volMuted ( ) const 124bool VolumeAppletControl::volMuted ( ) const
125{ 125{
126 return m_vol_muted; 126 return m_vol_muted;
127} 127}
128 128
129 129
130void VolumeAppletControl::showEvent( QShowEvent* e ) 130void 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
137void VolumeAppletControl::hideEvent( QHideEvent* e ) 137void 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
151VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) 151VolumeApplet::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 = Opie::Core::OResource::loadPixmap( "volume", Opie::Core::OResource::SmallIcon );
157// _pixmap = new QPixmap (Opie::Core::OResource::loadPixmap( "volume", Opie::Core::OResource::SmallIcon ));
157 _control = new VolumeAppletControl( this, "control" ); 158 _control = new VolumeAppletControl( this, "control" );
158} 159}
159 160
160 161
161VolumeApplet::~VolumeApplet() 162VolumeApplet::~VolumeApplet()
162{ 163{
163} 164}
164 165
165 166
166int VolumeApplet::position() 167int VolumeApplet::position()
167{ 168{
168 return 4; 169 return 4;
169} 170}
170 171
171 172
172void VolumeApplet::paintEvent( QPaintEvent* ) 173void VolumeApplet::paintEvent( QPaintEvent* )
173{ 174{
174 QPainter p(this); 175 QPainter p(this);
175 p.drawPixmap(0, 2, _pixmap ); 176 p.drawPixmap(0, 2, _pixmap );
176 177
177/* 178/*
178 p. drawPixmap ( (width()- _pixmap->width())/2, QMAX( (height()-4-_pixmap->height() )/2, 1), *_pixmap ); 179 p. drawPixmap ( (width()- _pixmap->width())/2, QMAX( (height()-4-_pixmap->height() )/2, 1), *_pixmap );
179 p. setPen ( darkGray ); 180 p. setPen ( darkGray );
180 p. drawRect ( 1, height() - 4, width() - 2, 4 ); 181 p. drawRect ( 1, height() - 4, width() - 2, 4 );
181 182
182 OMixerInterface* mixer = new OMixerInterface( this, "/dev/mixer" ); 183 OMixerInterface* mixer = new OMixerInterface( this, "/dev/mixer" );
183 184
184 int volPercent = mixer->volume( "Vol" ) >> 8; 185 int volPercent = mixer->volume( "Vol" ) >> 8;
185 186
186 int pixelsWide = volPercent * ( width() - 4 ) / 100; 187 int pixelsWide = volPercent * ( width() - 4 ) / 100;
187 p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); 188 p. fillRect ( 2, height() - 3, pixelsWide, 2, red );
188 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); 189 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray );
189*/ 190*/
190 191
191// if ( _control-> volMuted ( )) { 192// if ( _control-> volMuted ( )) {
192// p. setPen ( red ); 193// p. setPen ( red );
193// p. drawLine ( 1, 2, width() - 2, height() - 5 ); 194// p. drawLine ( 1, 2, width() - 2, height() - 5 );
194// p. drawLine ( 1, 3, width() - 2, height() - 4 ); 195// p. drawLine ( 1, 3, width() - 2, height() - 4 );
195// p. drawLine ( width() - 2, 2, 1, height() - 5 ); 196// p. drawLine ( width() - 2, 2, 1, height() - 5 );
196// p. drawLine ( width() - 2, 3, 1, height() - 4 ); 197// p. drawLine ( width() - 2, 3, 1, height() - 4 );
197// } 198// }
198 199
199// QPainter p(this); 200// QPainter p(this);
200 // p.drawPixmap(0, 2, _pixmap ); 201 // p.drawPixmap(0, 2, _pixmap );
201} 202}
202 203
203 204
204void VolumeApplet::mousePressEvent( QMouseEvent* ) 205void VolumeApplet::mousePressEvent( QMouseEvent* )
205{ 206{
206 if ( !_control->isVisible() ) 207 if ( !_control->isVisible() )
207 { 208 {
208 popup( _control ); 209 popup( _control );
209 } 210 }
210 else 211 else
211 { 212 {
212 _control->hide(); 213 _control->hide();
213 } 214 }
214} 215}
215 216
216EXPORT_OPIE_APPLET_v1( VolumeApplet ) 217EXPORT_OPIE_APPLET_v1( VolumeApplet )
diff --git a/noncore/applets/volumeapplet2/volumeapplet.h b/noncore/applets/volumeapplet2/volumeapplet.h
index 953c305..e5dd4b9 100644
--- a/noncore/applets/volumeapplet2/volumeapplet.h
+++ b/noncore/applets/volumeapplet2/volumeapplet.h
@@ -1,112 +1,112 @@
1/* 1/*
2 � � � � � � � � This file is part of the Opie Project 2 � � � � � � � � This file is part of the Opie Project
3 3
4 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 4 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
5 .=l. 5 .=l.
6� � � � � �.>+-= 6� � � � � �.>+-=
7�_;:, � � .> � �:=|. This program is free software; you can 7�_;:, � � .> � �:=|. This program is free software; you can
8.> <`_, � > �. � <= redistribute it and/or modify it under 8.> <`_, � > �. � <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- � : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- � : the terms of the GNU Library General Public
10.="- .-=="i, � � .._ License as published by the Free Software 10.="- .-=="i, � � .._ License as published by the Free Software
11�- . � .-<_> � � .<> Foundation; either version 2 of the License, 11�- . � .-<_> � � .<> Foundation; either version 2 of the License,
12� � �._= =} � � � : or (at your option) any later version. 12� � �._= =} � � � : or (at your option) any later version.
13� � .%`+i> � � � _;_. 13� � .%`+i> � � � _;_.
14� � .i_,=:_. � � �-<s. This program is distributed in the hope that 14� � .i_,=:_. � � �-<s. This program is distributed in the hope that
15� � �+ �. �-:. � � � = it will be useful, but WITHOUT ANY WARRANTY; 15� � �+ �. �-:. � � � = it will be useful, but WITHOUT ANY WARRANTY;
16� � : .. � �.:, � � . . . without even the implied warranty of 16� � : .. � �.:, � � . . . without even the implied warranty of
17� � =_ � � � �+ � � =;=|` MERCHANTABILITY or FITNESS FOR A 17� � =_ � � � �+ � � =;=|` MERCHANTABILITY or FITNESS FOR A
18� _.=:. � � � : � �:=>`: PARTICULAR PURPOSE. See the GNU 18� _.=:. � � � : � �:=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= � � � = � � � ; Library General Public License for more 19..}^=.= � � � = � � � ; Library General Public License for more
20++= � -. � � .` � � .: details. 20++= � -. � � .` � � .: details.
21�: � � = �...= . :.=- 21�: � � = �...= . :.=-
22�-. � .:....=;==+<; You should have received a copy of the GNU 22�-. � .:....=;==+<; You should have received a copy of the GNU
23� -_. . . � )=. �= Library General Public License along with 23� -_. . . � )=. �= Library General Public License along with
24� � -- � � � �:-=` this library; see the file COPYING.LIB. 24� � -- � � � �:-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef VOLUMEAPPLET_H 31#ifndef VOLUMEAPPLET_H
32#define VOLUMEAPPLET_H 32#define VOLUMEAPPLET_H
33 33
34#include <opie2/otaskbarapplet.h> 34#include <opie2/otaskbarapplet.h>
35#include <opie2/osoundsystem.h> 35#include <opie2/osoundsystem.h>
36#include <qframe.h> 36#include <qframe.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qvbox.h> 38#include <qvbox.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40//using namespace Opie::MM; 40//using namespace Opie::MM;
41 41
42namespace Opie 42namespace Opie
43{ 43{
44 namespace Ui { class OLedBox; } 44 namespace Ui { class OLedBox; }
45// namespace MM { class OMixerInterface; } 45// namespace MM { class OMixerInterface; }
46} 46}
47class QLabel; 47class QLabel;
48class QSlider; 48class QSlider;
49class QShowEvent; 49class QShowEvent;
50class QHideEvent; 50class QHideEvent;
51class QGridLayout; 51class QGridLayout;
52 52
53class Channel : public QVBox 53class Channel : public QVBox
54{ 54{
55 public: 55 public:
56 Channel( Opie::MM::OMixerInterface* mixer, QWidget* parent, const char* name ); 56 Channel( Opie::MM::OMixerInterface* mixer, QWidget* parent, const char* name );
57 virtual ~Channel(); 57 virtual ~Channel();
58 58
59 // public slots: 59 // public slots:
60 // virtual void clicked(); 60 // virtual void clicked();
61 61
62 private: 62 private:
63 QLabel* _name; 63 QLabel* _name;
64 QSlider* _volume; 64 QSlider* _volume;
65 Opie::Ui::OLedBox* _mute; 65 Opie::Ui::OLedBox* _mute;
66 Opie::MM::OMixerInterface* _mixer; 66 Opie::MM::OMixerInterface* _mixer;
67}; 67};
68 68
69class VolumeAppletControl : public QFrame 69class VolumeAppletControl : public QFrame
70{ 70{
71 public: 71 public:
72 VolumeAppletControl( Opie::Ui::OTaskbarApplet* parent, const char* name = 0 ); 72 VolumeAppletControl( Opie::Ui::OTaskbarApplet* parent, const char* name = 0 );
73 ~VolumeAppletControl(); 73 ~VolumeAppletControl();
74 bool volMuted() const; 74 bool volMuted() const;
75 int volPercent() const; 75 int volPercent() const;
76 76
77 int m_vol_percent; 77 int m_vol_percent;
78 bool m_vol_muted; 78 bool m_vol_muted;
79 79
80 Opie::MM::OMixerInterface* mixer; 80 Opie::MM::OMixerInterface* mixer;
81 81
82 virtual QSize sizeHint() const; 82 virtual QSize sizeHint() const;
83 83
84 protected: 84 protected:
85 virtual void showEvent( QShowEvent* ); 85 virtual void showEvent( QShowEvent* );
86 virtual void hideEvent( QHideEvent* ); 86 virtual void hideEvent( QHideEvent* );
87 void build(); 87 void build();
88 88
89 private: 89 private:
90 90
91 QGridLayout* l; 91 QGridLayout* l;
92}; 92};
93 93
94 94
95class VolumeApplet : public Opie::Ui::OTaskbarApplet 95class VolumeApplet : public Opie::Ui::OTaskbarApplet
96{ 96{
97 public: 97 public:
98 VolumeApplet( QWidget* parent = 0, const char* name = 0 ); 98 VolumeApplet( QWidget* parent = 0, const char* name = 0 );
99 ~VolumeApplet(); 99 ~VolumeApplet();
100 100
101 static int position(); 101 static int position();
102 protected: 102 protected:
103 virtual void paintEvent( QPaintEvent* ); 103 virtual void paintEvent( QPaintEvent* );
104 virtual void mousePressEvent( QMouseEvent* ); 104 virtual void mousePressEvent( QMouseEvent* );
105 105
106 private: 106 private:
107 VolumeAppletControl* _control; 107 VolumeAppletControl* _control;
108 QPixmap* _pixmap; 108 QPixmap _pixmap;
109}; 109};
110 110
111#endif 111#endif
112 112