Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

Commit d918b29b authored by Benjamin Long's avatar Benjamin Long

Add QtoolButton long click

parent cf517f3d
......@@ -39,6 +39,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QMenuBar>
#include <QPushButton>
#include <QtDebug>
#include <QToolButton>
#include "pqEventDispatcher.h"
......@@ -52,7 +53,7 @@ bool pqAbstractActivateEventPlayer::playEvent(QObject* Object,
const QString& Arguments,
bool& Error)
{
if(Command != "activate")
if(Command != "activate" && Command != "longActivate")
return false;
if (QMenuBar* const menu_bar = qobject_cast<QMenuBar*>(Object))
......@@ -109,7 +110,6 @@ bool pqAbstractActivateEventPlayer::playEvent(QObject* Object,
else if(QMenu* menu = qobject_cast<QMenu*>(p))
{
menu->setActiveAction(next->menuAction());
int max_wait = 0;
while(!next->isVisible() && (++max_wait) <= 2)
{
......@@ -134,11 +134,23 @@ bool pqAbstractActivateEventPlayer::playEvent(QObject* Object,
}
if(QAbstractButton* const object = qobject_cast<QAbstractButton*>(Object))
{
if (Command == "activate")
{
object->click();
//QApplication::processEvents();
return true;
}
if(Command == "longActivate")
{
QToolButton* tButton = qobject_cast<QToolButton*>(Object);
if(tButton)
{
tButton->showMenu();
return true;
}
}
}
if (QAction* const action = qobject_cast<QAction*>(Object))
{
......
......@@ -32,6 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqAbstractButtonEventTranslator.h"
#include <QDebug>
#include <QAbstractButton>
#include <QAction>
#include <QKeyEvent>
......@@ -74,6 +75,24 @@ bool pqAbstractButtonEventTranslator::translateEvent(QObject* Object, QEvent* Ev
{
onActivate(object);
}
QToolButton* toolButton = qobject_cast<QToolButton*>(object);
if(toolButton &&
e->button() == Qt::LeftButton &&
object->rect().contains(e->pos()) &&
toolButton->menu())
{
onActivate(object);
}
}
break;
case QEvent::Timer:
{
QToolButton* tButton = qobject_cast<QToolButton*>(object);
if(tButton &&
tButton->popupMode() == QToolButton::DelayedPopup)
{
emit recordEvent(object, "longActivate", "");
}
}
break;
case QEvent::MouseButtonRelease:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment