Index: kdemultimedia-4.1.2/kmix/kmix.h =================================================================== --- kdemultimedia-4.1.2.orig/kmix/kmix.h 2008-11-02 23:12:00.169635871 -0500 +++ kdemultimedia-4.1.2/kmix/kmix.h 2008-11-02 23:14:29.069635452 -0500 @@ -29,6 +29,8 @@ class QLabel; #include #include +#include +#include class KTabWidget; // KDE @@ -115,6 +117,9 @@ QLabel *m_errorLabel; ViewDockAreaPopup *_dockAreaPopup; unsigned int m_configVersion; + QProgressBar* volumeDisplay; + QTimer* volumeDisplayTimer; + void showVolumeDisplay(); private slots: void saveConfig(); @@ -124,6 +129,10 @@ void plugged( const char* driverName, const QString& udi, QString& dev); void unplugged( const QString& udi); void hideOrClose(); + void slotIncreaseVolume(); + void slotDecreaseVolume(); + void slotHideVolumeDisplay(); + void slotMute(); }; #endif // KMIX_H Index: kdemultimedia-4.1.2/kmix/kmix.cpp =================================================================== --- kdemultimedia-4.1.2.orig/kmix/kmix.cpp 2008-11-02 23:12:00.081635859 -0500 +++ kdemultimedia-4.1.2/kmix/kmix.cpp 2008-11-02 23:14:54.528636526 -0500 @@ -25,6 +25,7 @@ // include files for QT #include #include +#include #include #include @@ -122,6 +123,32 @@ 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("Mute")); + globalAction->setGlobalShortcut(KShortcut(Qt::Key_VolumeMute)); + connect(globalAction, SIGNAL(triggered(bool) ), SLOT(slotMute())); + + volumeDisplay = new QProgressBar(); + volumeDisplay->setWindowFlags(Qt::X11BypassWindowManagerHint); + QDesktopWidget* desktop = KApplication::kApplication()->desktop(); + QRect rect = desktop->screenGeometry(); + int width = (rect.width()/2) - (volumeDisplay->width()/2); + int height = (rect.height()/2) - (volumeDisplay->height()/2); + volumeDisplay->move(width, height); + volumeDisplayTimer = new QTimer(this); + connect(volumeDisplayTimer, SIGNAL(timeout()), this, SLOT(slotHideVolumeDisplay())); + createGUI( "kmixui.rc" ); } @@ -570,6 +597,58 @@ } } +void KMixWindow::slotIncreaseVolume() +{ + Mixer* mixer = Mixer::getGlobalMasterMixer(); + MixDevice *master = mixer->getLocalMasterMD(); + mixer->setMute(master->id(), false); + mixer->increaseVolume(master->id()); + showVolumeDisplay(); +} + +void KMixWindow::slotDecreaseVolume() +{ + Mixer* mixer = Mixer::getGlobalMasterMixer(); + MixDevice *master = mixer->getLocalMasterMD(); + mixer->setMute(master->id(), false); + mixer->decreaseVolume(master->id()); + showVolumeDisplay(); +} + +void KMixWindow::showVolumeDisplay() +{ + Mixer* mixer = Mixer::getGlobalMasterMixer(); + int currentVolume = mixer->masterVolume(); + volumeDisplay->setValue(currentVolume); + if (mixer->mute("Master:0")) { + volumeDisplay->setValue(0); + } + volumeDisplay->show(); + + //FIXME, how to get this to work before it is displayed for the first time? + QDesktopWidget* desktop = KApplication::kApplication()->desktop(); + QRect rect = desktop->screenGeometry(); + int width = (rect.width()/2) - (volumeDisplay->width()/2); + int height = (rect.height()/2) - (volumeDisplay->height()/2); + volumeDisplay->move(width, height); + + volumeDisplayTimer->setInterval(2000); + volumeDisplayTimer->start(); +} + +void KMixWindow::slotHideVolumeDisplay() +{ + volumeDisplay->hide(); +} + +void KMixWindow::slotMute() +{ + Mixer* mixer = Mixer::getGlobalMasterMixer(); + MixDevice *master = mixer->getLocalMasterMD(); + mixer->toggleMute(master->id()); + showVolumeDisplay(); +} + void KMixWindow::quit() { // kDebug(67100) << "quit";