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

📄 qmmainwindow.cpp

📁 可以播放MP3,wma等文件格式的播放器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
}/*!  Remove(s) the current item(s), if any, from the play list.  If the  current item is the playing item, it will stop playing and the  next one, if any, will start playing.*/voidQmMainWindow::removeItem(){	if (m_pPlayList->hasFocus())	{		bool was_playing = m_pPlayer->isPlaying();		bool stop_playing;		QmSongItem *newsong = m_pPlayList->removeSelected(&stop_playing);                if (m_pContinueHere == newsong)            m_pContinueHere = 0;		if (newsong != 0)		{			// The reason for this variable is to distinguish between user Stop action			// and end of song Stop.			m_StopClicked = false;				m_pStatusBar->clearName();			m_pStatusBar->clearTime();			if (was_playing)				selected(newsong);		}		else if (stop_playing)			stop();		m_pControlBar->updateControls();	}	else if (m_pBrowser->hasBrowserFocus())	{		m_pBrowser->removeItem();	}}/*!  Starts a player process and assigns this to m_pPlayer.*/voidQmMainWindow::startPlayer(){	bool reinit;		if(m_pPlayer != 0)	{		reinit = true;		delete m_pPlayer;	}	else		reinit = false;	int			rc = -1;	QmPlayer	*p = 0;	#ifdef _WS_X11_	#ifdef ENABLE_MPG123	QmMpg123Player *p2 = new QmMpg123Player;	rc = p2->init();	p = p2;#endif // mpg123//	QmMadPlayer *p2 = new QmMadPlayer;//	rc = 0;//	p = p2;//	QmXmpPlayer *p2 = new QmXmpPlayer;//	rc = 0;//	p = p2;#endif	// x11	if (rc < 0)		m_pPlayer = QmNullPlayer::instance();	else		m_pPlayer = p;	QObject::connect(m_pPlayer, SIGNAL(playingStopped()), this, SLOT(playingStopped()));	QObject::connect(m_pPlayer, SIGNAL(playerMessage(const QString&)),					 this, SLOT(playerMessage(const QString&)));	if(reinit)	{		m_pPositionBar->initialize(m_pPlayer);		m_pStatusBar->initialize(m_pPlayer);	}}/*!  Marks the current (focus) item to be played next (overrides any previous setting).*/voidQmMainWindow::continueHere(    QmPlayListItem *here){    CHECK_PTR(here);        if (here->isSong())    {        m_ContinueHerep = true;        m_pContinueHere = here;        m_ContinuePlayList = m_pPlayList->filename();        m_ContinueSong = static_cast<QmSongItem*>(here)->filePath();    }}/*!  Sets the current item(s) to be 'bad'.  Bad items will be skipped automatically  when playing a play list.  Marking items as bad is useful if there are some  files that the underlaying player cannot cope with, even though the files  may be correct.  \sa showMarkDialog()*/voidQmMainWindow::setMark(){	QListViewItem *item = m_pPlayList->firstChild();	QmSongItem *song;	while (item)	{		song = dynamic_cast<QmSongItem*>(item);		if (song)		{			if (song->isSelected())				song->setMark(true);		}		item = item->itemBelow();			}		m_pControlBar->updateControls();	current(m_pPlayList->currentItem());}/*!  Shows the mark dialog.*/voidQmMainWindow::showMarkDialog(){	if (m_pMarkDialog == 0)		m_pMarkDialog = new QmMarkDialog(0, "markdialog");		m_pMarkDialog->show();	m_pMarkDialog->raise();	m_pControlBar->updateControls();	current(m_pPlayList->currentItem());}/*!  Returns the main state of the program.  \sa playingState()*/QmMainWindow::MainStateQmMainWindow::state() const{    return m_State;}/*!  Sets the main state of the program and enables/disables the various  parts of the GUI.    \sa setPlayingState()*/voidQmMainWindow::setState(    QmMainWindow::MainState state){    if ( m_State == state )        return;	    m_State = state;    m_pControlBar->updateWidgets();}/*!  Returns the play state of the program, this tells wheter a song is  playing, paused or is stopped.    \sa state()*/QmMainWindow::PlayStateQmMainWindow::playingState() const{    return m_PlayState;}/*!  Sets the state of the player, this will update the various parts of the GUI  by enabling/disabling buttons and text.    \sa setState()*/voidQmMainWindow::setPlayingState(    QmMainWindow::PlayState state){    if ( state == m_PlayState )        return;	    m_PlayState = state;    if ( state == QmMainWindow::Stopped )		m_pStatusBar->clearTime();    m_pStatusBar->updateStatus();    m_pStatusBar->updateCaption();    m_pControlBar->updateControls();}/*!  Updates the items in the list view.  This will typically happen when a  mark is cleared from an item in the mark editor.*/voidQmMainWindow::updateItems(){	m_pPlayList->triggerUpdate();	m_pControlBar->updateControls();	}/*!  \return The playlist.  \deprecated Only the main window should know about the playlist.*/QmPlayList *QmMainWindow::playList(){	CHECK_PTR(m_pPlayList);	return m_pPlayList;}/*!  Hides/shows the play list.*/voidQmMainWindow::togglePlayList(){	if (m_pListsSplitter->isVisible())		m_pListsSplitter->hide();	else		m_pListsSplitter->show();}/*!  Flatten: remove all directories (but not the songs in them).*/voidQmMainWindow::flattenPlayList(){    m_pPlayList->flatten();}/*!  \return The browser position.  \sa setBrowserPosition(QmMainWindow::BrowserPosition) */QmMainWindow::BrowserPositionQmMainWindow::browserPosition() const{	return m_Position;}/*!  Sets the integrated browser to be \a pos. If the requested position is the  same as the current position, this function will do nothing.  \sa browserPosition()*/voidQmMainWindow::setBrowserPosition(	QmMainWindow::BrowserPosition pos){	if (m_Position == pos)		return;		switch(pos)	{		case LeftBrowser:			if (m_pListBrowserSplitter->orientation() == Vertical)				m_pListBrowserSplitter->setOrientation(Horizontal);					m_pListBrowserSplitter->moveToFirst(m_pBrowser);			m_pListBrowserSplitter->moveToLast(m_pListsSplitter);			m_pListBrowserSplitter->refresh();			break;		case RightBrowser:			if (m_pListBrowserSplitter->orientation() == Vertical)				m_pListBrowserSplitter->setOrientation(Horizontal);					m_pListBrowserSplitter->moveToFirst(m_pListsSplitter);			m_pListBrowserSplitter->moveToLast(m_pBrowser);			m_pListBrowserSplitter->refresh();			break;		case TopBrowser:			if (m_pListBrowserSplitter->orientation() == Horizontal)				m_pListBrowserSplitter->setOrientation(Vertical);					m_pListBrowserSplitter->moveToFirst(m_pBrowser);			m_pListBrowserSplitter->moveToLast(m_pListsSplitter);			m_pListBrowserSplitter->refresh();			break;		case BottomBrowser:			if (m_pListBrowserSplitter->orientation() == Horizontal)				m_pListBrowserSplitter->setOrientation(Vertical);					m_pListBrowserSplitter->moveToFirst(m_pListsSplitter);			m_pListBrowserSplitter->moveToLast(m_pBrowser);			m_pListBrowserSplitter->refresh();			break;		default:			qWarning("QmMainWindow::setBrowserPosition(): Invalid position %d.", m_Position);			return;			break;	}	m_Position = pos;}void QmMainWindow::setBrowserLeft()   { setBrowserPosition(LeftBrowser); }void QmMainWindow::setBrowserRight()  { setBrowserPosition(RightBrowser); }void QmMainWindow::setBrowserTop()    { setBrowserPosition(TopBrowser); }void QmMainWindow::setBrowserBottom() { setBrowserPosition(BottomBrowser); }/*!  Hides the browser.  \sa showBrowser()*/voidQmMainWindow::hideBrowser(){	m_pBrowser->hide();}/*!  Shows the browser.  \sa hideBrowser()*/voidQmMainWindow::showBrowser(){	m_pBrowser->show();}/*!  Returns the browser object.*/QmBrowser *QmMainWindow::browser() const{    return m_pBrowser;}/*!  Returns the control bar object.*/QmControlBar *QmMainWindow::controlBar() const{    return m_pControlBar;}/*!  Shows the directory browser.*/voidQmMainWindow::showDirectoryBrowser(){    m_pBrowser->showDirectories();}/*!  Shows the playlist browser.*/voidQmMainWindow::showPlaylistBrowser(){    m_pBrowser->showPlaylists();}/*!  Toggles the browser on/off.  \sa showBrowser(), hideBrowser()*/voidQmMainWindow::toggleBrowser(){	m_pControlBar->toggleBrowser();}/*!  Updates the display format, currently passes it to the play list.*/voidQmMainWindow::setDisplayFormat(){    m_pPlayList->setDisplayFormat(QmConfig::instance()->getString("stuff", "display-format"),								  QmConfig::instance()->getString("stuff", "display-format-multi"));}/*!  Loads the playlist with the given name into the current playlist, places it  below `above'.  \param filename defaults to ~/.apollo/playlist  \param above defaults to the bottom of the current list*/// void// QmMainWindow::loadPlayList(const QString &filename = QString::null, QmPlayListItem *above = 0)// {}voidQmMainWindow::loadPlayListTree(    const QString &filename){    m_pBrowser->loadPlayListTree(filename);}/*!  \todo*/voidQmMainWindow::savePlayListTree(    const QString & /*filename = QString::null*/){}/*!  Appends the currently selected playlist song to playfirst, if any.*/voidQmMainWindow::addToPlayFirst() {    addToPlayFirst(0);}/*!  Appends \a addme to playfirst. If \a addme is null, the current item of  the playlist will be added if it's a non-bad song. If there is no current  item, this function does nothing.  \sa addToPlayFirst()*/voidQmMainWindow::addToPlayFirst(    QmPlayListItem *addme){    QmPlayListItem *tmp = addme != 0 ? addme : static_cast<QmPlayListItem *>(m_pPlayList->currentItem());	if (tmp && tmp->isSong() && ! tmp->isBad())        m_pPlayFirst->append(static_cast<QmSongItem *>(tmp));}/*!  Replaces playListAtEnd() to enable/disable next button.*/boolQmMainWindow::moreSongsp() const{    return !m_pPlayFirst->isEmpty() ||        (!m_pPlayList->isEmpty() && (m_Loopp || m_LoopOnep || m_Randomp || !m_pPlayList->atEnd()));}/*!  Replaces playListAtBeginning() to enable/disable prev button.*/boolQmMainWindow::prevSongAvailablep() const{	if (m_Randomp || !m_pPlayFirst->isEmpty() || m_pPlayList->isEmpty())		return false;    	return m_Loopp || m_LoopOnep || !m_pPlayList->atBeginning();}/*!  Updates play length of currently playing song.*/voidQmMainWindow::updateSongLength(    int length){    QmSongItem *song = activePlayList()->currentSong();    if (song && song->length()==0)	{        song->setLengthSeconds(length);        activePlayList()->triggerUpdate();    }}/*!  Updates bitrate of currently playing song.*/voidQmMainWindow::updateBitrate(    int bitrate){    QmSongItem *song = activePlayList()->currentSong();    if (song)         song->setBitrate(bitrate);}/*!  Sets the volume to \a vol.  \todo define range*/voidQmMainWindow::setVolume(    int vol){	QmMixer::instance()->setVolume(vol);}/*!  Jumps \a seconds into the song. If no song is playing, this function does  nothing. */voidQmMainWindow::jumpToSeconds(    int seconds){	if (isPlaying())		m_pPlayer->jump(seconds);}/*!  Activates the search field in the minibuffer. */voidQmMainWindow::activateSearch(){    m_pMiniBuffer->activateSearch();}/*!  \todo */voidQmMainWindow::playerMessage(	const QString &info){	m_pPlayerMessage->append(info);}/*!  \todo */voidQmMainWindow::showPlayerMessages(){	m_pPlayerMessage->resize(400, 400);	m_pPlayerMessage->show();}

⌨️ 快捷键说明

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