Commit b306b3a7 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt, new utility class to differentiate short and long clicks

ShortClick is the normal click
LongClick is emitted regularly until the button is released
parent 6bf1a3ba
...@@ -411,3 +411,25 @@ SpinningIcon::SpinningIcon( QWidget *parent, bool noIdleFrame ) ...@@ -411,3 +411,25 @@ SpinningIcon::SpinningIcon( QWidget *parent, bool noIdleFrame )
SpinningIcon::~SpinningIcon() SpinningIcon::~SpinningIcon()
{ {
} }
QToolButtonExt::QToolButtonExt(QWidget *parent, int ms ): longClick( false )
{
setAutoRepeat( true );
setAutoRepeatDelay( ms );
setAutoRepeatInterval( 100 );
connect( this, SIGNAL(released()), this, SLOT(releasedSlot()) );
}
void QToolButtonExt::releasedSlot()
{
if( isDown() )
longClick = true;
if( longClick )
emit longClicked();
else
emit shortClicked();
if( !isDown() )
longClick = false;
}
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <QSpinBox> #include <QSpinBox>
#include <QList> #include <QList>
#include <QTimer> #include <QTimer>
#include <QToolButton>
class QPixmap; class QPixmap;
class QFramelessButton : public QPushButton class QFramelessButton : public QPushButton
...@@ -46,6 +48,19 @@ protected: ...@@ -46,6 +48,19 @@ protected:
virtual void paintEvent( QPaintEvent * event ); virtual void paintEvent( QPaintEvent * event );
}; };
class QToolButtonExt : public QToolButton
{
Q_OBJECT
public:
QToolButtonExt( QWidget *parent = 0, int ms = 1000 );
private:
bool longClick;
private slots:
void releasedSlot();
signals:
void shortClicked();
void longClicked();
};
class QElidingLabel : public QLabel class QElidingLabel : public QLabel
{ {
...@@ -166,4 +181,3 @@ int qtWheelEventToVLCKey( QWheelEvent *e ); ...@@ -166,4 +181,3 @@ int qtWheelEventToVLCKey( QWheelEvent *e );
QString VLCKeyToString( unsigned val ); QString VLCKeyToString( unsigned val );
#endif #endif
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