Turn off pick mode when the link dialog is closed

This commit is contained in:
parax0 2016-03-06 18:05:40 -07:00
parent 8f82dcbdd9
commit c3ae63718b
2 changed files with 13 additions and 0 deletions

View File

@ -16,6 +16,7 @@ CLinkDialog::CLinkDialog(CWorldEditor *pEditor, QWidget *pParent /*= 0*/)
, mpReceiver(nullptr) , mpReceiver(nullptr)
, mSenderStateModel(CStateMessageModel::eStates, this) , mSenderStateModel(CStateMessageModel::eStates, this)
, mReceiverMessageModel(CStateMessageModel::eMessages, this) , mReceiverMessageModel(CStateMessageModel::eMessages, this)
, mIsPicking(false)
, mpEditLink(nullptr) , mpEditLink(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -48,6 +49,12 @@ void CLinkDialog::showEvent(QShowEvent *)
SetReceiverNameLabel(); SetReceiverNameLabel();
} }
void CLinkDialog::closeEvent(QCloseEvent *)
{
if (mIsPicking)
mpEditor->ExitPickMode();
}
void CLinkDialog::NewLink(CScriptObject *pSender, CScriptObject *pReceiver) void CLinkDialog::NewLink(CScriptObject *pSender, CScriptObject *pReceiver)
{ {
mpEditLink = nullptr; mpEditLink = nullptr;
@ -193,6 +200,8 @@ void CLinkDialog::OnPickFromViewportClicked()
QPushButton *pOtherButton = (pButton == ui->SenderPickFromViewport ? ui->ReceiverPickFromViewport : ui->SenderPickFromViewport); QPushButton *pOtherButton = (pButton == ui->SenderPickFromViewport ? ui->ReceiverPickFromViewport : ui->SenderPickFromViewport);
pOtherButton->setChecked(false); pOtherButton->setChecked(false);
mIsPicking = true;
} }
else else
@ -217,6 +226,7 @@ void CLinkDialog::OnPickModeExit()
ui->ReceiverPickFromViewport->setChecked(false); ui->ReceiverPickFromViewport->setChecked(false);
disconnect(mpEditor, SIGNAL(PickModeClick(SRayIntersection,QMouseEvent*)), this, 0); disconnect(mpEditor, SIGNAL(PickModeClick(SRayIntersection,QMouseEvent*)), this, 0);
disconnect(mpEditor, SIGNAL(PickModeExited()), this, 0); disconnect(mpEditor, SIGNAL(PickModeExited()), this, 0);
mIsPicking = false;
} }
void CLinkDialog::OnPickFromListClicked() void CLinkDialog::OnPickFromListClicked()

View File

@ -23,6 +23,8 @@ class CLinkDialog : public QDialog
CStateMessageModel mSenderStateModel; CStateMessageModel mSenderStateModel;
CStateMessageModel mReceiverMessageModel; CStateMessageModel mReceiverMessageModel;
bool mIsPicking;
Ui::CLinkDialog *ui; Ui::CLinkDialog *ui;
public: public:
@ -30,6 +32,7 @@ public:
~CLinkDialog(); ~CLinkDialog();
void resizeEvent(QResizeEvent *); void resizeEvent(QResizeEvent *);
void showEvent(QShowEvent *); void showEvent(QShowEvent *);
void closeEvent(QCloseEvent *);
void NewLink(CScriptObject *pSender, CScriptObject *pReceiver); void NewLink(CScriptObject *pSender, CScriptObject *pReceiver);
void EditLink(CLink *pLink); void EditLink(CLink *pLink);