void KMixDockWidget::createActions() { // Put "Mute" selector in context menu (void)new KToggleAction( i18n( "M&ute" ), 0, this, SLOT( dockMute() ), actionCollection(), "dock_mute" ); KAction *a = actionCollection()->action( "dock_mute" ); KPopupMenu *popupMenu = contextMenu(); if ( a ) a->plug( popupMenu ); // Put "Select Master Channel" dialog in context menu if ( m_mixer != 0 ) { (void)new KAction( i18n("Select Master Channel..."), 0, this, SLOT(selectMaster()), actionCollection(), "select_master"); KAction *a2 = actionCollection()->action( "select_master" ); if (a2) a2->plug( popupMenu ); } // Setup volume preview if ( _playBeepOnVolumeChange ) { _audioPlayer = new KAudioPlayer("KDE_Beep_Digital_1.ogg"); } }
KMixDockWidget::KMixDockWidget(KMixWindow* parent) : KStatusNotifierItem(parent) , _oldToolTipValue(-1) , _oldPixmapType('-') , _kmixMainWindow(parent) , _delta(0) { setToolTipIconByName("kmix"); setTitle(i18n( "Volume Control")); setCategory(Hardware); setStatus(Active); // TODO Unity / Gnome only support one type of activation (left-click == right-click) // So we should show here the ViewDockAreaPopup instead of the menu: //bool onlyOneMouseButtonAction = onlyHaveOneMouseButtonAction(); createMenuActions(); connect(this, SIGNAL(scrollRequested(int,Qt::Orientation)), this, SLOT(trayWheelEvent(int,Qt::Orientation))); connect(this, SIGNAL(secondaryActivateRequested(QPoint)), this, SLOT(dockMute())); // For bizarre reasons, we wrap the ViewDockAreaPopup in a KMenu. Must relate to how KStatusNotifierItem works. _dockAreaPopupMenuWrapper = new KMenu(parent); _volWA = new QWidgetAction(_dockAreaPopupMenuWrapper); _dockView = new ViewDockAreaPopup(_dockAreaPopupMenuWrapper, "dockArea", 0, QString("no-guiprofile-yet-in-dock"), parent); _volWA->setDefaultWidget(_dockView); _dockAreaPopupMenuWrapper->addAction(_volWA); connect(contextMenu(), SIGNAL(aboutToShow()), this, SLOT(contextMenuAboutToShow())); ControlManager::instance().addListener( QString(), // All mixers (as the Global master Mixer might change) (ControlChangeType::Type) (ControlChangeType::Volume | ControlChangeType::MasterChanged), this, QString("KMixDockWidget")); // Refresh in all cases. When there is no Golbal Master we still need // to initialize correctly (e.g. for showin 0% or hiding it) refreshVolumeLevels(); }