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

📄 recordservice.cpp

📁 基于linux的录音程序
💻 CPP
字号:
#include "mediarecorder.h"#include "recordservice.h"#include "mediarecorderbase.h"#include <qstring.h>#include <qpixmap.h>#include <qdir.h>//#include <qpainter.h>//#include <qpen.h>RecordService::RecordService( QWidget *parent, const char *name,WFlags f1 )	:QMainWindow( parent, name, f1 ){	resize( 640,480 );	setCaption( QString::fromLocal8Bit("留言服务") );		Layout = new QVBoxLayout( this );	Layout->setSpacing( 10 );	Layout->setMargin( 50 );//	QPainter painter( this );//	painter.setPen( QPen( black,3,SolidLine ) );		Layout1 = new QHBoxLayout; 	tipLabel = new QLabel( QString::fromLocal8Bit("留言 (请选择用户)"),this );		quitButton = new QPushButton(this,"quitButton");       	quitButton->setText( QString::fromLocal8Bit("退出") );//        quitButton->setMinimumSize(quitButton->sizeHint());		Layout1->addWidget( tipLabel );	Layout1->addWidget( quitButton );	Layout->addLayout( Layout1 );	Layout2 = new QHBoxLayout;	nameLabel = new QLabel( QString::fromLocal8Bit("用户"),this );	nameLabel->setAlignment( AlignHCenter );		numLabel = new QLabel( QString::fromLocal8Bit("留言数目(条)"),this );	numLabel->setAlignment( AlignHCenter );	Layout2->addWidget( nameLabel );	Layout2->addWidget( numLabel );	Layout->addLayout( Layout2 );	manLayout = new QHBoxLayout;	manLabel = new QLabel( QString::fromLocal8Bit("男主人"),this );	manLabel->setAlignment( AlignBottom | AlignLeft );	manButton = new QToolButton( this,"manButton" );	manButton->setMinimumSize( 100,100 );	manButton->setMaximumSize( 100,100 );	QPixmap imageman( "/usr/qpe/pics/manmaster.png" );	manButton->setUsesBigPixmap( true );	manButton->setPixmap( imageman );  	manrecordnumLabel = new QLabel( this );        QDir dir( "/Documents/audio/x-wav/","man*.wav" );	manrecordnumLabel->setNum( int(dir.count()) );	manrecordnumLabel->setAlignment( AlignHCenter | AlignVCenter );	manLayout->addWidget( manButton );	manLayout->addWidget( manLabel );	manLayout->addWidget( manrecordnumLabel );	Layout->addLayout( manLayout );	womanLayout = new QHBoxLayout;	womanLabel = new QLabel( QString::fromLocal8Bit("女主人"),this ); 	womanLabel->setAlignment( AlignBottom | AlignLeft );	womanButton = new QToolButton( this,"womanButton" );	womanButton->setMinimumSize( 100,100 );        womanButton->setMaximumSize( 100,100 );	QPixmap imagewoman( "/usr/qpe/pics/womanmaster.png" );	womanButton->setUsesBigPixmap( true );	womanButton->setPixmap( imagewoman );	womanrecordnumLabel = new QLabel( this );	dir.setPath( "/Documents/audio/x-wav/" );        dir.setNameFilter("woman*.wav");        womanrecordnumLabel->setNum( int(dir.count()) );        womanrecordnumLabel->setAlignment( AlignHCenter | AlignVCenter );	womanLayout->addWidget( womanButton );	womanLayout->addWidget( womanLabel );	womanLayout->addWidget( womanrecordnumLabel );	Layout->addLayout( womanLayout );		boyLayout = new QHBoxLayout;	boyLabel = new QLabel( QString::fromLocal8Bit("小主人"),this );	boyLabel->setAlignment( AlignBottom | AlignLeft );	boyButton = new QToolButton( this,"boyButton" );	boyButton->setMinimumSize( 100,100 );	boyButton->setMaximumSize( 100,100 );	QPixmap imageboy( "/usr/qpe/pics/boymaster.png" );	boyButton->setUsesBigPixmap( true );	boyButton->setPixmap( imageboy );	boyrecordnumLabel = new QLabel( this );	dir.setPath( "/Documents/audio/x-wav/" );        dir.setNameFilter("boy*.wav");	boyrecordnumLabel->setNum( int(dir.count()) );	boyrecordnumLabel->setAlignment( AlignHCenter | AlignVCenter );	boyLayout->addWidget( boyButton );	boyLayout->addWidget( boyLabel );	boyLayout->addWidget( boyrecordnumLabel );	Layout->addLayout( boyLayout );		connect(quitButton,SIGNAL(clicked()),this,SLOT(close()));	connect(manButton,SIGNAL(clicked()),this,SLOT(manClicked()));	connect(womanButton,SIGNAL(clicked()),this,SLOT(womanClicked()));	connect(boyButton,SIGNAL(clicked()),this,SLOT(boyClicked()));}RecordService::~RecordService(){}void RecordService::manClicked(){	QDir dir( "/Documents/audio/x-wav/","man*.wav" );	manrecordnumLabel->setNum( int(dir.count()) );	dir.setPath( "/Documents/audio/x-wav/" );        dir.setNameFilter("woman*.wav");        womanrecordnumLabel->setNum( int(dir.count()) );	dir.setPath( "/Documents/audio/x-wav/" );        dir.setNameFilter("boy*.wav");        boyrecordnumLabel->setNum( int(dir.count()) );	record = new MediaRecorder( 0 );	record->mydir.setPath("/Documents/audio/x-wav/");	record->mydir.setNameFilter("man*.wav");	record->sign = 1;	QString str("男主人");        record->contents->capLabel->setText( QString::fromLocal8Bit("留言: "+str ) );	if( int(record->mydir.count())!=0 ){		QString timestr( record->mydir[0].mid(22,4) 				+ record->mydir[0].mid(3,9) + " "				+ record->mydir[0].mid(13,2) + ":"				+ record->mydir[0].mid(16,2) + ":"				+ record->mydir[0].mid(19,2) );		record->contents->timeLabel->setText( timestr );		record->contents->disLabel->setNum( 1 );		if( record->mydir.count() == 1 ) {			record->contents->upButton->setEnabled( FALSE );		}		else{			record->contents->upButton->setEnabled( TRUE );		}		record->contents->downButton->setEnabled( FALSE );	}	else{		record->contents->disLabel->setNum( 0 );                record->contents->playButton->setEnabled( FALSE );		record->contents->delButton->setEnabled( FALSE );		record->contents->upButton->setEnabled( FALSE );                record->contents->downButton->setEnabled( FALSE );		        }         	record->show();}void RecordService::womanClicked(){	QDir dir( "/Documents/audio/x-wav/","man*.wav" );        manrecordnumLabel->setNum( int(dir.count()) );        dir.setPath( "/Documents/audio/x-wav/" );        dir.setNameFilter("woman*.wav");        womanrecordnumLabel->setNum( int(dir.count()) );        dir.setPath( "/Documents/audio/x-wav/" );        dir.setNameFilter("boy*.wav");        boyrecordnumLabel->setNum( int(dir.count()) );	record = new MediaRecorder( 0 );        record->mydir.setPath("/Documents/audio/x-wav/");        record->mydir.setNameFilter("woman*.wav");	record->sign = 2;        QString str("女主人");        record->contents->capLabel->setText( QString::fromLocal8Bit("留言: "+str ) );	if( int(record->mydir.count())!=0 ){                QString timestr( record->mydir[0].mid(24,4)                                + record->mydir[0].mid(5,9) + " "                                + record->mydir[0].mid(15,2) + ":"                                + record->mydir[0].mid(18,2) + ":"                                + record->mydir[0].mid(21,2) );                record->contents->timeLabel->setText( timestr );                record->contents->disLabel->setNum( 1 );		if( record->mydir.count() == 1 ) {                        record->contents->upButton->setEnabled( FALSE );                }                else{                        record->contents->upButton->setEnabled( TRUE );                }                record->contents->downButton->setEnabled( FALSE );        }        else{                record->contents->disLabel->setNum( 0 );                record->contents->playButton->setEnabled( FALSE );		record->contents->delButton->setEnabled( FALSE );                record->contents->upButton->setEnabled( FALSE );                record->contents->downButton->setEnabled( FALSE );        }        record->show();}void RecordService::boyClicked(){	QDir dir( "/Documents/audio/x-wav/","man*.wav" );        manrecordnumLabel->setNum( int(dir.count()) );        dir.setPath( "/Documents/audio/x-wav/" );        dir.setNameFilter("woman*.wav");        womanrecordnumLabel->setNum( int(dir.count()) );        dir.setPath( "/Documents/audio/x-wav/" );        dir.setNameFilter("boy*.wav");        boyrecordnumLabel->setNum( int(dir.count()) );	record = new MediaRecorder( 0 );        record->mydir.setPath("/Documents/audio/x-wav/");        record->mydir.setNameFilter("boy*.wav");	record->sign = 3;        QString str("小主人");        record->contents->capLabel->setText( QString::fromLocal8Bit("留言: "+str ) );	if( int(record->mydir.count())!=0 ){                QString timestr( record->mydir[0].mid(21,4)                                + record->mydir[0].mid(4,7) + " "                                + record->mydir[0].mid(12,2) + ":"                                + record->mydir[0].mid(15,2) + ":"                                + record->mydir[0].mid(18,2) );                record->contents->timeLabel->setText( timestr );                record->contents->disLabel->setNum( 1 );                if( record->mydir.count() == 1 ) {                        record->contents->upButton->setEnabled( FALSE );                }                else{                        record->contents->upButton->setEnabled( TRUE );                }                record->contents->downButton->setEnabled( FALSE );        }        else{                record->contents->disLabel->setNum( 0 );                record->contents->playButton->setEnabled( FALSE );		record->contents->delButton->setEnabled( FALSE );                record->contents->upButton->setEnabled( FALSE );                record->contents->downButton->setEnabled( FALSE );        }        record->show();}

⌨️ 快捷键说明

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