Add ScreenSaver.
This commit is contained in:
@@ -37,7 +37,7 @@ source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_cxx})
|
|||||||
source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_cc})
|
source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_cc})
|
||||||
source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_c})
|
source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_c})
|
||||||
|
|
||||||
find_package(Qt5 COMPONENTS Core Widgets Gui OpenGL Sql VirtualKeyboard Network REQUIRED)
|
find_package(Qt5 COMPONENTS Core Widgets Gui OpenGL Sql VirtualKeyboard Network REQUIRED Multimedia MultimediaWidgets)
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
file(GLOB_RECURSE project_uis ./src/*.ui)
|
file(GLOB_RECURSE project_uis ./src/*.ui)
|
||||||
@@ -78,11 +78,11 @@ endif()
|
|||||||
|
|
||||||
if(UNIX AND USE_SHIMLIB)
|
if(UNIX AND USE_SHIMLIB)
|
||||||
link_directories(/usr/local/lib64)
|
link_directories(/usr/local/lib64)
|
||||||
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::OpenGL Qt5::Sql Qt5::VirtualKeyboard Qt5::Network pthread usct_shim dmapi log4c cunit ctomat hdf5 matio m)
|
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::OpenGL Qt5::Sql Qt5::VirtualKeyboard Qt5::Network Qt5::Multimedia Qt5::MultimediaWidgets pthread usct_shim dmapi log4c cunit ctomat hdf5 matio m)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::OpenGL Qt5::Sql Qt5::VirtualKeyboard Qt5::Network pthread)
|
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::OpenGL Qt5::Sql Qt5::VirtualKeyboard Qt5::Network Qt5::Multimedia Qt5::MultimediaWidgets pthread)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::OpenGL Qt5::Sql Qt5::VirtualKeyboard Qt5::Network)
|
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::OpenGL Qt5::Sql Qt5::VirtualKeyboard Qt5::Network Qt5::Multimedia Qt5::MultimediaWidgets)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
@@ -125,6 +125,10 @@ if(UNIX)
|
|||||||
install(CODE "file(RENAME ${CMAKE_INSTALL_BINDIR}/libQt5VirtualKeyboard.so.5.12.0 ${CMAKE_INSTALL_BINDIR}/libQt5VirtualKeyboard.so.5)")
|
install(CODE "file(RENAME ${CMAKE_INSTALL_BINDIR}/libQt5VirtualKeyboard.so.5.12.0 ${CMAKE_INSTALL_BINDIR}/libQt5VirtualKeyboard.so.5)")
|
||||||
install(CODE "file(COPY ${qt_LIB_DIR}/libQt5OpenGL.so.5.12.0 DESTINATION ${CMAKE_INSTALL_BINDIR})")
|
install(CODE "file(COPY ${qt_LIB_DIR}/libQt5OpenGL.so.5.12.0 DESTINATION ${CMAKE_INSTALL_BINDIR})")
|
||||||
install(CODE "file(RENAME ${CMAKE_INSTALL_BINDIR}/libQt5OpenGL.so.5.12.0 ${CMAKE_INSTALL_BINDIR}/libQt5OpenGL.so.5)")
|
install(CODE "file(RENAME ${CMAKE_INSTALL_BINDIR}/libQt5OpenGL.so.5.12.0 ${CMAKE_INSTALL_BINDIR}/libQt5OpenGL.so.5)")
|
||||||
|
install(CODE "file(COPY ${qt_LIB_DIR}/libQt5Multimedia.so.5.12.0 DESTINATION ${CMAKE_INSTALL_BINDIR})")
|
||||||
|
install(CODE "file(RENAME ${CMAKE_INSTALL_BINDIR}/libQt5Multimedia.so.5.12.0 ${CMAKE_INSTALL_BINDIR}/libQt5Multimedia.so.5)")
|
||||||
|
install(CODE "file(COPY ${qt_LIB_DIR}/libQt5MultimediaWidgets.so.5.12.0 DESTINATION ${CMAKE_INSTALL_BINDIR})")
|
||||||
|
install(CODE "file(RENAME ${CMAKE_INSTALL_BINDIR}/libQt5MultimediaWidgets.so.5.12.0 ${CMAKE_INSTALL_BINDIR}/libQt5MultimediaWidgets.so.5)")
|
||||||
install(CODE "file(COPY ${qt_LIB_DIR}/libQt5Widgets.so.5.12.0 DESTINATION ${CMAKE_INSTALL_BINDIR})")
|
install(CODE "file(COPY ${qt_LIB_DIR}/libQt5Widgets.so.5.12.0 DESTINATION ${CMAKE_INSTALL_BINDIR})")
|
||||||
install(CODE "file(RENAME ${CMAKE_INSTALL_BINDIR}/libQt5Widgets.so.5.12.0 ${CMAKE_INSTALL_BINDIR}/libQt5Widgets.so.5)")
|
install(CODE "file(RENAME ${CMAKE_INSTALL_BINDIR}/libQt5Widgets.so.5.12.0 ${CMAKE_INSTALL_BINDIR}/libQt5Widgets.so.5)")
|
||||||
install(CODE "file(COPY ${qt_LIB_DIR}/libQt5Qml.so.5.12.0 DESTINATION ${CMAKE_INSTALL_BINDIR})")
|
install(CODE "file(COPY ${qt_LIB_DIR}/libQt5Qml.so.5.12.0 DESTINATION ${CMAKE_INSTALL_BINDIR})")
|
||||||
|
|||||||
@@ -70,5 +70,8 @@
|
|||||||
"worklistfilter": {
|
"worklistfilter": {
|
||||||
"default": "Today",
|
"default": "Today",
|
||||||
"lists": "Today;Recent3Days;ThisWeek;ThisMonth"
|
"lists": "Today;Recent3Days;ThisWeek;ThisMonth"
|
||||||
|
},
|
||||||
|
"screensaver": {
|
||||||
|
"content": "screensaver.PNG;screensaver.mp4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,5 +88,8 @@
|
|||||||
"worklistfilter": {
|
"worklistfilter": {
|
||||||
"default": "Recent3Days",
|
"default": "Recent3Days",
|
||||||
"lists": "Today;Recent3Days;ThisWeek;ThisMonth"
|
"lists": "Today;Recent3Days;ThisWeek;ThisMonth"
|
||||||
|
},
|
||||||
|
"screensaver": {
|
||||||
|
"content": "screensaver.PNG;screensaver.mp4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,8 +23,10 @@
|
|||||||
#include "network/GetIPDialog.h"
|
#include "network/GetIPDialog.h"
|
||||||
#include "network/GetRouteDialog.h"
|
#include "network/GetRouteDialog.h"
|
||||||
|
|
||||||
#include "appvals/AppGlobalValues.h"
|
|
||||||
#include "windows/LoginDialog.h"
|
#include "windows/LoginDialog.h"
|
||||||
|
#include "screensaver/ScreenSaverWindow.h"
|
||||||
|
|
||||||
|
#include "appvals/AppGlobalValues.h"
|
||||||
#include "json/jsonobject.h"
|
#include "json/jsonobject.h"
|
||||||
#include "shimlib/ShimLib.h"
|
#include "shimlib/ShimLib.h"
|
||||||
|
|
||||||
@@ -36,6 +38,7 @@ namespace
|
|||||||
DialogManager::DialogManager()
|
DialogManager::DialogManager()
|
||||||
: QObject()
|
: QObject()
|
||||||
, mFunctionDialog(nullptr)
|
, mFunctionDialog(nullptr)
|
||||||
|
, mScreenSaverWindow(nullptr)
|
||||||
, mOperationMessageDialog(nullptr)
|
, mOperationMessageDialog(nullptr)
|
||||||
, mSyncDialog(nullptr)
|
, mSyncDialog(nullptr)
|
||||||
, mTopWidget(nullptr)
|
, mTopWidget(nullptr)
|
||||||
@@ -52,6 +55,7 @@ void DialogManager::init(QWidget* aParent) {
|
|||||||
connect(EventCenter::Default(), &EventCenter::InvokeOperationEnd,this,&DialogManager::invokeOperationEnd);
|
connect(EventCenter::Default(), &EventCenter::InvokeOperationEnd,this,&DialogManager::invokeOperationEnd);
|
||||||
MultyMessageDialogManager::getInstance()->setDialogParent(aParent);
|
MultyMessageDialogManager::getInstance()->setDialogParent(aParent);
|
||||||
mTopWidget = aParent;
|
mTopWidget = aParent;
|
||||||
|
mScreenSaverWindow = new ScreenSaverWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
//得考虑多线程的问题
|
//得考虑多线程的问题
|
||||||
@@ -84,12 +88,25 @@ void DialogManager::requestLogin(QWidget* aParent)
|
|||||||
if (!mFunctionDialog){
|
if (!mFunctionDialog){
|
||||||
mFunctionDialog = new LoginDialog(aParent);
|
mFunctionDialog = new LoginDialog(aParent);
|
||||||
}
|
}
|
||||||
|
setTopWidget(mFunctionDialog);
|
||||||
mFunctionDialog->setWindowModality(Qt::WindowModal);
|
mFunctionDialog->setWindowModality(Qt::WindowModal);
|
||||||
mFunctionDialog->exec();
|
mFunctionDialog->exec();
|
||||||
while (QDialog::Accepted != mFunctionDialog->result())
|
while (QDialog::Accepted != mFunctionDialog->result())
|
||||||
{
|
{
|
||||||
mFunctionDialog->exec();
|
mFunctionDialog->exec();
|
||||||
}
|
}
|
||||||
|
releaseTopWidget(mFunctionDialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogManager::requestScreenSaverPlay()
|
||||||
|
{
|
||||||
|
setFocusToTopDialog();
|
||||||
|
mScreenSaverWindow->play();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogManager::requestScreenSaverStop(bool aIsStopLocker)
|
||||||
|
{
|
||||||
|
mScreenSaverWindow->stop(aIsStopLocker);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DialogManager::requestAddAccount(QSqlTableModel* model) {
|
int DialogManager::requestAddAccount(QSqlTableModel* model) {
|
||||||
@@ -308,10 +325,12 @@ void DialogManager::raiseDeviceError(QObject *parent, QObject *msg) {
|
|||||||
dialog->showExitButton();
|
dialog->showExitButton();
|
||||||
setTopWidget(dialog);
|
setTopWidget(dialog);
|
||||||
dialog->setWindowModality(Qt::WindowModal);
|
dialog->setWindowModality(Qt::WindowModal);
|
||||||
|
mScreenSaverWindow->stop(true);
|
||||||
dialog->showFullScreen ();
|
dialog->showFullScreen ();
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
releaseTopWidget(dialog);
|
releaseTopWidget(dialog);
|
||||||
dialog->deleteLater();
|
dialog->deleteLater();
|
||||||
|
mScreenSaverWindow->startLocker();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 扫描过程 dialog 只能为最底层,并且会被error dialog 清除!
|
// 扫描过程 dialog 只能为最底层,并且会被error dialog 清除!
|
||||||
@@ -408,6 +427,7 @@ void DialogManager::clearMessageDialog() {
|
|||||||
|
|
||||||
DialogManager::~DialogManager() {
|
DialogManager::~DialogManager() {
|
||||||
clearMessageDialog();
|
clearMessageDialog();
|
||||||
|
delete mScreenSaverWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogManager::raiseMultyMessageDialog(const QString& aMessage, MessageLevel aMessageLevel)
|
void DialogManager::raiseMultyMessageDialog(const QString& aMessage, MessageLevel aMessageLevel)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class GUIMessageDialog;
|
|||||||
class QSqlTableModel;
|
class QSqlTableModel;
|
||||||
class PatientInformation;
|
class PatientInformation;
|
||||||
class LoginDialog;
|
class LoginDialog;
|
||||||
|
class ScreenSaverWindow;
|
||||||
|
|
||||||
enum MessageLevel:unsigned int;
|
enum MessageLevel:unsigned int;
|
||||||
|
|
||||||
@@ -43,6 +44,8 @@ public:
|
|||||||
|
|
||||||
void init(QWidget* aParent);
|
void init(QWidget* aParent);
|
||||||
void requestLogin(QWidget* aParent);
|
void requestLogin(QWidget* aParent);
|
||||||
|
void requestScreenSaverPlay();
|
||||||
|
void requestScreenSaverStop(bool aIsStopLocker = false);
|
||||||
int requestAddAccount(QSqlTableModel* model);
|
int requestAddAccount(QSqlTableModel* model);
|
||||||
int requestEditSelfAccount();
|
int requestEditSelfAccount();
|
||||||
int requestEditAdminAccount(const QMap<QString, QVariant>& values);
|
int requestEditAdminAccount(const QMap<QString, QVariant>& values);
|
||||||
@@ -78,6 +81,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
LoginDialog* mFunctionDialog;
|
LoginDialog* mFunctionDialog;
|
||||||
|
ScreenSaverWindow* mScreenSaverWindow;
|
||||||
QPointer<GUIMessageDialog> mOperationMessageDialog;
|
QPointer<GUIMessageDialog> mOperationMessageDialog;
|
||||||
QPointer<GUIMessageDialog> mSyncDialog;
|
QPointer<GUIMessageDialog> mSyncDialog;
|
||||||
QWidget* mTopWidget;
|
QWidget* mTopWidget;
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ ADD_EVENT_VALUE(GlobalBannerMessage)\
|
|||||||
ADD_EVENT_VALUE(ReloadLanguage)\
|
ADD_EVENT_VALUE(ReloadLanguage)\
|
||||||
ADD_EVENT_VALUE(WarnStateFlagChange)\
|
ADD_EVENT_VALUE(WarnStateFlagChange)\
|
||||||
ADD_EVENT_VALUE(GUIErrorRaise)\
|
ADD_EVENT_VALUE(GUIErrorRaise)\
|
||||||
ADD_EVENT_VALUE(DeviceInfoRaise)
|
ADD_EVENT_VALUE(DeviceInfoRaise)\
|
||||||
|
ADD_EVENT_VALUE(RequestScreenSaver)
|
||||||
|
|
||||||
enum GUIEvents {
|
enum GUIEvents {
|
||||||
#define ADD_EVENT_VALUE(val) val,
|
#define ADD_EVENT_VALUE(val) val,
|
||||||
|
|||||||
@@ -16,6 +16,11 @@
|
|||||||
#include "components/ULineEdit.h"
|
#include "components/ULineEdit.h"
|
||||||
#include "components/ListBox.h"
|
#include "components/ListBox.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const int MINIMUM_LOCKTIME = 30;
|
||||||
|
}
|
||||||
|
|
||||||
GeneralForm::GeneralForm(QWidget* aParent)
|
GeneralForm::GeneralForm(QWidget* aParent)
|
||||||
: QWidget(aParent)
|
: QWidget(aParent)
|
||||||
, mLayout(new QVBoxLayout(this))
|
, mLayout(new QVBoxLayout(this))
|
||||||
@@ -86,8 +91,12 @@ GeneralForm::GeneralForm(QWidget* aParent)
|
|||||||
connect(lockTime, &QLineEdit::textChanged, [=](const QString& str)
|
connect(lockTime, &QLineEdit::textChanged, [=](const QString& str)
|
||||||
{
|
{
|
||||||
//take effect
|
//take effect
|
||||||
JsonObject::Instance()->setLockScreenTimeout(str);
|
int time = str.toInt();
|
||||||
Locker::getInstance()->setTimer(JsonObject::Instance()->lockerCount());
|
if (MINIMUM_LOCKTIME < time)
|
||||||
|
{
|
||||||
|
JsonObject::Instance()->setLockScreenTimeout(str);
|
||||||
|
Locker::getInstance()->setTimer(str.toInt() * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -539,4 +539,7 @@ void JsonObject::setCompleteNotify(bool val) {
|
|||||||
setBool("general","CompleteNotify", val, true);
|
setBool("general","CompleteNotify", val, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList JsonObject::getScreenSaverInfomation()
|
||||||
|
{
|
||||||
|
return QString(getJsonString("screensaver", "content")).split(";");
|
||||||
|
}
|
||||||
|
|||||||
@@ -108,6 +108,8 @@ public:
|
|||||||
QList<QStringList> getIpRouteList();
|
QList<QStringList> getIpRouteList();
|
||||||
void setIpRouteList(const QList<QStringList>& list);
|
void setIpRouteList(const QList<QStringList>& list);
|
||||||
|
|
||||||
|
QStringList getScreenSaverInfomation();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setJsonString(const char* catergory, const char* stringName, const char* stringValue, bool save = true);
|
void setJsonString(const char* catergory, const char* stringName, const char* stringValue, bool save = true);
|
||||||
|
|||||||
@@ -73,9 +73,11 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
SQLHelper::Open();
|
SQLHelper::Open();
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
DialogManager::Default()->init(&w);
|
||||||
UserOperationLog::Default()->init();
|
UserOperationLog::Default()->init();
|
||||||
|
|
||||||
//暂时为了调试关闭锁屏
|
//暂时为了调试关闭锁屏
|
||||||
|
//Locker::getInstance()->setIsEnable(true);
|
||||||
//Locker::getInstance()->start();
|
//Locker::getInstance()->start();
|
||||||
//QObject::connect(TouchScreenSignalSender::getInstance(), SIGNAL(touchScreen()), Locker::getInstance(), SLOT(refreshTimer()));
|
//QObject::connect(TouchScreenSignalSender::getInstance(), SIGNAL(touchScreen()), Locker::getInstance(), SLOT(refreshTimer()));
|
||||||
QList<Qt::GestureType> gestures;
|
QList<Qt::GestureType> gestures;
|
||||||
@@ -107,7 +109,6 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
w.requestLogin();
|
w.requestLogin();
|
||||||
|
|
||||||
DialogManager::Default()->init(&w);
|
|
||||||
DeviceManager::Default()->initDevice();
|
DeviceManager::Default()->initDevice();
|
||||||
|
|
||||||
ret = a.exec();
|
ret = a.exec();
|
||||||
@@ -118,7 +119,7 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
w.showFullScreen();
|
w.showFullScreen();
|
||||||
w.requestLogin();
|
w.requestLogin();
|
||||||
DialogManager::Default()->init(&w);
|
|
||||||
DeviceManager::Default()->initDevice();
|
DeviceManager::Default()->initDevice();
|
||||||
ret = a.exec();
|
ret = a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
146
src/screensaver/ScreenSaverWindow.cpp
Normal file
146
src/screensaver/ScreenSaverWindow.cpp
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
#include "ScreenSaverWindow.h"
|
||||||
|
|
||||||
|
#include <QPropertyAnimation>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
#include <QMediaPlaylist>
|
||||||
|
#include <QVideoWidget>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "json/jsonobject.h"
|
||||||
|
#include "utilities/Locker.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const QString SCREENSAVER_PATH = "./screensaver";
|
||||||
|
const QStringList VEDIOSUFFIX_FILTER = QStringList() << "*.mp4" << "*.avi";
|
||||||
|
const QStringList PHOTOSUFFIX_FILTER = QStringList() << "*.PNG" << "*.JPG";
|
||||||
|
const int PHOTOPLAYED_TIME = 5000;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScreenSaverWindow::ScreenSaverWindow(QWidget *aParent)
|
||||||
|
: QWidget(aParent)
|
||||||
|
, mMediaPlayer(new QMediaPlayer(this))
|
||||||
|
, mVideoWidget(new QVideoWidget(this))
|
||||||
|
, mMultiMediaList()
|
||||||
|
, mPhotoWidget(new QLabel(this))
|
||||||
|
, mPhotoTimer(new QTimer(this))
|
||||||
|
, mCurrentPlayIndex(0)
|
||||||
|
, mIsPlaying(false)
|
||||||
|
{
|
||||||
|
setGeometry(QApplication::desktop()->screenGeometry());
|
||||||
|
//this code must be first
|
||||||
|
mMediaPlayer->setVideoOutput(mVideoWidget);
|
||||||
|
|
||||||
|
initializeMultimediaList();
|
||||||
|
setWindowFlags( Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool | Qt::BypassWindowManagerHint);
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||||
|
layout->addWidget(mVideoWidget);
|
||||||
|
layout->addWidget(mPhotoWidget);
|
||||||
|
mPhotoWidget->setScaledContents(true);
|
||||||
|
mPhotoWidget->hide();
|
||||||
|
mVideoWidget->hide();
|
||||||
|
mPhotoTimer->setSingleShot(true);
|
||||||
|
connect(mPhotoTimer, &QTimer::timeout, this, &ScreenSaverWindow::playMultimedia);
|
||||||
|
connect(mMediaPlayer, &QMediaPlayer::mediaStatusChanged, this, &ScreenSaverWindow::handleVideoStatusChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSaverWindow::initializeMultimediaList()
|
||||||
|
{
|
||||||
|
QDir screenSaverDir(SCREENSAVER_PATH);
|
||||||
|
QStringList videoFileList = screenSaverDir.entryList(VEDIOSUFFIX_FILTER);
|
||||||
|
QStringList photoFileList = screenSaverDir.entryList(PHOTOSUFFIX_FILTER);
|
||||||
|
|
||||||
|
foreach(QString multimediaInfo, JsonObject::Instance()->getScreenSaverInfomation())
|
||||||
|
{
|
||||||
|
if (videoFileList.contains(multimediaInfo))
|
||||||
|
{
|
||||||
|
mMultiMediaList << MultiMediaData(screenSaverDir.absoluteFilePath(multimediaInfo),MultiMediaType::Video);
|
||||||
|
}
|
||||||
|
else if (photoFileList.contains(multimediaInfo))
|
||||||
|
{
|
||||||
|
mMultiMediaList << MultiMediaData(screenSaverDir.absoluteFilePath(multimediaInfo),MultiMediaType::Photo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSaverWindow::mousePressEvent(QMouseEvent* aEvent)
|
||||||
|
{
|
||||||
|
stop();
|
||||||
|
QWidget::mousePressEvent(aEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSaverWindow::play()
|
||||||
|
{
|
||||||
|
if (mIsPlaying || mMultiMediaList.count() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mIsPlaying = true;
|
||||||
|
show();
|
||||||
|
playMultimedia();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSaverWindow::playMultimedia()
|
||||||
|
{
|
||||||
|
if (mMultiMediaList.count() <= mCurrentPlayIndex)
|
||||||
|
{
|
||||||
|
mCurrentPlayIndex = 0;
|
||||||
|
}
|
||||||
|
MultiMediaData data = mMultiMediaList.at(mCurrentPlayIndex);
|
||||||
|
if (MultiMediaType::Video == data.MediaType)
|
||||||
|
{
|
||||||
|
mPhotoWidget->hide();
|
||||||
|
mVideoWidget->show();
|
||||||
|
mMediaPlayer->setMedia(QUrl::fromLocalFile(data.MediaPath));
|
||||||
|
mMediaPlayer->play();
|
||||||
|
}
|
||||||
|
else if ( MultiMediaType::Photo == data.MediaType)
|
||||||
|
{
|
||||||
|
mVideoWidget->hide();
|
||||||
|
mPhotoWidget->show();
|
||||||
|
mPhotoWidget->setPixmap(data.MediaPath);
|
||||||
|
mPhotoTimer->start(PHOTOPLAYED_TIME);
|
||||||
|
}
|
||||||
|
mCurrentPlayIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSaverWindow::stop(bool aIsStopLocker)
|
||||||
|
{
|
||||||
|
if (aIsStopLocker)
|
||||||
|
{
|
||||||
|
Locker::getInstance()->stop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Locker::getInstance()->start();
|
||||||
|
}
|
||||||
|
if (!mIsPlaying)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mIsPlaying = false;
|
||||||
|
mPhotoTimer->stop();
|
||||||
|
mPhotoWidget->hide();
|
||||||
|
mVideoWidget->hide();
|
||||||
|
mCurrentPlayIndex = 0;
|
||||||
|
hide();
|
||||||
|
mMediaPlayer->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSaverWindow::handleVideoStatusChanged(QMediaPlayer::MediaStatus aStatus)
|
||||||
|
{
|
||||||
|
if (QMediaPlayer::EndOfMedia == aStatus)
|
||||||
|
{
|
||||||
|
playMultimedia();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSaverWindow::startLocker()
|
||||||
|
{
|
||||||
|
Locker::getInstance()->start();
|
||||||
|
}
|
||||||
54
src/screensaver/ScreenSaverWindow.h
Normal file
54
src/screensaver/ScreenSaverWindow.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#ifndef SCREENSAVERWINDOW_H
|
||||||
|
#define SCREENSAVERWINDOW_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QMediaPlayer>
|
||||||
|
|
||||||
|
class QMediaPlayer;
|
||||||
|
class QVideoWidget;
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
|
class ScreenSaverWindow : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
enum MultiMediaType
|
||||||
|
{
|
||||||
|
Video,Photo
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MultiMediaData
|
||||||
|
{
|
||||||
|
MultiMediaData(const QString& aMediaPath, MultiMediaType aMediaType)
|
||||||
|
{
|
||||||
|
MediaPath = aMediaPath;
|
||||||
|
MediaType = aMediaType;
|
||||||
|
};
|
||||||
|
QString MediaPath;
|
||||||
|
MultiMediaType MediaType;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ScreenSaverWindow(QWidget *aParent = nullptr);
|
||||||
|
void play();
|
||||||
|
void stop(bool aIsStopLocker = false);
|
||||||
|
void startLocker();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent* aEvent);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initializeMultimediaList();
|
||||||
|
void handleVideoStatusChanged(QMediaPlayer::MediaStatus aStatus);
|
||||||
|
void playMultimedia();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMediaPlayer* mMediaPlayer;
|
||||||
|
QVideoWidget* mVideoWidget;
|
||||||
|
QList<MultiMediaData> mMultiMediaList;
|
||||||
|
QLabel* mPhotoWidget;
|
||||||
|
QTimer* mPhotoTimer;
|
||||||
|
int mCurrentPlayIndex;
|
||||||
|
bool mIsPlaying;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SCREENSAVERWINDOW_H
|
||||||
@@ -15,6 +15,7 @@ Locker::Locker()
|
|||||||
: QObject()
|
: QObject()
|
||||||
, mScreenTimer(new QTimer(this))
|
, mScreenTimer(new QTimer(this))
|
||||||
, mCounter(JsonObject::Instance()->lockerCount())
|
, mCounter(JsonObject::Instance()->lockerCount())
|
||||||
|
, mIsEnable(false)
|
||||||
{
|
{
|
||||||
connect(mScreenTimer, SIGNAL(timeout()), this, SLOT(coverScreen()));
|
connect(mScreenTimer, SIGNAL(timeout()), this, SLOT(coverScreen()));
|
||||||
}
|
}
|
||||||
@@ -25,7 +26,19 @@ Locker::~Locker()
|
|||||||
|
|
||||||
void Locker::start()
|
void Locker::start()
|
||||||
{
|
{
|
||||||
mScreenTimer->start(mCounter);
|
if (mIsEnable)
|
||||||
|
{
|
||||||
|
mScreenTimer->start(mCounter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Locker::setIsEnable(bool aIsEnable)
|
||||||
|
{
|
||||||
|
mIsEnable = aIsEnable;
|
||||||
|
if (!mIsEnable)
|
||||||
|
{
|
||||||
|
mScreenTimer->stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Locker::coverScreen()
|
void Locker::coverScreen()
|
||||||
@@ -37,7 +50,8 @@ void Locker::coverScreen()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mScreenTimer->stop();
|
mScreenTimer->stop();
|
||||||
EventCenter::Default()->triggerEvent(GUIEvents::RequestLogin, nullptr, nullptr);
|
//EventCenter::Default()->triggerEvent(GUIEvents::RequestLogin, nullptr, nullptr);
|
||||||
|
EventCenter::Default()->triggerEvent(GUIEvents::RequestScreenSaver, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Locker::setTimer(int aInterval)
|
void Locker::setTimer(int aInterval)
|
||||||
@@ -51,3 +65,8 @@ void Locker::refreshTimer()
|
|||||||
mScreenTimer->stop();
|
mScreenTimer->stop();
|
||||||
mScreenTimer->start(mCounter);
|
mScreenTimer->start(mCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Locker::stop()
|
||||||
|
{
|
||||||
|
mScreenTimer->stop();
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ class Locker : public QObject
|
|||||||
public:
|
public:
|
||||||
static Locker* getInstance();
|
static Locker* getInstance();
|
||||||
void start();
|
void start();
|
||||||
|
void stop();
|
||||||
void setTimer(int aInterval);
|
void setTimer(int aInterval);
|
||||||
|
void setIsEnable(bool aIsEnable);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void refreshTimer();
|
void refreshTimer();
|
||||||
@@ -21,6 +23,7 @@ private:
|
|||||||
|
|
||||||
QTimer* mScreenTimer;
|
QTimer* mScreenTimer;
|
||||||
int mCounter;
|
int mCounter;
|
||||||
|
bool mIsEnable;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LOCKER_H
|
#endif // LOCKER_H
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ MainWindow::MainWindow(QWidget* aParent)
|
|||||||
, mDebugMessageConsole(nullptr)
|
, mDebugMessageConsole(nullptr)
|
||||||
, mTabWidget(new QTabWidget(this))
|
, mTabWidget(new QTabWidget(this))
|
||||||
, mAdminTabIndex(-1)
|
, mAdminTabIndex(-1)
|
||||||
, mLoginDialog(new LoginDialog(this))
|
|
||||||
, mThread(nullptr)
|
, mThread(nullptr)
|
||||||
, mIsDebugMode(false)
|
, mIsDebugMode(false)
|
||||||
{
|
{
|
||||||
@@ -45,6 +44,7 @@ MainWindow::MainWindow(QWidget* aParent)
|
|||||||
connect(DeviceManager::Default(), &DeviceManager::raiseGlobalError, this, &MainWindow::triggerError);
|
connect(DeviceManager::Default(), &DeviceManager::raiseGlobalError, this, &MainWindow::triggerError);
|
||||||
connect(DeviceManager::Default(), &DeviceManager::raiseGlobalInfo, this, &MainWindow::triggerInfo);
|
connect(DeviceManager::Default(), &DeviceManager::raiseGlobalInfo, this, &MainWindow::triggerInfo);
|
||||||
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, this, &MainWindow::reloadLanguage);
|
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, this, &MainWindow::reloadLanguage);
|
||||||
|
connect(EventCenter::Default(), &EventCenter::RequestScreenSaver, this, &MainWindow::requestScreenSaver);
|
||||||
GUIErrorHandle::Default()->init();
|
GUIErrorHandle::Default()->init();
|
||||||
mThread = QThread::create([]() {
|
mThread = QThread::create([]() {
|
||||||
QThread::sleep(10);
|
QThread::sleep(10);
|
||||||
@@ -276,6 +276,11 @@ void MainWindow::requestLogin()
|
|||||||
QApplication::setActiveWindow(centralWidget());
|
QApplication::setActiveWindow(centralWidget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::requestScreenSaver()
|
||||||
|
{
|
||||||
|
DialogManager::Default()->requestScreenSaverPlay();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::resetRoleLayout() {
|
void MainWindow::resetRoleLayout() {
|
||||||
if (User::Current()->isAdmin())
|
if (User::Current()->isAdmin())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ class QGestureEvent;
|
|||||||
class QSwipeGesture;
|
class QSwipeGesture;
|
||||||
class QPanGesture;
|
class QPanGesture;
|
||||||
class QDockWidget;
|
class QDockWidget;
|
||||||
class LoginDialog;
|
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
@@ -31,6 +30,7 @@ public:
|
|||||||
void centerWidgetHide();
|
void centerWidgetHide();
|
||||||
void centerWidgetShow();
|
void centerWidgetShow();
|
||||||
void requestLogin();
|
void requestLogin();
|
||||||
|
void requestScreenSaver();
|
||||||
QTextEdit* getEdit();
|
QTextEdit* getEdit();
|
||||||
void debugConsoleOn();
|
void debugConsoleOn();
|
||||||
void grabGestures(const QList<Qt::GestureType>& aGestures);
|
void grabGestures(const QList<Qt::GestureType>& aGestures);
|
||||||
@@ -59,7 +59,6 @@ private:
|
|||||||
QTextEdit* mDebugMessageConsole;
|
QTextEdit* mDebugMessageConsole;
|
||||||
QTabWidget* mTabWidget;
|
QTabWidget* mTabWidget;
|
||||||
int mAdminTabIndex;
|
int mAdminTabIndex;
|
||||||
LoginDialog* mLoginDialog;
|
|
||||||
QThread* mThread;
|
QThread* mThread;
|
||||||
bool mIsDebugMode;
|
bool mIsDebugMode;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user