-rw-r--r-- | noncore/applets/volumeapplet2/volumeapplet.cpp | 52 | ||||
-rw-r--r-- | noncore/applets/volumeapplet2/volumeapplet.h | 15 |
2 files changed, 57 insertions, 10 deletions
diff --git a/noncore/applets/volumeapplet2/volumeapplet.cpp b/noncore/applets/volumeapplet2/volumeapplet.cpp index 2f61f48..2122007 100644 --- a/noncore/applets/volumeapplet2/volumeapplet.cpp +++ b/noncore/applets/volumeapplet2/volumeapplet.cpp | |||
@@ -40,2 +40,3 @@ _;:, .> :=|. This program is free software; you can | |||
40 | #include <qpe/applnk.h> | 40 | #include <qpe/applnk.h> |
41 | #include <qpe/qpeapplication.h> | ||
41 | 42 | ||
@@ -90,3 +91,4 @@ void VolumeAppletControl::build() | |||
90 | 91 | ||
91 | OMixerInterface* mixer = new OMixerInterface( this, "/dev/mixer" ); | 92 | // OMixerInterface* |
93 | mixer = new OMixerInterface( this, "/dev/mixer" ); | ||
92 | 94 | ||
@@ -99,4 +101,7 @@ void VolumeAppletControl::build() | |||
99 | { | 101 | { |
100 | odebug << "OSSDEMO: Mixer has channel " << *it << "" << oendl; | 102 | if((*it) == mixer->volume( "Vol")) { |
101 | odebug << "OSSDEMO: +--- volume " << ( mixer->volume( *it ) & 0xff ) | 103 | m_vol_percent=mixer->volume( *it ) >> 8; |
104 | } | ||
105 | owarn << "OSSDEMO: Mixer has channel " << *it << "" << oendl; | ||
106 | owarn << "OSSDEMO: +--- volume " << ( mixer->volume( *it ) & 0xff ) | ||
102 | << " (left) | " << ( mixer->volume( *it ) >> 8 ) << " (right)" << oendl; | 107 | << " (left) | " << ( mixer->volume( *it ) >> 8 ) << " (right)" << oendl; |
@@ -113,2 +118,12 @@ VolumeAppletControl::~VolumeAppletControl() | |||
113 | 118 | ||
119 | int VolumeAppletControl::volPercent ( ) const | ||
120 | { | ||
121 | return m_vol_percent; | ||
122 | } | ||
123 | |||
124 | bool VolumeAppletControl::volMuted ( ) const | ||
125 | { | ||
126 | return m_vol_muted; | ||
127 | } | ||
128 | |||
114 | 129 | ||
@@ -130,3 +145,4 @@ QSize VolumeAppletControl::sizeHint() const | |||
130 | { | 145 | { |
131 | return QSize( 200, 200 ); //QFrame::sizeHint(); | 146 | int wd = QPEApplication::desktop()->width(); |
147 | return QSize( wd, 200 ); //QFrame::sizeHint(); | ||
132 | } | 148 | } |
@@ -137,5 +153,5 @@ VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | |||
137 | { | 153 | { |
138 | setFixedHeight( AppLnk::smallIconSize() ); | 154 | setFixedHeight( AppLnk::smallIconSize() +4); |
139 | setFixedWidth( AppLnk::smallIconSize() ); | 155 | setFixedWidth( AppLnk::smallIconSize() ); |
140 | _pixmap = Opie::Core::OResource::loadPixmap( "volume", Opie::Core::OResource::SmallIcon ); | 156 | _pixmap = new QPixmap (Opie::Core::OResource::loadPixmap( "volume", Opie::Core::OResource::SmallIcon )); |
141 | _control = new VolumeAppletControl( this, "control" ); | 157 | _control = new VolumeAppletControl( this, "control" ); |
@@ -158,3 +174,25 @@ void VolumeApplet::paintEvent( QPaintEvent* ) | |||
158 | QPainter p(this); | 174 | QPainter p(this); |
159 | p.drawPixmap(0, 2, _pixmap ); | 175 | |
176 | p. drawPixmap ( (width()- _pixmap->width())/2, QMAX( (height()-4-_pixmap->height() )/2, 1), *_pixmap ); | ||
177 | p. setPen ( darkGray ); | ||
178 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); | ||
179 | |||
180 | OMixerInterface* mixer = new OMixerInterface( this, "/dev/mixer" ); | ||
181 | |||
182 | int volPercent = mixer->volume( "Vol" ) >> 8; | ||
183 | |||
184 | int pixelsWide = volPercent * ( width() - 4 ) / 100; | ||
185 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); | ||
186 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | ||
187 | |||
188 | // if ( _control-> volMuted ( )) { | ||
189 | // p. setPen ( red ); | ||
190 | // p. drawLine ( 1, 2, width() - 2, height() - 5 ); | ||
191 | // p. drawLine ( 1, 3, width() - 2, height() - 4 ); | ||
192 | // p. drawLine ( width() - 2, 2, 1, height() - 5 ); | ||
193 | // p. drawLine ( width() - 2, 3, 1, height() - 4 ); | ||
194 | // } | ||
195 | |||
196 | // QPainter p(this); | ||
197 | // p.drawPixmap(0, 2, _pixmap ); | ||
160 | } | 198 | } |
diff --git a/noncore/applets/volumeapplet2/volumeapplet.h b/noncore/applets/volumeapplet2/volumeapplet.h index c1f1a3a..953c305 100644 --- a/noncore/applets/volumeapplet2/volumeapplet.h +++ b/noncore/applets/volumeapplet2/volumeapplet.h | |||
@@ -34,2 +34,3 @@ | |||
34 | #include <opie2/otaskbarapplet.h> | 34 | #include <opie2/otaskbarapplet.h> |
35 | #include <opie2/osoundsystem.h> | ||
35 | #include <qframe.h> | 36 | #include <qframe.h> |
@@ -38,2 +39,3 @@ | |||
38 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | //using namespace Opie::MM; | ||
39 | 41 | ||
@@ -42,3 +44,3 @@ namespace Opie | |||
42 | namespace Ui { class OLedBox; } | 44 | namespace Ui { class OLedBox; } |
43 | namespace MM { class OMixerInterface; } | 45 | // namespace MM { class OMixerInterface; } |
44 | } | 46 | } |
@@ -71,2 +73,9 @@ class VolumeAppletControl : public QFrame | |||
71 | ~VolumeAppletControl(); | 73 | ~VolumeAppletControl(); |
74 | bool volMuted() const; | ||
75 | int volPercent() const; | ||
76 | |||
77 | int m_vol_percent; | ||
78 | bool m_vol_muted; | ||
79 | |||
80 | Opie::MM::OMixerInterface* mixer; | ||
72 | 81 | ||
@@ -80,4 +89,4 @@ class VolumeAppletControl : public QFrame | |||
80 | private: | 89 | private: |
81 | QGridLayout* l; | ||
82 | 90 | ||
91 | QGridLayout* l; | ||
83 | }; | 92 | }; |
@@ -98,3 +107,3 @@ class VolumeApplet : public Opie::Ui::OTaskbarApplet | |||
98 | VolumeAppletControl* _control; | 107 | VolumeAppletControl* _control; |
99 | QPixmap _pixmap; | 108 | QPixmap* _pixmap; |
100 | }; | 109 | }; |