2020-10-10 12:12:30 +08:00
|
|
|
#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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-10-10 15:25:17 +08:00
|
|
|
|
2020-10-10 12:12:30 +08:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|