author | sandman <sandman> | 2002-06-24 20:06:38 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-06-24 20:06:38 (UTC) |
commit | 793a63d9cce0502616cad6999643b1a61836a3db (patch) (side-by-side diff) | |
tree | 3ea020afd5a06236e5e889f3acae429d87171488 /core/applets/volumeapplet | |
parent | fe4cb014e959518e4835d15593f2c392174af55b (diff) | |
download | opie-793a63d9cce0502616cad6999643b1a61836a3db.zip opie-793a63d9cce0502616cad6999643b1a61836a3db.tar.gz opie-793a63d9cce0502616cad6999643b1a61836a3db.tar.bz2 |
Started as a bug fix this is a near complete restructuring/rewrite:
- Added a alarm volume slider on iPAQs
- Made mic mutable
- Correctly inform the launcher about tap/key sounds
-rw-r--r-- | core/applets/volumeapplet/oledbox.cpp | 270 | ||||
-rw-r--r-- | core/applets/volumeapplet/oledbox.h | 51 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 744 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.h | 124 | ||||
-rw-r--r-- | core/applets/volumeapplet/volumeapplet.pro | 4 | ||||
-rw-r--r-- | core/applets/volumeapplet/volumeappletimpl.cpp | 9 |
6 files changed, 857 insertions, 345 deletions
diff --git a/core/applets/volumeapplet/oledbox.cpp b/core/applets/volumeapplet/oledbox.cpp new file mode 100644 index 0000000..3036929 --- a/dev/null +++ b/core/applets/volumeapplet/oledbox.cpp @@ -0,0 +1,270 @@ + +#include <qpixmap.h> +#include <qbitmap.h> +#include <qpainter.h> + +#include "oledbox.h" + + +#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC + +/* XPM */ +static const char * ledborder_xpm[] = { +"16 16 11 1", +" c None", +". c #626562", +"+ c #7B7D7B", +"@ c #949594", +"# c #ACAEAC", +"$ c #CDCACD", +"% c #CDCECD", +"; c #E6E6E6", +"> c #FFFFFF", +", c #E6E2E6", +"' c #FFFAFF", +" .++@@# ", +" ...++@@##$ ", +" .....+@##$$% ", +" ..... #$%%% ", +" ... %%; ", +".... ;;;;", +"++. ;>>", +"+++ >>>", +"@@@ >>>", +"@@# >>>", +"#### >>>>", +" #$$ >>> ", +" $$,,' >>>>> ", +" ,,,''>>>>>>> ", +" ,''>>>>>>> ", +" '>>>>> "}; + + +QPixmap *OLedBox::s_border_pix = 0; + +#endif + + +OLedBox::OLedBox ( const QColor &col, QWidget *parent, const char *name ) : QWidget ( parent, name ) +{ + m_color = col; + m_on = false; + + m_pix [ 0 ] = m_pix [ 1 ] = false; + + setBackgroundMode ( PaletteBackground ); + +#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC + if ( !s_border_pix ) + s_border_pix = new QPixmap ( ledborder_xpm ); +#endif +} + +OLedBox::~OLedBox ( ) +{ + delete m_pix [ 0 ]; + delete m_pix [ 1 ]; +} + +QSize OLedBox::sizeHint ( ) const +{ + return QSize ( 16, 16 ); +} + +bool OLedBox::isOn ( ) const +{ + return m_on; +} + +QColor OLedBox::color ( ) const +{ + return m_color; +} + +void OLedBox::setOn ( bool b ) +{ + if ( m_on != b ) { + m_on = b; + update ( ); + } +} + +void OLedBox::toggle ( ) +{ + setOn ( !isOn ( ) ); +} + +void OLedBox::setColor ( const QColor &col ) +{ + if ( m_color != col ) { + m_color = col; + + delete m_pix [ 0 ]; + delete m_pix [ 1 ]; + + update ( ); + } +} + +void OLedBox::mousePressEvent ( QMouseEvent *e ) +{ + if ( e-> button ( ) == LeftButton ) { + m_on = !m_on; + update ( ); + emit toggled ( m_on ); + } +} + + +void OLedBox::resizeEvent ( QResizeEvent * ) +{ + delete m_pix [ 0 ]; + delete m_pix [ 1 ]; + + update ( ); +} + +void OLedBox::paintEvent ( QPaintEvent *e ) +{ + int ind = m_on ? 1 : 0; + + if ( !m_pix [ ind ] ) { + m_pix [ ind ] = new QPixmap ( size ( )); + + drawLed ( m_pix [ ind ], m_on ? m_color : m_color. dark ( 300 ) ); + } + if ( !e-> erased ( )) + erase ( ); + + QPainter p ( this ); + p. drawPixmap ( 0, 0, *m_pix [ ind ] ); +} + +// From KDE libkdeui / led.cpp + +void OLedBox::drawLed ( QPixmap *pix, const QColor &col ) // paint a ROUND SUNKEN led lamp +{ + QPainter paint; + QColor color; + QBrush brush; + QPen pen; + + // First of all we want to know what area should be updated + // Initialize coordinates, width, and height of the LED + int width = pix-> width ( ); + + // Make sure the LED is round! + if ( width > pix-> height ( )) + width = pix-> height ( ); + width -= 2; // leave one pixel border + if ( width < 0 ) + width = 0; + + // maybe we could stop HERE, if width <=0 ? + + // start painting widget + // + paint.begin( pix ); + + // Set the color of the LED according to given parameters + color = col; + + // Set the brush to SolidPattern, this fills the entire area + // of the ellipse which is drawn first + brush.setStyle( QBrush::SolidPattern ); + brush.setColor( color ); + paint.setBrush( brush ); // Assign the brush to the painter + + // Draws a "flat" LED with the given color: + paint.drawEllipse( 1, 1, width, width ); + + // Draw the bright light spot of the LED now, using modified "old" + // painter routine taken from KDEUIs KLed widget: + + // Setting the new width of the pen is essential to avoid "pixelized" + // shadow like it can be observed with the old LED code + pen.setWidth( 2 ); + + // shrink the light on the LED to a size about 2/3 of the complete LED + int pos = width / 5 + 1; + int light_width = width; + light_width *= 2; + light_width /= 3; + + // Calculate the LEDs "light factor": + int light_quote = ( 130 * 2 / ( light_width ? light_width : 1 ) ) + 100; + + // Now draw the bright spot on the LED: + while ( light_width ) + { + color = color.light( light_quote ); // make color lighter + pen.setColor( color ); // set color as pen color + paint.setPen( pen ); // select the pen for drawing + paint.drawEllipse( pos, pos, light_width, light_width ); // draw the ellipse (circle) + light_width--; + if ( !light_width ) + break; + paint.drawEllipse( pos, pos, light_width, light_width ); + light_width--; + if ( !light_width ) + break; + paint.drawEllipse( pos, pos, light_width, light_width ); + pos++; + light_width--; + } + + // Drawing of bright spot finished, now draw a thin border + // around the LED which resembles a shadow with light coming + // from the upper left. + +#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC + paint. drawPixmap ( 0, 0, *s_border_pix ); + +#else + pen.setWidth( 3 ); + brush.setStyle( QBrush::NoBrush ); // Switch off the brush + paint.setBrush( brush ); // This avoids filling of the ellipse + + // Set the initial color value to 200 (bright) and start + // drawing the shadow border at 45 (45*16 = 720). + int shadow_color = 200, angle; + + for ( angle = 720; angle < 6480; angle += 240 ) + { + color.setRgb( shadow_color, shadow_color, shadow_color ); + pen.setColor( color ); + paint.setPen( pen ); + paint.drawArc( 0, 0, width+2, width+2, angle, 240 ); + paint.drawArc( 1, 1, width, width, angle, 240 ); + paint.drawArc( 2, 2, width-2, width-2, angle, 240 ); + if ( angle < 2320 ) { + shadow_color -= 25; // set color to a darker value + if ( shadow_color < 100 ) + shadow_color = 100; + } + else if ( ( angle > 2320 ) && ( angle < 5760 ) ) { + shadow_color += 25; // set color to a brighter value + if ( shadow_color > 255 ) + shadow_color = 255; + } + else { + shadow_color -= 25; // set color to a darker value again + if ( shadow_color < 100 ) + shadow_color = 100; + } // end if ( angle < 2320 ) + } // end for ( angle = 720; angle < 6480; angle += 160 ) +#endif + paint.end(); + // + // painting done + + QBitmap mask ( pix-> width ( ), pix-> height ( ), true ); + QPainter mp ( &mask ); + mp. setPen ( Qt::NoPen ); + mp. setBrush ( Qt::color1 ); + mp. drawEllipse ( 0, 0, width + 2, width + 2 ); + mp. end ( ); + + pix-> setMask ( mask ); +} + diff --git a/core/applets/volumeapplet/oledbox.h b/core/applets/volumeapplet/oledbox.h new file mode 100644 index 0000000..4371a22 --- a/dev/null +++ b/core/applets/volumeapplet/oledbox.h @@ -0,0 +1,51 @@ +#ifndef __OPIE_OLED_H__ +#define __OPIE_OLED_H__ + +#include <qwidget.h> +#include <qcolor.h> + +class QPixmap; + +#define _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC + +class OLedBox : public QWidget { + Q_OBJECT + +public: + OLedBox ( const QColor &col = red, QWidget *parent = 0, const char *name = 0 ); + virtual ~OLedBox ( ); + + QColor color ( ) const; + bool isOn ( ) const; + + virtual QSize sizeHint ( ) const; + +public slots: + void toggle ( ); + void setOn ( bool on ); + void setColor ( const QColor &col ); + +signals: + void toggled ( bool ); + +protected: + virtual void paintEvent ( QPaintEvent *e ); + virtual void resizeEvent ( QResizeEvent *e ); + + virtual void mousePressEvent ( QMouseEvent *e ); + +private: + void drawLed ( QPixmap *, const QColor &col ); + +private: + QPixmap *m_pix [2]; + + QColor m_color; + bool m_on; + +#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC + static QPixmap *s_border_pix; +#endif +}; + +#endif diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index d871a35..a000087 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp @@ -1,451 +1,635 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +#include <stdio.h> #include "volume.h" #include <qpe/resource.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) #include <qpe/qcopenvelope_qws.h> #endif #include <qpainter.h> #include <qcheckbox.h> #include <qslider.h> #include <qlayout.h> #include <qframe.h> #include <qpixmap.h> #include <qlabel.h> +#include <qtoolbutton.h> #include <qpushbutton.h> #include <qtimer.h> +#include <opie/odevice.h> + +#include "oledbox.h" + #define RATE_TIMER_INTERVAL 100 // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. -VolumeControl::VolumeControl( bool showMic, QWidget *parent, const char *name ) - : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) + +/* XPM */ +static const char * vol_xpm[] = { +"20 20 3 1", +" c None", +". c #0000FF", +"+ c #000000", +" ", +" . ", +" . . . . ", +" . . . . . . ", +" . . . . . . . ", +" . . ..... . . ", +" . ... ..... ... ", +" ........... .... ", +" ................. ", +"++++++++++++++++++++", +" .................. ", +" . ............. . ", +" . ..... ....... ", +" . ... ..... . ", +" . ... ..... . ", +" . ... ..... ", +" . . . . . ", +" . . . ", +" . . . ", +" "}; +/* XPM */ +static const char * mic_xpm[] = { +"20 20 21 1", +" c None", +". c #000000", +"+ c #EEEEEE", +"@ c #B4B6B4", +"# c #8B8D8B", +"$ c #D5D6D5", +"% c #E6E6E6", +"& c #9C9D9C", +"* c #6A696A", +"= c #E6E2E6", +"- c #F6F2F6", +"; c #CDC6CD", +"> c #737573", +", c #4A484A", +"' c #DEDEDE", +") c #F6EEF6", +"! c #414041", +"~ c #202020", +"{ c #ACAEAC", +"] c #838583", +"^ c #6A656A", +" ", +" .... ", +" .+@+#. ", +" ..$%&%*. ", +" .=-.;=>=,. ", +" .'+).&+!+. ", +" .+;+;.~+~. ", +" ..%{%,.... ", +" ..&=>=~.. ", +" .+..]^,.. ", +" .+....... ", +" .%... ", +" .=... ", +" .+... ", +" .+... ", +" .... ", +" .... ", +" .. ", +" . ", +". "}; + +/* XPM */ +static const char * alarm_xpm[] = { +"20 20 33 1", +" c None", +". c #080602", +"+ c #AAA602", +"@ c #252002", +"# c #434202", +"$ c #795602", +"% c #C3C20D", +"& c #DADAC2", +"* c #826002", +"= c #740502", +"- c #D6D602", +"; c #322E02", +"> c #826A02", +", c #F1F195", +"' c #959215", +") c #423602", +"! c #4B0302", +"~ c #844315", +"{ c #AAAA2A", +"] c #E2DE42", +"^ c #BA7E04", +"/ c #7F7502", +"( c #828276", +"_ c #FEFE4E", +": c #7D1902", +"< c #989656", +"[ c #260B02", +"} c #F7F7D8", +"| c #DCDA5A", +"1 c #823102", +"2 c #B1AC6B", +"3 c #F7F710", +"4 c #838204", +" ", +" ", +" 4'4/ ", +" /-^= ", +" 42{4>4 ", +" '2|+*$44 ", +" +2&3+$1*44 ", +" (%_}_+/$:>/4 ", +" 4%_}3+#;>:*4 ", +" 4%_}&+#[1$/4 ", +" 4%_,2')[~~>4 ", +" 4%33'4#@~1>4 ", +" 4%3344#[:>/4 ", +" 42&_3'4#@>:*44 ", +" 42|}}3'4#[;$)$44 ", +"444{]]2^~~:!!#.@##/ ", +"4444-%*:==!!=...../ ", +" /:[.. ", +" /@. ", +" "}; + +VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) + : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) { - setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); - createView(showMic); + m_icon = icon; + + bool has_wav_alarm = false; + + switch ( ODevice::inst ( )-> model ( )) { + case OMODEL_iPAQ_H31xx: + case OMODEL_iPAQ_H36xx: + case OMODEL_iPAQ_H37xx: + case OMODEL_iPAQ_H38xx: + has_wav_alarm = true; + break; + default: + break; } -void VolumeControl::createView(bool showMic) -{ - Config cfg("qpe"); - cfg.setGroup("Volume"); -//showMic = TRUE; - QHBoxLayout *hboxLayout = new QHBoxLayout(this); - hboxLayout->setMargin( 3 ); - hboxLayout->setSpacing( 0); - QVBoxLayout *vboxButtons = new QVBoxLayout(this); + setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); + + QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); + grid-> setSpacing ( 4 ); + grid-> setMargin ( 6 ); + + QVBoxLayout *vbox; + QLabel *l; + + vbox = new QVBoxLayout ( ); + vbox-> setSpacing ( 4 ); + grid-> addLayout ( vbox, 1, 0 ); + upButton = new QPushButton( this ); upButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); upButton->setPixmap( Resource::loadPixmap( "up" ) ); + upButton-> setFocusPolicy ( QWidget::NoFocus ); + + vbox-> addWidget ( upButton ); + downButton = new QPushButton( this ); downButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); downButton->setPixmap( Resource::loadPixmap( "down" ) ); - vboxButtons->setSpacing( 2 ); - - upButton->setFixedHeight(26); - downButton->setFixedHeight(26); - - vboxButtons->addWidget( upButton ); - vboxButtons->addWidget( downButton ); - - QVBoxLayout *vbox = new QVBoxLayout( this ); - QHBoxLayout *hbox = NULL; - - slider = new QSlider( this ); - slider->setRange( 0, 100 ); - slider->setTickmarks( QSlider::Both ); - slider->setTickInterval( 20 ); - slider->setFocusPolicy( QWidget::NoFocus ); - slider->setValue(cfg.readNumEntry("VolumePercent")); - - QVBoxLayout *sbox = new QVBoxLayout(this); - sbox->setMargin( 3 ); - sbox->setSpacing( 3 ); - sbox->addWidget( new QLabel("Vol", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); - sbox->addWidget( slider, 0, Qt::AlignVCenter | Qt::AlignHCenter ); - -// if (showMic == TRUE) { - mic = new QSlider(this); - mic->setRange( 0, 100 ); - mic->setTickmarks( QSlider::Both ); - mic->setTickInterval( 20 ); - mic->setFocusPolicy( QWidget::NoFocus ); - mic->setValue(cfg.readNumEntry("Mic")); - - QVBoxLayout *mbox = new QVBoxLayout(this); - mbox->setMargin( 3 ); - mbox->setSpacing( 3 ); - mbox->addWidget( new QLabel("Mic", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); - mbox->addWidget( mic, 0, Qt::AlignVCenter | Qt::AlignHCenter ); - - hbox = new QHBoxLayout( this ); - hbox->setMargin( 3 ); - hbox->setSpacing( 3 ); - hbox->addLayout( sbox, 1); - hbox->addLayout( mbox, 1); - // } - - muteBox = new QCheckBox( tr("Mute"), this ); - muteBox->setFocusPolicy( QWidget::NoFocus ); - - QVBoxLayout *klbox = new QVBoxLayout(this); - - QLabel *Label1; - Label1 = new QLabel( this, "Label1" ); - Label1->setText( tr( "Enable Sounds for:" )); - - alarmSound = new QCheckBox( tr("Alarm Sound"), this ); - alarmSound->setFocusPolicy( QWidget::NoFocus ); - - keyclicks = new QCheckBox( tr("Key Clicks"), this ); - keyclicks->setFocusPolicy( QWidget::NoFocus ); - - screentaps = new QCheckBox( tr("Screen taps"), this ); - screentaps->setFocusPolicy( QWidget::NoFocus ); - - - keyclicks->setChecked( cfg.readBoolEntry("KeySound",0)); - screentaps->setChecked( cfg.readBoolEntry("TouchSound",0)); - alarmSound->setChecked( cfg.readBoolEntry("AlarmSound",1)); - - klbox->setMargin( 3 ); - klbox->setSpacing( 0 ); - klbox->addWidget( Label1, 1); - klbox->addWidget( alarmSound, 1); - klbox->addWidget( keyclicks, 1); - klbox->addWidget( screentaps, 1); - vbox->setMargin( 3 ); - vbox->setSpacing( 0 ); -// if (showMic == TRUE) - vbox->addLayout( hbox, 1 ); -// else -// vbox->addLayout( sbox, 1); - vbox->addWidget( muteBox, 0, Qt::AlignVCenter | Qt::AlignHCenter ); - - hboxLayout->addLayout( vboxButtons ); - hboxLayout->addLayout( vbox); - hboxLayout->addLayout( klbox); - - - setFixedHeight( 120); -// setFixedWidth( sizeHint().width() ); + downButton-> setFocusPolicy ( QWidget::NoFocus ); + + vbox-> addWidget ( downButton ); + + volSlider = new QSlider ( this ); + volSlider-> setRange ( 0, 100 ); + volSlider-> setTickmarks ( QSlider::Both ); + volSlider-> setTickInterval ( 20 ); + volSlider-> setFocusPolicy ( QWidget::NoFocus ); + + l = new QLabel ( this ); + l-> setPixmap ( QPixmap ( vol_xpm )); + + grid-> addWidget ( l, 0, 1, AlignCenter ); + grid-> addWidget ( volSlider, 1, 1, AlignCenter ); + + volLed = new OLedBox ( green, this ); + volLed-> setFocusPolicy ( QWidget::NoFocus ); + volLed-> setFixedSize ( 16, 16 ); + + grid-> addWidget ( volLed, 2, 1, AlignCenter ); + + micSlider = new QSlider ( this ); + micSlider-> setRange ( 0, 100 ); + micSlider-> setTickmarks ( QSlider::Both ); + micSlider-> setTickInterval ( 20 ); + micSlider-> setFocusPolicy ( QWidget::NoFocus ); + + l = new QLabel ( this ); + l-> setPixmap ( QPixmap ( mic_xpm )); + + grid-> addWidget ( l, 0, 2, AlignCenter ); + grid-> addWidget ( micSlider, 1, 2, AlignCenter ); + + micLed = new OLedBox ( red, this ); + micLed-> setFocusPolicy ( QWidget::NoFocus ); + micLed-> setFixedSize ( 16, 16 ); + + grid-> addWidget ( micLed, 2, 2, AlignCenter ); + + alarmSlider = new QSlider ( this ); + alarmSlider-> setRange ( 0, 100 ); + alarmSlider-> setTickmarks ( QSlider::Both ); + alarmSlider-> setTickInterval ( 20 ); + alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); + + QLabel *alarmLabel = new QLabel ( this ); + alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); + + grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); + grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); + + alarmLed = new OLedBox ( yellow, this ); + alarmLed-> setFocusPolicy ( QWidget::NoFocus ); + alarmLed-> setFixedSize ( 16, 16 ); + + grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); + + if ( !has_wav_alarm ) { + alarmSlider-> hide ( ); + alarmLabel-> hide ( ); + alarmLed-> hide ( ); + } + + grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 4, AlignVCenter | AlignLeft ); + + vbox = new QVBoxLayout ( ); + vbox-> setSpacing ( 4 ); + grid-> addMultiCellLayout ( vbox, 1, 2, 4, 4 ); + + tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); + tapBox-> setFocusPolicy ( QWidget::NoFocus ); + + vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); + + keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); + keyBox-> setFocusPolicy ( QWidget::NoFocus ); + + vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); + + alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); + alarmBox-> setFocusPolicy ( QWidget::NoFocus ); + + vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); + + if ( has_wav_alarm ) { + alarmBox-> hide ( ); + } + + vbox-> addStretch ( 100 ); + + setFixedSize ( sizeHint ( )); setFocusPolicy(QWidget::NoFocus); - connect( upButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); - connect( upButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); - connect( downButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); - connect( downButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); rateTimer = new QTimer(this); connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); + + connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); + connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); + connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); + connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); + + connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); + connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); + connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); + + connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); + connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); + connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); + + connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); + connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); + connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); + + // initialize variables + + readConfig ( true ); + + // initialize the config file, in case some entries are missing + + writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); + writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); + writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); + writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); + writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); + writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); + + writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); + writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); } -void VolumeControl::keyPressEvent( QKeyEvent *e) +bool VolumeControl::volMuted ( ) const +{ + return m_vol_muted; +} + +int VolumeControl::volPercent ( ) const { - switch(e->key()) + return m_vol_percent; +} + +void VolumeControl::keyPressEvent ( QKeyEvent *e ) { + switch ( e-> key ( )) { case Key_Up: - slider->subtractStep(); + volSlider-> subtractStep ( ); break; case Key_Down: - slider->addStep(); + volSlider-> addStep ( ); break; case Key_Space: - muteBox->toggle(); + volLed-> toggle ( ); break; case Key_Escape: - close(); + hide ( ); break; } } -void VolumeControl::ButtonChanged() -{ - if ( upButton->isDown() || downButton->isDown() ) +void VolumeControl::buttonChanged ( ) { + if ( upButton-> isDown ( ) || downButton->isDown ( )) { rateTimerDone(); // Call it one time manually, otherwise it wont get // called at all when a button is pressed for a time // shorter than RATE_TIMER_INTERVAL. rateTimer->start( RATE_TIMER_INTERVAL, false ); } else rateTimer->stop(); } void VolumeControl::rateTimerDone() { if ( upButton->isDown() ) - slider->setValue( slider->value() - 2 ); - else // downButton->isDown() - slider->setValue( slider->value() + 2 ); + volSlider-> setValue ( volSlider-> value ( ) - 2 ); + else // if ( downButton-> isDown ( )) + volSlider-> setValue ( volSlider-> value ( ) + 2 ); } -//=========================================================================== - -VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) - : QWidget( parent, name ) +void VolumeControl::show ( bool /*showMic*/ ) { - Config cfg("qpe"); - cfg.setGroup("Volume"); + readConfig ( ); - setFixedHeight( 18 ); - setFixedWidth( 14 ); - - volumePixmap = Resource::loadPixmap( "volume" ); - - volumePercent = cfg.readNumEntry("VolumePercent",50); - micPercent = cfg.readNumEntry("Mic", 50); - muted = FALSE; // ### read from pref - micMuted = FALSE; // ### read from pref - - advancedTimer = new QTimer(this); + QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); + printf ( "SHOW AT : %d/%d\n", curPos.x(), curPos.y()); + printf ( "SIZEHINT: %d/%d\n", sizeHint().width(),sizeHint().height()); - connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); - connect( qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); - connect( advancedTimer, SIGNAL( timeout() ),this, SLOT( advVolControl()) ); + int w = sizeHint ( ). width ( ); + int x = curPos.x ( ) - ( w / 2 ); - writeSystemVolume(); - writeSystemMic(); -} - -VolumeApplet::~VolumeApplet() -{ -} + if (( x + w ) > QPEApplication::desktop ( )-> width ( )) + x = QPEApplication::desktop ( )-> width ( ) - w; -void VolumeApplet::keyPressEvent ( QKeyEvent * e ) -{ - QString s; - s.setNum(e->key()); - qWarning(s); -} -void VolumeApplet::mousePressEvent( QMouseEvent * ) -{ - advancedTimer->start( 750, TRUE ); -} -void VolumeApplet::mouseReleaseEvent( QMouseEvent * ) -{ - showVolControl(FALSE); -} + move ( x, curPos. y ( ) - sizeHint ( ). height ( )); + QFrame::show ( ); -void VolumeApplet::advVolControl() -{ - showVolControl(TRUE); } -void VolumeApplet::showVolControl(bool showMic) +void VolumeControl::readConfig ( bool force ) { Config cfg("qpe"); cfg.setGroup("Volume"); - volumePercent = cfg.readNumEntry("VolumePercent",50); - micPercent = cfg.readNumEntry("Mic", 50); - - // Create a small volume control window to adjust the volume with - VolumeControl *vc = new VolumeControl(showMic); - vc->slider->setValue( 100 - volumePercent ); -// if (showMic) -// { - vc->mic->setValue( 100 - micPercent ); - connect( vc->mic, SIGNAL( valueChanged( int ) ), this, SLOT( micMoved( int ) ) ); -// } - - vc->muteBox->setChecked( muted ); - connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); - connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); - - Config config("qpe"); - config.setGroup("Volume"); - vc->keyclicks->setChecked( config.readBoolEntry("KeySound",0)); - vc->screentaps->setChecked( config.readBoolEntry("TouchSound",0)); - vc->alarmSound->setChecked( config.readBoolEntry("AlarmSound",1)); - - connect( vc->alarmSound, SIGNAL(toggled(bool)), this, SLOT( alarmSoundCheckToggled(bool))); - connect( vc->keyclicks, SIGNAL(toggled(bool)), this, SLOT( keyclicksCheckToggled(bool))); - connect( vc->screentaps, SIGNAL(toggled(bool)), this, SLOT( screentapsCheckToggled(bool))); - - QPoint curPos = mapToGlobal( rect().topLeft() ); - vc->move( curPos.x()-(vc->sizeHint().width()/2+50), curPos.y() - 120 ); - vc->show(); - - advancedTimer->stop(); -} - -void VolumeApplet::volumeChanged( bool nowMuted ) + int old_vp = m_vol_percent; + int old_mp = m_mic_percent; + bool old_vm = m_vol_muted; + bool old_mm = m_mic_muted; + bool old_sk = m_snd_key; + bool old_st = m_snd_touch; + bool old_sa = m_snd_alarm; + int old_ap = m_alarm_percent; + + m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); + m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); + m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); + m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); + m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); + m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); + m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); + m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); + + if ( force || ( m_vol_percent != old_vp )) + volSlider-> setValue ( 100 - m_vol_percent ); + if ( force || ( m_mic_percent != old_mp )) + micSlider-> setValue ( 100 - m_mic_percent ); + if ( force || ( m_alarm_percent != old_ap )) + alarmSlider-> setValue ( 100 - m_alarm_percent ); + + if ( force || ( m_vol_muted != old_vm )) + volLed-> setOn ( !m_vol_muted ); + if ( force || ( m_mic_muted != old_mm )) + micLed-> setOn ( !m_mic_muted ); + if ( force || ( m_snd_alarm != old_sa )) + alarmLed-> setOn ( m_snd_alarm ); + + if ( force || ( m_snd_key != old_sk )) + keyBox-> setChecked ( m_snd_key ); + if ( force || ( m_snd_touch != old_st )) + tapBox-> setChecked ( m_snd_touch ); + if ( force || ( m_snd_alarm != old_sa )) + alarmBox-> setChecked ( m_snd_alarm ); +} + + +void VolumeControl::volumeChanged ( bool nowMuted ) { - int previousVolume = volumePercent; + int previousVolume = m_vol_percent; if ( !nowMuted ) - readSystemVolume(); + readConfig ( ); // Handle case where muting it toggled - if ( muted != nowMuted ) { - muted = nowMuted; - repaint( TRUE ); - return; + if ( m_vol_muted != nowMuted ) { + m_vol_muted = nowMuted; + m_icon-> repaint ( true ); } - + else if ( previousVolume != m_vol_percent ) { // Avoid over repainting - if ( previousVolume != volumePercent ) - repaint( 2, height() - 3, width() - 4, 2, FALSE ); + m_icon-> repaint( 2, height ( ) - 3, width ( ) - 4, 2, false ); + } + } -void VolumeApplet::micChanged( bool nowMuted ) +void VolumeControl::micChanged ( bool nowMuted ) { if (!nowMuted) - readSystemMic(); - micMuted = nowMuted; + readConfig ( ); + m_mic_muted = nowMuted; } -void VolumeApplet::mute( bool toggled ) +void VolumeControl::screenTapToggled ( bool b ) { - muted = toggled; - - // clear if removing mute - repaint( !toggled ); - writeSystemVolume(); - Config cfg("qpe"); - cfg.setGroup("Volume"); - if(muted) - cfg.writeEntry("Mute", "TRUE"); - else - cfg.writeEntry("Mute", "FALSE"); - cfg.write(); + m_snd_touch = b; + writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); } - -void VolumeApplet::sliderMoved( int percent ) +void VolumeControl::keyClickToggled ( bool b ) { - setVolume( 100 - percent ); + m_snd_key = b; + writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); } -void VolumeApplet::micMoved( int percent ) +void VolumeControl::alarmSoundToggled ( bool b ) { - setMic( 100 - percent ); + m_snd_alarm = b; + writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); } -void VolumeApplet::readSystemVolume() +void VolumeControl::volMuteToggled ( bool b ) { - Config cfg("qpe"); - cfg.setGroup("Volume"); - volumePercent = cfg.readNumEntry("VolumePercent"); + m_vol_muted = !b; + + m_icon-> repaint ( !m_vol_muted ); // clear if removing mute + + writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); } -void VolumeApplet::readSystemMic() +void VolumeControl::micMuteToggled ( bool b ) { - Config cfg("qpe"); - cfg.setGroup("Volume"); - micPercent = cfg.readNumEntry("Mic"); + m_mic_muted = !b; + writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); } -void VolumeApplet::setVolume( int percent ) + +void VolumeControl::volMoved ( int percent ) { + m_vol_percent = 100 - percent; + // clamp volume percent to be between 0 and 100 - volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); + m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); // repaint just the little volume rectangle - repaint( 2, height() - 3, width() - 4, 2, FALSE ); - writeSystemVolume(); + repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); + + writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); } -void VolumeApplet::setMic( int percent ) +void VolumeControl::micMoved ( int percent ) { + m_mic_percent = 100 - percent; + // clamp volume percent to be between 0 and 100 - micPercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); - writeSystemMic(); + m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); + + writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); } -void VolumeApplet::writeSystemVolume() +void VolumeControl::alarmMoved ( int percent ) { + m_alarm_percent = 100 - percent; + + // clamp volume percent to be between 0 and 100 + m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); + + writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); +} + + +void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) { Config cfg("qpe"); cfg.setGroup("Volume"); - cfg.writeEntry("VolumePercent",volumePercent); - } + cfg. writeEntry ( entry, val ); +// cfg. write ( ); + #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) - // Send notification that the volume has changed - QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; + switch ( upd ) { + case UPD_Vol: { + QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; + break; + } + case UPD_Mic: { + QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; + break; + } + case UPD_None: + break; + } #endif } -void VolumeApplet::writeSystemMic() +//=========================================================================== + +VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) + : QWidget( parent, name ) { + setFixedHeight ( 18 ); + setFixedWidth ( 14 ); + + m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); + m_dialog = new VolumeControl ( this ); + + connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); + connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); +} + +VolumeApplet::~VolumeApplet() { - Config cfg("qpe"); - cfg.setGroup("Volume"); - cfg.writeEntry("Mic",micPercent); + delete m_pixmap; } -#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) - // Send notification that the volume has changed - QCopEnvelope( "QPE/System", "micChange(bool)" ) << micMuted; -#endif + + +void VolumeApplet::mousePressEvent ( QMouseEvent * ) +{ + if ( m_dialog-> isVisible ( )) + m_dialog-> hide ( ); + else + m_dialog-> show ( true ); } + void VolumeApplet::paintEvent( QPaintEvent* ) { QPainter p(this); - if (volumePixmap.isNull()) - volumePixmap = Resource::loadPixmap( "volume" ); - p.drawPixmap( 0, 1, volumePixmap ); + p. drawPixmap ( 0, 1, *m_pixmap ); p.setPen( darkGray ); p.drawRect( 1, height() - 4, width() - 2, 4 ); - int pixelsWide = volumePercent * (width() - 4) / 100; + int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; p.fillRect( 2, height() - 3, pixelsWide, 2, red ); p.fillRect( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); - if ( muted ) { + if ( m_dialog-> volMuted ( )) { p.setPen( red ); p.drawLine( 1, 2, width() - 2, height() - 5 ); p.drawLine( 1, 3, width() - 2, height() - 4 ); p.drawLine( width() - 2, 2, 1, height() - 5 ); p.drawLine( width() - 2, 3, 1, height() - 4 ); } } -void VolumeApplet::screentapsCheckToggled(bool b) { - Config cfg("qpe"); - cfg.setGroup("Volume"); - cfg.writeEntry("TouchSound",b ); - cfg.write(); -} - -void VolumeApplet::keyclicksCheckToggled(bool b) { - Config cfg("qpe"); - cfg.setGroup("Volume"); - cfg.writeEntry("KeySound",b); - cfg.write(); -} - -void VolumeApplet::alarmSoundCheckToggled(bool b) { - Config cfg("qpe"); - cfg.setGroup("Volume"); - cfg.writeEntry("AlarmSound",b); - cfg.write(); -} diff --git a/core/applets/volumeapplet/volume.h b/core/applets/volumeapplet/volume.h index 6e631f2..ff5c64a 100644 --- a/core/applets/volumeapplet/volume.h +++ b/core/applets/volumeapplet/volume.h @@ -1,108 +1,124 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef __VOLUME_APPLET_H__ #define __VOLUME_APPLET_H__ -#include <qwidget.h> #include <qframe.h> -#include <qpixmap.h> -#include <qguardedptr.h> -#include <qtimer.h> +class QPixmap; +class QTimer; class QSlider; class QCheckBox; +class QButton; +class OLedBox; -class VolumeControl : public QFrame -{ +class VolumeApplet; + +class VolumeControl : public QFrame { Q_OBJECT -public: - VolumeControl( bool showMic=FALSE, QWidget *parent=0, const char *name=0 ); public: - QSlider *slider; - QSlider *mic; - QCheckBox *muteBox; - QCheckBox *alarmSound; - QCheckBox *screentaps; - QCheckBox *keyclicks; + VolumeControl ( VolumeApplet *icon, bool showMic = false, QWidget *parent=0, const char *name=0 ); + + bool volMuted ( ) const; + int volPercent ( ) const; + + virtual void show ( bool showmic ); + +protected: + virtual void keyPressEvent ( QKeyEvent * e ); + +protected slots: + void volumeChanged ( bool muted ); + void micChanged ( bool muted ); + +private slots: + void volMoved ( int percent ); + void micMoved ( int percent ); + void alarmMoved ( int percent ); + void volMuteToggled ( bool ); + void micMuteToggled ( bool ); + void alarmSoundToggled ( bool ); + void keyClickToggled ( bool ); + void screenTapToggled ( bool ); + + void buttonChanged ( ); + void rateTimerDone ( ); private: + void readConfig ( bool force = false ); + + enum eUpdate { + UPD_None, + UPD_Vol, + UPD_Mic + }; + void writeConfigEntry ( const char *entry, int val, eUpdate upd ); + + +private: + QSlider *volSlider; + QSlider *micSlider; + QSlider *alarmSlider; + OLedBox *volLed; + OLedBox *micLed; + OLedBox *alarmLed; + + QCheckBox *alarmBox; + QCheckBox *tapBox; + QCheckBox *keyBox; QPushButton *upButton; QPushButton *downButton; QTimer *rateTimer; - void keyPressEvent( QKeyEvent * ); - void createView(bool showMic = FALSE); -private slots: - void ButtonChanged(); - void rateTimerDone(); + int m_vol_percent; + int m_mic_percent; + int m_alarm_percent; + bool m_vol_muted; + bool m_mic_muted; + bool m_snd_alarm; + bool m_snd_touch; + bool m_snd_key; + VolumeApplet *m_icon; }; -class VolumeApplet : public QWidget -{ +class VolumeApplet : public QWidget { Q_OBJECT + public: VolumeApplet( QWidget *parent = 0, const char *name=0 ); ~VolumeApplet(); - bool isMute( ) { return muted; } - int percent( ) { return volumePercent; } -public slots: - void volumeChanged( bool muted ); - void micChanged( bool muted ); - void sliderMoved( int percent ); - void mute( bool ); - - void micMoved( int percent ); - void setVolume( int percent ); - void setMic( int percent ); - - void showVolControl(bool showMic = FALSE); - void advVolControl(); +protected: + virtual void mousePressEvent ( QMouseEvent * ); + virtual void paintEvent ( QPaintEvent* ); private: - int volumePercent, micPercent; - bool muted, micMuted; - QPixmap volumePixmap; - QTimer *advancedTimer; - - void readSystemVolume(); - void writeSystemVolume(); - void mousePressEvent( QMouseEvent * ); - void paintEvent( QPaintEvent* ); - - void readSystemMic(); - void keyPressEvent ( QKeyEvent * e ); - void mouseReleaseEvent( QMouseEvent *); - void writeSystemMic(); - -protected slots: - void alarmSoundCheckToggled(bool); - void keyclicksCheckToggled(bool); - void screentapsCheckToggled(bool); + QPixmap * m_pixmap; + VolumeControl *m_dialog; }; #endif // __VOLUME_APPLET_H__ diff --git a/core/applets/volumeapplet/volumeapplet.pro b/core/applets/volumeapplet/volumeapplet.pro index f89eea2..937a537 100644 --- a/core/applets/volumeapplet/volumeapplet.pro +++ b/core/applets/volumeapplet/volumeapplet.pro @@ -1,15 +1,15 @@ TEMPLATE = lib CONFIG += qt warn_on release -HEADERS = volume.h volumeappletimpl.h -SOURCES = volume.cpp volumeappletimpl.cpp +HEADERS = volume.h volumeappletimpl.h oledbox.h +SOURCES = volume.cpp volumeappletimpl.cpp oledbox.cpp TARGET = volumeapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += ../$(OPIEDIR)/include LIBS += -lqpe VERSION = 1.0.0 TRANSLATIONS = ../../i18n/de/libvolumeapplet.ts TRANSLATIONS += ../../i18n/es/libvolumeapplet.ts TRANSLATIONS += ../../i18n/pt/libvolumeapplet.ts TRANSLATIONS += ../../i18n/pt_BR/libvolumeapplet.ts diff --git a/core/applets/volumeapplet/volumeappletimpl.cpp b/core/applets/volumeapplet/volumeappletimpl.cpp index 943e71a..47506cc 100644 --- a/core/applets/volumeapplet/volumeappletimpl.cpp +++ b/core/applets/volumeapplet/volumeappletimpl.cpp @@ -1,74 +1,65 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "volume.h" #include "volumeappletimpl.h" #include <qpe/qcopenvelope_qws.h> #include <qpe/config.h> VolumeAppletImpl::VolumeAppletImpl() : volume(0), ref(0) { } VolumeAppletImpl::~VolumeAppletImpl() { delete volume; } QWidget *VolumeAppletImpl::applet( QWidget *parent ) { if ( !volume ) volume = new VolumeApplet( parent ); - - Config cfg("qpe"); - cfg.setGroup("Volume"); - QString foo = cfg.readEntry("Mute","TRUE"); - bool muted; - if(foo.find("TRUE",0,TRUE) != -1) - muted = TRUE; - else muted = FALSE; - QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; //mute return volume; } int VolumeAppletImpl::position() const { return 6; } QRESULT VolumeAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; if ( uuid == IID_QUnknown ) *iface = this; else if ( uuid == IID_TaskbarApplet ) *iface = this; if ( *iface ) (*iface)->addRef(); return QS_OK; } Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( VolumeAppletImpl ) } |