diff options
author | Arno <arno@disconnect.de> | 2018-04-04 08:54:05 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2018-04-04 08:54:05 +0200 |
commit | d8b964698d8bae30a0a0d609cbe5b01bd410e937 (patch) | |
tree | 7dbc425cbdb74da4857393d730d36b0821d83868 | |
parent | 1d45add3f8ea48c2e55090477ebec999d80d1f80 (diff) | |
download | SheMov-d8b964698d8bae30a0a0d609cbe5b01bd410e937.tar.gz SheMov-d8b964698d8bae30a0a0d609cbe5b01bd410e937.tar.bz2 SheMov-d8b964698d8bae30a0a0d609cbe5b01bd410e937.zip |
MovieWidget: turn bottom view into SmView
Also, play the movie on doubleclick if it's available.
-rw-r--r-- | moviewidget.cpp | 15 | ||||
-rw-r--r-- | moviewidget.h | 4 |
2 files changed, 17 insertions, 2 deletions
diff --git a/moviewidget.cpp b/moviewidget.cpp index 884d2c2..27489e7 100644 --- a/moviewidget.cpp +++ b/moviewidget.cpp @@ -12,9 +12,11 @@ #include <QSqlQuery> #include <QSettings> #include <QFileInfo> +#include <QProcess> #include <QApplication> #include "moviewidget.h" +#include "smview.h" #include "helper.h" MovieWidget::MovieWidget(QWidget *parent) : QWidget(parent){ @@ -80,7 +82,7 @@ void MovieWidget::setupWidget(){ mTopView->setModel(mTopProxy); connect(mTopView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MovieWidget::topSelectionChanged); - mBottomView = new QTreeView; + mBottomView = new SmView; mBottomView->setAlternatingRowColors(true); mBottomView->setSortingEnabled(true); mBottomView->setUniformRowHeights(true); @@ -90,6 +92,7 @@ void MovieWidget::setupWidget(){ mBottomProxy = new QSortFilterProxyModel; mBottomProxy->setSourceModel(mBottomModel); mBottomView->setModel(mBottomProxy); + connect(mBottomView, &SmView::doubleClicked, this, &MovieWidget::bottomDoubleClicked); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(topWL); @@ -377,3 +380,13 @@ void MovieWidget::topSelectionChanged(){ mBottomView->resizeColumnToContents(i); } } + +void MovieWidget::bottomDoubleClicked(const QModelIndex &idx){ + QString fullPath = idx.data(FullPathRole).toString(); + if(fullPath.startsWith("/")){ + QPair<QString, QStringList> playerData = Helper::programData("movieviewer"); + QStringList args = playerData.second; + args << fullPath; + QProcess::startDetached(playerData.first, args); + } +} diff --git a/moviewidget.h b/moviewidget.h index a3ea99e..8c8fc84 100644 --- a/moviewidget.h +++ b/moviewidget.h @@ -8,6 +8,7 @@ class QComboBox; class QTreeView; class QSortFilterProxyModel; class QStandardItemModel; +class SmView; class MovieWidget : public QWidget { Q_OBJECT @@ -26,6 +27,7 @@ class MovieWidget : public QWidget { void populateByActors(); void populateByGenres(); void topSelectionChanged(); + void bottomDoubleClicked(const QModelIndex &idx); private: void setupWidget(); @@ -34,7 +36,7 @@ class MovieWidget : public QWidget { QTreeView *mTopView; QSortFilterProxyModel *mTopProxy; QStandardItemModel *mTopModel; - QTreeView *mBottomView; + SmView *mBottomView; QSortFilterProxyModel *mBottomProxy; QStandardItemModel *mBottomModel; }; |