⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmvolumebar.cpp

📁 可以播放MP3,wma等文件格式的播放器
💻 CPP
字号:
/* qmvolumebar.cpp * * $Id: qmvolumebar.cpp,v 1.9 2002/03/07 03:44:17 mariuss Exp $ * * Apollo sound player: http://www.apolloplayer.org * Copyright(C) 2000-2002 Apollo Team.  See CREDITS file. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * * The GNU General Public License is also available online at: * * http://www.gnu.org/copyleft/gpl.html */#include "qmvolumebar.h"#include "qmmainwindow.h"#include "qmmixer.h"#include "qmstatusbar.h"#include <qlabel.h>#include <qslider.h>#include <qtimer.h>#include <qtoolbar.h>#include <qtooltip.h>/*!  \file qmvolumebar.cpp  Volume widget *//*!  \class QmVolumeBar qmvolumebar.h  \brief Represents the volume bar.  This class provides functionality for showing a volume bar in the main window.  Note that, despite the name, this class is derived from QToolBar.  So, it's really  a tool bar, but it's used as a volume bar.*//*!  Constructs a volume bar.  The \a status argument is needed for the communication  with the status bar. */QmVolumeBar::QmVolumeBar(	QmMainWindow *parent,	QmStatusBar *status)	: QToolBar(parent),	  m_pStatusBar(status),	  m_VolumePressed(false),	  m_ShortMessageTime(2000){	m_pMixer = QmMixer::instance();	setHorizontalStretchable(true);	(void) new QLabel(tr(" Volume "), this);	m_pVolume = new QSlider(0, 100, 1, 0, Horizontal, this);    m_pVolume->setValue( m_pMixer->volume() );	connect(m_pVolume, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int)));	connect(m_pVolume, SIGNAL(sliderPressed()), this, SLOT(volumePressed()));	connect(m_pVolume, SIGNAL(sliderReleased()), this, SLOT(volumeReleased()));	    m_pVolumeTimer = new QTimer(this);    connect(m_pVolumeTimer, SIGNAL(timeout()), this, SLOT(refreshVolume()));    m_pVolumeTimer->start(100, false);}/*!*/QmVolumeBar::~QmVolumeBar(){}/*!  Adjust the volume to \a v, this is called whenever the volume slider changes.*/voidQmVolumeBar::volumeChanged(	int v){    if ( ! m_VolumePressed )        m_pVolumeTimer->blockSignals( true );		m_pMixer->setVolume(v);	    if ( ! m_VolumePressed )        m_pVolumeTimer->blockSignals( false );    QToolTip::remove( m_pVolume );    QToolTip::add( m_pVolume, volumeText()  );    m_pStatusBar->showMessage( volumeText(), 2000 );}/*!  Refreshes the volume slider by reading from the mixer, this is done each 100 ms.  Adjust the timer value of m_pVolumeTimer to get a better update.*/voidQmVolumeBar::refreshVolume(){    if ( ! m_VolumePressed )    {        m_pVolume->blockSignals( true );        int vol = m_pMixer->volume();		        if ( vol != m_pVolume->value() )        {            m_pVolume->setValue( vol );            updateVolume( true, m_ShortMessageTime );        }		        m_pVolume->blockSignals( false );    }}/*!  Returns a text string saying "Volume: " and the current volume setting in percentage.  This is used for tooltips and status bars.*/QStringQmVolumeBar::volumeText() const{	return QString( "Volume: %1%" ).arg( m_pVolume->value() );}/*!  This is called when the volume slider is pressed.  This makes sure that the volume  is not updated when it changes externally, i.e. the user can change the volume.    \sa updateVolume()*/voidQmVolumeBar::volumePressed(){    m_pVolumeTimer->blockSignals( true );    m_VolumePressed = true;    updateVolume( true );}/*!  This is called when the volume slider is released.  This makes sure that the volume  can be updated when it changes externally.    \sa updateVolume()*/voidQmVolumeBar::volumeReleased(){    m_pVolumeTimer->blockSignals( false );    m_VolumePressed = false;    m_pStatusBar->showNameStatus(true);;    updateVolume( false );}/*!  Updates the volume information tooltip on the slider.  If \a in_status is true it will show show the volume information  in the status bar as well using \a time as the timeout.  \sa updateVolume()*/voidQmVolumeBar::updateVolume(	bool in_status,	int time){    QToolTip::remove( m_pVolume );    QToolTip::add( m_pVolume, volumeText() );    if ( in_status )        m_pStatusBar->showMessage( volumeText(), time );    else        m_pStatusBar->showSongInfo();}/*!  Updates the volume to show the current value of the mixer.  \sa updateVolume(bool, int)*/voidQmVolumeBar::updateVolume(){	m_pVolume->setValue(m_pMixer->volume());}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -