diff --git a/CMakeLists.txt b/CMakeLists.txt
index 224e402..23b83bf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,68 +1,70 @@
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(atelier)
find_package(ECM REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
include(KDECompilerSettings)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(ECMInstallIcons)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(QT_MIN_VERSION "5.9.0")
set(KF5_DEP_VERSION "5.30.0")
set(KDE_APPLICATIONS_VERSION_MAJOR "1")
set(KDE_APPLICATIONS_VERSION_MINOR "0")
set(KDE_APPLICATIONS_VERSION_MICRO "0")
set(KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}")
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ")
endif()
#Atelier Dependencies
find_package(AtCore REQUIRED COMPONENTS
AtCore
)
find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS
Solid
I18n
XmlGui
ConfigWidgets
TextEditor
)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS
Core
Widgets
SerialPort
Charts
Quick
Qml
3DCore
3DExtras
3DRender
3DInput
+ Multimedia
+ MultimediaWidgets
)
if(BUILD_TESTING)
find_package(Qt5Test ${QT_MIN_VERSION} CONFIG REQUIRED)
endif()
# config.h
configure_file (config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
include(ECMPoQmTools)
include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(src)
add_subdirectory(deploy)
if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po")
ecm_install_po_files_as_qm(po)
endif()
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index 47b713b..9ff5ab7 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -1,23 +1,26 @@
set(widgets_SRCS
gcodeeditorwidget.cpp
axiscontrol.cpp
bedextruderwidget.cpp
plotwidget.cpp
pushgcodewidget.cpp
ratescontrolwidget.cpp
printprogresswidget.cpp
logwidget.cpp
+ videomonitorwidget.cpp
)
add_library(AtelierWidgets STATIC ${widgets_SRCS})
target_link_libraries(AtelierWidgets
Qt5::Core
Qt5::Widgets
Qt5::SerialPort
KF5::Solid
KF5::I18n
KF5::TextEditor
- Qt5::Charts)
+ Qt5::Charts
+ Qt5::Multimedia
+ Qt5::MultimediaWidgets)
add_subdirectory(3dview)
diff --git a/src/widgets/videomonitorwidget.cpp b/src/widgets/videomonitorwidget.cpp
new file mode 100644
index 0000000..cbf2a21
--- /dev/null
+++ b/src/widgets/videomonitorwidget.cpp
@@ -0,0 +1,99 @@
+/* Atelier KDE Printer Host for 3D Printing
+ Copyright (C) <2017>
+ Author: Lays Rodrigues - laysrodriguessilva@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 .
+*/
+#include "videomonitorwidget.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+VideoMonitorWidget::VideoMonitorWidget(QWidget *parent) :
+ QWidget(parent),
+ _mediaplayer(nullptr, QMediaPlayer::VideoSurface)
+{
+ auto _layout = new QGridLayout();
+ auto _label = new QLabel(i18n("Source url:"));
+ _layout->addWidget(_label, 0, 0);
+
+ auto _sourceCB = new QComboBox();
+ _sourceCB->setEditable(true);
+ _sourceCB->setToolTip(i18n("Valid Urls:\n\
+ http://www.example.com/stream.avi\n\
+ rtp://@:1234\n\
+ mms://mms.examples.com/stream.asx\n\
+ rtsp://server.example.org:8080/test.sdp"));
+ _layout->addWidget(_sourceCB, 0, 1);
+
+ auto _playPB = new QPushButton();
+ _playPB->setCheckable(true);
+ _playPB->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
+ _layout->addWidget(_playPB, 0, 2);
+
+ auto _videoWidget = new QVideoWidget();
+ _layout->addWidget(_videoWidget, 1, 0, -1, -1);
+
+ _errorlabel = new QLabel;
+ _layout->addWidget(_errorlabel, 2, 0, 0, -1);
+
+ this->setLayout(_layout);
+
+ _mediaplayer.setVideoOutput(_videoWidget);
+
+#ifdef Q_OS_LINUX
+ QStringList sources;
+ sources << QString("video*");
+ _sourceCB->addItems(QDir("/dev/")\
+ .entryList(sources, QDir::System)\
+ .replaceInStrings( QRegExp("^"), "v4l2:///dev/"));
+#endif
+
+ connect(_playPB, &QPushButton::clicked, [=](bool b){
+ if(b){
+ _playPB->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
+ QString source = _sourceCB->currentText();
+ _mediaplayer.setMedia(QUrl(source));
+ _mediaplayer.play();
+ }else{
+ _mediaplayer.pause();
+ _playPB->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
+ }
+ });
+
+ typedef void (QMediaPlayer::*ErrorSignal)(QMediaPlayer::Error);
+ connect(&_mediaplayer, static_cast(&QMediaPlayer::error),
+ this, &VideoMonitorWidget::handleError);
+}
+
+
+VideoMonitorWidget::~VideoMonitorWidget()
+{
+
+}
+
+void VideoMonitorWidget::handleError()
+{
+ const QString errorString = _mediaplayer.errorString();
+ QString message = "Error: ";
+ if (errorString.isEmpty())
+ message += " #" + QString::number(int(_mediaplayer.error()));
+ else
+ message += errorString;
+ _errorlabel->setText(message);
+}
diff --git a/src/widgets/videomonitorwidget.h b/src/widgets/videomonitorwidget.h
new file mode 100644
index 0000000..9177c27
--- /dev/null
+++ b/src/widgets/videomonitorwidget.h
@@ -0,0 +1,36 @@
+/* Atelier KDE Printer Host for 3D Printing
+ Copyright (C) <2017>
+ Author: Lays Rodrigues - laysrodriguessilva@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 .
+*/
+#pragma once
+
+#include
+#include
+#include
+
+class VideoMonitorWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit VideoMonitorWidget(QWidget *parent = nullptr);
+ ~VideoMonitorWidget();
+
+private:
+ QMediaPlayer _mediaplayer;
+ QLabel *_errorlabel;
+ void handleError();
+};