更新代码
This commit is contained in:
@@ -43,5 +43,5 @@ SOURCES += \
|
|||||||
$$PWD/quitipbox.cpp \
|
$$PWD/quitipbox.cpp \
|
||||||
$$PWD/quiwidget.cpp
|
$$PWD/quiwidget.cpp
|
||||||
|
|
||||||
RESOURCES += $$PWD/source/qm.qrc
|
RESOURCES += $$PWD/resource/qm.qrc
|
||||||
RESOURCES += $$PWD/source/ttf.qrc
|
RESOURCES += $$PWD/resource/ttf.qrc
|
||||||
|
|||||||
@@ -199,22 +199,20 @@ void VideoWidget::dropEvent(QDropEvent *event)
|
|||||||
{
|
{
|
||||||
//拖放完毕鼠标松开的时候执行
|
//拖放完毕鼠标松开的时候执行
|
||||||
//判断拖放进来的类型,取出文件,进行播放
|
//判断拖放进来的类型,取出文件,进行播放
|
||||||
|
QString url;
|
||||||
if (event->mimeData()->hasUrls()) {
|
if (event->mimeData()->hasUrls()) {
|
||||||
QString url = event->mimeData()->urls().first().toLocalFile();
|
url = event->mimeData()->urls().first().toLocalFile();
|
||||||
this->close();
|
|
||||||
this->setUrl(url);
|
|
||||||
this->open();
|
|
||||||
emit fileDrag(url);
|
|
||||||
} else if (event->mimeData()->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
} else if (event->mimeData()->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
||||||
QTreeWidget *treeWidget = (QTreeWidget *)event->source();
|
QTreeWidget *treeWidget = (QTreeWidget *)event->source();
|
||||||
if (treeWidget != 0) {
|
if (treeWidget != 0) {
|
||||||
QString url = treeWidget->currentItem()->data(0, Qt::UserRole).toString();
|
url = treeWidget->currentItem()->data(0, Qt::UserRole).toString();
|
||||||
this->close();
|
|
||||||
this->setUrl(url);
|
|
||||||
this->open();
|
|
||||||
emit fileDrag(url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!url.isEmpty()) {
|
||||||
|
emit fileDrag(url);
|
||||||
|
this->restart(url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoWidget::dragEnterEvent(QDragEnterEvent *event)
|
void VideoWidget::dragEnterEvent(QDragEnterEvent *event)
|
||||||
@@ -592,7 +590,7 @@ void VideoWidget::checkVideo()
|
|||||||
QDateTime lastTime = now;
|
QDateTime lastTime = now;
|
||||||
int sec = lastTime.secsTo(now);
|
int sec = lastTime.secsTo(now);
|
||||||
if (sec >= timeout) {
|
if (sec >= timeout) {
|
||||||
restart();
|
restart(this->getUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -922,21 +920,30 @@ void VideoWidget::open()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//thread->play();
|
||||||
|
//thread->start();
|
||||||
|
|
||||||
if (checkLive) {
|
if (checkLive) {
|
||||||
timerCheck->start();
|
timerCheck->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->setProperty("isPause", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoWidget::pause()
|
void VideoWidget::pause()
|
||||||
{
|
{
|
||||||
|
if (!this->property("isPause").toBool()) {
|
||||||
|
//thread->pause();
|
||||||
|
this->setProperty("isPause", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoWidget::next()
|
void VideoWidget::next()
|
||||||
{
|
{
|
||||||
|
if (this->property("isPause").toBool()) {
|
||||||
|
//thread->next();
|
||||||
|
this->setProperty("isPause", false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoWidget::close()
|
void VideoWidget::close()
|
||||||
@@ -945,13 +952,19 @@ void VideoWidget::close()
|
|||||||
timerCheck->stop();
|
timerCheck->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
QTimer::singleShot(1, this, SLOT(clear()));
|
this->clear();
|
||||||
|
//QTimer::singleShot(5, this, SLOT(clear()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoWidget::restart(int delayOpen)
|
void VideoWidget::restart(const QString &url, int delayOpen)
|
||||||
{
|
{
|
||||||
//qDebug() << TIMEMS << "restart video" << objectName();
|
//qDebug() << TIMEMS << "restart video" << objectName();
|
||||||
|
//关闭视频
|
||||||
close();
|
close();
|
||||||
|
//重新设置播放地址
|
||||||
|
setUrl(url);
|
||||||
|
|
||||||
|
//打开视频
|
||||||
if (delayOpen > 0) {
|
if (delayOpen > 0) {
|
||||||
QTimer::singleShot(delayOpen, this, SLOT(open()));
|
QTimer::singleShot(delayOpen, this, SLOT(open()));
|
||||||
} else {
|
} else {
|
||||||
@@ -969,4 +982,3 @@ void VideoWidget::snap(const QString &fileName)
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -360,17 +360,17 @@ public slots:
|
|||||||
|
|
||||||
//打开设备
|
//打开设备
|
||||||
void open();
|
void open();
|
||||||
//暂停
|
//暂停播放
|
||||||
void pause();
|
void pause();
|
||||||
//继续
|
//继续播放
|
||||||
void next();
|
void next();
|
||||||
//关闭设备
|
//关闭设备
|
||||||
void close();
|
void close();
|
||||||
//重新加载
|
//重新加载
|
||||||
void restart(int delayOpen = 500);
|
void restart(const QString &url, int delayOpen = 500);
|
||||||
//清空
|
//清空图片
|
||||||
void clear();
|
void clear();
|
||||||
//快照
|
//截图快照
|
||||||
void snap(const QString &fileName);
|
void snap(const QString &fileName);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user