summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/volumeapplet/volume.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index 23c847d..11ba2f6 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -227,104 +227,107 @@ static const char * alarm_xpm[] = {
" 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 ));
- upButton-> setPixmap ( Resource::loadPixmap ( "up" ));
+ QPixmap pic;
+ pic.convertFromImage( Resource::loadImage( "up" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
+ upButton-> setPixmap ( pic );
upButton-> setFocusPolicy ( QWidget::NoFocus );
vbox-> addWidget ( upButton );
downButton = new QPushButton ( this );
downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
- downButton-> setPixmap ( Resource::loadPixmap ( "down" ));
+ pic.convertFromImage( Resource::loadImage( "down" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
+ downButton-> setPixmap ( pic );
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 );
@@ -679,97 +682,99 @@ void VolumeControl::trebleMoved ( int 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 );
- m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" ));
+ QPixmap pic;
+ pic.convertFromImage( Resource::loadImage( "volume" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
+ m_pixmap = new QPixmap ( pic );
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 );