summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/volumeapplet2/volumeapplet.cpp48
1 files changed, 25 insertions, 23 deletions
diff --git a/noncore/applets/volumeapplet2/volumeapplet.cpp b/noncore/applets/volumeapplet2/volumeapplet.cpp
index c153a78..2f61f48 100644
--- a/noncore/applets/volumeapplet2/volumeapplet.cpp
+++ b/noncore/applets/volumeapplet2/volumeapplet.cpp
@@ -1,173 +1,175 @@
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>
39
38#include <qpe/applnk.h> 40#include <qpe/applnk.h>
39#include <qpe/resource.h> 41
40using namespace Opie::Core; 42using namespace Opie::Core;
41using namespace Opie::MM; 43using namespace Opie::MM;
42using namespace Opie::Ui; 44using namespace Opie::Ui;
43 45
44/* QT */ 46/* QT */
45#include <qpainter.h> 47#include <qpainter.h>
46#include <qlabel.h> 48#include <qlabel.h>
47#include <qlayout.h> 49#include <qlayout.h>
48#include <qslider.h> 50#include <qslider.h>
49 51
50/* STD */ 52/* STD */
51#include <assert.h> 53#include <assert.h>
52 54
53Channel::Channel( OMixerInterface* mixer, QWidget* parent, const char* name ) 55Channel::Channel( OMixerInterface* mixer, QWidget* parent, const char* name )
54 :QVBox( parent, name ) 56 :QVBox( parent, name )
55{ 57{
56 _name = new QLabel( name, this ); 58 _name = new QLabel( name, this );
57 _name->setFont( QFont( "Vera", 8 ) ); 59 _name->setFont( QFont( "Vera", 8 ) );
58 _volume = new QSlider( 0, 100, 10, mixer->volume( name ) & 0xff, QSlider::Vertical, this ); 60 _volume = new QSlider( 0, 100, 10, mixer->volume( name ) & 0xff, QSlider::Vertical, this );
59 _volume->setTickmarks( QSlider::Both ); 61 _volume->setTickmarks( QSlider::Both );
60 _volume->setTickInterval( 20 ); 62 _volume->setTickInterval( 20 );
61 _mute = new OLedBox( green, this ); 63 _mute = new OLedBox( green, this );
62 _mute->setFocusPolicy( QWidget::NoFocus ); 64 _mute->setFocusPolicy( QWidget::NoFocus );
63 _mute->setFixedSize( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 65 _mute->setFixedSize( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
64 _name->show(); 66 _name->show();
65 _volume->show(); 67 _volume->show();
66 _mute->show(); 68 _mute->show();
67} 69}
68 70
69 71
70Channel::~Channel() 72Channel::~Channel()
71{ 73{
72} 74}
73 75
74 76
75VolumeAppletControl::VolumeAppletControl( OTaskbarApplet* parent, const char* name ) 77VolumeAppletControl::VolumeAppletControl( OTaskbarApplet* parent, const char* name )
76 :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), l(0) 78 :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), l(0)
77{ 79{
78 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 80 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
79 l = new QGridLayout( this ); 81 l = new QGridLayout( this );
80 build(); 82 build();
81} 83}
82 84
83 85
84void VolumeAppletControl::build() 86void VolumeAppletControl::build()
85{ 87{
86 OSoundSystem* sound = OSoundSystem::instance(); 88 OSoundSystem* sound = OSoundSystem::instance();
87 OSoundSystem::CardIterator it = sound->iterator(); 89 OSoundSystem::CardIterator it = sound->iterator();
88 90
89 OMixerInterface* mixer = new OMixerInterface( this, "/dev/mixer" ); 91 OMixerInterface* mixer = new OMixerInterface( this, "/dev/mixer" );
90 92
91 QStringList channels = mixer->allChannels(); 93 QStringList channels = mixer->allChannels();
92 94
93 int x = 0; 95 int x = 0;
94 int y = 0; 96 // int y = 0;
95 97
96 for ( QStringList::Iterator it = channels.begin(); it != channels.end(); ++it ) 98 for ( QStringList::Iterator it = channels.begin(); it != channels.end(); ++it )
97 { 99 {
98 odebug << "OSSDEMO: Mixer has channel " << *it << "" << oendl; 100 odebug << "OSSDEMO: Mixer has channel " << *it << "" << oendl;
99 odebug << "OSSDEMO: +--- volume " << ( mixer->volume( *it ) & 0xff ) 101 odebug << "OSSDEMO: +--- volume " << ( mixer->volume( *it ) & 0xff )
100 << " (left) | " << ( mixer->volume( *it ) >> 8 ) << " (right)" << oendl; 102 << " (left) | " << ( mixer->volume( *it ) >> 8 ) << " (right)" << oendl;
101 103
102 l->addWidget( new Channel( mixer, this, *it ), 0, x++, AlignCenter ); 104 l->addWidget( new Channel( mixer, this, *it ), 0, x++, AlignCenter );
103 } 105 }
104 106
105} 107}
106 108
107 109
108VolumeAppletControl::~VolumeAppletControl() 110VolumeAppletControl::~VolumeAppletControl()
109{ 111{
110} 112}
111 113
112 114
113void VolumeAppletControl::showEvent( QShowEvent* e ) 115void VolumeAppletControl::showEvent( QShowEvent* e )
114{ 116{
115 odebug << "showEvent" << oendl; 117 odebug << "showEvent" << oendl;
116 QWidget::showEvent( e ); 118 QWidget::showEvent( e );
117} 119}
118 120
119 121
120void VolumeAppletControl::hideEvent( QHideEvent* e ) 122void VolumeAppletControl::hideEvent( QHideEvent* e )
121{ 123{
122 odebug << "hideEvent" << oendl; 124 odebug << "hideEvent" << oendl;
123 QWidget::hideEvent( e ); 125 QWidget::hideEvent( e );
124} 126}
125 127
126 128
127QSize VolumeAppletControl::sizeHint() const 129QSize VolumeAppletControl::sizeHint() const
128{ 130{
129 return QSize( 200, 200 ); //QFrame::sizeHint(); 131 return QSize( 200, 200 ); //QFrame::sizeHint();
130} 132}
131 133
132 134
133VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) 135VolumeApplet::VolumeApplet( QWidget *parent, const char *name )
134 :OTaskbarApplet( parent, name ) 136 :OTaskbarApplet( parent, name )
135{ 137{
136 setFixedHeight( AppLnk::smallIconSize() ); 138 setFixedHeight( AppLnk::smallIconSize() );
137 setFixedWidth( AppLnk::smallIconSize() ); 139 setFixedWidth( AppLnk::smallIconSize() );
138 _pixmap.convertFromImage( Resource::loadImage( "volumeapplet/volume" ).smoothScale( height(), width() ) ); 140 _pixmap = Opie::Core::OResource::loadPixmap( "volume", Opie::Core::OResource::SmallIcon );
139 _control = new VolumeAppletControl( this, "control" ); 141 _control = new VolumeAppletControl( this, "control" );
140} 142}
141 143
142 144
143VolumeApplet::~VolumeApplet() 145VolumeApplet::~VolumeApplet()
144{ 146{
145} 147}
146 148
147 149
148int VolumeApplet::position() 150int VolumeApplet::position()
149{ 151{
150 return 4; 152 return 4;
151} 153}
152 154
153 155
154void VolumeApplet::paintEvent( QPaintEvent* ) 156void VolumeApplet::paintEvent( QPaintEvent* )
155{ 157{
156 QPainter p(this); 158 QPainter p(this);
157 p.drawPixmap(0, 2, _pixmap ); 159 p.drawPixmap(0, 2, _pixmap );
158} 160}
159 161
160 162
161void VolumeApplet::mousePressEvent( QMouseEvent* ) 163void VolumeApplet::mousePressEvent( QMouseEvent* )
162{ 164{
163 if ( !_control->isVisible() ) 165 if ( !_control->isVisible() )
164 { 166 {
165 popup( _control ); 167 popup( _control );
166 } 168 }
167 else 169 else
168 { 170 {
169 _control->hide(); 171 _control->hide();
170 } 172 }
171} 173}
172 174
173EXPORT_OPIE_APPLET_v1( VolumeApplet ) 175EXPORT_OPIE_APPLET_v1( VolumeApplet )