1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 03:39:14 +00:00
OpenMW/apps/opencs/view/widget/pushbutton.cpp
2014-07-10 11:45:20 +02:00

47 lines
1.1 KiB
C++

#include "pushbutton.hpp"
#include <QMouseEvent>
#include <QKeyEvent>
void CSVWidget::PushButton::keyPressEvent (QKeyEvent *event)
{
if (event->key()!=Qt::Key_Shift)
mKeepOpen = false;
QPushButton::keyPressEvent (event);
}
void CSVWidget::PushButton::keyReleaseEvent (QKeyEvent *event)
{
if (event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter)
{
mKeepOpen = event->modifiers() & Qt::ShiftModifier;
emit clicked();
}
QPushButton::keyReleaseEvent (event);
}
void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event)
{
mKeepOpen = event->button()==Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier);
QPushButton::mouseReleaseEvent (event);
}
CSVWidget::PushButton::PushButton (const QIcon& icon, bool push, QWidget *parent)
: QPushButton (icon, "", parent), mKeepOpen (false)
{
setCheckable (!push);
}
CSVWidget::PushButton::PushButton (bool push, QWidget *parent)
: QPushButton (parent), mKeepOpen (false)
{
setCheckable (!push);
}
bool CSVWidget::PushButton::hasKeepOpen() const
{
return mKeepOpen;
}