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