mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 11:22:58 +00:00
rework mouse buttons debugging
avoid symbols in anonymous namespace and round-trips to the meta-object system Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
451ad1f204
commit
fb97bea482
1 changed files with 35 additions and 26 deletions
|
@ -2180,14 +2180,25 @@ static const char *eventClassName(QEvent::Type t)
|
||||||
return "QEvent";
|
return "QEvent";
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
// Make protected QObject::staticQtMetaObject accessible for formatting enums.
|
|
||||||
class DebugHelper : public QObject {
|
|
||||||
public:
|
|
||||||
static const char *mouseButtonToString(Qt::MouseButton button)
|
static const char *mouseButtonToString(Qt::MouseButton button)
|
||||||
{
|
{
|
||||||
static const int enumIdx = QObject::staticQtMetaObject.indexOfEnumerator("MouseButtons");
|
switch (button) {
|
||||||
return QObject::staticQtMetaObject.enumerator(enumIdx).valueToKey(button);
|
case Qt::NoButton:
|
||||||
|
return "Qt::NoButton";
|
||||||
|
case Qt::LeftButton:
|
||||||
|
return "Qt::LeftButton";
|
||||||
|
case Qt::RightButton:
|
||||||
|
return "Qt::RightButton";
|
||||||
|
case Qt::MiddleButton:
|
||||||
|
return "Qt::MiddleButton";
|
||||||
|
case Qt::XButton1:
|
||||||
|
return "Qt::XButton1";
|
||||||
|
case Qt::XButton2:
|
||||||
|
return "Qt::XButton2";
|
||||||
|
default:
|
||||||
|
Q_ASSERT_X(false, "mouseButtonToString", "internal error");
|
||||||
|
}
|
||||||
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QByteArray mouseButtonsToString(Qt::MouseButtons buttons)
|
static QByteArray mouseButtonsToString(Qt::MouseButtons buttons)
|
||||||
|
@ -2205,8 +2216,6 @@ public:
|
||||||
result.append("NoButton");
|
result.append("NoButton");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
# ifndef QT_NO_DRAGANDDROP
|
# ifndef QT_NO_DRAGANDDROP
|
||||||
|
|
||||||
|
@ -2220,7 +2229,7 @@ static void formatDropEvent(QDebug d, const QDropEvent *e)
|
||||||
d << ", formats=" << e->mimeData()->formats();
|
d << ", formats=" << e->mimeData()->formats();
|
||||||
if (const Qt::KeyboardModifiers mods = e->keyboardModifiers())
|
if (const Qt::KeyboardModifiers mods = e->keyboardModifiers())
|
||||||
d << ", keyboardModifiers=" << mods;
|
d << ", keyboardModifiers=" << mods;
|
||||||
d << ", " << DebugHelper::mouseButtonsToString(e->mouseButtons()).constData();
|
d << ", " << mouseButtonsToString(e->mouseButtons()).constData();
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // !QT_NO_DRAGANDDROP
|
# endif // !QT_NO_DRAGANDDROP
|
||||||
|
@ -2256,9 +2265,9 @@ QDebug operator<<(QDebug dbg, const QEvent *e) {
|
||||||
const Qt::MouseButtons buttons = me->buttons();
|
const Qt::MouseButtons buttons = me->buttons();
|
||||||
dbg << "QMouseEvent(" << eventTypeName(type);
|
dbg << "QMouseEvent(" << eventTypeName(type);
|
||||||
if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove)
|
if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove)
|
||||||
dbg << ", " << DebugHelper::mouseButtonToString(button);
|
dbg << ", " << mouseButtonToString(button);
|
||||||
if (buttons && button != buttons)
|
if (buttons && button != buttons)
|
||||||
dbg << ", buttons=" << DebugHelper::mouseButtonsToString(buttons).constData();
|
dbg << ", buttons=" << mouseButtonsToString(buttons).constData();
|
||||||
if (const int mods = int(me->modifiers()))
|
if (const int mods = int(me->modifiers()))
|
||||||
dbg << ", modifiers=0x" << hex << mods << dec;
|
dbg << ", modifiers=0x" << hex << mods << dec;
|
||||||
dbg << ')';
|
dbg << ')';
|
||||||
|
|
Loading…
Add table
Reference in a new issue