-rw-r--r-- | core/applets/volumeapplet/opie-volumeapplet.control | 2 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 13 |
2 files changed, 5 insertions, 10 deletions
diff --git a/core/applets/volumeapplet/opie-volumeapplet.control b/core/applets/volumeapplet/opie-volumeapplet.control index 3056520..731692a 100644 --- a/core/applets/volumeapplet/opie-volumeapplet.control +++ b/core/applets/volumeapplet/opie-volumeapplet.control @@ -1,10 +1,10 @@ Package: opie-volumeapplet Files: plugins/applets/libvolumeapplet.so* Priority: optional Section: opie/applets Maintainer: L.J. Potter <lpotter@trolltech.com> Architecture: arm -Depends: task-opie-minimal +Depends: task-opie-minimal, libopiecore2, libopieui2 Description: Volume applet Volume applet for the Opie environment taskbar. Version: $QPE_VERSION$EXTRAVERSION diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index 7f0aca5..7d67311 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp @@ -1,123 +1,123 @@ /********************************************************************** ** 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" /* OPIE */ #include <opie2/oledbox.h> #include <opie2/odevice.h> #include <opie2/otaskbarapplet.h> -#include <qpe/resource.h> +#include <opie2/oresource.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> using namespace Opie::Core; using namespace Opie::Ui; /* QT */ #include <qpainter.h> #include <qcheckbox.h> #include <qslider.h> #include <qlayout.h> #include <qvbox.h> #include <qlabel.h> #include <qpushbutton.h> #include <qtimer.h> /* STD */ #include <stdio.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. /* XPM */ using namespace Opie::Ui; 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", " ", " .... ", " .+@+#. ", " ..$%&%*. ", " .=-.;=>=,. ", " .'+).&+!+. ", " .+;+;.~+~. ", " ..%{%,.... ", " ..&=>=~.. ", " .+..]^,.. ", " .+....... ", " .%... ", " .=... ", " .+... ", " .+... ", " .... ", " .... ", " .. ", " . ", ". "}; @@ -179,203 +179,200 @@ static const char * treble_xpm[] = { /* 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 ) { m_icon = icon; bool has_wav_alarm = true; bool has_bass = true; bool has_treble = true; switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually case Model_Zaurus_SL5000: has_wav_alarm = false; //poor guys probably feeling left out... break; default: break; } if ( !ODevice::inst()->modelString().contains( "Model_iPAQ" )) { has_bass = false; has_treble = false; } 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 )); - QPixmap pic; - pic.convertFromImage( Resource::loadImage( "up" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); - upButton-> setPixmap ( pic ); + upButton-> setPixmap ( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) ); upButton-> setFocusPolicy ( QWidget::NoFocus ); vbox-> addWidget ( upButton ); downButton = new QPushButton ( this ); downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); - pic.convertFromImage( Resource::loadImage( "down" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); - downButton-> setPixmap ( pic ); + downButton-> setPixmap ( Opie::Core::OResource::loadPixmap( "down", Opie::Core::OResource::SmallIcon ) ); 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 ); QVBox *basstrebleBox = new QVBox( this ); trebleSlider = new QSlider ( basstrebleBox ); trebleSlider-> setRange ( 0, 100 ); trebleSlider-> setTickmarks ( QSlider::Both ); trebleSlider-> setTickInterval ( 20 ); trebleSlider->setMaximumHeight( 40 ); trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); bassSlider = new QSlider ( basstrebleBox ); bassSlider-> setRange ( 0, 100 ); bassSlider-> setTickmarks ( QSlider::Both ); bassSlider-> setTickInterval ( 20 ); bassSlider->setMaximumHeight( 40 ); bassSlider-> setFocusPolicy ( QWidget::NoFocus ); QLabel *bassLabel = new QLabel ( this ); bassLabel-> setPixmap ( QPixmap ( bass_xpm )); QLabel *trebleLabel = new QLabel( this ); trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); grid->addWidget( trebleLabel, 0, 4, AlignCenter ); grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); if ( !has_bass ) { bassSlider->hide(); bassLabel->hide(); } if ( !has_treble ) { trebleSlider->hide(); trebleLabel->hide(); } 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 ( ); @@ -634,155 +631,153 @@ void VolumeControl::volMoved ( int percent ) { m_vol_percent = 100 - percent; // clamp volume percent to be between 0 and 100 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); // repaint just the little volume rectangle m_icon-> redraw ( false ); writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); } void VolumeControl::micMoved ( int percent ) { m_mic_percent = 100 - percent; // clamp volume percent to be between 0 and 100 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); } 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::bassMoved ( int percent ) { m_bass_percent = 100 - percent; // clamp bass percent to be between 0 and 100 m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); } void VolumeControl::trebleMoved ( int percent ) { m_treble_percent = 100 - percent; // clamp treble percent to be between 0 and 100 m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); } void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) { Config cfg ( "qpe" ); cfg. setGroup ( "Volume" ); cfg. writeEntry ( entry, val ); // cfg. write ( ); #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 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_Bass: { QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; break; } case UPD_Treble: { QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; break; } case UPD_None: break; } #endif } //=========================================================================== VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { setFixedWidth ( AppLnk::smallIconSize() ); setFixedHeight ( AppLnk::smallIconSize()+4 ); - QPixmap pic; - pic.convertFromImage( Resource::loadImage( "volume" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); - m_pixmap = new QPixmap ( pic ); + m_pixmap = new QPixmap ( Opie::Core::OResource::loadPixmap( "volume", Opie::Core::OResource::SmallIcon ) ); m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool))); connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool))); } VolumeApplet::~VolumeApplet() { delete m_pixmap; } int VolumeApplet::position() { return 6; } void VolumeApplet::mousePressEvent ( QMouseEvent * ) { if ( m_dialog-> isVisible ( )) m_dialog-> hide ( ); else m_dialog-> show ( true ); } void VolumeApplet::redraw ( bool all ) { if ( all ) repaint ( true ); else repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); } void VolumeApplet::paintEvent ( QPaintEvent * ) { QPainter p ( this ); p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); p. setPen ( darkGray ); p. drawRect ( 1, height() - 4, width() - 2, 4 ); 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 ( 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 ); } } EXPORT_OPIE_APPLET_v1( VolumeApplet ) |