2017-09-05 18:07:05 +08:00
|
|
|
|
#include "qqtwindow.h"
|
|
|
|
|
#include "ui_qqtwindow.h"
|
2018-04-22 16:17:15 +08:00
|
|
|
|
#include "qqtobjectmanager.h"
|
2017-10-22 12:21:19 +08:00
|
|
|
|
#include "qqt-qt.h"
|
2017-09-05 18:07:05 +08:00
|
|
|
|
#include "qqtcore.h"
|
|
|
|
|
#include "qqtgui.h"
|
|
|
|
|
#include "animationmanager.h"
|
|
|
|
|
|
|
|
|
|
#include <VLCQtCore/Common.h>
|
|
|
|
|
#include <VLCQtCore/Instance.h>
|
|
|
|
|
#include <VLCQtCore/Media.h>
|
|
|
|
|
#include <VLCQtCore/MediaPlayer.h>
|
|
|
|
|
#include <VLCQtWidgets/WidgetVideo.h>
|
|
|
|
|
|
|
|
|
|
#include "qqtwidgets.h"
|
|
|
|
|
#include "qqttreewidget.h"
|
|
|
|
|
#include "qqtsqltreemodel.h"
|
|
|
|
|
|
2018-05-29 09:15:15 +08:00
|
|
|
|
QQTWindow::QQTWindow ( QWidget* parent ) :
|
|
|
|
|
QStackedWidget ( parent ),
|
|
|
|
|
ui ( new Ui::QQTWindow )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
{
|
2018-05-29 09:15:15 +08:00
|
|
|
|
ui->setupUi ( this );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
|
2018-05-29 09:15:15 +08:00
|
|
|
|
QQtObjectManager::registerObject ( this );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
|
2017-10-20 19:28:52 +08:00
|
|
|
|
#ifdef __EMBEDDED_LINUX__
|
2017-09-05 18:07:05 +08:00
|
|
|
|
/*
|
|
|
|
|
* 这里只要frameless足够
|
|
|
|
|
*/
|
2018-05-29 09:15:15 +08:00
|
|
|
|
setWindowFlags ( Qt::FramelessWindowHint );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
/*
|
|
|
|
|
* 控件背景透明,显示设置的图片背景或者下一级背景。
|
|
|
|
|
*/
|
2018-05-29 09:15:15 +08:00
|
|
|
|
setAttribute ( Qt::WA_TranslucentBackground, true );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
#endif
|
2018-05-29 09:15:15 +08:00
|
|
|
|
setFixedSize ( 1024, 600 );
|
|
|
|
|
moveCenter ( this );
|
|
|
|
|
setAcceptDrops ( true );
|
|
|
|
|
|
|
|
|
|
QQtSqlTreeModel* model = new QQtSqlTreeModel ( this );
|
|
|
|
|
ui->treeView->setModel ( model );
|
|
|
|
|
|
|
|
|
|
( ( QQtSqlTreeModel* ) ui->treeView->model() )
|
|
|
|
|
->setAbsoluteFilePath ( "LiveStream.db" );
|
|
|
|
|
( ( QQtSqlTreeModel* ) ui->treeView->model() )
|
|
|
|
|
->query ( "" );
|
|
|
|
|
for ( int i = 1; i < 11; i++ )
|
|
|
|
|
ui->treeView->setColumnHidden ( i, true );
|
|
|
|
|
( ( QQtSqlTreeModel* ) ui->treeView->model() )
|
|
|
|
|
->setHeaderData ( 0, Qt::Horizontal, tr ( "pindao liebiao" ) );
|
|
|
|
|
connect ( ui->treeView, SIGNAL ( doubleClicked ( const QModelIndex& ) ),
|
|
|
|
|
this, SLOT ( doubleClicked ( const QModelIndex& ) ) );
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
QPixmap pixmap ( "./skin/default/splash.png" );
|
|
|
|
|
QSplashScreen splash ( pixmap );
|
|
|
|
|
splash.showMessage ( tr ( "Loading..." ), Qt::AlignBottom );
|
|
|
|
|
splash.setFixedSize ( 600, 400 );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
splash.show();
|
2018-05-29 09:15:15 +08:00
|
|
|
|
QQtSleep ( 400 );
|
|
|
|
|
splash.finish ( this );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
#elif 0
|
|
|
|
|
/**
|
|
|
|
|
* set movie in label0
|
|
|
|
|
* label0 will dispear in this function
|
|
|
|
|
*/
|
2018-05-29 09:15:15 +08:00
|
|
|
|
QMovie mov ( "./skin/default/splash.gif" );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
QLabel label;
|
2018-05-29 09:15:15 +08:00
|
|
|
|
label.setMovie ( &mov );
|
|
|
|
|
label.setFixedSize ( 400, 300 );
|
|
|
|
|
moveCenter ( &label );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
mov.start();
|
|
|
|
|
label.show();
|
2018-05-29 09:15:15 +08:00
|
|
|
|
QQtSleep ( 3000 );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
//QCoreApplication::setAttribute(Qt::AA_X11InitThreads);
|
|
|
|
|
//VlcCommon::setPluginPath(QCoreApplication::applicationDirPath() + "/plugins");
|
2018-05-29 09:15:15 +08:00
|
|
|
|
_instance = new VlcInstance ( VlcCommon::args(), this );
|
|
|
|
|
_player = new VlcMediaPlayer ( _instance );
|
|
|
|
|
_player->setVideoWidget ( ui->widget );
|
|
|
|
|
ui->widget->setMediaPlayer ( _player );
|
|
|
|
|
ui->widget->setWindowFlags ( ui->widget->windowFlags() | Qt::WindowTransparentForInput );
|
|
|
|
|
ui->horizontalSlider->setMediaPlayer ( _player );
|
|
|
|
|
ui->horizontalSlider->setVolume ( 100 );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
_media = NULL;
|
|
|
|
|
|
|
|
|
|
//VlcMediaPlayer *_player2;
|
|
|
|
|
//_player2 = new VlcMediaPlayer(_instance);
|
|
|
|
|
//_player2->setVideoWidget(ui->widget_2);
|
|
|
|
|
//QString url2 = "rtmp://live.hkstv.hk.lxdns.com/live/hks";
|
|
|
|
|
//VlcMedia *_media2;
|
|
|
|
|
//_media2 = new VlcMedia(url2, _instance);
|
|
|
|
|
//ui->widget_2->setMediaPlayer(_player2);
|
|
|
|
|
//_player2->open(_media2);
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* decorate all windows
|
|
|
|
|
* nobody use animation to mainwindow
|
|
|
|
|
* so this animation use to child window
|
|
|
|
|
*/
|
2018-05-29 09:15:15 +08:00
|
|
|
|
AnimationManager::Instance ( this );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QQTWindow::~QQTWindow()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-29 09:15:15 +08:00
|
|
|
|
void QQTWindow::doubleClicked ( const QModelIndex& index )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
{
|
2018-05-29 09:15:15 +08:00
|
|
|
|
if ( !index.parent().isValid() )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
return;
|
|
|
|
|
|
2018-05-29 09:15:15 +08:00
|
|
|
|
QString uri = index.model()->index ( index.row(), 1, index.parent() ).data().toString();
|
2017-09-05 18:07:05 +08:00
|
|
|
|
|
|
|
|
|
pline() << uri;
|
|
|
|
|
|
2018-05-29 09:15:15 +08:00
|
|
|
|
if ( _player->hasVout() )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
_player->stop();
|
2018-05-29 09:15:15 +08:00
|
|
|
|
if ( _media )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
delete _media;
|
|
|
|
|
|
|
|
|
|
//QString url = "http://ivi.bupt.edu.cn/hls/cctv1.m3u8";
|
2018-05-29 09:15:15 +08:00
|
|
|
|
_media = new VlcMedia ( uri, _instance );
|
|
|
|
|
_player->open ( _media );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief QQTWindow::dragEnterEvent
|
|
|
|
|
* 当用户拖动文件到窗口部件上时候,就会触发dragEnterEvent事件
|
|
|
|
|
*/
|
2018-05-29 09:15:15 +08:00
|
|
|
|
void QQTWindow::dragEnterEvent ( QDragEnterEvent* event )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
{
|
|
|
|
|
//如果为文件,则支持拖放
|
2018-05-29 09:15:15 +08:00
|
|
|
|
if ( event->mimeData()->hasFormat ( "text/uri-list" ) )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
event->acceptProposedAction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief QQTWindow::dropEvent
|
|
|
|
|
* 当用户放下这个文件后,就会触发dropEvent事件
|
|
|
|
|
*/
|
2018-05-29 09:15:15 +08:00
|
|
|
|
void QQTWindow::dropEvent ( QDropEvent* event )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* 注意:这里如果有多文件存在,意思是用户一下子拖动了多个文件,而不是拖动一个目录
|
|
|
|
|
* 如果想读取整个目录,自己编写函数实现读取整个目录文件名
|
|
|
|
|
*/
|
|
|
|
|
QList<QUrl> urls = event->mimeData()->urls();
|
2018-05-29 09:15:15 +08:00
|
|
|
|
if ( urls.isEmpty() )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 往文本框中追加文件名
|
|
|
|
|
*/
|
2018-05-29 09:15:15 +08:00
|
|
|
|
foreach ( QUrl url, urls )
|
|
|
|
|
{
|
2017-09-05 18:07:05 +08:00
|
|
|
|
QString file_name = url.toLocalFile();
|
|
|
|
|
pline() << file_name;
|
2018-05-29 09:15:15 +08:00
|
|
|
|
if ( _player->hasVout() )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
_player->stop();
|
2018-05-29 09:15:15 +08:00
|
|
|
|
if ( _media )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
delete _media;
|
2018-05-29 09:15:15 +08:00
|
|
|
|
_media = new VlcMedia ( file_name, true, _instance );
|
|
|
|
|
_player->open ( _media );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|