优化tools 相关代码
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
#include "ToolsWidget.h"
|
||||
|
||||
ToolsWidget::ToolsWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_parent = parent;
|
||||
}
|
||||
|
||||
ToolsWidget::~ToolsWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ToolsWidget::setColor(QWidget *w,state s)
|
||||
{
|
||||
w->setProperty("state",s);
|
||||
w->style()->unpolish(w);
|
||||
w->style()->polish(w);
|
||||
}
|
||||
|
||||
void ToolsWidget::setValue(QLabel *w,QString s)
|
||||
{
|
||||
w->setText(s);
|
||||
}
|
||||
|
||||
void ToolsWidget::setFloat(void)
|
||||
{
|
||||
if(this->parent())
|
||||
{
|
||||
this->setParent(nullptr);
|
||||
this->move(m_parent->pos().x() + (m_parent->width() - this->width()) * 0.5,
|
||||
m_parent->pos().y() + (m_parent->height() - this->height()) * 0.5);
|
||||
this->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setParent(m_parent);
|
||||
this->setGeometry(m_parent->geometry());
|
||||
this->move(0,0);
|
||||
this->hide();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ToolsWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
void ToolsWidget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
setFloat();
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user