📄 qmcontrolbar.cpp
字号:
} m_pMainWindow->setState( QmMainWindow::Busy ); m_pMainWindow->savePlayList(s); m_pMainWindow->setState( QmMainWindow::Ready ); } } trash( dlg );}/*! Makes sure the play, pause and stop buttons are enabled or disabled according to the playing state. Call this whenever the playlist is modified or the song changes state. \sa playingState(), setPlayingState(), PlayState*/voidQmControlBar::updateControls(){ switch ( m_pMainWindow->playingState() ) { case QmMainWindow::Playing: m_pPlay->setEnabled( true ); m_pStop->setEnabled( true ); m_pPause->setEnabled( true ); m_pPause->setOn( false ); break; case QmMainWindow::Paused: m_pPlay->setEnabled( true ); m_pStop->setEnabled( true ); m_pPause->setEnabled( true ); m_pPause->setOn( true ); break; case QmMainWindow::Stopped: m_pPlay->setEnabled( m_pMainWindow->moreSongsp() ); m_pStop->setEnabled( false ); m_pPause->setEnabled( false ); m_pPause->setOn( false ); break; default: QmMainWindow::mainwin->statusUpdate(new Message(Message::Bug, "Bug: QmControlBar::updateControls() - Invalid case.")); break; } m_pRandom->setOn( m_pMainWindow->randomMode() ); if ( m_pMainWindow->loopOneMode() ) m_pLoop->setPixmap(QmPixmapSupplier::instance()->pixmap( "icons-one" )); else m_pLoop->setPixmap(QmPixmapSupplier::instance()->pixmap( "icons-loop" )); m_pLoop->setOn( m_pMainWindow->loopMode() || m_pMainWindow->loopOneMode() ); updatePositionControls(); }/*! Makes sure the position controls (next and prev) are enabled or disabled according to the song position. Call this whenever the playlist is modified or the current song changes.*/voidQmControlBar::updatePositionControls(){ updatePositionControls(m_pMainWindow->prevSongAvailablep(), m_pMainWindow->moreSongsp());}voidQmControlBar::updatePositionControls(bool prev, bool next){ m_pPrev->setEnabled(prev); m_pNext->setEnabled(next);}/*! Makes sure the file, playlist and option menus are enabled or disabled. The state of the program decides this. \sa state(), setState(), MainState*/voidQmControlBar::updateWidgets(){ switch ( m_pMainWindow->state() ) { case QmMainWindow::Ready: m_pAddFiles->setEnabled( true ); m_pPlayListButton->setEnabled( true ); m_pOptions->setEnabled( true ); break; case QmMainWindow::Busy: m_pAddFiles->setEnabled( false ); m_pPlayListButton->setEnabled( false ); m_pOptions->setEnabled( false ); break; default: QmMainWindow::mainwin->statusUpdate(new Message(Message::Bug, "Bug: QmControlBar::updateWidgets() - Invalid case.")); break; // Should never happen }}/*! Adds the \c obj object to the trashcan and notifies the timer that it shall cleanup as soon as it gets triggered. This allows one to add QObjects that one cannot delete at the moment to a trash list.*/voidQmControlBar::trash( QObject *obj ){ m_Trash.append( obj ); m_pTrashTimer->start( 0, true );}/*! Cleans up the trashcan. \sa trash()*/void QmControlBar::cleanup(){ m_Trash.clear();}/*! Shows information about Apollo. */voidQmControlBar::about(){ if ( m_pMainWindow->state() == QmMainWindow::Busy ) // Do not show dialogs when busy return; QmAboutDialog dlg(this, "about", true); dlg.adjustSize(); dlg.move( QApplication::desktop()->geometry().center() - dlg.rect().center() ); dlg.show(); // Try signal handler:// int *ptr = 0;// *ptr = 1;}/*! Shows information about Qt.*/voidQmControlBar::aboutQt(){ QMessageBox::aboutQt(this, tr("Apollo - About Qt"));}/*! Opens the configuration dialog.*/voidQmControlBar::openConfigDialog(){ if ( m_pMainWindow->state() == QmMainWindow::Busy ) // Do not show dialogs when busy return; QmConfigDialog dlg; dlg.exec();}voidQmControlBar::toggleCompactWindow(){ if (m_pMainWindow->isVisible()) showCompactWindow(); else m_pCompactWindow->showMainWindow();}/*! Hides the main window and shows the compact window.*/voidQmControlBar::showCompactWindow(){ m_pMainWindow->hide(); if(m_pCompactWindow == 0) m_pCompactWindow = new QmCompactWindow(m_pMainWindow); m_pCompactWindow->show();}/*! Toggles the play list selector on/off and its corresponding menuitem checkmark.*/voidQmControlBar::toggleBrowser(){ if(m_pBrowserMenu->isItemChecked(m_BrowserId)) { m_pBrowserMenu->setItemChecked(m_BrowserId, false); m_pBrowserMenu->setItemEnabled(m_BrowserLeftId, false); m_pBrowserMenu->setItemEnabled(m_BrowserRightId, false); m_pBrowserMenu->setItemEnabled(m_BrowserTopId, false); m_pBrowserMenu->setItemEnabled(m_BrowserBottomId, false); m_pBrowserMenu->setItemEnabled(m_BrowserFullId, false); m_pMainWindow->hideBrowser(); } else { m_pBrowserMenu->setItemChecked(m_BrowserId, true); m_pBrowserMenu->setItemEnabled(m_BrowserLeftId, true); m_pBrowserMenu->setItemEnabled(m_BrowserRightId, true); m_pBrowserMenu->setItemEnabled(m_BrowserTopId, true); m_pBrowserMenu->setItemEnabled(m_BrowserBottomId, true); m_pBrowserMenu->setItemEnabled(m_BrowserFullId, true); m_pMainWindow->showBrowser(); }}/*! Toggles the playlist on/off.*/voidQmControlBar::togglePlayList(){ if(m_pBrowserMenu->isItemChecked(m_BrowserFullId)) { m_pBrowserMenu->setItemEnabled(m_BrowserId, true); m_pBrowserMenu->setItemEnabled(m_BrowserLeftId, true); m_pBrowserMenu->setItemEnabled(m_BrowserRightId, true); m_pBrowserMenu->setItemEnabled(m_BrowserTopId, true); m_pBrowserMenu->setItemEnabled(m_BrowserBottomId, true); m_pBrowserMenu->setItemChecked(m_BrowserFullId, false); } else { m_pBrowserMenu->setItemEnabled(m_BrowserId, false); m_pBrowserMenu->setItemEnabled(m_BrowserLeftId, false); m_pBrowserMenu->setItemEnabled(m_BrowserRightId, false); m_pBrowserMenu->setItemEnabled(m_BrowserTopId, false); m_pBrowserMenu->setItemEnabled(m_BrowserBottomId, false); m_pBrowserMenu->setItemChecked(m_BrowserFullId, true); } m_pMainWindow->togglePlayList();}/*! Opens up a file requester for a PLList*/voidQmControlBar::loadPlayListTree(){ if ( m_pMainWindow->state() == QmMainWindow::Busy ) return; QmConfig *conf = QmConfig::instance(); QmFileDialog *dlg = new QmFileDialog( 0, "file-dialog", false ); connect( dlg, SIGNAL( dialogDone( QFileDialog *, int ) ), this, SLOT( doLoadPLList( QFileDialog *, int ) ) ); dlg->setDir( QDir( conf->getString( "path", "playlist" ) ) ); dlg->setMode( QFileDialog::ExistingFile ); dlg->setCaption( "Apollo - Load Playlist list" ); QRect file_rect = conf->getRect( "file-dialog", "geometry" ); if ( file_rect.isValid() ) { dlg->resize( file_rect.size() ); dlg->move( file_rect.topLeft() ); } dlg->show();}/*! Helper function which calls QmPlayListSelector::loadPlayListTree \sa loadPlayListTree()*/voidQmControlBar::doLoadPLList( QFileDialog *dlg, int val ){ QString s = dlg->selectedFile(); QmConfig::instance()->set( "file-dialog", "geometry", QRect( dlg->pos(), dlg->size() ) ); if ( val == QDialog::Accepted ) { QmConfig *conf = QmConfig::instance(); conf->set( "path", "playlisttree", dlg->dir()->absPath() ); m_pMainWindow->setState( QmMainWindow::Busy ); if( ! s.isEmpty()) m_pMainWindow->loadPlayListTree( s ); m_pMainWindow->setState( QmMainWindow::Ready ); } trash( dlg );}/*! Sets the state of the pause button to be enabled if \a b is true, disabled if false.*/voidQmControlBar::setPauseEnabled(bool b){ m_pPause->setEnabled(b);}/*! Sets the state of the stop button to be enabled if \a b is true, disabled if false.*/voidQmControlBar::setStopEnabled(bool b){ m_pStop->setEnabled(b);}/*! Sets the state of the play button to be enabled if \a b is true, disabled if false.*/voidQmControlBar::setPlayEnabled(bool b){ m_pPlay->setEnabled(b);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -