Skip to content

Commit

Permalink
Fixes: jamulussoftware#3145 Support tap-hold for Musician Profile
Browse files Browse the repository at this point in the history
  • Loading branch information
pljones committed Aug 4, 2024
1 parent bd117d9 commit 325dceb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/audiomixerboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,16 +865,42 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo )

plblCountryFlag->setToolTip ( strToolTip );
plblCountryFlag->setAccessibleDescription ( strLocationAccessible );

plblInstrument->setToolTip ( strToolTip );
plblInstrument->setAccessibleDescription ( strInstrumentAccessible );

plblLabel->setToolTip ( strToolTip );
plblLabel->setAccessibleName ( strAliasAccessible );
plblLabel->setAccessibleDescription ( tr ( "Alias" ) );

QFrame* pFrame = dynamic_cast<QFrame*> ( plblLabel->parent() );

pFrame->setToolTip ( strToolTip );
pFrame->setAccessibleName ( strAliasAccessible + ", " + strInstrumentAccessible + ", " + strLocationAccessible );

CChannelFaderTapAndHoldGestureEventFilter* filter = new CChannelFaderTapAndHoldGestureEventFilter();
pFrame->installEventFilter ( filter );
pFrame->grabGesture ( Qt::TapAndHoldGesture, Qt::GestureFlag::DontStartGestureOnChildren | Qt::GestureFlag::IgnoredGesturesPropagateToParent );

pcbMute->setAccessibleName ( "Mute " + strAliasAccessible + ", " + strInstrumentAccessible );
pcbSolo->setAccessibleName ( "Solo " + strAliasAccessible + ", " + strInstrumentAccessible );
pcbGroup->setAccessibleName ( "Group " + strAliasAccessible + ", " + strInstrumentAccessible );
dynamic_cast<QWidget*> ( plblLabel->parent() )
->setAccessibleName ( strAliasAccessible + ", " + strInstrumentAccessible + ", " + strLocationAccessible );
}

bool CChannelFaderTapAndHoldGestureEventFilter::eventFilter ( QObject* obj, QEvent* event )
{
if ( obj->isWidgetType() && event->type() == QEvent::Gesture && !event->isAccepted() )
{
QGesture* gesture = ( static_cast<QGestureEvent*> ( event ) )->gesture ( Qt::TapAndHoldGesture );

if ( gesture != nullptr && gesture->state() == Qt::GestureFinished )
{
QToolTip::showText ( gesture->hotSpot().toPoint(), ( static_cast<QFrame*> ( obj ) )->toolTip() );

return true;
}
}
return QObject::eventFilter ( obj, event );
}

/******************************************************************************\
Expand Down
9 changes: 9 additions & 0 deletions src/audiomixerboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include <QMenu>
#include <QMutex>
#include <QTextBoundaryFinder>
#include <QGestureEvent>
#include <QToolTip>
#include "global.h"
#include "util.h"
#include "levelmeter.h"
Expand Down Expand Up @@ -154,6 +156,13 @@ public slots:
void soloStateChanged ( int value );
};

class CChannelFaderTapAndHoldGestureEventFilter : public QObject
{
Q_OBJECT
protected:
bool eventFilter ( QObject* obj, QEvent* event ) override;
};

template<unsigned int slotId>
class CAudioMixerBoardSlots : public CAudioMixerBoardSlots<slotId - 1>
{
Expand Down

0 comments on commit 325dceb

Please sign in to comment.