2014-07-10 09:03:55 +00:00
|
|
|
|
|
|
|
#include "pushbutton.hpp"
|
|
|
|
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
|
2014-07-13 12:21:50 +00:00
|
|
|
void CSVWidget::PushButton::setExtendedToolTip (const QString& text)
|
2014-07-10 10:53:57 +00:00
|
|
|
{
|
2014-07-13 12:21:50 +00:00
|
|
|
QString tooltip = text;
|
2014-07-10 10:53:57 +00:00
|
|
|
|
2014-07-13 12:21:50 +00:00
|
|
|
if (tooltip.isEmpty())
|
2014-07-10 10:53:57 +00:00
|
|
|
tooltip = "(Tool tip not implemented yet)";
|
|
|
|
|
2014-07-10 11:04:30 +00:00
|
|
|
switch (mType)
|
|
|
|
{
|
|
|
|
case Type_TopMode:
|
|
|
|
|
|
|
|
tooltip +=
|
|
|
|
"<p>(left click to change mode)";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Type_Mode:
|
|
|
|
|
|
|
|
tooltip +=
|
|
|
|
"<p>(left click to activate,"
|
|
|
|
"<br>shift-left click to activate and keep panel open)";
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2014-07-10 10:53:57 +00:00
|
|
|
|
2014-07-13 12:21:50 +00:00
|
|
|
setToolTip (tooltip);
|
2014-07-10 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
2014-07-10 09:03:55 +00:00
|
|
|
void CSVWidget::PushButton::keyPressEvent (QKeyEvent *event)
|
|
|
|
{
|
|
|
|
if (event->key()!=Qt::Key_Shift)
|
|
|
|
mKeepOpen = false;
|
|
|
|
|
|
|
|
QPushButton::keyPressEvent (event);
|
|
|
|
}
|
|
|
|
|
2014-07-10 09:32:20 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-07-13 12:21:50 +00:00
|
|
|
CSVWidget::PushButton::PushButton (const QIcon& icon, Type type, const QString& tooltip,
|
2014-07-10 10:53:57 +00:00
|
|
|
QWidget *parent)
|
2014-07-13 12:21:50 +00:00
|
|
|
: QPushButton (icon, "", parent), mKeepOpen (false), mType (type), mToolTip (tooltip)
|
2014-07-10 09:03:55 +00:00
|
|
|
{
|
2014-07-10 11:04:30 +00:00
|
|
|
setCheckable (type==Type_Mode);
|
2014-07-10 10:53:57 +00:00
|
|
|
setExtendedToolTip (tooltip);
|
2014-07-10 09:44:01 +00:00
|
|
|
}
|
|
|
|
|
2014-07-13 12:21:50 +00:00
|
|
|
CSVWidget::PushButton::PushButton (Type type, const QString& tooltip, QWidget *parent)
|
|
|
|
: QPushButton (parent), mKeepOpen (false), mType (type), mToolTip (tooltip)
|
2014-07-10 09:44:01 +00:00
|
|
|
{
|
2014-07-10 11:04:30 +00:00
|
|
|
setCheckable (type==Type_Mode);
|
2014-07-10 10:53:57 +00:00
|
|
|
setExtendedToolTip (tooltip);
|
2014-07-10 09:03:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSVWidget::PushButton::hasKeepOpen() const
|
|
|
|
{
|
|
|
|
return mKeepOpen;
|
2014-07-13 12:21:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString CSVWidget::PushButton::getBaseToolTip() const
|
|
|
|
{
|
|
|
|
return mToolTip;
|
2014-07-10 09:03:55 +00:00
|
|
|
}
|