void VolumePopup::updateStockIcon() { if (!m_device) return; QString iconName; if (m_device->volume() <= 0 || m_device->mute()) iconName = "audio-volume-muted"; else if (m_device->volume() <= 33) iconName = "audio-volume-low"; else if (m_device->volume() <= 66) iconName = "audio-volume-medium"; else iconName = "audio-volume-high"; m_muteToggleButton->setIcon(XdgIcon::fromTheme(iconName)); emit stockIconChanged(iconName); }
VolumeButton::VolumeButton(ILxQtPanelPlugin *plugin, QWidget* parent): QToolButton(parent), mPlugin(plugin), m_panel(plugin->panel()), m_showOnClick(true), m_muteOnMiddleClick(true) { // initial icon for button. It will be replaced after devices scan. // In the worst case - no soundcard/pulse - is found it remains // in the button but at least the button is not blank ("invisible") handleStockIconChanged("dialog-error"); m_volumePopup = new VolumePopup(); m_popupHideTimer.setInterval(1000); connect(this, SIGNAL(clicked()), this, SLOT(toggleVolumeSlider())); connect(&m_popupHideTimer, SIGNAL(timeout()), this, SLOT(hideVolumeSlider())); connect(m_volumePopup, SIGNAL(mouseEntered()), &m_popupHideTimer, SLOT(stop())); connect(m_volumePopup, SIGNAL(mouseLeft()), &m_popupHideTimer, SLOT(start())); connect(m_volumePopup, SIGNAL(launchMixer()), this, SLOT(handleMixerLaunch())); connect(m_volumePopup, SIGNAL(stockIconChanged(QString)), this, SLOT(handleStockIconChanged(QString))); }