diff --git a/Jamulus.pro b/Jamulus.pro index e46ad40929..6581cf0401 100644 --- a/Jamulus.pro +++ b/Jamulus.pro @@ -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 \ diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 1ff376d794..de1ee36b18 100644 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -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 ); @@ -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 ) diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index ea4fbf59df..0dd10c4398 100644 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -39,10 +39,12 @@ #include #include #include +#include #include "global.h" #include "util.h" #include "levelmeter.h" #include "settings.h" +#include "ui.h" /* Classes ********************************************************************/ class CChannelFader : public QObject @@ -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; diff --git a/src/ui.h b/src/ui.h new file mode 100644 index 0000000000..3b3cfe8187 --- /dev/null +++ b/src/ui.h @@ -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 +#include +#include +#include +#include +#include + +#include +#include +#include + +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 ( event ); + QGesture* gesture = nullptr; + + if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::PanGesture ) ) != nullptr ) + { + emit panGestureSignal ( gestureEvent, static_cast ( gesture ) ); + } + if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::PinchGesture ) ) != nullptr ) + { + emit pinchGestureSignal ( gestureEvent, static_cast ( gesture ) ); + } + if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::SwipeGesture ) ) != nullptr ) + { + emit swipeGestureSignal ( gestureEvent, static_cast ( gesture ) ); + } + if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::TapAndHoldGesture ) ) != nullptr ) + { + emit tapAndHoldGestureSignal ( gestureEvent, static_cast ( gesture ) ); + } + if ( !event->isAccepted() && ( gesture = gestureEvent->gesture ( Qt::TapGesture ) ) != nullptr ) + { + emit tapGestureSignal ( gestureEvent, static_cast ( 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 ); +};