Files
gcs-nf/App/ToolsUI/ToolsWidget.cpp
T

86 lines
1.4 KiB
C++
Raw Normal View History

2021-01-07 10:55:02 +08:00
#include "ToolsWidget.h"
ToolsWidget::ToolsWidget(QWidget *parent) : QWidget(parent)
{
m_parent = parent;
}
ToolsWidget::~ToolsWidget()
{
}
2021-05-15 15:01:24 +08:00
void ToolsWidget::mousePressEvent(QMouseEvent *event)
{
}
2021-01-07 10:55:02 +08:00
void ToolsWidget::setColor(QWidget *w,state s)
{
w->setProperty("state",s);
w->style()->unpolish(w);
w->style()->polish(w);
2022-07-16 23:54:47 +08:00
update();
2021-01-07 10:55:02 +08:00
}
void ToolsWidget::setValue(QLabel *w,QString s)
{
w->setText(s);
2022-07-16 23:54:47 +08:00
update();
2021-01-07 10:55:02 +08:00
}
void ToolsWidget::setFloat(void)
{
if(this->parent())
{
2021-01-12 19:29:03 +08:00
m_parent = qobject_cast<QWidget *>(this->parent());
2021-01-09 18:08:45 +08:00
QPoint pos = mapToGlobal(m_parent->pos());
2021-01-07 10:55:02 +08:00
this->setParent(nullptr);
this->resize(this->minimumSize());
2021-01-09 18:08:45 +08:00
this->move(pos.x() + (m_parent->width() - this->width()) * 0.5,
2021-05-15 15:01:24 +08:00
pos.y());
2021-01-22 11:59:56 +08:00
if(Top())
{
this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
}
2021-01-07 10:55:02 +08:00
this->show();
}
else
{
2021-01-12 19:29:03 +08:00
if(m_parent)
{
this->setParent(m_parent);
this->setGeometry(m_parent->geometry());
}
2021-01-07 10:55:02 +08:00
this->move(0,0);
this->show();
this->resize(m_parent->size());
2021-01-07 10:55:02 +08:00
update();
}
}
void ToolsWidget::resizeEvent(QResizeEvent *event)
{
update();
}
void ToolsWidget::closeEvent(QCloseEvent *event)
{
setFloat();
event->ignore();
}
2022-06-15 18:52:14 +08:00
void ToolsWidget::recieveData(int const &id,const QByteArray &data)
{
}
2021-01-07 10:55:02 +08:00