summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fswidget.cpp55
-rw-r--r--fswidget.h1
-rw-r--r--programconfigurator.cpp41
-rw-r--r--programconfigurator.h6
-rw-r--r--shemov.cpp1
-rw-r--r--shemov.pro8
-rw-r--r--smglobals.cpp34
-rw-r--r--smglobals.h11
-rw-r--r--videoviewer.cpp81
-rw-r--r--videoviewer.h32
10 files changed, 222 insertions, 48 deletions
diff --git a/fswidget.cpp b/fswidget.cpp
index c084c12..0215e3a 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);
@@ -570,16 +573,52 @@ void FSWidget::playSelected(int count, QString player){
for(const QModelIndex &idx : selected){
paths << idx.data(FullPathRole).toString();
}
- if(player.isEmpty()){
- QSettings s;
- player = s.value("programs_movieviewer/default").toString();
+ QSettings s;
+ bool useInternal = s.value("vw/internal").toBool();
+ if(useInternal && player.isEmpty()){
+ VideoViewer *wv = new VideoViewer;
+ QMediaPlaylist *pl = wv->player()->playlist();
+ pl->clear();
+ for(int i = 0; i < count; ++i){
+ for(const QString &p : paths){
+ pl->addMedia(QUrl::fromLocalFile(p));
+ }
+ }
+ pl->setCurrentIndex(0);
+ wv->setVisible(true);
+ wv->player()->play();
+ }else{
+ if(player.isEmpty()){
+ QSettings s;
+ player = s.value("programs_movieviewer/default").toString();
+ }
+ QPair<QString, QStringList> playerData = Helper::programData("movieviewer", player);
+ QStringList args = playerData.second;
+ for(int i = 0; i < count; ++i){
+ args << paths;
+ }
+ 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();
}
- QPair<QString, QStringList> playerData = Helper::programData("movieviewer", player);
- QStringList args = playerData.second;
- for(int i = 0; i < count; ++i){
- args << paths;
+ VideoViewer *wv = new VideoViewer;
+ QMediaPlaylist *pl = wv->player()->playlist();
+ pl->clear();
+ for(const QString &p : paths){
+ pl->addMedia(QUrl::fromLocalFile(p));
}
- QProcess::startDetached(playerData.first, args);
+ pl->setCurrentIndex(0);
+ wv->setVisible(true);
+ wv->player()->play();
}
void FSWidget::selectFilter(){
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/programconfigurator.cpp b/programconfigurator.cpp
index fa05e5c..ae272f5 100644
--- a/programconfigurator.cpp
+++ b/programconfigurator.cpp
@@ -5,16 +5,17 @@
2 of the License, or (at your option) any later version.
*/
-#include <QtWidgets/QPushButton>
-#include <QtWidgets/QComboBox>
-#include <QtWidgets/QLineEdit>
-#include <QtWidgets/QLabel>
-#include <QtWidgets/QGridLayout>
-#include <QtWidgets/QHBoxLayout>
-#include <QtWidgets/QCompleter>
+#include <QPushButton>
+#include <QComboBox>
+#include <QLineEdit>
+#include <QLabel>
+#include <QCheckBox>
+#include <QGridLayout>
+#include <QHBoxLayout>
+#include <QCompleter>
#include <QSettings>
-#include <QtWidgets/QDirModel>
-#include <QtWidgets/QMessageBox>
+#include <QDirModel>
+#include <QMessageBox>
#include <QRegExp>
#include <QFileInfo>
@@ -56,15 +57,21 @@ ProgramConfigurator::ProgramConfigurator(const QString &prefix, const QString &d
buttonLayout->addWidget(mUpdate);
buttonLayout->addWidget(mDefault);
buttonLayout->addStretch();
- mainLayout->addLayout(buttonLayout, 5, 0, 1, 2, Qt::AlignCenter);
+ mainLayout->addLayout(buttonLayout, 5, 0, 1, 2, Qt::AlignCenter);
+ mInternalViewer = new QCheckBox(tr("Use internal Viewer"));
+ QHBoxLayout *intViewerL = new QHBoxLayout;
+ intViewerL->addStretch();
+ intViewerL->addWidget(mInternalViewer);
+ intViewerL->addStretch();
+ mainLayout->addLayout(intViewerL, 6, 0, 1, 2, Qt::AlignCenter);
QVBoxLayout *stretchLayout = new QVBoxLayout;
stretchLayout->addStretch();
mainLayout->addLayout(stretchLayout, 6, 0, 1, 2);
- connect(mProgramSelector, SIGNAL(currentIndexChanged(QString)), this, SLOT(programChanged(QString)));
- connect(mAdd, SIGNAL(clicked()), this, SLOT(addProgram()));
- connect(mRemove, SIGNAL(clicked()), this, SLOT(removeProgram()));
- connect(mUpdate, SIGNAL(clicked()), this, SLOT(updateProgram()));
- connect(mDefault, SIGNAL(clicked()), this, SLOT(setDefault()));
+ connect(mProgramSelector, QOverload<const QString &>::of(&QComboBox::currentIndexChanged), this, &ProgramConfigurator::programChanged);
+ connect(mAdd, &QPushButton::clicked, this, &ProgramConfigurator::addProgram);
+ connect(mRemove, &QPushButton::clicked, this, &ProgramConfigurator::removeProgram);
+ connect(mUpdate, &QPushButton::clicked, this, &ProgramConfigurator::updateProgram);
+ connect(mDefault, &QPushButton::clicked, this, &ProgramConfigurator::setDefault);
readSettings();
setLayout(mainLayout);
}
@@ -76,6 +83,7 @@ void ProgramConfigurator::writeSettings(){
QSettings s;
s.setValue(defaultString, mDefautProg);
s.setValue(dataString, mData);
+ s.setValue("vw/internal", mInternalViewer->isChecked());
}
void ProgramConfigurator::programChanged(const QString &program){
@@ -162,7 +170,7 @@ void ProgramConfigurator::readSettings(){
QSettings s;
mData = s.value(dataString).toHash();
QStringList progs;
- foreach(QString p, mData.keys()){
+ for(QString p : mData.keys()){
progs << p;
}
mProgramSelector->addItems(progs);
@@ -171,6 +179,7 @@ void ProgramConfigurator::readSettings(){
if(idx != -1){
mProgramSelector->setCurrentIndex(idx);
}
+ mInternalViewer->setChecked(s.value("vw/internal").toBool());
setDefault();
}
diff --git a/programconfigurator.h b/programconfigurator.h
index 05e3e9e..3df66a5 100644
--- a/programconfigurator.h
+++ b/programconfigurator.h
@@ -8,7 +8,7 @@
#ifndef PROGRAMCONFIGURATOR_H
#define PROGRAMCONFIGURATOR_H
-#include <QtWidgets/QWidget>
+#include <QWidget>
#include <QString>
#include <QHash>
#include <QVariant>
@@ -19,11 +19,12 @@ class QComboBox;
class QStringList;
class QLabel;
class QStringList;
+class QCheckBox;
class ProgramConfigurator : public QWidget {
Q_OBJECT
public:
- ProgramConfigurator(const QString &prefix, const QString &description, QWidget *parent = 0);
+ ProgramConfigurator(const QString &prefix, const QString &description, QWidget *parent = nullptr);
~ProgramConfigurator() {}
public slots:
@@ -50,6 +51,7 @@ class ProgramConfigurator : public QWidget {
QPushButton *mRemove;
QPushButton *mUpdate;
QPushButton *mDefault;
+ QCheckBox *mInternalViewer;
QLabel *mDefaultLabel;
QHash<QString, QVariant> mData;
QString mDefautProg;
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 2aa6cbe..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"
@@ -21,12 +22,15 @@
#include <X11/extensions/Xfixes.h>
-SmGlobals *SmGlobals::mInstance = 0;
+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(){
@@ -40,10 +44,10 @@ SmGlobals *SmGlobals::instance(){
db.setPassword(s.value("database/dbpass").toString());
db.setDatabaseName(s.value("database/dbname").toString());
if(!db.open()){
- QMessageBox::critical(0, tr("Error"), tr("Could not open database."));
+ QMessageBox::critical(nullptr, tr("Error"), tr("Could not open database."));
ConfigurationDialog configDlg;
configDlg.exec();
- QMessageBox::information(0, tr("Notice"), tr("I will exit now. Start me again!"));
+ QMessageBox::information(nullptr, tr("Notice"), tr("I will exit now. Start me again!"));
exit(EXIT_SUCCESS);
}
}
@@ -89,7 +93,7 @@ QAbstractItemModel *SmGlobals::model(const QString &which){
mModels.insert(which, model);
}
}
- return mModels.contains(which) ? mModels.value(which) : 0;
+ return mModels.contains(which) ? mModels.value(which) : nullptr;
}
PictureViewer2 *SmGlobals::pictureViewer() {
@@ -99,9 +103,17 @@ 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(0);
+ Display *dpy = XOpenDisplay(nullptr);
XFixesCursorImage *curImage = XFixesGetCursorImage(dpy);
mCursorSize = QSize(curImage->width, curImage->height);
XFree(curImage);
@@ -117,7 +129,7 @@ QIcon SmGlobals::iconFor(const QString &type){
return retval;
}
-SmGlobals::SmGlobals() : mPictureViewer(0), mArchiveController(0){
+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(0), mArchiveController(0){
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..b94790a
--- /dev/null
+++ b/videoviewer.cpp
@@ -0,0 +1,81 @@
+/*
+ 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 <QSettings>
+
+#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);
+ readSettings();
+}
+
+void VideoViewer::readSettings(){
+ QSettings s;
+ QRect winSize = s.value("vw/size").toRect();
+ setGeometry(winSize);
+ bool fullScreen = s.value("vw/fullscreen").toBool();
+ setFullScreen(fullScreen);
+}
+
+void VideoViewer::writeSettings(){
+ QSettings s;
+ s.setValue("vw/size", geometry());
+ s.setValue("vw/fullscreen", isFullScreen());
+}
+
+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){
+ int mediaCount = mPlayer->playlist()->mediaCount();
+ int nextIndex = mPlayer->playlist()->currentIndex() + 1;
+ if(nextIndex >= mediaCount){
+ nextIndex = 0;
+ }
+ mPlayer->playlist()->setCurrentIndex(nextIndex);
+ }else if(keyNum == Qt::Key_P){
+ int mediaCount = mPlayer->playlist()->mediaCount();
+ int prevIndex = mPlayer->playlist()->currentIndex() - 1;
+ if(prevIndex < 0){
+ prevIndex = mediaCount - 1;
+ }
+ mPlayer->playlist()->setCurrentIndex(prevIndex);
+ }else if(keyNum == Qt::Key_M){
+ mPlayer->setMuted(mPlayer->isMuted() ? false : true);
+ }
+}
+
+void VideoViewer::closeEvent(QCloseEvent *e){
+ mPlayer->stop();
+ writeSettings();
+ SmGlobals::instance()->removeGlobalWidget(this);
+ deleteLater();
+ e->accept();
+}
diff --git a/videoviewer.h b/videoviewer.h
new file mode 100644
index 0000000..2bbb8db
--- /dev/null
+++ b/videoviewer.h
@@ -0,0 +1,32 @@
+/*
+ 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; }
+
+ public slots:
+ void readSettings();
+ void writeSettings();
+
+ protected:
+ virtual void keyPressEvent(QKeyEvent *e);
+ virtual void closeEvent(QCloseEvent *e);
+
+ private:
+ QMediaPlayer *mPlayer;
+};
+
+#endif // VIDEOVIEWER_H