/
cleps_vidplayer.cpp
124 lines (93 loc) · 4.23 KB
/
cleps_vidplayer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/******************************************************************************
* Cleps Video Player. Simply a media player, no more, no less. *
* Copyright (C) 2014 Eshton Robateau <eshtonrob@gmail.com> *
* *
* 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 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
#include "cleps_vidplayer.h"
#include <QVideoWidget>
Cleps_VidPlayer::Cleps_VidPlayer(QWidget *parent)
: QWidget(parent)
{
videoWidget = new QVideoWidget(this);
videoWidget->setContextMenuPolicy(Qt::CustomContextMenu);
videoWidget->setAspectRatioMode(Qt::IgnoreAspectRatio);
QBoxLayout *mreLayout = new QHBoxLayout;
mreLayout->setMargin(0);
mreLayout->setSpacing(0);
QBoxLayout *layout = new QVBoxLayout;
layout->addWidget(videoWidget);
layout->addLayout(mreLayout);
setLayout(layout);
QShortcut *fll = new QShortcut(QKeySequence(Qt::Key_F11), videoWidget);
fll->setContext(Qt::ApplicationShortcut);
QShortcut *fllve = new QShortcut(QKeySequence(Qt::Key_Escape), videoWidget);
fllve->setContext(Qt::ApplicationShortcut);
connect(fll,SIGNAL(activated()),this,SLOT(fullScreen()));
connect(fllve,SIGNAL(activated()),this,SLOT(exitFullScreen()));
connect(videoWidget, SIGNAL(customContextMenuRequested(QPoint)),this, SLOT(context(QPoint)));
}
void Cleps_VidPlayer::fullScreen(){
if(videoWidget->isFullScreen()){
videoWidget->setFullScreen(false);
}else {
videoWidget->setFullScreen(true);
}
}
void Cleps_VidPlayer::mouseDoubleClickEvent(QMouseEvent *event)
{
fullScreen();
event->accept();
}
void Cleps_VidPlayer::contextMenuEvent(QContextMenuEvent *event)
{
QMenu menu(this);
menu.addAction(tr("View Playlist"), this->parent(), SLOT(showPlaylist()));
menu.addAction(tr("Add Media"), this->parent(), SLOT(open()));
menu.addSeparator();
menu.addAction(tr("Toggle Fullscreen"),this, SLOT(fullScreen()));
menu.addSeparator();
menu.addAction(tr("Play/Pause"),this->parent(), SLOT(play()));
menu.addAction(tr("Previous"),this->parent(), SLOT(previousMedia()));
menu.addAction(tr("Next"),this->parent(), SLOT(nextMedia()));
menu.addAction(tr("Stop"),this->parent(), SLOT(stop()));
menu.addSeparator();
menu.addAction(tr("Quit"),this->parent(), SLOT(quit()));
menu.exec(event->globalPos());
}
Cleps_VidPlayer::~Cleps_VidPlayer()
{
}
void Cleps_VidPlayer::context(QPoint pos)
{
QMenu menu(this);
menu.addAction(tr("View Playlist"), this->parent(), SLOT(showPlaylist()));
menu.addAction(tr("Add Media"), this->parent(), SLOT(open()));
menu.addSeparator();
menu.addAction(tr("Toggle Fullscreen"),this, SLOT(fullScreen()));
menu.addSeparator();
menu.addAction(tr("Play/Pause"),this->parent(), SLOT(play()));
menu.addAction(tr("Previous"),this->parent(), SLOT(previousMedia()));
menu.addAction(tr("Next"),this->parent(), SLOT(nextMedia()));
menu.addAction(tr("Stop"),this->parent(), SLOT(stop()));
menu.addSeparator();
menu.addAction(tr("Quit"),this->parent(), SLOT(quit()));
menu.exec(pos);
}
void Cleps_VidPlayer::exitFullScreen()
{
if(videoWidget->isFullScreen()){
videoWidget->setFullScreen(false);
}
}