1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 12:54:00 +00:00
OpenMW/apps/opencs/view/widget/pushbutton.cpp

41 lines
955 B
C++
Raw Normal View History

2014-07-10 09:03:55 +00:00
#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);
}
2014-07-10 09:03:55 +00:00
void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event)
{
mKeepOpen = event->button()==Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier);
QPushButton::mouseReleaseEvent (event);
}
CSVWidget::PushButton::PushButton (const QIcon& icon, QWidget *parent)
: QPushButton (icon, "", parent), mKeepOpen (false)
2014-07-10 09:03:55 +00:00
{
setCheckable (true);
2014-07-10 09:03:55 +00:00
}
bool CSVWidget::PushButton::hasKeepOpen() const
{
return mKeepOpen;
}