Skip to content

Commit 184668f

Browse files
committed
Fixes: jamulussoftware#3145 Support tap-hold for Musician Profile
1 parent e4ff7e4 commit 184668f

File tree

4 files changed

+114
-6
lines changed

4 files changed

+114
-6
lines changed

Jamulus.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ HEADERS += src/plugins/audioreverb.h \
408408
src/testbench.h
409409
}
410410

411-
HEADERS_GUI = src/serverdlg.h
411+
HEADERS_GUI = src/serverdlg.h \
412+
src/ui.h
412413

413414
!contains(CONFIG, "serveronly") {
414415
HEADERS_GUI += src/audiomixerboard.h \

src/audiomixerboard.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ CChannelFader::CChannelFader ( QWidget* pNW ) :
4949
pcbSolo = new QCheckBox ( tr ( "Solo" ), pMuteSoloBox );
5050
pcbGroup = new QCheckBox ( "", pMuteSoloBox );
5151

52-
pLabelInstBox = new QGroupBox ( pFrame );
52+
pLabelInstBox = new CGGroupBox ( pFrame );
5353
plblLabel = new QLabel ( "", pFrame );
5454
plblInstrument = new QLabel ( pFrame );
5555
plblCountryFlag = new QLabel ( pFrame );
@@ -197,6 +197,11 @@ CChannelFader::CChannelFader ( QWidget* pNW ) :
197197
QObject::connect ( pcbSolo, &QCheckBox::stateChanged, this, &CChannelFader::soloStateChanged );
198198

199199
QObject::connect ( pcbGroup, &QCheckBox::stateChanged, this, &CChannelFader::OnGroupStateChanged );
200+
201+
QObject::connect ( pLabelInstBox, &CGGroupBox::tapAndHoldGestureSignal, this, [=] ( QGestureEvent* event, QTapAndHoldGesture* gesture ) {
202+
QToolTip::showText ( gesture->position().toPoint(), plblCountryFlag->toolTip() );
203+
event->accept();
204+
} );
200205
}
201206

202207
void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign )

src/audiomixerboard.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@
3939
#include <QMenu>
4040
#include <QMutex>
4141
#include <QTextBoundaryFinder>
42+
#include <QToolTip>
4243
#include "global.h"
4344
#include "util.h"
4445
#include "levelmeter.h"
4546
#include "settings.h"
47+
#include "ui.h"
4648

4749
/* Classes ********************************************************************/
4850
class CChannelFader : public QObject
@@ -114,10 +116,10 @@ class CChannelFader : public QObject
114116
QCheckBox* pcbGroup;
115117
QMenu* pGroupPopupMenu;
116118

117-
QGroupBox* pLabelInstBox;
118-
QLabel* plblLabel;
119-
QLabel* plblInstrument;
120-
QLabel* plblCountryFlag;
119+
CGGroupBox* pLabelInstBox;
120+
QLabel* plblLabel;
121+
QLabel* plblInstrument;
122+
QLabel* plblCountryFlag;
121123

122124
CChannelInfo cReceivedChanInfo;
123125

src/ui.h

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/******************************************************************************\
2+
* Copyright (c) 2023
3+
*
4+
* Author(s):
5+
* Peter L Jones
6+
*
7+
******************************************************************************
8+
*
9+
* This program is free software; you can redistribute it and/or modify it under
10+
* the terms of the GNU General Public License as published by the Free Software
11+
* Foundation; either version 2 of the License, or (at your option) any later
12+
* version.
13+
*
14+
* This program is distributed in the hope that it will be useful, but WITHOUT
15+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17+
* details.
18+
*
19+
* You should have received a copy of the GNU General Public License along with
20+
* this program; if not, write to the Free Software Foundation, Inc.,
21+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22+
*
23+
\******************************************************************************/
24+
#pragma once
25+
26+
#include <QGesture>
27+
#include <QPanGesture>
28+
#include <QPinchGesture>
29+
#include <QSwipeGesture>
30+
#include <QTapAndHoldGesture>
31+
#include <QTapGesture>
32+
33+
#include <QWidget>
34+
#include <QGroupBox>
35+
#include <QMessageBox>
36+
37+
class CGGroupBox : public QGroupBox
38+
{
39+
40+
Q_OBJECT
41+
42+
public:
43+
CGGroupBox ( QWidget* parent = nullptr ) : QGroupBox ( parent )
44+
{
45+
grabGesture ( Qt::PanGesture );
46+
grabGesture ( Qt::PinchGesture );
47+
grabGesture ( Qt::SwipeGesture );
48+
grabGesture ( Qt::TapAndHoldGesture );
49+
grabGesture ( Qt::TapGesture );
50+
grabGesture ( Qt::CustomGesture );
51+
}
52+
53+
bool event ( QEvent* event )
54+
{
55+
if ( event->type() != QEvent::Gesture )
56+
{
57+
return QGroupBox::event ( event );
58+
}
59+
60+
QMessageBox::information(this, "Jamulus", "CGGroupBox gesture detected");
61+
62+
QGestureEvent* gestureEvent = static_cast<QGestureEvent*> ( event );
63+
QGesture* gesture = nullptr;
64+
65+
if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::PanGesture ) ) != nullptr )
66+
{
67+
emit panGestureSignal ( gestureEvent, static_cast<QPanGesture*> ( gesture ) );
68+
}
69+
if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::PinchGesture ) ) != nullptr )
70+
{
71+
emit pinchGestureSignal ( gestureEvent, static_cast<QPinchGesture*> ( gesture ) );
72+
}
73+
if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::SwipeGesture ) ) != nullptr )
74+
{
75+
emit swipeGestureSignal ( gestureEvent, static_cast<QSwipeGesture*> ( gesture ) );
76+
}
77+
if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::TapAndHoldGesture ) ) != nullptr )
78+
{
79+
emit tapAndHoldGestureSignal ( gestureEvent, static_cast<QTapAndHoldGesture*> ( gesture ) );
80+
}
81+
if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::TapGesture ) ) != nullptr )
82+
{
83+
emit tapGestureSignal ( gestureEvent, static_cast<QTapGesture*> ( gesture ) );
84+
}
85+
if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::CustomGesture ) ) != nullptr )
86+
{
87+
emit customGestureSignal ( gestureEvent, gesture );
88+
}
89+
90+
return event->isAccepted() ? true : QGroupBox::event ( event );
91+
}
92+
93+
signals:
94+
void panGestureSignal ( QGestureEvent* gestureEvent, QPanGesture* gesture );
95+
void pinchGestureSignal ( QGestureEvent* gestureEvent, QPinchGesture* gesture );
96+
void swipeGestureSignal ( QGestureEvent* gestureEvent, QSwipeGesture* gesture );
97+
void tapAndHoldGestureSignal ( QGestureEvent* gestureEvent, QTapAndHoldGesture* gesture );
98+
void tapGestureSignal ( QGestureEvent* gestureEvent, QTapGesture* gesture );
99+
void customGestureSignal ( QGestureEvent* gestureEvent, QGesture* gesture );
100+
};

0 commit comments

Comments
 (0)