Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.2
kdemultimedia4
kmix-global-shortcuts.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File kmix-global-shortcuts.diff of Package kdemultimedia4
Subject: Assign multimedia volumeup/volumedown/mute keys to kmix by default From: Lubos Lunak Patch-upstream: no (4.2 seems to have something slightly different) This is just adding global shortcuts with default assignments (the i18n strings are not new, they are also elsewhere) and more or less copy&pasting code from the tray widget that does the same on scrollwheel. --- kmix/kmix.cpp.sav 2008-11-04 16:29:16.000000000 +0100 +++ kmix/kmix.cpp 2008-11-04 17:04:06.000000000 +0100 @@ -122,6 +122,22 @@ void KMixWindow::initActions() action = actionCollection()->addAction("toggle_channels_currentview"); action->setText(i18n("Configure &Channels...")); connect(action, SIGNAL(triggered(bool) ), SLOT(slotConfigureCurrentView())); + + KAction* globalAction = actionCollection()->addAction("increase_volume"); + globalAction->setText(i18n("Increase Volume")); + globalAction->setGlobalShortcut(KShortcut(Qt::Key_VolumeUp)); + connect(globalAction, SIGNAL(triggered(bool) ), SLOT(slotIncreaseVolume())); + + globalAction = actionCollection()->addAction("decrease_volume"); + globalAction->setText(i18n("Decrease Volume")); + globalAction->setGlobalShortcut(KShortcut(Qt::Key_VolumeDown)); + connect(globalAction, SIGNAL(triggered(bool) ), SLOT(slotDecreaseVolume())); + + globalAction = actionCollection()->addAction("mute"); + globalAction->setText(i18n("Toggle Mute")); + globalAction->setGlobalShortcut(KShortcut(Qt::Key_VolumeMute)); + connect(globalAction, SIGNAL(triggered(bool) ), SLOT(slotMute())); + createGUI( "kmixui.rc" ); } @@ -694,6 +710,54 @@ void KMixWindow::newMixerShown(int /*tab } } +// based on code from kmixdockwidget.cpp +void KMixWindow::slotIncreaseVolume() +{ + volumeHelper( true ); +} + +void KMixWindow::slotDecreaseVolume() +{ + volumeHelper( false ); +} + +void KMixWindow::volumeHelper( bool up ) +{ + MixDevice *md = Mixer::getGlobalMasterMD(); + if ( md != 0 ) + { + Volume vol = md->playbackVolume(); + if ( md->playbackVolume().hasVolume() ) + vol = md->playbackVolume(); + else + vol = md->captureVolume(); + + int inc = vol.maxVolume() / 20; + + if ( inc < 1 ) inc = 1; + + for ( int i = 0; i < vol.count(); i++ ) { + int newVal = vol[i] + (inc * ( up ? 1 : -1 )); + if( newVal < 0 ) newVal = 0; + vol.setVolume( (Volume::ChannelID)i, newVal < vol.maxVolume() ? newVal : vol.maxVolume() ); + } + + if ( md->playbackVolume().hasVolume() ) + md->playbackVolume().setVolume(vol); + else + md->captureVolume().setVolume(vol); + (Mixer::getGlobalMasterMixer())->commitVolumeChange(md); + } +} + +void KMixWindow::slotMute() +{ + MixDevice *md = Mixer::getGlobalMasterMD(); + if ( md != 0 ) { + md->setMuted( !md->isMuted() ); + md->mixer()->commitVolumeChange( md ); + } +} #include "kmix.moc" --- kmix/kmix.h.sav 2008-11-04 16:29:16.000000000 +0100 +++ kmix/kmix.h 2008-11-04 16:42:38.000000000 +0100 @@ -70,6 +70,7 @@ KMixWindow : public KXmlGuiWindow void clearMixerWidgets(); void fixConfigAfterRead(); + void volumeHelper( bool up ); virtual bool queryClose(); @@ -124,6 +125,9 @@ KMixWindow : public KXmlGuiWindow void plugged( const char* driverName, const QString& udi, QString& dev); void unplugged( const QString& udi); void hideOrClose(); + void slotIncreaseVolume(); + void slotDecreaseVolume(); + void slotMute(); }; #endif // KMIX_H
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor