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 69f19a3
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Jamulus.pro
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ HEADERS += src/buffer.h \
src/testbench.h
}

HEADERS_GUI = src/serverdlg.h
HEADERS_GUI = src/serverdlg.h \
src/ui.h

!contains(CONFIG, "serveronly") {
HEADERS_GUI += src/audiomixerboard.h \
Expand Down
7 changes: 6 additions & 1 deletion src/audiomixerboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CChannelFader::CChannelFader ( QWidget* pNW ) :
pcbSolo = new QCheckBox ( tr ( "Solo" ), pMuteSoloBox );
pcbGroup = new QCheckBox ( "", pMuteSoloBox );

pLabelInstBox = new QGroupBox ( pFrame );
pLabelInstBox = new CGGroupBox ( pFrame );
plblLabel = new QLabel ( "", pFrame );
plblInstrument = new QLabel ( pFrame );
plblCountryFlag = new QLabel ( pFrame );
Expand Down Expand Up @@ -197,6 +197,11 @@ CChannelFader::CChannelFader ( QWidget* pNW ) :
QObject::connect ( pcbSolo, &QCheckBox::stateChanged, this, &CChannelFader::soloStateChanged );

QObject::connect ( pcbGroup, &QCheckBox::stateChanged, this, &CChannelFader::OnGroupStateChanged );

QObject::connect ( pLabelInstBox, &CGGroupBox::tapAndHoldGestureSignal, this, [=] ( QGestureEvent* event, QTapAndHoldGesture* gesture ) {
QToolTip::showText ( gesture->position().toPoint(), plblCountryFlag->toolTip() );
event->accept();
} );
}

void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign )
Expand Down
10 changes: 6 additions & 4 deletions src/audiomixerboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
#include <QMenu>
#include <QMutex>
#include <QTextBoundaryFinder>
#include <QToolTip>
#include "global.h"
#include "util.h"
#include "levelmeter.h"
#include "settings.h"
#include "ui.h"

/* Classes ********************************************************************/
class CChannelFader : public QObject
Expand Down Expand Up @@ -113,10 +115,10 @@ class CChannelFader : public QObject
QCheckBox* pcbGroup;
QMenu* pGroupPopupMenu;

QGroupBox* pLabelInstBox;
QLabel* plblLabel;
QLabel* plblInstrument;
QLabel* plblCountryFlag;
CGGroupBox* pLabelInstBox;
QLabel* plblLabel;
QLabel* plblInstrument;
QLabel* plblCountryFlag;

CChannelInfo cReceivedChanInfo;

Expand Down
100 changes: 100 additions & 0 deletions src/ui.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/******************************************************************************\
* Copyright (c) 2023
*
* Author(s):
* Peter L Jones
*
******************************************************************************
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
\******************************************************************************/
#pragma once

#include <QGesture>
#include <QPanGesture>
#include <QPinchGesture>
#include <QSwipeGesture>
#include <QTapAndHoldGesture>
#include <QTapGesture>

#include <QWidget>
#include <QGroupBox>
#include <QMessageBox>

class CGGroupBox : public QGroupBox
{

Q_OBJECT

public:
CGGroupBox ( QWidget* parent = nullptr ) : QGroupBox ( parent )
{
grabGesture ( Qt::PanGesture );
grabGesture ( Qt::PinchGesture );
grabGesture ( Qt::SwipeGesture );
grabGesture ( Qt::TapAndHoldGesture );
grabGesture ( Qt::TapGesture );
grabGesture ( Qt::CustomGesture );
}

bool event ( QEvent* event )
{
if ( event->type() != QEvent::Gesture )
{
return QGroupBox::event ( event );
}

QMessageBox::information(this, "Jamulus", "CGGroupBox gesture detected");

QGestureEvent* gestureEvent = static_cast<QGestureEvent*> ( event );
QGesture* gesture = nullptr;

if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::PanGesture ) ) != nullptr )
{
emit panGestureSignal ( gestureEvent, static_cast<QPanGesture*> ( gesture ) );
}
if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::PinchGesture ) ) != nullptr )
{
emit pinchGestureSignal ( gestureEvent, static_cast<QPinchGesture*> ( gesture ) );
}
if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::SwipeGesture ) ) != nullptr )
{
emit swipeGestureSignal ( gestureEvent, static_cast<QSwipeGesture*> ( gesture ) );
}
if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::TapAndHoldGesture ) ) != nullptr )
{
emit tapAndHoldGestureSignal ( gestureEvent, static_cast<QTapAndHoldGesture*> ( gesture ) );
}
if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::TapGesture ) ) != nullptr )
{
emit tapGestureSignal ( gestureEvent, static_cast<QTapGesture*> ( gesture ) );
}
if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::CustomGesture ) ) != nullptr )
{
emit customGestureSignal ( gestureEvent, gesture );
}

return event->isAccepted() ? true : QGroupBox::event ( event );
}

signals:
void panGestureSignal ( QGestureEvent* gestureEvent, QPanGesture* gesture );
void pinchGestureSignal ( QGestureEvent* gestureEvent, QPinchGesture* gesture );
void swipeGestureSignal ( QGestureEvent* gestureEvent, QSwipeGesture* gesture );
void tapAndHoldGestureSignal ( QGestureEvent* gestureEvent, QTapAndHoldGesture* gesture );
void tapGestureSignal ( QGestureEvent* gestureEvent, QTapGesture* gesture );
void customGestureSignal ( QGestureEvent* gestureEvent, QGesture* gesture );
};

0 comments on commit 69f19a3

Please sign in to comment.