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

📄 qmmpg123page.cpp

📁 可以播放MP3,wma等文件格式的播放器
💻 CPP
字号:
/* qmmpg123page.cpp * * $Id: qmmpg123page.cpp,v 1.19 2002/03/17 15:34:30 kyllingstad 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 "qmmpg123page.h"#include "qmconfig.h"#include "qmconfigpage.h"#include <iostream>#include <qbuttongroup.h>#include <qfiledialog.h>#include <qlabel.h>#include <qlayout.h>#include <qlineedit.h>#include <qpushbutton.h>#include <qradiobutton.h>#include <qslider.h>#include <qvgroupbox.h>#include <qcheckbox.h>/** * @file qmmpg123page.cpp * @brief The preferences page for mpg123.*//*!  \class QmMpg123Page qmmpg123page.h  \brief The preferences page for mpg123.  \todo Make a common config page interface into a base class.  Deal with 'Cancel',  'Apply', 'Okay', 'Reset' etc.*//*!  Initializes the page.*/QmMpg123Page::QmMpg123Page(	QmConfigDialog *parent,	const char *name)	: QmConfigPage(parent, name){	QmConfig *conf = QmConfig::instance();	QVBoxLayout *main = new QVBoxLayout(this, 4);	// The labels use <table> ... to make the contents resizable.	QVGroupBox *filegroup = new QVGroupBox(tr("Path"), this);	(void) new QLabel(tr("<table><tr><td>"						 "Enter the full path to mpg123 below.  "						 "Apollo uses mpg123 to play MP3 files."						 "</td></tr></table>"),					  filegroup);	m_pPath	= new QLineEdit(conf->getString( "mpg123", "path" ), filegroup);	connect(m_pPath, SIGNAL(textChanged(const QString&)), this, SLOT(changed())); 	QPushButton *browse = new QPushButton(tr("Browse"), filegroup);	connect(browse, SIGNAL(clicked()), this, SLOT(browse()));//	m_pUseArtsdsp = new QCheckBox(tr("<table><tr><td>"	(void) new QLabel(tr("<table><tr><td>"							 "Path to artsdsp, leave blank if you don't use it.  "						 "It's needed when artsd is used.  If you don't know, "						 "check with `ps | grep artsd' on the command line."						 "</td></tr></table>"), filegroup);	m_pArtsdspPath = new QLineEdit(conf->getString( "mpg123", "artsdsp" ), filegroup);	connect(m_pArtsdspPath, SIGNAL(textChanged(const QString&)), this, SLOT(changed()));			QPushButton *browseArtsdsp = new QPushButton(tr("Browse"), filegroup);	connect(browseArtsdsp, SIGNAL(clicked()), this, SLOT(browseArtsdp()));	main->addWidget(filegroup);    QHBoxLayout *sub1 = new QHBoxLayout(4);    main->addLayout( sub1, 0 );    {//          QButtonGroup *res = new QButtonGroup(2, Qt::Vertical,//                                               tr("Resolution"),this);//          QRadioButton *bits_sixteen = new QRadioButton(tr("16 bit"), res, "16Bit");//          QRadioButton *bits_eight = new QRadioButton(tr("8 bit"), res, "8Bit");        m_pChannelGroup = new QButtonGroup(2, Qt::Vertical,                                              tr("Channels"),this);		connect(m_pChannelGroup, SIGNAL(clicked(int)), this, SLOT(changed()));        (void) new QRadioButton(tr("Stereo (if available)"), m_pChannelGroup, "Stereo");        (void) new QRadioButton(tr("Mono"), m_pChannelGroup, "Mono");        m_pDownSampleGroup = new QButtonGroup(3, Qt::Vertical,                                              tr("Down sample"),this);		connect(m_pDownSampleGroup, SIGNAL(clicked(int)), this, SLOT(changed()));        (void) new QRadioButton(tr("1:1 (44 kHz)"), m_pDownSampleGroup, "1:1");        (void) new QRadioButton(tr("1:2 (22 kHz)"), m_pDownSampleGroup, "1:2");        (void) new QRadioButton(tr("1:4 (11 kHz)"), m_pDownSampleGroup, "1:4");//          sub1->addWidget(res);        sub1->addWidget(m_pChannelGroup);        sub1->addWidget(m_pDownSampleGroup);        // Set defaults        m_pChannelGroup->setButton( 0 );        m_pDownSampleGroup->setButton( 0 );    }// 	main->addWidget(filegroup);//     QHBoxLayout *sub1 = new QHBoxLayout(4);//     main->addLayout( sub1, 0 );//     {// //          QButtonGroup *res = new QButtonGroup(2, Qt::Vertical,// //                                               tr("Resolution"),this);// //          QRadioButton *bits_sixteen = new QRadioButton(tr("16 bit"), res, "16Bit");// //          QRadioButton *bits_eight = new QRadioButton(tr("8 bit"), res, "8Bit");//         m_pChannelGroup = new QButtonGroup(2, Qt::Vertical,//                                               tr("Channels"),this);//         (void) new QRadioButton(tr("Stereo (if available)"), m_pChannelGroup, "Stereo");//         (void) new QRadioButton(tr("Mono"), m_pChannelGroup, "Mono");//         m_pDownSampleGroup = new QButtonGroup(3, Qt::Vertical,//                                               tr("Down sample"),this);//         (void) new QRadioButton(tr("1:1 (44 kHz)"), m_pDownSampleGroup, "1:1");//         (void) new QRadioButton(tr("1:2 (22 kHz)"), m_pDownSampleGroup, "1:2");//         (void) new QRadioButton(tr("1:4 (11 kHz)"), m_pDownSampleGroup, "1:4");// //          sub1->addWidget(res);//         sub1->addWidget(m_pChannelGroup);//         sub1->addWidget(m_pDownSampleGroup);//         // Set defaults//         m_pChannelGroup->setButton( 0 );//         m_pDownSampleGroup->setButton( 0 );//     }#ifdef ENABLE_MPG123_BUFFER		QVGroupBox *buffergroup = new QVGroupBox(tr("Buffer"), this);	(void) new QLabel(tr("<table><tr><td>"						 "If you provide mpg123 with a buffer, you are less "						 "likely to experience \"jumps\" during play when "						 "the load on the system is high.  Player operations "						 "will be delayed, however, as mpg123 will play from "						 "the buffer before responding to commands."						 "</td></tr></table>"),					  buffergroup);	m_pBuffer = new QSlider(0, 10, 1, 0, Horizontal, buffergroup);	m_pBuffer->setTracking(true);	m_pBuffer->setTickmarks(QSlider::Below);		m_pBufferSize = new QLabel(tr("No buffer"), buffergroup);	m_pBufferSize->setFixedSize(m_pBufferSize->sizeHint());	connect(m_pBuffer, SIGNAL(valueChanged(int)), this, SLOT(bufferChanged(int)));		main->addWidget(buffergroup);#endif // ENABLE_MPG123_BUFFER	}/*!  Destroys the page.*/QmMpg123Page::~QmMpg123Page(){}/*!  Displays the buffer size \a value (megabytes) in the corresponding label. */voidQmMpg123Page::bufferChanged(	int value){	QString str;	if(value == 0)		str = tr("No buffer");	else		str = tr("%1 MB").arg(value);		m_pBufferSize->setText(str);	changed();}/*!  Opens a file dialog for locating mpg123.*/voidQmMpg123Page::browse(){	QString str = QFileDialog::getOpenFileName(QString::null, QString::null, this);	if( ! str.isNull())		m_pPath->setText(str);		changed();}voidQmMpg123Page::browseArtsdp(){	QString str = QFileDialog::getOpenFileName(QString::null, QString::null, this);	if( ! str.isNull())	{		m_pArtsdspPath->setText(str);		changed();	}}/*! */voidQmMpg123Page::load(){	QmConfig *conf = QmConfig::instance();	m_pPath->setText(conf->getString( "mpg123", "path" ));	m_pArtsdspPath->setText(conf->getString( "mpg123", "artsdsp" ));	m_pChannelGroup->setButton(conf->getString( "mpg123", "channels" ) == "mono" ? 1 : 0);    int down_id = conf->getInt( "mpg123", "downsample" );	m_pDownSampleGroup->setButton((down_id > 2 || down_id < 0) ? 0 : down_id);#ifdef ENABLE_MPG123_BUFFER		int initval;	conf->get( "mpg123", "buffer", initval );	m_pBuffer->setValue(initval);#endif	}// void// QmMpg123Page::load()// {// 	m_pPath->setText(QmConfig::instance()->getString( "mpg123", "path" ));// 	m_pChannelGroup->setButton(QmConfig::instance()->getString( "mpg123", "channels" ) == "mono" ? 1 : 0);//     int down_id = QmConfig::instance()->getInt( "mpg123", "downsample" );// 	m_pDownSampleGroup->setButton((down_id > 2 || down_id < 0) ? 0 : down_id);// #ifdef ENABLE_MPG123_BUFFER	// 	int initval;// 	QmConfig::instance()->get( "mpg123", "buffer", initval );// 	m_pBuffer->setValue(initval);// #endif	// }/*! */voidQmMpg123Page::save(){#ifdef ENABLE_MPG123_BUFFER	QmConfig::instance()->set("mpg123", "buffer", m_pBuffer->value());#endif	QmConfig::instance()->set("mpg123", "channels",                              m_pChannelGroup->id(m_pChannelGroup->selected()) == 1 ? "mono" : "stereo");	QmConfig::instance()->set("mpg123", "downsample",                              m_pDownSampleGroup->id(m_pDownSampleGroup->selected()));	QmConfig::instance()->set("mpg123", "path", m_pPath->text());	QmConfig::instance()->set("mpg123", "artsdsp", m_pArtsdspPath->text());}// void// QmMpg123Page::save()// {// #ifdef ENABLE_MPG123_BUFFER	// 	QmConfig::instance()->set("mpg123", "buffer", m_pBuffer->value());// #endif// 	QmConfig::instance()->set("mpg123", "channels",//                               m_pChannelGroup->id(m_pChannelGroup->selected()) == 1 ? "mono" : "stereo");// 	QmConfig::instance()->set("mpg123", "downsample",//                               m_pDownSampleGroup->id(m_pDownSampleGroup->selected()));// 	QmConfig::instance()->set("mpg123", "path", m_pPath->text());// }/*! */voidQmMpg123Page::discard(){	load();}

⌨️ 快捷键说明

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