From 97bb1c88687641c269017f9fd7f0e34a5278c2ea Mon Sep 17 00:00:00 2001 From: Tony Mountifield Date: Tue, 24 Dec 2024 14:57:41 +0000 Subject: [PATCH] Add tooltip event filters controlled by setting --- src/clientdlg.cpp | 16 ++++++++++++++++ src/clientdlg.h | 2 ++ src/clientsettingsdlg.cpp | 22 ++++++++++++++++++++++ src/clientsettingsdlg.h | 2 ++ 4 files changed, 42 insertions(+) diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index cbfa04518d..799749d616 100644 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -84,11 +84,13 @@ CClientDlg::CClientDlg ( CClient* pNCliP, lbrInputLevelL->setAccessibleName ( strInpLevHAccText ); lbrInputLevelL->setAccessibleDescription ( strInpLevHAccDescr ); lbrInputLevelL->setToolTip ( strInpLevHTT ); + lbrInputLevelL->installEventFilter ( this ); // install event filter for tooltips lbrInputLevelL->setEnabled ( false ); lbrInputLevelR->setWhatsThis ( strInpLevH ); lbrInputLevelR->setAccessibleName ( strInpLevHAccText ); lbrInputLevelR->setAccessibleDescription ( strInpLevHAccDescr ); lbrInputLevelR->setToolTip ( strInpLevHTT ); + lbrInputLevelR->installEventFilter ( this ); // install event filter for tooltips lbrInputLevelR->setEnabled ( false ); // connect/disconnect button @@ -153,6 +155,7 @@ CClientDlg::CClientDlg ( CClient* pNCliP, "you will not have much fun using %1." ) .arg ( APP_NAME ) + TOOLTIP_COM_END_TEXT ); + ledDelay->installEventFilter ( this ); // install event filter for tooltips ledDelay->setAccessibleName ( tr ( "Delay status LED indicator" ) ); @@ -184,6 +187,7 @@ CClientDlg::CClientDlg ( CClient* pNCliP, ledBuffers->setToolTip ( tr ( "If this LED indicator turns red, " "the audio stream is interrupted." ) + TOOLTIP_COM_END_TEXT ); + ledBuffers->installEventFilter ( this ); // install event filter for tooltips ledBuffers->setAccessibleName ( tr ( "Local Jitter Buffer status LED indicator" ) ); @@ -1516,3 +1520,15 @@ void CClientDlg::SetPingTime ( const int iPingTime, const int iOverallDelayMs, c // set current LED status ledDelay->SetLight ( eOverallDelayLEDColor ); } + +bool CClientDlg::eventFilter ( QObject* obj, QEvent* event ) +{ + if ( event->type() == QEvent::ToolTip ) + { + // return true to suppress tooltip, false to allow it + return !pSettings->bShowToolTips; + } + + // continue with normal processing for other events + return QObject::eventFilter ( obj, event ); +} diff --git a/src/clientdlg.h b/src/clientdlg.h index 2a9062a58d..ba67ba6664 100644 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -121,6 +121,8 @@ class CClientDlg : public CBaseDlg, private Ui_CClientDlgBase virtual void dropEvent ( QDropEvent* Event ) { ManageDragNDrop ( Event, false ); } void UpdateDisplay(); + bool eventFilter ( QObject* obj, QEvent* event ); + CClientSettingsDlg ClientSettingsDlg; CChatDlg ChatDlg; CConnectDlg ConnectDlg; diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index 1fb4c0813e..a043e830c2 100644 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -106,16 +106,21 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet lblNetBuf->setWhatsThis ( strJitterBufferSize ); lblNetBuf->setToolTip ( strJitterBufferSizeTT ); + lblNetBuf->installEventFilter ( this ); // install event filter for tooltips grbJitterBuffer->setWhatsThis ( strJitterBufferSize ); grbJitterBuffer->setToolTip ( strJitterBufferSizeTT ); + grbJitterBuffer->installEventFilter ( this ); // install event filter for tooltips sldNetBuf->setWhatsThis ( strJitterBufferSize ); sldNetBuf->setAccessibleName ( tr ( "Local jitter buffer slider control" ) ); sldNetBuf->setToolTip ( strJitterBufferSizeTT ); + sldNetBuf->installEventFilter ( this ); // install event filter for tooltips sldNetBufServer->setWhatsThis ( strJitterBufferSize ); sldNetBufServer->setAccessibleName ( tr ( "Server jitter buffer slider control" ) ); sldNetBufServer->setToolTip ( strJitterBufferSizeTT ); + sldNetBufServer->installEventFilter ( this ); // install event filter for tooltips chbAutoJitBuf->setAccessibleName ( tr ( "Auto jitter buffer check box" ) ); chbAutoJitBuf->setToolTip ( strJitterBufferSizeTT ); + chbAutoJitBuf->installEventFilter ( this ); // install event filter for tooltips #if !defined( WITH_JACK ) // sound card device @@ -143,6 +148,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet "driver, make sure to connect the ASIO inputs in the kX DSP settings " "panel." ) + TOOLTIP_COM_END_TEXT ); + cbxSoundcard->installEventFilter ( this ); // install event filter for tooltips # endif // sound card input/output channel mapping @@ -249,17 +255,21 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet rbtBufferDelayPreferred->setWhatsThis ( strSndCrdBufDelay ); rbtBufferDelayPreferred->setAccessibleName ( tr ( "64 samples setting radio button" ) ); rbtBufferDelayPreferred->setToolTip ( strSndCrdBufDelayTT ); + rbtBufferDelayPreferred->installEventFilter ( this ); // install event filter for tooltips rbtBufferDelayDefault->setWhatsThis ( strSndCrdBufDelay ); rbtBufferDelayDefault->setAccessibleName ( tr ( "128 samples setting radio button" ) ); rbtBufferDelayDefault->setToolTip ( strSndCrdBufDelayTT ); + rbtBufferDelayDefault->installEventFilter ( this ); // install event filter for tooltips rbtBufferDelaySafe->setWhatsThis ( strSndCrdBufDelay ); rbtBufferDelaySafe->setAccessibleName ( tr ( "256 samples setting radio button" ) ); rbtBufferDelaySafe->setToolTip ( strSndCrdBufDelayTT ); + rbtBufferDelaySafe->installEventFilter ( this ); // install event filter for tooltips #if defined( _WIN32 ) && !defined( WITH_JACK ) butDriverSetup->setWhatsThis ( strSndCardDriverSetup ); butDriverSetup->setAccessibleName ( tr ( "ASIO Device Settings push button" ) ); butDriverSetup->setToolTip ( strSndCardDriverSetupTT ); + butDriverSetup->installEventFilter ( this ); // install event filter for tooltips #endif // fancy skin @@ -1228,3 +1238,15 @@ void CClientSettingsDlg::OnAudioPanValueChanged ( int value ) pClient->SetAudioInFader ( value ); UpdateAudioFaderSlider(); } + +bool CClientSettingsDlg::eventFilter ( QObject* obj, QEvent* event ) +{ + if ( event->type() == QEvent::ToolTip ) + { + // return true to suppress tooltip, false to allow it + return !pSettings->bShowToolTips; + } + + // continue with normal processing for other events + return QObject::eventFilter ( obj, event ); +} diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index 1855784069..e310bab803 100644 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -71,6 +71,8 @@ class CClientSettingsDlg : public CBaseDlg, private Ui_CClientSettingsDlgBase virtual void showEvent ( QShowEvent* ); + bool eventFilter ( QObject* obj, QEvent* event ); + CClient* pClient; CClientSettings* pSettings; QTimer TimerStatus;