void ActionsManager::doAction( int id_action ) { switch( id_action ) { case PLAY_ACTION: play(); break; case STOP_ACTION: THEMIM->stop(); break; case OPEN_ACTION: THEDP->openDialog(); break; case PREVIOUS_ACTION: THEMIM->prev(); break; case NEXT_ACTION: THEMIM->next(); break; case SLOWER_ACTION: THEMIM->getIM()->slower(); break; case FASTER_ACTION: THEMIM->getIM()->faster(); break; case FULLSCREEN_ACTION: fullscreen(); break; case EXTENDED_ACTION: THEDP->extendedDialog(); break; case PLAYLIST_ACTION: playlist(); break; case SNAPSHOT_ACTION: snapshot(); break; case RECORD_ACTION: record(); break; case FRAME_ACTION: frame(); break; case ATOB_ACTION: THEMIM->getIM()->setAtoB(); break; case REVERSE_ACTION: THEMIM->getIM()->reverse(); break; case SKIP_BACK_ACTION: skipBackward(); break; case SKIP_FW_ACTION: skipForward(); break; case QUIT_ACTION: THEDP->quit(); break; case RANDOM_ACTION: THEMIM->toggleRandom(); break; case INFO_ACTION: THEDP->mediaInfoDialog(); break; case OPEN_SUB_ACTION: THEDP->loadSubtitlesFile(); break; case FULLWIDTH_ACTION: if( p_intf->p_sys->p_mi ) p_intf->p_sys->p_mi->getFullscreenControllerWidget()->toggleFullwidth(); break; default: msg_Warn( p_intf, "Action not supported: %i", id_action ); break; } }
void ActionsManager::doAction( int id_action ) { switch( id_action ) { case PLAY_ACTION: play(); break; case STOP_ACTION: THEMIM->stop(); break; case OPEN_ACTION: THEDP->openDialog(); break; case PREVIOUS_ACTION: THEMIM->prev(); break; case NEXT_ACTION: THEMIM->next(); break; case SLOWER_ACTION: THEMIM->getIM()->slower(); break; case FASTER_ACTION: THEMIM->getIM()->faster(); break; case FULLSCREEN_ACTION: fullscreen(); break; case EXTENDED_ACTION: THEDP->extendedDialog(); break; case PLAYLIST_ACTION: playlist(); break; case SNAPSHOT_ACTION: snapshot(); break; case RECORD_ACTION: record(); break; case FRAME_ACTION: frame(); break; case ATOB_ACTION: THEMIM->getIM()->setAtoB(); break; case REVERSE_ACTION: THEMIM->getIM()->reverse(); break; case SKIP_BACK_ACTION: skipBackward(); break; case SKIP_FW_ACTION: skipForward(); break; case QUIT_ACTION: THEDP->quit(); break; case RANDOM_ACTION: THEMIM->toggleRandom(); break; case INFO_ACTION: THEDP->mediaInfoDialog(); break; default: msg_Dbg( p_intf, "Action: %i", id_action ); break; } }
void PlaylistDock::setupActions() { QAction *deleteAllAction = new QAction(this); deleteAllAction->setText(i18n("Clear playlist")); deleteAllAction->setIcon(KIcon("edit-clear-list")); connect(deleteAllAction, SIGNAL(triggered()), this, SLOT(deleteAll())); QAction *addItemAction = new QAction(this); addItemAction->setText(i18n("Add file(s)")); addItemAction->setIcon(KIcon("list-add")); connect(addItemAction, SIGNAL(triggered()), parent, SLOT(addFile())); QAction *deleteItemAction = new QAction(this); deleteItemAction->setText(i18n("Clear selected")); deleteItemAction->setIcon(KIcon("list-remove")); connect(deleteItemAction, SIGNAL(triggered()), this, SLOT(deleteItem())); QAction* moveItemUpAction = new QAction(this); moveItemUpAction->setText(i18n("Move up")); moveItemUpAction->setIcon(KIcon("arrow-up")); connect(moveItemUpAction, SIGNAL(triggered()), this, SLOT(moveItemUp())); QAction* moveItemDownAction = new QAction(this); moveItemDownAction->setText(i18n("Move down")); moveItemDownAction->setIcon(KIcon("arrow-down")); connect(moveItemDownAction, SIGNAL(triggered()), this, SLOT(moveItemDown())); QAction* skipForwardAction = new QAction(this); skipForwardAction->setText(i18n("Playlist Skip Forward")); skipForwardAction->setIcon(KIcon("media-skip-forward")); connect(skipForwardAction, SIGNAL(triggered()), parent, SLOT(skipForward())); QAction* skipBackwardAction = new QAction(this); skipBackwardAction->setText(i18n("Playlist Skip Backward")); skipBackwardAction->setIcon(KIcon("media-skip-backward")); connect(skipBackwardAction, SIGNAL(triggered()), parent, SLOT(skipBackward())); toolbar = new QToolBar(this); toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); toolbar->setIconSize(QSize(16, 16)); toolbar->setObjectName("playlisttoolbar"); toolbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); toolbar->addAction(deleteAllAction); toolbar->addAction(addItemAction); toolbar->addAction(deleteItemAction); toolbar->addAction(moveItemUpAction); toolbar->addAction(moveItemDownAction); toolbar->addAction(skipBackwardAction); toolbar->addAction(skipForwardAction); }
Jmplayer::Jmplayer( QWidget * parent, Qt::WFlags f) : QMainWindow(parent, f) { setupUi(this); timer = new QTimer(this); ms = 0; fileIndex = 0; firstTime = true; running = false; connect(timer, SIGNAL(timeout()), this, SLOT(showTime())); connect(timer, SIGNAL(timeout()), this, SLOT(setSliderValue())); connect(play_button, SIGNAL(clicked()), this, SLOT(pauseContinue())); connect(prev_button, SIGNAL(clicked()), this, SLOT(skipBackward())); connect(next_button, SIGNAL(clicked()), this, SLOT(skipForward())); connect(add_button, SIGNAL(clicked()), this, SLOT(loadFiles())); connect(timeSlider, SIGNAL(sliderReleased()),this, SLOT(seekFile())); connect(volumeSlider, SIGNAL(valueChanged(int)),this, SLOT(changeVolume())); program = "/usr/bin/mplayer"; myProcess = new QProcess(parent); adjustWindow(); initUi(); }
// 初始化播放器 void MyWidget::initPlayer() { // 设置主界面标题、图标和大小 setWindowTitle(tr("MyPlayer音乐播放器")); setWindowIcon(QIcon(":/images/icon.png")); setMinimumSize(320, 160); setMaximumSize(320, 160); // 创建媒体图 mediaObject = new Phonon::MediaObject(this); Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); Phonon::createPath(mediaObject, audioOutput); // 关联媒体对象的tick()信号来更新播放时间的显示 connect(mediaObject, SIGNAL(tick(qint64)), this, SLOT(updateTime(qint64))); // 创建顶部标签,用于显示一些信息 topLabel = new QLabel(tr("<a href = \" http://www.yafeilinux.com \"> www.yafeilinux.com </a>")); topLabel->setTextFormat(Qt::RichText); topLabel->setOpenExternalLinks(true); topLabel->setAlignment(Qt::AlignCenter); // 创建控制播放进度的滑块 Phonon::SeekSlider *seekSlider = new Phonon::SeekSlider(mediaObject, this); // 创建包含播放列表图标、显示时间标签和桌面歌词图标的工具栏 QToolBar *widgetBar = new QToolBar(this); // 显示播放时间的标签 timeLabel = new QLabel(tr("00:00 / 00:00"), this); timeLabel->setToolTip(tr("当前时间 / 总时间")); timeLabel->setAlignment(Qt::AlignCenter); timeLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); // 创建图标,用于控制是否显示播放列表 QAction *PLAction = new QAction(tr("PL"), this); PLAction->setShortcut(QKeySequence("F4")); PLAction->setToolTip(tr("播放列表(F4)")); connect(PLAction, SIGNAL(triggered()), this, SLOT(setPlaylistShown())); // 创建图标,用于控制是否显示桌面歌词 QAction *LRCAction = new QAction(tr("LRC"), this); LRCAction->setShortcut(QKeySequence("F2")); LRCAction->setToolTip(tr("桌面歌词(F2)")); connect(LRCAction, SIGNAL(triggered()), this, SLOT(setLrcShown())); // 添加到工具栏 widgetBar->addAction(PLAction); widgetBar->addSeparator(); widgetBar->addWidget(timeLabel); widgetBar->addSeparator(); widgetBar->addAction(LRCAction); // 创建播放控制动作工具栏 QToolBar *toolBar = new QToolBar(this); // 播放动作 playAction = new QAction(this); playAction->setIcon(QIcon(":/images/play.png")); playAction->setText(tr("播放(F5)")); playAction->setShortcut(QKeySequence(tr("F5"))); connect(playAction, SIGNAL(triggered()), this, SLOT(setPaused())); // 停止动作 stopAction = new QAction(this); stopAction->setIcon(QIcon(":/images/stop.png")); stopAction->setText(tr("停止(F6)")); stopAction->setShortcut(QKeySequence(tr("F6"))); connect(stopAction, SIGNAL(triggered()), mediaObject, SLOT(stop())); // 跳转到上一首动作 skipBackwardAction = new QAction(this); skipBackwardAction->setIcon(QIcon(":/images/skipBackward.png")); skipBackwardAction->setText(tr("上一首(Ctrl+Left)")); skipBackwardAction->setShortcut(QKeySequence(tr("Ctrl+Left"))); connect(skipBackwardAction, SIGNAL(triggered()), this, SLOT(skipBackward())); // 跳转到下一首动作 skipForwardAction = new QAction(this); skipForwardAction->setIcon(QIcon(":/images/skipForward.png")); skipForwardAction->setText(tr("下一首(Ctrl+Right)")); skipForwardAction->setShortcut(QKeySequence(tr("Ctrl+Right"))); connect(skipForwardAction, SIGNAL(triggered()), this, SLOT(skipForward())); // 打开文件动作 QAction *openAction = new QAction(this); openAction->setIcon(QIcon(":/images/open.png")); openAction->setText(tr("播放文件(Ctrl+O)")); openAction->setShortcut(QKeySequence(tr("Ctrl+O"))); connect(openAction, SIGNAL(triggered()), this, SLOT(openFile())); // 音量控制部件 Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider(audioOutput, this); volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); // 添加到工具栏 toolBar->addAction(playAction); toolBar->addSeparator(); toolBar->addAction(stopAction); toolBar->addSeparator(); toolBar->addAction(skipBackwardAction); toolBar->addSeparator(); toolBar->addAction(skipForwardAction); toolBar->addSeparator(); toolBar->addWidget(volumeSlider); toolBar->addSeparator(); toolBar->addAction(openAction); // 创建主界面布局管理器 QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(topLabel); mainLayout->addWidget(seekSlider); mainLayout->addWidget(widgetBar); mainLayout->addWidget(toolBar); setLayout(mainLayout); // 在3-2中添加的代码 connect(mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(stateChanged(Phonon::State, Phonon::State))); // 以下是在3-3中添加的代码 // 创建播放列表 playlist = new MyPlaylist(this); connect(playlist, SIGNAL(cellClicked(int, int)), this, SLOT(tableClicked(int))); connect(playlist, SIGNAL(playlistClean()), this, SLOT(clearSources())); // 创建用来解析媒体的信息的元信息解析器 metaInformationResolver = new Phonon::MediaObject(this); // 需要与AudioOutput连接后才能使用metaInformationResolver来获取歌曲的总时间 Phonon::AudioOutput *metaInformationAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); Phonon::createPath(metaInformationResolver, metaInformationAudioOutput); connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(metaStateChanged(Phonon::State, Phonon::State))); connect(mediaObject, SIGNAL(currentSourceChanged(Phonon::MediaSource)), this, SLOT(sourceChanged(Phonon::MediaSource))); connect(mediaObject, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish())); // 初始化动作图标的状态 playAction->setEnabled(false); stopAction->setEnabled(false); skipBackwardAction->setEnabled(false); skipForwardAction->setEnabled(false); topLabel->setFocus(); }
QWidget *AbstractController::createWidget( buttonType_e button, int options ) { bool b_flat = options & WIDGET_FLAT; bool b_big = options & WIDGET_BIG; bool b_shiny = options & WIDGET_SHINY; bool b_special = false; QWidget *widget = NULL; switch( button ) { case PLAY_BUTTON: { PlayButton *playButton = new PlayButton; setupButton( playButton ); BUTTON_SET_BAR( playButton ); CONNECT_MAP_SET( playButton, PLAY_ACTION ); CONNECT( this, inputPlaying( bool ), playButton, updateButtonIcons( bool )); playButton->updateButtonIcons( THEMIM->getIM()->playingStatus() == PLAYING_S ); widget = playButton; } break; case STOP_BUTTON:{ NORMAL_BUTTON( STOP ); } break; case OPEN_BUTTON:{ NORMAL_BUTTON( OPEN ); } break; case OPEN_SUB_BUTTON:{ NORMAL_BUTTON( OPEN_SUB ); } break; case PREVIOUS_BUTTON:{ NORMAL_BUTTON( PREVIOUS ); } break; case NEXT_BUTTON: { NORMAL_BUTTON( NEXT ); } break; case SLOWER_BUTTON:{ NORMAL_BUTTON( SLOWER ); ENABLE_ON_INPUT( SLOWERButton ); } break; case FASTER_BUTTON:{ NORMAL_BUTTON( FASTER ); ENABLE_ON_INPUT( FASTERButton ); } break; case PREV_SLOW_BUTTON:{ QToolButtonExt *but = new QToolButtonExt; setupButton( but ); BUTTON_SET_BAR( but ); CONNECT( but, shortClicked(), THEMIM, prev() ); CONNECT( but, longClicked(), THEAM, skipBackward() ); widget = but; } break; case NEXT_FAST_BUTTON:{ QToolButtonExt *but = new QToolButtonExt; setupButton( but ); BUTTON_SET_BAR( but ); CONNECT( but, shortClicked(), THEMIM, next() ); CONNECT( but, longClicked(), THEAM, skipForward() ); widget = but; } break; case FRAME_BUTTON: { NORMAL_BUTTON( FRAME ); ENABLE_ON_VIDEO( FRAMEButton ); } break; case FULLSCREEN_BUTTON: case DEFULLSCREEN_BUTTON: { NORMAL_BUTTON( FULLSCREEN ); ENABLE_ON_VIDEO( FULLSCREENButton ); } break; case FULLWIDTH_BUTTON: { NORMAL_BUTTON( FULLWIDTH ); } break; case EXTENDED_BUTTON:{ NORMAL_BUTTON( EXTENDED ); } break; case PLAYLIST_BUTTON:{ NORMAL_BUTTON( PLAYLIST ); } break; case SNAPSHOT_BUTTON:{ NORMAL_BUTTON( SNAPSHOT ); ENABLE_ON_VIDEO( SNAPSHOTButton ); } break; case RECORD_BUTTON:{ QToolButton *recordButton = new QToolButton; setupButton( recordButton ); CONNECT_MAP_SET( recordButton, RECORD_ACTION ); BUTTON_SET_BAR( recordButton ); ENABLE_ON_INPUT( recordButton ); recordButton->setCheckable( true ); CONNECT( THEMIM->getIM(), recordingStateChanged( bool ), recordButton, setChecked( bool ) ); widget = recordButton; } break; case ATOB_BUTTON: { AtoB_Button *ABButton = new AtoB_Button; setupButton( ABButton ); ABButton->setShortcut( qtr("Shift+L") ); BUTTON_SET_BAR( ABButton ); ENABLE_ON_INPUT( ABButton ); CONNECT_MAP_SET( ABButton, ATOB_ACTION ); CONNECT( THEMIM->getIM(), AtoBchanged( bool, bool), ABButton, updateButtonIcons( bool, bool ) ); widget = ABButton; } break; case INPUT_SLIDER: { SeekSlider *slider = new SeekSlider( Qt::Horizontal, NULL, !b_shiny ); SeekPoints *chapters = new SeekPoints( this, p_intf ); CONNECT( THEMIM->getIM(), chapterChanged( bool ), chapters, update() ); slider->setChapters( chapters ); /* Update the position when the IM has changed */ CONNECT( THEMIM->getIM(), positionUpdated( float, int64_t, int ), slider, setPosition( float, int64_t, int ) ); /* And update the IM, when the position has changed */ CONNECT( slider, sliderDragged( float ), THEMIM->getIM(), sliderUpdate( float ) ); CONNECT( THEMIM->getIM(), cachingChanged( float ), slider, updateBuffering( float ) ); /* Give hint to disable slider's interactivity when useless */ CONNECT( THEMIM->getIM(), inputCanSeek( bool ), slider, setSeekable( bool ) ); widget = slider; } break; case MENU_BUTTONS: widget = discFrame(); break; case TELETEXT_BUTTONS: widget = telexFrame(); widget->hide(); break; case VOLUME_SPECIAL: b_special = true; case VOLUME: { SoundWidget *snd = new SoundWidget( this, p_intf, b_shiny, b_special ); widget = snd; } break; case TIME_LABEL: { TimeLabel *timeLabel = new TimeLabel( p_intf ); widget = timeLabel; } break; case SPLITTER: { QFrame *line = new QFrame; line->setFrameShape( QFrame::VLine ); line->setFrameShadow( QFrame::Raised ); line->setLineWidth( 0 ); line->setMidLineWidth( 1 ); widget = line; } break; case ADVANCED_CONTROLLER: if( qobject_cast<AdvControlsWidget *>(this) == NULL ) { advControls = new AdvControlsWidget( p_intf, this ); widget = advControls; } break; case REVERSE_BUTTON:{ QToolButton *reverseButton = new QToolButton; setupButton( reverseButton ); CONNECT_MAP_SET( reverseButton, REVERSE_ACTION ); BUTTON_SET_BAR( reverseButton ); reverseButton->setCheckable( true ); /* You should, of COURSE change this to the correct event, when/if we have one, that tells us if trickplay is possible . */ CONNECT( this, inputIsTrickPlayable( bool ), reverseButton, setVisible( bool ) ); reverseButton->setVisible( false ); widget = reverseButton; } break; case SKIP_BACK_BUTTON: { NORMAL_BUTTON( SKIP_BACK ); ENABLE_ON_INPUT( SKIP_BACKButton ); } break; case SKIP_FW_BUTTON: { NORMAL_BUTTON( SKIP_FW ); ENABLE_ON_INPUT( SKIP_FWButton ); } break; case QUIT_BUTTON: { NORMAL_BUTTON( QUIT ); } break; case RANDOM_BUTTON: { NORMAL_BUTTON( RANDOM ); RANDOMButton->setCheckable( true ); RANDOMButton->setChecked( var_GetBool( THEPL, "random" ) ); CONNECT( THEMIM, randomChanged( bool ), RANDOMButton, setChecked( bool ) ); } break; case LOOP_BUTTON:{ LoopButton *loopButton = new LoopButton; setupButton( loopButton ); loopButton->setToolTip( qtr( "Click to toggle between loop all, loop one and no loop") ); loopButton->setCheckable( true ); { int i_state = NORMAL; if( var_GetBool( THEPL, "loop" ) ) i_state = REPEAT_ALL; if( var_GetBool( THEPL, "repeat" ) ) i_state = REPEAT_ONE; loopButton->updateButtonIcons( i_state ); } CONNECT( THEMIM, repeatLoopChanged( int ), loopButton, updateButtonIcons( int ) ); CONNECT( loopButton, clicked(), THEMIM, loopRepeatLoopStatus() ); widget = loopButton; } break; case INFO_BUTTON: { NORMAL_BUTTON( INFO ); } break; case PLAYBACK_BUTTONS:{ widget = new QWidget; DeckButtonsLayout *layout = new DeckButtonsLayout( widget ); BrowseButton *prev = new BrowseButton( widget, BrowseButton::Backward ); BrowseButton *next = new BrowseButton( widget ); RoundButton *play = new RoundButton( widget ); layout->setBackwardButton( prev ); layout->setForwardButton( next ); layout->setRoundButton( play ); CONNECT_MAP_SET( prev, PREVIOUS_ACTION ); CONNECT_MAP_SET( next, NEXT_ACTION ); CONNECT_MAP_SET( play, PLAY_ACTION ); } break; case ASPECT_RATIO_COMBOBOX: widget = new AspectRatioComboBox( p_intf ); widget->setMinimumHeight( 26 ); break; case SPEED_LABEL: widget = new SpeedLabel( p_intf, this ); break; case TIME_LABEL_ELAPSED: widget = new TimeLabel( p_intf, TimeLabel::Elapsed ); break; case TIME_LABEL_REMAINING: widget = new TimeLabel( p_intf, TimeLabel::Remaining ); break; default: msg_Warn( p_intf, "This should not happen %i", button ); break; } /* Customize Buttons */ if( b_flat || b_big ) { QFrame *frame = qobject_cast<QFrame *>(widget); if( frame ) { QList<QToolButton *> allTButtons = frame->findChildren<QToolButton *>(); for( int i = 0; i < allTButtons.count(); i++ ) applyAttributes( allTButtons[i], b_flat, b_big ); } else { QToolButton *tmpButton = qobject_cast<QToolButton *>(widget); if( tmpButton ) applyAttributes( tmpButton, b_flat, b_big ); } } return widget; }