#include "gui_cctv_wrapper.hpp"
#include "gui_image.hpp"
gui_cctv_wrapper
::gui_cctv_wrapper(QWidget *parent
) :{
CCTV_Process->setProgram(CCTV_Process_Path);
CCTV_Process->start();
connect(this,SIGNAL(started()),this,SLOT(Thread_Slot()));
emit started();
//delay(20000);
//CCTV_Container->setStyleSheet("background-color: black");
}
/// Class destructor
gui_cctv_wrapper::~gui_cctv_wrapper(void)
{
try
{
this->CCTV_Process->close();
delete CCTV_Process;
//LOG_DEBUG << "Deleting Process";
//
// Nothing to tidy. Smart pointers will take care of the dynamically
// created classes.
}
catch(...)
{
// prevent exceptions from destructor
}
}
void gui_cctv_wrapper::createprocess()
{
//QPalette pl ;
//pl.setColor(Qt::black);
/// delay 160 ms so that windows can find the ID
delay(200);
id = NULL;
do
{
id = (WId)FindWindow(NULL,L"LXC CCTV Monitor");
delay(100);
}while(id == NULL);
if(id != NULL)
{
Window = QWindow::fromWinId(id);
//Window->requestActivate();
qDebug() << Window->geometry().width();
qDebug() << Window->geometry().height();
//Window->setMinimumSize(*Size);
//->setStyleSheet("border: 1px solid green");
Window->setSurfaceType(QWindow::OpenGLSurface);
CCTV_Container
= QWidget::createWindowContainer(Window,
this, Qt
::FramelessWindowHint);
qDebug() << CCTV_Container->geometry().width();
qDebug() << CCTV_Container->geometry().height();
//CCTV_Container->setMinimumSize(*Size);
//CCTV_Container->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
CCTV_Container->setStyleSheet("background-color: blue");
//CCTV_Container->setPalette(p1);
CCTV_Container->setMinimumSize(1696,1066);
CCTV_Container->autoFillBackground();
qDebug() << CCTV_Container->geometry().width();
qDebug() << CCTV_Container->geometry().height();
Layout2->setMargin(0);
Layout2->addWidget(CCTV_Container);
this->setLayout(Layout2);
update();
}
}
void gui_cctv_wrapper::delay(int n)
{
while( QTime::currentTime() < dieTime
) }
{
Opt.init(this);
QPainter p
(this);
/* First line of most paintEvents. */ style
()->drawPrimitive
(QStyle::PE_Widget,
&Opt,
&p,
this);
}
{
this->QWidget::resizeEvent(Event);
update();
}
void gui_cctv_wrapper::Thread_Slot()
{
moveToThread(&Thread);
connect(&Thread,SIGNAL(started()),this,SLOT(createprocess()));
Thread.start();
}
#include "gui_cctv_wrapper.hpp"
#include "gui_image.hpp"
gui_cctv_wrapper::gui_cctv_wrapper(QWidget *parent) :
QWidget(parent)
{
CCTV_Process = new QProcess(this);
CCTV_Process->setProgram(CCTV_Process_Path);
CCTV_Process->start();
connect(this,SIGNAL(started()),this,SLOT(Thread_Slot()));
emit started();
//delay(20000);
//CCTV_Container->setStyleSheet("background-color: black");
}
/// Class destructor
gui_cctv_wrapper::~gui_cctv_wrapper(void)
{
try
{
this->CCTV_Process->close();
delete CCTV_Process;
//LOG_DEBUG << "Deleting Process";
//
// Nothing to tidy. Smart pointers will take care of the dynamically
// created classes.
}
catch(...)
{
// prevent exceptions from destructor
}
}
void gui_cctv_wrapper::createprocess()
{
//QPalette pl ;
//pl.setColor(Qt::black);
/// delay 160 ms so that windows can find the ID
delay(200);
id = NULL;
do
{
id = (WId)FindWindow(NULL,L"LXC CCTV Monitor");
delay(100);
}while(id == NULL);
if(id != NULL)
{
Window = QWindow::fromWinId(id);
//Window->requestActivate();
qDebug() << Window->geometry().width();
qDebug() << Window->geometry().height();
QSize* Size = new QSize(1900,680);
//Window->setMinimumSize(*Size);
//->setStyleSheet("border: 1px solid green");
Window->setSurfaceType(QWindow::OpenGLSurface);
CCTV_Container = QWidget::createWindowContainer(Window, this, Qt::FramelessWindowHint);
qDebug() << CCTV_Container->geometry().width();
qDebug() << CCTV_Container->geometry().height();
//CCTV_Container->setMinimumSize(*Size);
//CCTV_Container->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
CCTV_Container->setStyleSheet("background-color: blue");
//CCTV_Container->setPalette(p1);
CCTV_Container->setMinimumSize(1696,1066);
CCTV_Container->autoFillBackground();
qDebug() << CCTV_Container->geometry().width();
qDebug() << CCTV_Container->geometry().height();
QVBoxLayout *Layout2 = new QVBoxLayout(this);
Layout2->setMargin(0);
Layout2->addWidget(CCTV_Container);
this->setLayout(Layout2);
update();
}
}
void gui_cctv_wrapper::delay(int n)
{
QTime dieTime = QTime::currentTime().addMSecs(n);
while( QTime::currentTime() < dieTime )
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
void gui_cctv_wrapper::paintEvent(QPaintEvent* aEvent)
{
QStyleOption Opt;
Opt.init(this);
QPainter p(this); /* First line of most paintEvents. */
style()->drawPrimitive(QStyle::PE_Widget,&Opt,&p,this);
}
void gui_cctv_wrapper::resizeEvent(QResizeEvent * Event)
{
this->QWidget::resizeEvent(Event);
update();
}
void gui_cctv_wrapper::Thread_Slot()
{
moveToThread(&Thread);
connect(&Thread,SIGNAL(started()),this,SLOT(createprocess()));
Thread.start();
}
To copy to clipboard, switch view to plain text mode
#ifndef GUI_CCTV_WRAPPER_HPP_
#define GUI_CCTV_WRAPPER_HPP_
#include <QWidget>
#include <QProcess>
#include <QGridLayout>
#include <QWindow>
#include <QTime>
#include <QCoreApplication>
#include <memory>
#include <QThread>
#include <QResizeEvent>
#include <QSize>
#include "windows.h"
//#include "gui_configuration.hpp"
//#include "common/logging/log_client.hpp"
class gui_cctv_wrapper
: public QWidget{
Q_OBJECT
public:
explicit gui_cctv_wrapper
(QWidget *parent
= 0);
~gui_cctv_wrapper();
void delay(int n);
signals:
void started();
public slots:
void Thread_Slot();
void createprocess();
private:
QWindow * Window;
WId id;
//std::unique_ptr< QProcess > CCTV_Process;
QString CCTV_Process_Path
= "C:\\Software\\lxc\\bin\\bin\\lxc_cctv.exe";
//std::unique_ptr<QWidget> CCTV_Container;
};
#endif // GUI_CCTV_WRAPPER_HPP_
#ifndef GUI_CCTV_WRAPPER_HPP_
#define GUI_CCTV_WRAPPER_HPP_
#include <QWidget>
#include <QProcess>
#include <QGridLayout>
#include <QWindow>
#include <QTime>
#include <QCoreApplication>
#include <memory>
#include <QThread>
#include <QResizeEvent>
#include <QSize>
#include "windows.h"
//#include "gui_configuration.hpp"
//#include "common/logging/log_client.hpp"
class gui_cctv_wrapper : public QWidget
{
Q_OBJECT
public:
explicit gui_cctv_wrapper(QWidget *parent = 0);
~gui_cctv_wrapper();
void delay(int n);
void paintEvent(QPaintEvent* aEvent);
void resizeEvent(QResizeEvent * Event);
signals:
void started();
public slots:
void Thread_Slot();
void createprocess();
private:
QWindow * Window;
WId id;
QThread Thread;
//std::unique_ptr< QProcess > CCTV_Process;
QProcess * CCTV_Process;
QString CCTV_Process_Path = "C:\\Software\\lxc\\bin\\bin\\lxc_cctv.exe";
//std::unique_ptr<QWidget> CCTV_Container;
QWidget * CCTV_Container;
};
#endif // GUI_CCTV_WRAPPER_HPP_
To copy to clipboard, switch view to plain text mode
Bookmarks