Commit ca088972 authored by Benjamin Long's avatar Benjamin Long

Fix QToolButton translator, and remove useless qDebug.

parent 4d42969a
......@@ -45,6 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
pqAbstractButtonEventTranslator::pqAbstractButtonEventTranslator(QObject* p)
: pqWidgetEventTranslator(p)
{
this->LastMouseEvent = 0;
}
bool pqAbstractButtonEventTranslator::translateEvent(QObject* Object, QEvent* Event, bool& /*Error*/)
......@@ -52,7 +53,6 @@ bool pqAbstractButtonEventTranslator::translateEvent(QObject* Object, QEvent* Ev
QAbstractButton* const object = qobject_cast<QAbstractButton*>(Object);
if(!object)
return false;
switch(Event->type())
{
case QEvent::KeyPress:
......@@ -67,6 +67,7 @@ bool pqAbstractButtonEventTranslator::translateEvent(QObject* Object, QEvent* Ev
case QEvent::MouseButtonPress:
{
QMouseEvent* const e = static_cast<QMouseEvent*>(Event);
this->LastMouseEvent = e;
QPushButton* pushButton = qobject_cast<QPushButton*>(object);
if(pushButton &&
e->button() == Qt::LeftButton &&
......@@ -87,6 +88,9 @@ bool pqAbstractButtonEventTranslator::translateEvent(QObject* Object, QEvent* Ev
break;
case QEvent::Timer:
{
if (this->LastMouseEvent &&
this->LastMouseEvent->type() == QEvent::MouseButtonPress)
{
QToolButton* tButton = qobject_cast<QToolButton*>(object);
if(tButton &&
tButton->popupMode() == QToolButton::DelayedPopup)
......@@ -94,10 +98,12 @@ bool pqAbstractButtonEventTranslator::translateEvent(QObject* Object, QEvent* Ev
emit recordEvent(object, "longActivate", "");
}
}
}
break;
case QEvent::MouseButtonRelease:
{
QMouseEvent* const e = static_cast<QMouseEvent*>(Event);
this->LastMouseEvent = e;
if(e->button() == Qt::LeftButton && object->rect().contains(e->pos()))
{
onActivate(object);
......@@ -124,10 +130,13 @@ void pqAbstractButtonEventTranslator::onActivate(QAbstractButton* actualObject)
const bool new_value = !actualObject->isChecked();
emit recordEvent(object, "set_boolean", new_value ? "true" : "false");
}
else if(tb && tb->actions().count() < 2)
else if(tb)
{
if (!tb->menu())
{
emit recordEvent(tb, "activate", "");
}
}
else
{
emit recordEvent(object, "activate", "");
......
......@@ -33,6 +33,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _pqAbstractButtonEventTranslator_h
#define _pqAbstractButtonEventTranslator_h
// Qt includes
#include <QMouseEvent>
#include "pqWidgetEventTranslator.h"
class QAbstractButton;
......@@ -58,6 +61,8 @@ private:
pqAbstractButtonEventTranslator& operator=(const pqAbstractButtonEventTranslator&);
void onActivate(QAbstractButton*);
QMouseEvent* LastMouseEvent;
};
#endif // !_pqAbstractButtonEventTranslator_h
......
......@@ -155,7 +155,6 @@ void pqEventDispatcher::setTimeStep(int value)
//-----------------------------------------------------------------------------
void pqEventDispatcher::run(bool value)
{
qDebug() << "Dispatcher" << value;
this->PlayBackPaused = !value;
if (value)
{
......@@ -251,7 +250,6 @@ bool pqEventDispatcher::playEvents(pqEventSource& source, pqEventPlayer& player)
QObject::disconnect(QAbstractEventDispatcher::instance(), SIGNAL(awake()),
this, SLOT(awake()));
qDebug() << "About to Stop Dispatcher";
return this->PlayBackStatus;
}
......
......@@ -193,7 +193,6 @@ bool pqTestUtility::playTests(const QStringList& filenames)
}
this->PlayingTest = false;
qDebug() << "About to stop TestUtility";
emit this->stopped();
return success;
}
......
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