summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fswidget.cpp27
-rw-r--r--fswidget.h1
-rw-r--r--shemov.cpp1
-rw-r--r--shemov.pro8
-rw-r--r--smglobals.cpp24
-rw-r--r--smglobals.h11
-rw-r--r--videoviewer.cpp54
-rw-r--r--videoviewer.h28
8 files changed, 136 insertions, 18 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);
diff --git a/fswidget.h b/fswidget.h
index 90aeb70..25953a9 100644
--- a/fswidget.h
+++ b/fswidget.h
@@ -43,6 +43,7 @@ class FSWidget : public QWidget {
void doubleClicked(const QModelIndex &idx);
void preview();
void playSelected(int count, QString player);
+ void playQt();
void selectFilter();
void calculateSelectionChanged();
diff --git a/shemov.cpp b/shemov.cpp
index 9f9d1c0..23d4c54 100644
--- a/shemov.cpp
+++ b/shemov.cpp
@@ -190,6 +190,7 @@ void SheMov::closeEvent(QCloseEvent *event){
SmGlobals *globals = SmGlobals::instance();
delete globals;
QSqlDatabase::database("treedb").close();
+ qApp->closeAllWindows();
event->accept();
}
diff --git a/shemov.pro b/shemov.pro
index 544d2a3..b5dfce6 100644
--- a/shemov.pro
+++ b/shemov.pro
@@ -4,7 +4,7 @@ CONFIG += warn_on \
qt \
debug
CONFIG -= release
-QT += core gui widgets sql concurrent
+QT += core gui widgets sql concurrent multimediawidgets
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES = main.cpp \
shemov.cpp \
@@ -57,7 +57,8 @@ SOURCES = main.cpp \
mappingeditdialog.cpp \
mappingtreeproxy.cpp \
mappingtreeresultmodel.cpp \
- mappingdata.cpp
+ mappingdata.cpp \
+ videoviewer.cpp
HEADERS = \
shemov.h \
helper.h \
@@ -109,7 +110,8 @@ HEADERS = \
mappingeditdialog.h \
mappingtreeproxy.h \
mappingtreeresultmodel.h \
- mappingdata.h
+ mappingdata.h \
+ videoviewer.h
LIBS += -lmagic -lXfixes -lX11 -lMagick++-6.Q16HDRI
INCLUDEPATH += /usr/include/ImageMagick-6/
RESOURCES = shemov.qrc
diff --git a/smglobals.cpp b/smglobals.cpp
index 7a909b6..278772e 100644
--- a/smglobals.cpp
+++ b/smglobals.cpp
@@ -13,6 +13,7 @@
#include "mappingtablemodel.h"
#include "mappingtreemodel.h"
#include "pictureviewer2.h"
+#include "videoviewer.h"
#include "picfilesmodel.h"
#include "configurationdialog.h"
#include "archivebrowsermodel.h"
@@ -24,9 +25,12 @@
SmGlobals *SmGlobals::mInstance = nullptr;
SmGlobals::~SmGlobals(){
- foreach(QAbstractItemModel *model, mModels.values()){
+ for(QAbstractItemModel *model : mModels.values()){
model->deleteLater();
}
+ for(QWidget *w : mWidgets){
+ w->close();
+ }
}
SmGlobals *SmGlobals::instance(){
@@ -99,6 +103,14 @@ PictureViewer2 *SmGlobals::pictureViewer() {
return mPictureViewer;
}
+VideoViewer *SmGlobals::videoViewer() {
+ if(!mVideoViewer){
+ mVideoViewer = new VideoViewer;
+ mVideoViewer->setHidden(true);
+ }
+ return mVideoViewer;
+}
+
QSize SmGlobals::cursorSize() {
if(!mCursorSize.isValid()){
Display *dpy = XOpenDisplay(nullptr);
@@ -117,7 +129,7 @@ QIcon SmGlobals::iconFor(const QString &type){
return retval;
}
-SmGlobals::SmGlobals() : mPictureViewer(nullptr), mArchiveController(nullptr){
+SmGlobals::SmGlobals() : mPictureViewer(nullptr), mVideoViewer(nullptr), mArchiveController(nullptr){
mIcons.insert("Dildo", ":/dildo.png");
mIcons.insert("Dick to left", ":/back_dick.png");
mIcons.insert("Dick pointing up", ":/up_dick.png");
@@ -158,14 +170,6 @@ SmGlobals::SmGlobals() : mPictureViewer(nullptr), mArchiveController(nullptr){
mReencReasons = s.value("ui/reasons").toStringList();
}
-void SmGlobals::registerWidget(const QString &name, QWidget *w){
- mWidgets.insert(name, w);
-}
-
-QWidget *SmGlobals::getRegisteredWidget(const QString &name){
- return mWidgets.value(name);
-}
-
void SmGlobals::setReencReasons(const QStringList reasons){
mReencReasons = reasons;
std::sort(mReencReasons.begin(), mReencReasons.end());
diff --git a/smglobals.h b/smglobals.h
index c4eb6c3..83e63be 100644
--- a/smglobals.h
+++ b/smglobals.h
@@ -15,6 +15,7 @@
class QAbstractItemModel;
class PictureViewer2;
+class VideoViewer;
class QPixmap;
class SeriesTreeWidget;
class ArchiveController;
@@ -37,32 +38,34 @@ class SmGlobals : public QObject {
static SmGlobals *instance();
QAbstractItemModel *model(const QString &which);
PictureViewer2 *pictureViewer();
+ VideoViewer *videoViewer();
void setArchiveController(ArchiveController *c) { mArchiveController = c; }
ArchiveController *archiveController() { return mArchiveController; }
QSize cursorSize();
QIcon iconFor(const QString &type);
const QHash<QString, QString> & icons() const { return mIcons; }
QHash<int, QString> filetypeMap() const { return mFiletypeMap; }
- void registerWidget(const QString &name, QWidget *w);
- QWidget *getRegisteredWidget(const QString &name);
void setGlobalAction(QAction *a) { mGlobalActions = a; }
QAction *globalAction() { return mGlobalActions; }
QStringList reencReasons() const { return mReencReasons; }
void setReencReasons(const QStringList reasons);
+ void addGlobalWidget(QWidget *w) { mWidgets.append(w); }
+ void removeGlobalWidget(QWidget *w) { mWidgets.removeAll(w); }
private:
SmGlobals();
SmGlobals(const SmGlobals &other);
SmGlobals &operator=(const SmGlobals &other);
static SmGlobals *mInstance;
- QHash<QString, QAbstractItemModel*> mModels;
+ QHash<QString, QAbstractItemModel*> mModels;
PictureViewer2 *mPictureViewer;
+ VideoViewer *mVideoViewer;
SeriesTreeWidget *mSeriesTreeWidget;
QSize mCursorSize;
QHash<QString, QString> mIcons;
ArchiveController *mArchiveController;
QHash<int, QString> mFiletypeMap;
- QHash<QString, QWidget*> mWidgets;
+ QList<QWidget*> mWidgets;
QStringList mReencReasons;
QAction *mGlobalActions;
};
diff --git a/videoviewer.cpp b/videoviewer.cpp
new file mode 100644
index 0000000..5430e9f
--- /dev/null
+++ b/videoviewer.cpp
@@ -0,0 +1,54 @@
+/*
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version
+ 2 of the License, or (at your option) any later version.
+*/
+
+#include <QMediaPlayer>
+#include <QMediaPlaylist>
+#include <QKeyEvent>
+#include <QCloseEvent>
+
+#include "videoviewer.h"
+#include "smglobals.h"
+
+VideoViewer::VideoViewer(QWidget *parent) : QVideoWidget(parent) {
+ mPlayer = new QMediaPlayer(this);
+ mPlayer->setVideoOutput(this);
+ QMediaPlaylist *playList = new QMediaPlaylist;
+ mPlayer->setPlaylist(playList);
+ SmGlobals::instance()->addGlobalWidget(this);
+}
+
+void VideoViewer::keyPressEvent(QKeyEvent *e){
+ int keyNum = e->key();
+ if(keyNum == Qt::Key_Q){
+ close();
+ }else if(keyNum == Qt::Key_F){
+ setFullScreen(isFullScreen() ? false : true);
+ }else if(keyNum == Qt::Key_Right){
+ mPlayer->setPosition(mPlayer->position() + 5000);
+ }else if(keyNum == Qt::Key_Left){
+ qint64 pos = mPlayer->position();
+ mPlayer->setPosition(pos - 5000 < 0 ? 0 : pos - 5000);
+ }else if(keyNum == Qt::Key_Up){
+ mPlayer->setPosition(mPlayer->position() + 60000);
+ }else if(keyNum == Qt::Key_Down){
+ qint64 pos = mPlayer->position();
+ mPlayer->setPosition(pos - 60000 < 0 ? 0 : pos - 60000);
+ }else if(keyNum == Qt::Key_N){
+ mPlayer->playlist()->next();
+ }else if(keyNum == Qt::Key_P){
+ mPlayer->playlist()->previous();
+ }else if(keyNum == Qt::Key_M){
+ mPlayer->setMuted(mPlayer->isMuted() ? false : true);
+ }
+}
+
+void VideoViewer::closeEvent(QCloseEvent *e){
+ mPlayer->stop();
+ SmGlobals::instance()->removeGlobalWidget(this);
+ deleteLater();
+ e->accept();
+}
diff --git a/videoviewer.h b/videoviewer.h
new file mode 100644
index 0000000..223bc01
--- /dev/null
+++ b/videoviewer.h
@@ -0,0 +1,28 @@
+/*
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version
+ 2 of the License, or (at your option) any later version.
+*/
+
+#ifndef VIDEOVIEWER_H
+#define VIDEOVIEWER_H
+
+#include <QVideoWidget>
+
+class QMediaPlayer;
+
+class VideoViewer : public QVideoWidget {
+ public:
+ VideoViewer(QWidget *parent = nullptr);
+ QMediaPlayer* player() { return mPlayer; }
+
+ protected:
+ virtual void keyPressEvent(QKeyEvent *e);
+ virtual void closeEvent(QCloseEvent *e);
+
+ private:
+ QMediaPlayer *mPlayer;
+};
+
+#endif // VIDEOVIEWER_H