Files
gcs-nf/App/CommandBox/CommandBox.cpp
T
2020-10-10 15:25:17 +08:00

73 lines
1.1 KiB
C++

#include "CommandBox.h"
#include "ui_CommandBox.h"
CommandBox::CommandBox(QWidget *parent) :
QWidget(parent),
ui(new Ui::CommandBox)
{
ui->setupUi(this);
m_parent = parent;
}
CommandBox::~CommandBox()
{
delete ui;
}
void CommandBox::closeEvent(QCloseEvent *event)
{
setFloat();
event->ignore();
}
void CommandBox::contextMenuEvent(QContextMenuEvent *event)
{
if(floatflag)
{
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 CommandBox::setFloat(void)
{
if(floatflag)
{
if(this->parent())
{
this->setParent(nullptr);
}
else
{
this->setParent(m_parent);
this->move(0,0);
}
this->show();
}
}
void CommandBox::setFloatFlag(bool flag)
{
floatflag = flag;
}