From 0f8d15f34397433bb31f67f3d5ac3f77ee69a2e5 Mon Sep 17 00:00:00 2001 From: Peter L Jones Date: Fri, 15 May 2020 22:04:55 +0100 Subject: [PATCH 1/3] Initial Recording GUI Issue #228. Display the recorder state and latest recording directory and allow a new recording to be requested. --- src/recorder/jamrecorder.cpp | 4 +- src/recorder/jamrecorder.h | 2 +- src/server.cpp | 4 ++ src/server.h | 7 ++++ src/serverdlg.cpp | 76 ++++++++++++++++++++++++++++++++++++ src/serverdlg.h | 11 +++++- src/serverdlgbase.ui | 71 +++++++++++++++++++++++++++++++++ 7 files changed, 170 insertions(+), 5 deletions(-) diff --git a/src/recorder/jamrecorder.cpp b/src/recorder/jamrecorder.cpp index ea79a57b..0fe05134 100755 --- a/src/recorder/jamrecorder.cpp +++ b/src/recorder/jamrecorder.cpp @@ -357,6 +357,8 @@ void CJamRecorder::Start() { currentSession = new CJamSession( recordBaseDir ); isRecording = true; + + emit RecordingSessionStarted ( currentSession->SessionDir().path() ); } @@ -402,8 +404,6 @@ void CJamRecorder::OnEnd() delete currentSession; currentSession = nullptr; } - - emit RecordingSessionEnded ( reaperProjectFileName ); } /** diff --git a/src/recorder/jamrecorder.h b/src/recorder/jamrecorder.h index 7ebbbe54..3713162a 100755 --- a/src/recorder/jamrecorder.h +++ b/src/recorder/jamrecorder.h @@ -169,7 +169,7 @@ private: QThread* thisThread; signals: - void RecordingSessionEnded ( QString sessionDir ); + void RecordingSessionStarted ( QString sessionDir ); private slots: /** diff --git a/src/server.cpp b/src/server.cpp index ae10d6b2..f9849530 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -468,6 +468,10 @@ CServer::CServer ( const int iNewMaxNumChan, SIGNAL ( SvrRegStatusChanged() ), this, SLOT ( OnSvrRegStatusChanged() ) ); + QObject::connect( &JamRecorder, + SIGNAL ( RecordingSessionStarted ( QString ) ), + this, SLOT ( OnRecordingSessionStarted ( QString ) ) ); + QObject::connect ( QCoreApplication::instance(), SIGNAL ( aboutToQuit() ), this, SLOT ( OnAboutToQuit() ) ); diff --git a/src/server.h b/src/server.h index 47ee5d04..49a45a25 100755 --- a/src/server.h +++ b/src/server.h @@ -197,6 +197,7 @@ public: CVector& veciJitBufNumFrames, CVector& veciNetwFrameSizeFact ); + bool GetRecordingEnabled() { return bEnableRecording; } // Server list management -------------------------------------------------- void UpdateServerList() { ServerListManager.Update(); } @@ -382,6 +383,7 @@ signals: const int iNumAudChan, const CVector vecsData ); void RestartRecorder(); + void RecordingSessionStarted ( QString sessionDir ); public slots: void OnTimer(); @@ -457,6 +459,11 @@ public slots: void OnCLDisconnection ( CHostAddress InetAddr ); + void OnRecordingSessionStarted ( QString sessionDir ) + { + emit RecordingSessionStarted ( sessionDir ); + } + void OnAboutToQuit(); void OnHandledSignal ( int sigNum ); diff --git a/src/serverdlg.cpp b/src/serverdlg.cpp index 7586bbf9..7dcd9d02 100755 --- a/src/serverdlg.cpp +++ b/src/serverdlg.cpp @@ -267,6 +267,22 @@ lvwClients->setMinimumHeight ( 140 ); ModifyAutoStartEntry ( bCurAutoStartMinState ); #endif + // Recorder controls + pbtNewRecording->setAutoDefault ( false ); + + if ( !pServer->GetRecordingEnabled() ) + { + // The recorder was not enabled from the command line + // TODO: Once enabling from the GUI is implemented, remove + lblRecorderStatus->setVisible ( false ); + pbtNewRecording->setVisible ( false ); + } + + // TODO: Not yet implemented, so hide them! + chbEnableRecorder->setVisible ( false ); + pbtRecordingDir->setVisible ( false ); + edtRecordingsDir->setVisible ( false ); + // update GUI dependencies UpdateGUIDependencies(); @@ -319,6 +335,10 @@ lvwClients->setMinimumHeight ( 140 ); QObject::connect ( cbxCentServAddrType, SIGNAL ( activated ( int ) ), this, SLOT ( OnCentServAddrTypeActivated ( int ) ) ); + // push buttons + QObject::connect( pbtNewRecording, SIGNAL ( released() ), + this, SLOT ( OnNewRecordingClicked() ) ); + // timers QObject::connect ( &Timer, SIGNAL ( timeout() ), this, SLOT ( OnTimer() ) ); @@ -332,6 +352,9 @@ lvwClients->setMinimumHeight ( 140 ); QObject::connect ( pServer, SIGNAL ( SvrRegStatusChanged() ), this, SLOT ( OnSvrRegStatusChanged() ) ); + QObject::connect ( pServer, SIGNAL ( RecordingSessionStarted ( QString ) ), + this, SLOT ( OnRecordingSessionStarted ( QString ) ) ); + QObject::connect ( QCoreApplication::instance(), SIGNAL ( aboutToQuit() ), this, SLOT ( OnAboutToQuit() ) ); @@ -451,6 +474,11 @@ void CServerDlg::OnCentServAddrTypeActivated ( int iTypeIdx ) UpdateGUIDependencies(); } +void CServerDlg::OnNewRecordingClicked() +{ + pServer->RestartRecorder(); +} + void CServerDlg::OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ActReason ) { // on double click on the icon, show window in fore ground @@ -504,6 +532,18 @@ void CServerDlg::OnTimer() ListViewMutex.unlock(); } +void CServerDlg::OnServerStarted() +{ + UpdateSystemTrayIcon ( true ); +} + +void CServerDlg::OnServerStopped() +{ + UpdateSystemTrayIcon ( false ); + + UpdateRecorderStatus ( QString::null ); +} + void CServerDlg::UpdateGUIDependencies() { // get the states which define the GUI dependencies from the server @@ -560,6 +600,9 @@ void CServerDlg::UpdateGUIDependencies() } lblRegSvrStatus->setText ( strStatus ); + + edtCurrentSessionDir->setText( "" ); + UpdateRecorderStatus ( QString::null ); } void CServerDlg::UpdateSystemTrayIcon ( const bool bIsActive ) @@ -618,6 +661,39 @@ void CServerDlg::ModifyAutoStartEntry ( const bool bDoAutoStart ) } } +void CServerDlg::UpdateRecorderStatus ( QString sessionDir ) +{ + QString currentSessionDir = edtCurrentSessionDir->text(); + QString strRecorderStatus; + bool bIsRecording = false; + + if ( pServer->GetRecordingEnabled() ) + { + if ( pServer->IsRunning() ) + { + currentSessionDir = sessionDir != QString::null ? sessionDir : ""; + strRecorderStatus = tr ( "Recording" ); + bIsRecording = true; + } + else + { + strRecorderStatus = tr ( "Not recording" ); + } + } + else + { + strRecorderStatus = tr ( "Not enabled" ); + } + + edtCurrentSessionDir->setVisible ( pServer->GetRecordingEnabled() ); + edtCurrentSessionDir->setEnabled ( bIsRecording ); + edtCurrentSessionDir->setText( currentSessionDir ); + + lblRecorderStatus->setText ( strRecorderStatus ); + + pbtNewRecording->setEnabled ( bIsRecording ); +} + void CServerDlg::changeEvent ( QEvent* pEvent ) { // if we have a system tray icon, we make the window invisible if it is diff --git a/src/serverdlg.h b/src/serverdlg.h index da06e0c4..dbfc9f3d 100755 --- a/src/serverdlg.h +++ b/src/serverdlg.h @@ -63,6 +63,7 @@ protected: void UpdateSystemTrayIcon ( const bool bIsActive ); void ShowWindowInForeground() { showNormal(); raise(); } void ModifyAutoStartEntry ( const bool bDoAutoStart ); + void UpdateRecorderStatus( QString sessionDir ); QTimer Timer; CServer* pServer; @@ -90,9 +91,10 @@ public slots: void OnLocationCityTextChanged ( const QString& strNewCity ); void OnLocationCountryActivated ( int iCntryListItem ); void OnCentServAddrTypeActivated ( int iTypeIdx ); + void OnNewRecordingClicked(); void OnTimer(); - void OnServerStarted() { UpdateSystemTrayIcon ( true ); } - void OnServerStopped() { UpdateSystemTrayIcon ( false ); } + void OnServerStarted(); + void OnServerStopped(); void OnSvrRegStatusChanged() { UpdateGUIDependencies(); } void OnSysTrayMenuOpen() { ShowWindowInForeground(); } void OnSysTrayMenuHide() { hide(); } @@ -101,4 +103,9 @@ public slots: void keyPressEvent ( QKeyEvent *e ) // block escape key { if ( e->key() != Qt::Key_Escape ) QDialog::keyPressEvent ( e ); } + + void OnRecordingSessionStarted ( QString sessionDir ) + { + UpdateRecorderStatus ( sessionDir ); + } }; diff --git a/src/serverdlgbase.ui b/src/serverdlgbase.ui index 3e336347..6e55a0ed 100755 --- a/src/serverdlgbase.ui +++ b/src/serverdlgbase.ui @@ -158,6 +158,72 @@ + + + + + + Enable jam recorder + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + true + + + + + + + STATUS + + + + + + + New recording + + + + + + + + + + + Recordings folder + + + + + + + true + + + + + @@ -215,6 +281,11 @@ edtServerName edtLocationCity cbxLocationCountry + chbEnableRecorder + edtCurrentSessionDir + pbtNewRecording + pbtRecordingDir + edtRecordingsDir From 7977413bb6aa8bc129ca0f8ab094f5ea9024c9fc Mon Sep 17 00:00:00 2001 From: Peter L Jones Date: Mon, 25 May 2020 18:47:14 +0100 Subject: [PATCH 2/3] Review comment changes --- src/server.cpp | 2 +- src/server.h | 5 ----- src/serverdlg.cpp | 20 ++------------------ src/serverdlg.h | 16 +++++++++++++--- 4 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/server.cpp b/src/server.cpp index f9849530..3901fbb4 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -470,7 +470,7 @@ CServer::CServer ( const int iNewMaxNumChan, QObject::connect( &JamRecorder, SIGNAL ( RecordingSessionStarted ( QString ) ), - this, SLOT ( OnRecordingSessionStarted ( QString ) ) ); + SIGNAL ( RecordingSessionStarted ( QString ) ) ); QObject::connect ( QCoreApplication::instance(), SIGNAL ( aboutToQuit() ), diff --git a/src/server.h b/src/server.h index 49a45a25..241fe119 100755 --- a/src/server.h +++ b/src/server.h @@ -459,11 +459,6 @@ public slots: void OnCLDisconnection ( CHostAddress InetAddr ); - void OnRecordingSessionStarted ( QString sessionDir ) - { - emit RecordingSessionStarted ( sessionDir ); - } - void OnAboutToQuit(); void OnHandledSignal ( int sigNum ); diff --git a/src/serverdlg.cpp b/src/serverdlg.cpp index 7dcd9d02..48895317 100755 --- a/src/serverdlg.cpp +++ b/src/serverdlg.cpp @@ -336,8 +336,8 @@ lvwClients->setMinimumHeight ( 140 ); this, SLOT ( OnCentServAddrTypeActivated ( int ) ) ); // push buttons - QObject::connect( pbtNewRecording, SIGNAL ( released() ), - this, SLOT ( OnNewRecordingClicked() ) ); + QObject::connect ( pbtNewRecording, SIGNAL ( released() ), + this, SLOT ( OnNewRecordingClicked() ) ); // timers QObject::connect ( &Timer, SIGNAL ( timeout() ), this, SLOT ( OnTimer() ) ); @@ -474,11 +474,6 @@ void CServerDlg::OnCentServAddrTypeActivated ( int iTypeIdx ) UpdateGUIDependencies(); } -void CServerDlg::OnNewRecordingClicked() -{ - pServer->RestartRecorder(); -} - void CServerDlg::OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ActReason ) { // on double click on the icon, show window in fore ground @@ -532,17 +527,6 @@ void CServerDlg::OnTimer() ListViewMutex.unlock(); } -void CServerDlg::OnServerStarted() -{ - UpdateSystemTrayIcon ( true ); -} - -void CServerDlg::OnServerStopped() -{ - UpdateSystemTrayIcon ( false ); - - UpdateRecorderStatus ( QString::null ); -} void CServerDlg::UpdateGUIDependencies() { diff --git a/src/serverdlg.h b/src/serverdlg.h index dbfc9f3d..55600744 100755 --- a/src/serverdlg.h +++ b/src/serverdlg.h @@ -91,10 +91,15 @@ public slots: void OnLocationCityTextChanged ( const QString& strNewCity ); void OnLocationCountryActivated ( int iCntryListItem ); void OnCentServAddrTypeActivated ( int iTypeIdx ); - void OnNewRecordingClicked(); void OnTimer(); - void OnServerStarted(); - void OnServerStopped(); + + void OnServerStarted() { UpdateSystemTrayIcon ( true ); } + void OnServerStopped() + { + UpdateSystemTrayIcon ( false ); + UpdateRecorderStatus ( QString::null ); + } + void OnSvrRegStatusChanged() { UpdateGUIDependencies(); } void OnSysTrayMenuOpen() { ShowWindowInForeground(); } void OnSysTrayMenuHide() { hide(); } @@ -104,6 +109,11 @@ public slots: void keyPressEvent ( QKeyEvent *e ) // block escape key { if ( e->key() != Qt::Key_Escape ) QDialog::keyPressEvent ( e ); } + void OnNewRecordingClicked(); + { + pServer->RestartRecorder(); + } + void OnRecordingSessionStarted ( QString sessionDir ) { UpdateRecorderStatus ( sessionDir ); From 62c4fbfb775034ac120d013ad9120b3dcabeff31 Mon Sep 17 00:00:00 2001 From: Peter L Jones Date: Mon, 25 May 2020 21:55:45 +0100 Subject: [PATCH 3/3] Further review comments --- ChangeLog | 2 ++ src/serverdlg.cpp | 6 ++++++ src/serverdlg.h | 18 +++--------------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9ed3e4f..91855ad6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ - faster update of musicians list in the server list table +- display recorder state and latest recording directory, + allow a new recording to be requested, by pljones (#228) diff --git a/src/serverdlg.cpp b/src/serverdlg.cpp index 48895317..0f967d52 100755 --- a/src/serverdlg.cpp +++ b/src/serverdlg.cpp @@ -474,6 +474,12 @@ void CServerDlg::OnCentServAddrTypeActivated ( int iTypeIdx ) UpdateGUIDependencies(); } +void CServerDlg::OnServerStopped(); +{ + UpdateSystemTrayIcon ( false ); + UpdateRecorderStatus ( QString::null ); +} + void CServerDlg::OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ActReason ) { // on double click on the icon, show window in fore ground diff --git a/src/serverdlg.h b/src/serverdlg.h index 55600744..ef80c8e4 100755 --- a/src/serverdlg.h +++ b/src/serverdlg.h @@ -92,14 +92,8 @@ public slots: void OnLocationCountryActivated ( int iCntryListItem ); void OnCentServAddrTypeActivated ( int iTypeIdx ); void OnTimer(); - void OnServerStarted() { UpdateSystemTrayIcon ( true ); } - void OnServerStopped() - { - UpdateSystemTrayIcon ( false ); - UpdateRecorderStatus ( QString::null ); - } - + void OnServerStopped(); void OnSvrRegStatusChanged() { UpdateGUIDependencies(); } void OnSysTrayMenuOpen() { ShowWindowInForeground(); } void OnSysTrayMenuHide() { hide(); } @@ -109,13 +103,7 @@ public slots: void keyPressEvent ( QKeyEvent *e ) // block escape key { if ( e->key() != Qt::Key_Escape ) QDialog::keyPressEvent ( e ); } - void OnNewRecordingClicked(); - { - pServer->RestartRecorder(); - } - + void OnNewRecordingClicked(); { pServer->RestartRecorder(); } void OnRecordingSessionStarted ( QString sessionDir ) - { - UpdateRecorderStatus ( sessionDir ); - } + { UpdateRecorderStatus ( sessionDir ); } };