void VideoItem::createPanel() { _panel = new VideoControlPanel(this); _panel->setParentItem(this); setPanelPosition(); _panel->setVolume(_player->volume()); // _panel->show(); _panel->hide(); connect (this, SIGNAL(playMedia()), _panel, SLOT(on_play())); connect (this, SIGNAL(pauseMedia()), _panel, SLOT(on_pause())); connect (this, SIGNAL(stopMedia()), _panel, SLOT(on_stop())); connect (_panel, SIGNAL(positionChanged(qint64)), _player, SLOT(setPosition(qint64))); connect (_panel, SIGNAL(playClicked()), _player, SLOT(play())); connect (_panel, SIGNAL(pauseClicked()), _player, SLOT(pause())); connect (_panel, SIGNAL(volumeChanged(int)), _player, SLOT(setVolume(int))); }
void TvrUiWidget::on_actionOpen_triggered(){ if(getRecordingState() || getRecordingPausedState() || getPlayingState() || getPlayingPausedState()){ stopMedia(); } if(!getFileSavedState()){ if(isLRAvailable()){ showSaveFileDlg(); } } setLastRecording(false); if(showOpenFileDlg()){ pd = g_new0(player_data, 1); tvr_init_player(pd, fileNameO.toStdString().c_str()); g_timeout_add(1000, (GSourceFunc)tvr_parse_stream_length, pd); setFileOpenedState(true); t->start(1000); playMedia(); } }
void VideoItem::on_stateChanged(QMediaPlayer::State state) { // qDebug () << "on media state changed: " << state; if (state == QMediaPlayer::PlayingState) { //_panel->show(); emit playMedia(); } else if (state == QMediaPlayer::PausedState) { emit pauseMedia(); } else if (state == QMediaPlayer::StoppedState) { emit stopMedia(); } }
MusicListView::MusicListView(QWidget *parent) : ListView(parent), d_ptr(new MusicListViewPrivate(this)) { Q_D(MusicListView); DThemeManager::instance()->registerWidget(this); setObjectName("MusicListView"); d->model = new MusiclistModel(0, 1, this); setModel(d->model); d->delegate = new MusicItemDelegate; setItemDelegate(d->delegate); setDragEnabled(true); viewport()->setAcceptDrops(true); setDropIndicatorShown(true); setDragDropOverwriteMode(false); setVerticalScrollMode(QAbstractItemView::ScrollPerItem); setHorizontalScrollMode(QAbstractItemView::ScrollPerItem); setDefaultDropAction(Qt::MoveAction); setDragDropMode(QAbstractItemView::InternalMove); setMovement(QListView::Free); setSelectionMode(QListView::ExtendedSelection); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setEditTriggers(QAbstractItemView::NoEditTriggers); setSelectionBehavior(QAbstractItemView::SelectRows); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, &MusicListView::customContextMenuRequested, this, &MusicListView::requestCustomContextMenu); connect(this, &MusicListView::doubleClicked, this, [ = ](const QModelIndex & index) { MetaPtr meta = d->model->meta(index); Q_EMIT playMedia(meta); }); // For debug // connect(selectionModel(), &QItemSelectionModel::selectionChanged, // this, [ = ](const QItemSelection & /*selected*/, const QItemSelection & deselected) { // if (!deselected.isEmpty()) { // qDebug() << "cancel" << deselected; // } // }); }
void TvrUiWidget::on_actionPlay_triggered(){ if(!getPlayingState() && !getPlayingPausedState()){ pd = g_new0(player_data, 1); statusLabelEdit->setText("Playing ..."); if(isLRAvailable()) { tvr_init_player(pd, tFile.toStdString().c_str()); } else { tvr_init_player(pd, fileNameO.toStdString().c_str()); } } if(!getPlayingPausedState()){ seconds = secondsCopy; } playButtonClicked = true; t->start(1000); playMedia(); }
void MusicListView::showContextMenu(const QPoint &pos, PlaylistPtr selectedPlaylist, PlaylistPtr favPlaylist, QList<PlaylistPtr> newPlaylists) { Q_D(MusicListView); QItemSelectionModel *selection = this->selectionModel(); if (selection->selectedRows().length() <= 0) { return; } QPoint globalPos = this->mapToGlobal(pos); QMenu playlistMenu; playlistMenu.setStyle(QStyleFactory::create("dlight")); auto newvar = QVariant::fromValue(PlaylistPtr()); auto createPlaylist = playlistMenu.addAction(tr("New playlist")); createPlaylist->setData(newvar); createPlaylist->setIcon(QIcon(":/light/image/plus.svg")); playlistMenu.addSeparator(); if (selectedPlaylist != favPlaylist) { auto act = playlistMenu.addAction(favPlaylist->displayName()); act->setData(QVariant::fromValue(favPlaylist)); } for (auto playlist : newPlaylists) { QFont font(playlistMenu.font()); QFontMetrics fm(font); auto text = fm.elidedText(QString(playlist->displayName().replace("&", "&&")), Qt::ElideMiddle, 160); auto act = playlistMenu.addAction(text); act->setData(QVariant::fromValue(playlist)); } connect(&playlistMenu, &QMenu::triggered, this, [ = ](QAction * action) { auto playlist = action->data().value<PlaylistPtr >(); qDebug() << playlist; MetaPtrList metalist; for (auto &index : selection->selectedRows()) { auto meta = d->model->meta(index); if (!meta.isNull()) { metalist << meta; } } Q_EMIT addToPlaylist(playlist, metalist); }); bool singleSelect = (1 == selection->selectedRows().length()); QMenu myMenu; myMenu.setStyle(QStyleFactory::create("dlight")); QAction *playAction = nullptr; if (singleSelect) { playAction = myMenu.addAction(tr("Play")); } myMenu.addAction(tr("Add to playlist"))->setMenu(&playlistMenu); myMenu.addSeparator(); QAction *displayAction = nullptr; if (singleSelect) { displayAction = myMenu.addAction(tr("Display in file manager")); } auto removeAction = myMenu.addAction(tr("Remove from playlist")); auto deleteAction = myMenu.addAction(tr("Delete from local disk")); QAction *songAction = nullptr; QMenu textCodecMenu; textCodecMenu.setStyle(QStyleFactory::create("dlight")); if (singleSelect) { auto index = selection->selectedRows().first(); auto meta = d->model->meta(index); QList<QByteArray> codecList = DMusic::detectMetaEncodings(meta); // codecList << "utf-8" ; for (auto codec : codecList) { auto act = textCodecMenu.addAction(codec); act->setData(QVariant::fromValue(codec)); } if (codecList.length() > 1) { myMenu.addSeparator(); myMenu.addAction(tr("Encoding"))->setMenu(&textCodecMenu); } myMenu.addSeparator(); songAction = myMenu.addAction(tr("Song info")); connect(&textCodecMenu, &QMenu::triggered, this, [ = ](QAction * action) { auto codec = action->data().toByteArray(); meta->updateCodec(codec); Q_EMIT updateMetaCodec(meta); }); } if (playAction) { connect(playAction, &QAction::triggered, this, [ = ](bool) { auto index = selection->selectedRows().first(); Q_EMIT playMedia(d->model->meta(index)); }); } if (displayAction) { connect(displayAction, &QAction::triggered, this, [ = ](bool) { auto index = selection->selectedRows().first(); auto meta = d->model->meta(index); auto dirUrl = QUrl::fromLocalFile(meta->localPath); Dtk::Widget::DDesktopServices::showFileItem(dirUrl); }); } if (removeAction) { connect(removeAction, &QAction::triggered, this, [ = ](bool) { d->removeSelection(selection); }); } if (deleteAction) { connect(deleteAction, &QAction::triggered, this, [ = ](bool) { bool containsCue = false; MetaPtrList metalist; for (auto index : selection->selectedRows()) { auto meta = d->model->meta(index); if (!meta->cuePath.isEmpty()) { containsCue = true; } metalist << meta; } Dtk::Widget::DDialog warnDlg(this); warnDlg.setStyle(QStyleFactory::create("dlight")); warnDlg.setTextFormat(Qt::RichText); warnDlg.addButton(tr("Cancel"), true, Dtk::Widget::DDialog::ButtonWarning); warnDlg.addButton(tr("Delete"), false, Dtk::Widget::DDialog::ButtonNormal); auto cover = QImage(QString(":/common/image/del_notify.svg")); if (1 == metalist.length()) { auto meta = metalist.first(); auto coverData = MetaSearchService::coverData(meta); if (coverData.length() > 0) { cover = QImage::fromData(coverData); } warnDlg.setMessage(QString(tr("Are you sure you want to delete %1?")).arg(meta->title)); } else { warnDlg.setMessage(QString(tr("Are you sure you want to delete the selected %1 songs?")).arg(metalist.length())); } if (containsCue) { warnDlg.setTitle(tr("Are you sure you want to delete the selected %1 songs?").arg(metalist.length())); warnDlg.setMessage(tr("Deleting the current song will also delete the song files contained")); } auto coverPixmap = QPixmap::fromImage(WidgetHelper::cropRect(cover, QSize(64, 64))); warnDlg.setIcon(QIcon(coverPixmap)); if (0 == warnDlg.exec()) { return; } Q_EMIT deleteMusicList(metalist); }); } if (songAction) { connect(songAction, &QAction::triggered, this, [ = ](bool) { auto index = selection->selectedRows().first(); auto meta = d->model->meta(index); Q_EMIT showInfoDialog(meta); }); } myMenu.exec(globalPos); }
FramelessMainWindow::FramelessMainWindow( QWidget *parent ) : QMainWindow( parent ), m_scene( new QGraphicsScene( this ) ), m_browser( new GraphicsBrowser( m_scene, *this ) ), m_mouseFilter( *this, *qApp ), m_video( new EventfulVidgetVideo( this ) ), m_intro( new QGraphicsScene ), m_control( new VideoControl( this ) ), m_closeControl( new QFrame( this ) ), m_hostApp( new HostApp( m_browser->webView(), this ) ) { m_video->hide(); m_control->hide(); m_browser->webView()->page()->settings()->setAttribute( QWebSettings::JavascriptCanOpenWindows, true ); m_control->setVolume( m_hostApp->getVolume() ); m_closeControl->hide(); m_closeControl->setStyleSheet( "QFrame{background-color:black; } " "QPushButton { background-image: url(':/close-styled'); width:31;} " "QWidget{border:none; padding:0; spacing:0; height:30;}" ); QHBoxLayout *hl = new QHBoxLayout( m_closeControl ); hl->setContentsMargins( QMargins() ); hl->addSpacerItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); m_closeButton = new QPushButton(); m_closeButton->setCursor( Qt::PointingHandCursor ); // btn->setFlat( true ); hl->addWidget( m_closeButton ); connect( m_control, SIGNAL( uiShow() ), m_closeButton, SLOT( show() ) ); connect( m_control, SIGNAL( uiHide() ), m_closeButton, SLOT( hide() ) ); setWindowTitle( "Popcorn Time" ); m_intro->addPixmap( QPixmap( ":/intro" ).scaled( DEFAULT_WIDTH, DEFAULT_HEIGHT, Qt::IgnoreAspectRatio ) ); m_browser->setScene( m_intro ); new QShortcut( QKeySequence( "Ctrl+M" ), this, SLOT( minimize() ) ); QObject::connect( m_hostApp->thread(), SIGNAL( torrentUrlAvailable( QString ) ), this, SLOT( playMedia( QString ) ) ); QObject::connect( m_browser->webView(), SIGNAL( loadFinished( bool ) ), this, SLOT( removeIntro() ) ); QObject::connect( m_hostApp, SIGNAL( commandedClose() ), this, SLOT( close() ) ); QObject::connect( m_hostApp, SIGNAL( commandedMinimize() ), this, SLOT( minimize() ) ); QObject::connect( m_hostApp, SIGNAL( toggledMaximize() ), this, SLOT( toggleMaximize() ) ); QObject::connect( m_hostApp, SIGNAL( haveSubtitles( SubtitleItem ) ), m_control, SLOT( addSubtitle( SubtitleItem ) ) ); QObject::connect( m_hostApp, SIGNAL( downloadInfoChanged( DownloadInfo ) ), m_control, SLOT( updateDownloadStatus( DownloadInfo ) ) ); QObject::connect( m_control, SIGNAL( volumeChanged( int ) ), m_hostApp, SLOT( setVolume( int ) ) ); QObject::connect( m_control, SIGNAL( newImage( QString ) ), m_video, SLOT( setImage( QString ) ) ); QObject::connect( m_control->fullscreenButton(), SIGNAL( clicked() ), this, SLOT( toggleMaximize() ) ); QObject::connect( &m_mouseFilter, SIGNAL( enterPressed() ), this, SLOT( toggleMaximize() ) ); QObject::connect( &m_mouseFilter, SIGNAL( upPressed() ), m_control, SLOT( volumeUp() ) ); QObject::connect( &m_mouseFilter, SIGNAL( downPressed() ), m_control, SLOT( volumeDown() ) ); QObject::connect( &m_mouseFilter, SIGNAL( pausePressed() ), m_control, SLOT( pauseToggleReq() ) ); connect( m_video, SIGNAL( mouseEnter() ), m_control, SLOT( showForDefaultPeriod() ) ); this->setWindowFlags( Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint ); #ifdef Q_OS_MAC fixNativeWindow( this ); #endif this->setMinimumSize( 800, 330 ); this->setMouseTracking( true ); this->setCentralWidget( m_browser ); qApp->installEventFilter( this ); reconnectMediaPlayer(); QObject::connect( VLC::VLCObject(), SIGNAL( mediaPlayerReplaced() ), this, SLOT( reconnectMediaPlayer() ) ); }