Files
gcs-nf/App/ToolsUI/tools_Index0/tools_Index0.cpp
T
2020-12-06 23:06:17 +08:00

101 lines
1.9 KiB
C++

#include "tools_Index0.h"
#include "ui_tools_Index0.h"
Tools_Index0::Tools_Index0(QWidget *parent) :
QWidget(parent),
ui(new Ui::Tools_Index0)
{
ui->setupUi(this);
m_parent = parent;
setWindowTitle(tr("MavlinkInspector"));
//load qss
QFile file(":/qss/ToolsUI.qss");
file.open(QFile::ReadOnly);
QTextStream filetext(&file);
QString stylesheet = filetext.readAll();
this->setStyleSheet(stylesheet);
file.close();
mavlinkinspector = new MAVLinkInspector("mavlink inspector",nullptr,nullptr);
mavlinkinspector->setParent(this);
mavlinkinspector->show();
//scope = new Scope(this);
//scope->setGeometry(ui->frame->geometry());
//scope->show();
}
Tools_Index0::~Tools_Index0()
{
delete ui;
}
void Tools_Index0::closeEvent(QCloseEvent *event)
{
setFloat();
event->ignore();
}
void Tools_Index0::contextMenuEvent(QContextMenuEvent *event)
{
/*
QMenu *menu = new QMenu(this);
QAction *pAction = new QAction("float",this);
connect(pAction,SIGNAL(triggered(bool)),
this,SLOT(setFloat()));
menu->addAction(pAction);
menu->move(cursor().pos());
menu->show();
*/
}
void Tools_Index0::setFloat(void)
{
if(this->parent())
{
this->setParent(nullptr);
this->move(50,50);
this->resize(800,480);
this->show();
}
else
{
this->setParent(m_parent);
this->setGeometry(m_parent->geometry());
this->move(0,0);
this->hide();
}
}
void Tools_Index0::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event)
if(mavlinkinspector)
{
mavlinkinspector->setGeometry(0,0,ui->frame->width(),ui->frame->height());
}
update();
}
void Tools_Index0::setInstallWidget(QWidget *w)
{
Inspect = w;
Inspect->setParent(this);
if(Inspect)
{
Inspect->setGeometry(0,0,ui->frame->width(),ui->frame->height());
Inspect->show();
}
}