diff options
author | Arno <arno@disconnect.de> | 2018-08-26 20:35:23 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2018-08-26 20:35:23 +0200 |
commit | 68ee6a0ec973940eb4f799b00f6518a902cbc4e5 (patch) | |
tree | 41ddac1434482ae0a20686c8bc8c8231bf9aed36 /fswidget.cpp | |
parent | 1aebcdcc41d60f891a12b70584d3ceb833d5bfdc (diff) | |
download | SheMov-68ee6a0ec973940eb4f799b00f6518a902cbc4e5.tar.gz SheMov-68ee6a0ec973940eb4f799b00f6518a902cbc4e5.tar.bz2 SheMov-68ee6a0ec973940eb4f799b00f6518a902cbc4e5.zip |
Implement custom Video player
Well, well, well. Due to several unforseen circumstances I ventured into
the sources again and implemented a Video player with Qt. Looks very
promising so far. There are some bugs to weed out, but I'm getting
there...
Diffstat (limited to 'fswidget.cpp')
-rw-r--r-- | fswidget.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/fswidget.cpp b/fswidget.cpp index c084c12..405d19d 100644 --- a/fswidget.cpp +++ b/fswidget.cpp @@ -19,6 +19,8 @@ #include <QProcess> #include <QSettings> #include <QApplication> +#include <QMediaPlayer> +#include <QMediaPlaylist> #include "fswidget.h" #include "helper.h" @@ -28,6 +30,7 @@ #include "fsproxy.h" #include "smview.h" #include "viewer.h" +#include "videoviewer.h" FSWidget::FSWidget(QWidget *parent) : QWidget(parent) { mMovieWizard = new NewMovieWizard(this); @@ -111,6 +114,8 @@ void FSWidget::setupWidget(){ toolbar->addAction(headerA); toolbar->addSeparator(); toolbar->addAction(SmGlobals::instance()->globalAction()); + QAction *playQtA = new QAction(QIcon(":/bizarre_amputee.png"), tr("Play with QT"), this); + connect(playQtA, &QAction::triggered, this, &FSWidget::playQt); QAction *playSelectedA = new QAction(QIcon(":/spreadingpants.png"), tr("Play selected"), this); connect(playSelectedA, &QAction::triggered, [=] { playSelected(1, QString()); }); playSelectedA->setShortcut(Qt::Key_Return); @@ -191,7 +196,7 @@ void FSWidget::setupWidget(){ mFileView->sortByColumn(0, Qt::AscendingOrder); connect(mFileView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &FSWidget::calculateSelectionChanged); - mFileView->addActions(QList<QAction*>() << playSelectedA << playRepeatMA << mPlayWithA << Helper::createSeparator(this) << backA << forwardA << Helper::createSeparator(this) << refreshA << deleteFilesA << Helper::createSeparator(this) << archiveMovieA << archivePicsA << Helper::createSeparator(this) << unpackA << previewA << selectFilterA << unselectAllA); + mFileView->addActions(QList<QAction*>() << playQtA << playSelectedA << playRepeatMA << mPlayWithA << Helper::createSeparator(this) << backA << forwardA << Helper::createSeparator(this) << refreshA << deleteFilesA << Helper::createSeparator(this) << archiveMovieA << archivePicsA << Helper::createSeparator(this) << unpackA << previewA << selectFilterA << unselectAllA); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(topWL); @@ -582,6 +587,26 @@ void FSWidget::playSelected(int count, QString player){ QProcess::startDetached(playerData.first, args); } +void FSWidget::playQt(){ + QModelIndexList selected = mFileView->selectionModel()->selectedRows(); + if(selected.isEmpty()){ + return; + } + QStringList paths; + for(const QModelIndex &idx : selected){ + paths << idx.data(FullPathRole).toString(); + } + VideoViewer *wv = new VideoViewer; + QMediaPlaylist *pl = wv->player()->playlist(); + pl->clear(); + for(const QString &p : paths){ + pl->addMedia(QUrl::fromLocalFile(p)); + } + pl->setCurrentIndex(0); + wv->setVisible(true); + wv->player()->play(); +} + void FSWidget::selectFilter(){ bool ok; QString retval = QInputDialog::getText(this, tr("File selection by regex!"), tr("Select"), QLineEdit::Normal, "mkv$", &ok); |