mirror of https://github.com/EspoTek/Labrador.git
23 lines
544 B
C++
23 lines
544 B
C++
#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);
|
|
}
|