void KMixDockWidget::wheelEvent(QWheelEvent *e) { MixDevice *md = 0; if ( _dockAreaPopup != 0 ) { md = _dockAreaPopup->dockDevice(); } if ( md != 0 ) { Volume vol = md->getVolume(); int inc = vol.maxVolume() / 20; if ( inc == 0 ) inc = 1; for ( int i = 0; i < vol.count(); i++ ) { int newVal = vol[i] + (inc * (e->delta() / 120)); if( newVal < 0 ) newVal = 0; vol.setVolume( (Volume::ChannelID)i, newVal < vol.maxVolume() ? newVal : vol.maxVolume() ); } if ( _playBeepOnVolumeChange ) { _audioPlayer->play(); } md->getVolume().setVolume(vol); m_mixer->commitVolumeChange(md); // refresh the toolTip (Qt removes it on a MouseWheel event) // Mhhh, it doesn't work. Qt does not show it again. setVolumeTip(); // Simulate a mouse move to make Qt show the tooltip again QApplication::postEvent( this, new QMouseEvent( QEvent::MouseMove, QCursor::pos(), Qt::NoButton, Qt::NoButton ) ); } }
void KMixDockWidget::createMasterVolWidget() { // Reset flags, so that the dock icon will be reconstructed _oldToolTipValue = -1; _oldPixmapType = '-'; if (m_mixer == 0) { // In case that there is no mixer installed, there will be no newVolumeLevels() signal's // Thus we prepare the dock areas manually setVolumeTip(); updatePixmap(); return; } // create devices _dockAreaPopup = new ViewDockAreaPopup(0, "dockArea", m_mixer, 0, this); _dockAreaPopup->createDeviceWidgets(); m_mixer->readSetFromHWforceUpdate(); // after changing the master device, make sure to re-read (otherwise no "changed()" signals might get sent by the Mixer /* With the recently introduced QSocketNotifier stuff, we can't rely on regular timer updates any longer. Also the readSetFromHWforceUpdate() won't be enough. As a workaround, we trigger all "repaints" manually here. The call to m_mixer->readSetFromHWforceUpdate() is most likely superfluous, even if we don't use QSocketNotifier (e.g. in backends OSS, Solaris, ...) */ setVolumeTip(); updatePixmap(); /* We are setting up 3 connections: * Refreshig the _dockAreaPopup (not anymore neccesary, because ViewBase already does it) * Refreshing the Tooltip * Refreshing the Icon * */ // connect( m_mixer, SIGNAL(newVolumeLevels()), _dockAreaPopup, SLOT(refreshVolumeLevels()) ); connect( m_mixer, SIGNAL(newVolumeLevels()), this, SLOT(setVolumeTip() ) ); connect( m_mixer, SIGNAL(newVolumeLevels()), this, SLOT(updatePixmap() ) ); }
/** * Updates all visual parts of the volume, namely tooltip and pixmap */ void KMixDockWidget::refreshVolumeLevels() { setVolumeTip(); updatePixmap(); }