added a GUI control to set the server Welcome Message in the server GUI

This commit is contained in:
Volker Fischer 2020-07-09 20:03:09 +02:00
parent 8cd4f5b3e8
commit e7daf34063
6 changed files with 51 additions and 6 deletions

View file

@ -19,9 +19,12 @@
- scale channel instrument picture in Compact skin mode
- redesign of the server dialog
- bug fix: grouping faders in the client should be proportional (see discussion in #202, #419)
TODO store welcome message set in the GUI in the ini file
TODO improve settings management -> move settings class in client/server classes, move actual settings variables
TODO improve interaction between use of inifile and command line parameters (edited) #120

View file

@ -404,7 +404,8 @@ CServer::CServer ( const int iNewMaxNumChan,
// manage welcome message: if the welcome message is a valid link to a local
// file, the content of that file is used as the welcome message (#361)
strWelcomeMessage = strNewWelcomeMessage; // first copy text, may be overwritten
SetWelcomeMessage ( strNewWelcomeMessage ); // first use given text, may be overwritten
if ( QFileInfo ( strNewWelcomeMessage ).exists() )
{
QFile file ( strNewWelcomeMessage );
@ -412,13 +413,10 @@ CServer::CServer ( const int iNewMaxNumChan,
if ( file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
{
// use entire file content for the welcome message
strWelcomeMessage = file.readAll();
SetWelcomeMessage ( file.readAll() );
}
}
// restrict welcome message to maximum allowed length
strWelcomeMessage = strWelcomeMessage.left ( MAX_LEN_CHAT_TEXT );
// enable jam recording (if requested) - kicks off the thread (note
// that jam recorder needs the frame size which is given to the jam
// recorder in the SetRecordingDir() function)
@ -631,6 +629,7 @@ void CServer::OnNewConnection ( int iChID,
vecChannels[iChID].CreateReqChanInfoMes();
// send welcome message (if enabled)
MutexWelcomeMessage.lock();
if ( !strWelcomeMessage.isEmpty() )
{
// create formatted server welcome message and send it just to
@ -640,6 +639,7 @@ void CServer::OnNewConnection ( int iChID,
vecChannels[iChID].CreateChatTextMes ( strWelcomeMessageFormated );
}
MutexWelcomeMessage.unlock();
// send licence request message (if enabled)
if ( eLicenceType != LT_NO_LICENCE )
@ -1554,6 +1554,16 @@ void CServer::SetEnableRecording ( bool bNewEnableRecording )
CreateAndSendRecorderStateForAllConChannels();
}
void CServer::SetWelcomeMessage ( const QString& strNWelcMess )
{
// we need a mutex to secure access
QMutexLocker locker ( &MutexWelcomeMessage );
strWelcomeMessage = strNWelcMess;
// restrict welcome message to maximum allowed length
strWelcomeMessage = strWelcomeMessage.left ( MAX_LEN_CHAT_TEXT );
}
void CServer::StartStatusHTMLFileWriting ( const QString& strNewFileName,
const QString& strNewServerNameWithPort )
{

View file

@ -254,6 +254,9 @@ public:
QLocale::Country GetServerCountry()
{ return ServerListManager.GetServerCountry(); }
void SetWelcomeMessage ( const QString& strNWelcMess );
QString GetWelcomeMessage() { return strWelcomeMessage; }
ESvrRegStatus GetSvrRegStatus() { return ServerListManager.GetSvrRegStatus(); }
@ -323,6 +326,7 @@ protected:
int iMaxNumChannels;
CProtocol ConnLessProtocol;
QMutex Mutex;
QMutex MutexWelcomeMessage;
// audio encoder/decoder
OpusCustomMode* Opus64Mode[MAX_NUM_CHANNELS];

View file

@ -333,6 +333,12 @@ lvwClients->setMinimumHeight ( 140 );
// language combo box (corrects the setting if language not found)
cbxLanguage->Init ( pSettings->strLanguage );
// setup welcome message GUI control
tedWelcomeMessage->setPlaceholderText ( tr (
"Type a message here. If no message is set, the server welcome is disabled." ) );
tedWelcomeMessage->setText ( pServer->GetWelcomeMessage() );
// update GUI dependencies
UpdateGUIDependencies();
@ -415,6 +421,9 @@ lvwClients->setMinimumHeight ( 140 );
this, &CServerDlg::OnTimer );
// other
QObject::connect ( tedWelcomeMessage, &QTextEdit::textChanged,
this, &CServerDlg::OnWelcomeMessageChanged );
QObject::connect ( pServer, &CServer::Started,
this, &CServerDlg::OnServerStarted );

View file

@ -113,6 +113,7 @@ public slots:
void OnSysTrayMenuHide() { hide(); }
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 ); }

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>588</width>
<height>435</height>
<height>560</height>
</rect>
</property>
<property name="windowTitle">
@ -185,6 +185,23 @@
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Chat Window Welcome (HTML/CSS Supported)</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="tedWelcomeMessage">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabOptions">
@ -279,6 +296,7 @@
<tabstop>chbEnableRecorder</tabstop>
<tabstop>edtCurrentSessionDir</tabstop>
<tabstop>pbtNewRecording</tabstop>
<tabstop>tedWelcomeMessage</tabstop>
<tabstop>cbxLanguage</tabstop>
<tabstop>pbtRecordingDir</tabstop>
<tabstop>edtRecordingDir</tabstop>