diff --git a/src/analyzerconsole.cpp b/src/analyzerconsole.cpp index 469ac9560a..b0013a77b8 100644 --- a/src/analyzerconsole.cpp +++ b/src/analyzerconsole.cpp @@ -28,7 +28,7 @@ // Analyzer console implementation ********************************************* CAnalyzerConsole::CAnalyzerConsole ( CClient* pNCliP, QWidget* parent ) : - QDialog ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons + CBaseDlg ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons pClient ( pNCliP ), GraphImage ( 1, 1, QImage::Format_RGB32 ), GraphErrRateCanvasRect ( 0, 0, 600, 450 ), // defines total size of graph diff --git a/src/analyzerconsole.h b/src/analyzerconsole.h index f5770da2a4..2d8ce44e95 100644 --- a/src/analyzerconsole.h +++ b/src/analyzerconsole.h @@ -32,6 +32,7 @@ #include #include #include "client.h" +#include "util.h" /* Definitions ****************************************************************/ @@ -40,7 +41,7 @@ /* Classes ********************************************************************/ -class CAnalyzerConsole : public QDialog +class CAnalyzerConsole : public CBaseDlg { Q_OBJECT diff --git a/src/chatdlg.cpp b/src/chatdlg.cpp index 9664794bbc..e9b42a018f 100755 --- a/src/chatdlg.cpp +++ b/src/chatdlg.cpp @@ -27,7 +27,7 @@ /* Implementation *************************************************************/ CChatDlg::CChatDlg ( QWidget* parent ) : - QDialog ( parent, Qt::Window ) // use Qt::Window to get min/max window buttons + CBaseDlg ( parent, Qt::Window ) // use Qt::Window to get min/max window buttons { setupUi ( this ); diff --git a/src/chatdlg.h b/src/chatdlg.h index 8ce46ff4e3..a5e99b8655 100755 --- a/src/chatdlg.h +++ b/src/chatdlg.h @@ -35,11 +35,12 @@ #include #include #include "global.h" +#include "util.h" #include "ui_chatdlgbase.h" /* Classes ********************************************************************/ -class CChatDlg : public QDialog, private Ui_CChatDlgBase +class CChatDlg : public CBaseDlg, private Ui_CChatDlgBase { Q_OBJECT @@ -54,9 +55,6 @@ public slots: void OnClearChatHistory(); void OnAnchorClicked ( const QUrl& Url ); - void keyPressEvent ( QKeyEvent *e ) // block escape key - { if ( e->key() != Qt::Key_Escape ) QDialog::keyPressEvent ( e ); } - signals: void NewLocalInputText ( QString strNewText ); }; diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index df2468cf7f..860310ce32 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -34,7 +34,7 @@ CClientDlg::CClientDlg ( CClient* pNCliP, const bool bShowAnalyzerConsole, const bool bMuteStream, QWidget* parent ) : - QDialog ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons + CBaseDlg ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons pClient ( pNCliP ), pSettings ( pNSetP ), bConnectDlgWasShown ( false ), diff --git a/src/clientdlg.h b/src/clientdlg.h index b58c1e967e..1cbecc8d7e 100755 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -41,6 +41,7 @@ # include #endif #include "global.h" +#include "util.h" #include "client.h" #include "settings.h" #include "multicolorled.h" @@ -69,7 +70,7 @@ /* Classes ********************************************************************/ -class CClientDlg : public QDialog, private Ui_CClientDlgBase +class CClientDlg : public CBaseDlg, private Ui_CClientDlgBase { Q_OBJECT @@ -237,7 +238,4 @@ public slots: void OnNumClientsChanged ( int iNewNumClients ); void accept() { close(); } // introduced by pljones - - void keyPressEvent ( QKeyEvent *e ) // block escape key - { if ( e->key() != Qt::Key_Escape ) QDialog::keyPressEvent ( e ); } }; diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index c697682227..4a740a5254 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -29,7 +29,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSetP, QWidget* parent ) : - QDialog ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons + CBaseDlg ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons pClient ( pNCliP ), pSettings ( pNSetP ) { diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index 78f17b80ed..d6fef72c3b 100755 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -38,6 +38,7 @@ #include #include #include "global.h" +#include "util.h" #include "client.h" #include "settings.h" #include "multicolorled.h" @@ -50,7 +51,7 @@ /* Classes ********************************************************************/ -class CClientSettingsDlg : public QDialog, private Ui_CClientSettingsDlgBase +class CClientSettingsDlg : public CBaseDlg, private Ui_CClientSettingsDlgBase { Q_OBJECT diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index b714f2f8cb..144c21ba6c 100755 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -29,7 +29,7 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteRegList, QWidget* parent ) - : QDialog ( parent, Qt::Dialog ), + : CBaseDlg ( parent, Qt::Dialog ), pSettings ( pNSetP ), strSelectedAddress ( "" ), strSelectedServerName ( "" ), diff --git a/src/connectdlg.h b/src/connectdlg.h index 5c15f3011a..bf4e255dde 100755 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -32,6 +32,7 @@ #include #include #include "global.h" +#include "util.h" #include "settings.h" #include "multicolorled.h" #include "ui_connectdlgbase.h" @@ -44,7 +45,7 @@ /* Classes ********************************************************************/ -class CConnectDlg : public QDialog, private Ui_CConnectDlgBase +class CConnectDlg : public CBaseDlg, private Ui_CConnectDlgBase { Q_OBJECT diff --git a/src/serverdlg.cpp b/src/serverdlg.cpp index 22d86e0a06..d134983c39 100755 --- a/src/serverdlg.cpp +++ b/src/serverdlg.cpp @@ -30,7 +30,7 @@ CServerDlg::CServerDlg ( CServer* pNServP, CServerSettings* pNSetP, const bool bStartMinimized, QWidget* parent ) - : QDialog ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons + : CBaseDlg ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons pServer ( pNServP ), pSettings ( pNSetP ), BitmapSystemTrayInactive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreyArrow.png" ) ), diff --git a/src/serverdlg.h b/src/serverdlg.h index 399b4b98e9..9906bbb1a3 100755 --- a/src/serverdlg.h +++ b/src/serverdlg.h @@ -40,6 +40,7 @@ # include #endif #include "global.h" +#include "util.h" #include "server.h" #include "settings.h" #include "ui_serverdlgbase.h" @@ -57,7 +58,7 @@ /* Classes ********************************************************************/ -class CServerDlg : public QDialog, private Ui_CServerDlgBase +class CServerDlg : public CBaseDlg, private Ui_CServerDlgBase { Q_OBJECT @@ -113,10 +114,6 @@ public slots: void OnSysTrayMenuExit() { close(); } void OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ActReason ); void OnWelcomeMessageChanged() { pServer->SetWelcomeMessage ( tedWelcomeMessage->toPlainText() ); } - - void keyPressEvent ( QKeyEvent *e ) // block escape key - { if ( e->key() != Qt::Key_Escape ) QDialog::keyPressEvent ( e ); } - void OnLanguageChanged ( QString strLanguage ) { pSettings->strLanguage = strLanguage; } void OnNewRecordingClicked() { pServer->RequestNewRecording(); } void OnRecordingDirClicked(); diff --git a/src/util.cpp b/src/util.cpp index 89fd36a0a5..5e9d76f076 100755 --- a/src/util.cpp +++ b/src/util.cpp @@ -398,7 +398,7 @@ void CAudioReverb::Process ( CVector& vecsStereoInOut, \******************************************************************************/ // About dialog ---------------------------------------------------------------- #ifndef HEADLESS -CAboutDlg::CAboutDlg ( QWidget* parent ) : QDialog ( parent ) +CAboutDlg::CAboutDlg ( QWidget* parent ) : CBaseDlg ( parent ) { setupUi ( this ); @@ -512,7 +512,7 @@ CAboutDlg::CAboutDlg ( QWidget* parent ) : QDialog ( parent ) // Licence dialog -------------------------------------------------------------- -CLicenceDlg::CLicenceDlg ( QWidget* parent ) : QDialog ( parent ) +CLicenceDlg::CLicenceDlg ( QWidget* parent ) : CBaseDlg ( parent ) { /* The licence dialog is structured as follows: @@ -555,8 +555,8 @@ CLicenceDlg::CLicenceDlg ( QWidget* parent ) : QDialog ( parent ) // Musician profile dialog ----------------------------------------------------- CMusProfDlg::CMusProfDlg ( CClient* pNCliP, QWidget* parent ) : - QDialog ( parent ), - pClient ( pNCliP ) + CBaseDlg ( parent ), + pClient ( pNCliP ) { /* The musician profile dialog is structured as follows: diff --git a/src/util.h b/src/util.h index d8a7485dc2..00ce811ebe 100755 --- a/src/util.h +++ b/src/util.h @@ -38,6 +38,7 @@ # include # include # include +# include # include "ui_aboutdlgbase.h" #endif #include @@ -368,8 +369,36 @@ template void CMovingAv::Add ( const TData tNewD ) * GUI Utilities * \******************************************************************************/ #ifndef HEADLESS +// Dialog base class ----------------------------------------------------------- +class CBaseDlg : public QDialog +{ + Q_OBJECT + +public: + CBaseDlg ( QWidget* parent = nullptr, + Qt::WindowFlags flags = Qt::WindowFlags() ) : QDialog ( parent, flags ) {} + +public slots: + void keyPressEvent ( QKeyEvent* pEvent ) + { + // block escape key + if ( pEvent->key() != Qt::Key_Escape ) + { +#ifdef ANDROID + if ( pEvent->key() == Qt::Key_Back ) + { + close(); // otherwise, dialog does not show properly again in android (nefarius2001, #832) + return; + } +#endif + QDialog::keyPressEvent ( pEvent ); + } + } +}; + + // About dialog ---------------------------------------------------------------- -class CAboutDlg : public QDialog, private Ui_CAboutDlgBase +class CAboutDlg : public CBaseDlg, private Ui_CAboutDlgBase { Q_OBJECT @@ -379,7 +408,7 @@ class CAboutDlg : public QDialog, private Ui_CAboutDlgBase // Licence dialog -------------------------------------------------------------- -class CLicenceDlg : public QDialog +class CLicenceDlg : public CBaseDlg { Q_OBJECT @@ -395,7 +424,7 @@ public slots: // Musician profile dialog ----------------------------------------------------- -class CMusProfDlg : public QDialog +class CMusProfDlg : public CBaseDlg { Q_OBJECT