From d8b964698d8bae30a0a0d609cbe5b01bd410e937 Mon Sep 17 00:00:00 2001 From: Arno Date: Wed, 4 Apr 2018 08:54:05 +0200 Subject: MovieWidget: turn bottom view into SmView Also, play the movie on doubleclick if it's available. --- moviewidget.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'moviewidget.cpp') diff --git a/moviewidget.cpp b/moviewidget.cpp index 884d2c2..27489e7 100644 --- a/moviewidget.cpp +++ b/moviewidget.cpp @@ -12,9 +12,11 @@ #include #include #include +#include #include #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 playerData = Helper::programData("movieviewer"); + QStringList args = playerData.second; + args << fullPath; + QProcess::startDetached(playerData.first, args); + } +} -- cgit v1.2.3-70-g09d2