Labrador/Desktop_Interface/ui_elements/noclosemenu.cpp

23 lines
544 B
C++
Raw Normal View History

#include "noclosemenu.h"
noCloseMenu::noCloseMenu(QWidget *parent) : QMenu(parent)
{
}
//Dankon, Jakob Leben
//http://stackoverflow.com/questions/2050462/prevent-a-qmenu-from-closing-when-one-of-its-qaction-is-triggered
void noCloseMenu::mouseReleaseEvent(QMouseEvent *e)
{
QAction *action = activeAction();
if (action && action->isEnabled()) {
action->setEnabled(false);
QMenu::mouseReleaseEvent(e);
action->setEnabled(true);
action->trigger();
}
else
QMenu::mouseReleaseEvent(e);
}