Commit bad4e52c authored by Clinton Stimpson's avatar Clinton Stimpson

ENH: Add ability to record and playback QPushButton's with QMenu's.

      Fall back to QAction::text() if QAction::objectName() is null.
parent 5ee70b66
......@@ -65,6 +65,18 @@ bool pqAbstractActivateEventPlayer::playEvent(QObject* Object,
action = actions[j];
}
}
// fall back to the text of the action
if(!action)
{
for(int j = 0; j != actions.size() && !action; ++j)
{
if(actions[j]->text() == Arguments)
{
action = actions[j];
}
}
}
if(!action)
{
......
......@@ -36,7 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QAction>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QToolButton>
#include <QPushButton>
#include <iostream>
......@@ -61,6 +61,19 @@ bool pqAbstractButtonEventTranslator::translateEvent(QObject* Object, QEvent* Ev
}
}
break;
case QEvent::MouseButtonPress:
{
QMouseEvent* const e = static_cast<QMouseEvent*>(Event);
QPushButton* pushButton = qobject_cast<QPushButton*>(object);
if(pushButton &&
e->button() == Qt::LeftButton &&
object->rect().contains(e->pos()) &&
pushButton->menu())
{
onActivate(object);
}
}
break;
case QEvent::MouseButtonRelease:
{
QMouseEvent* const e = static_cast<QMouseEvent*>(Event);
......
......@@ -60,7 +60,12 @@ bool pqMenuEventTranslator::translateEvent(QObject* Object, QEvent* Event,
QAction* action = menu->activeAction();
if(action)
{
emit recordEvent(menu, "activate", action->objectName());
QString which = action->objectName();
if(which == QString::null)
{
which = action->text();
}
emit recordEvent(menu, "activate", which);
return true;
}
}
......@@ -74,7 +79,12 @@ bool pqMenuEventTranslator::translateEvent(QObject* Object, QEvent* Event,
QAction* action = menu->actionAt(e->pos());
if(action && !action->menu())
{
emit recordEvent(menu, "activate", action->objectName());
QString which = action->objectName();
if(which == QString::null)
{
which = action->text();
}
emit recordEvent(menu, "activate", which);
return true;
}
}
......
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