2011-05-21 14:33:11 +02:00
|
|
|
/******************************************************************************\
|
2020-01-01 15:41:43 +01:00
|
|
|
* Copyright (c) 2004-2020
|
2011-05-21 14:33:11 +02:00
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Volker Fischer
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2013-03-24 11:49:25 +01:00
|
|
|
#include "serverdlg.h"
|
2011-05-21 14:33:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Implementation *************************************************************/
|
2013-03-24 16:42:23 +01:00
|
|
|
CServerDlg::CServerDlg ( CServer* pNServP,
|
|
|
|
CSettings* pNSetP,
|
|
|
|
const bool bStartMinimized,
|
|
|
|
QWidget* parent,
|
|
|
|
Qt::WindowFlags f )
|
2011-05-21 14:33:11 +02:00
|
|
|
: QDialog ( parent, f ),
|
|
|
|
pServer ( pNServP ),
|
2011-05-21 19:06:30 +02:00
|
|
|
pSettings ( pNSetP ),
|
2011-05-21 14:33:11 +02:00
|
|
|
BitmapSystemTrayInactive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreyArrow.png" ) ),
|
|
|
|
BitmapSystemTrayActive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenArrow.png" ) )
|
|
|
|
{
|
|
|
|
setupUi ( this );
|
|
|
|
|
|
|
|
|
|
|
|
// Add help text to controls -----------------------------------------------
|
|
|
|
// client list
|
2020-05-07 09:08:23 +02:00
|
|
|
lvwClients->setWhatsThis ( "<b>" + tr ( "Client List" ) + ":</b> " + tr (
|
|
|
|
"The client list shows all clients which are currently connected to this "
|
|
|
|
"server. Some information about the clients like the IP address and name "
|
|
|
|
"are given for each connected client." ) );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
|
|
|
lvwClients->setAccessibleName ( tr ( "Connected clients list view" ) );
|
|
|
|
|
|
|
|
// start minimized on operating system start
|
2020-05-07 09:08:23 +02:00
|
|
|
chbStartOnOSStart->setWhatsThis ( "<b>" + tr ( "Start Minimized on Operating "
|
|
|
|
"System Start" ) + ":</b> " + tr ( "If the start minimized on operating system start "
|
2020-06-04 17:51:32 +02:00
|
|
|
"check box is checked, the server will be "
|
2011-05-21 14:33:11 +02:00
|
|
|
"started when the operating system starts up and is automatically "
|
|
|
|
"minimized to a system task bar icon." ) );
|
|
|
|
|
2020-04-08 15:30:32 +02:00
|
|
|
// CC licence dialog switch
|
2020-05-07 09:08:23 +02:00
|
|
|
chbUseCCLicence->setWhatsThis ( "<b>" + tr ( "Show Creative Commons Licence "
|
|
|
|
"Dialog" ) + ":</b> " + tr ( "If enabled, a Creative Commons BY-NC-SA 4.0 Licence "
|
2020-04-21 14:14:20 +02:00
|
|
|
"dialog is shown each time a new user connects the server." ) );
|
2020-04-08 15:30:32 +02:00
|
|
|
|
2020-04-14 22:00:08 +02:00
|
|
|
// Make My Server Public flag
|
2020-05-07 09:08:23 +02:00
|
|
|
chbRegisterServer->setWhatsThis ( "<b>" + tr ( "Make My Server Public" ) + ":</b> " +
|
|
|
|
tr ( "If the Make My Server Public check box is checked, this server registers "
|
2020-06-04 17:51:32 +02:00
|
|
|
"itself at the central server so that all users of the application "
|
|
|
|
"can see the server in the connect dialog server list and "
|
2020-05-21 15:24:44 +02:00
|
|
|
"connect to it. The registration of the server is renewed periodically "
|
2011-05-21 14:33:11 +02:00
|
|
|
"to make sure that all servers in the connect dialog server list are "
|
|
|
|
"actually available." ) );
|
|
|
|
|
2020-04-14 22:00:08 +02:00
|
|
|
// register server status label
|
2020-05-07 09:08:23 +02:00
|
|
|
lblRegSvrStatus->setWhatsThis ( "<b>" + tr ( "Register Server Status" ) + ":</b> " +
|
|
|
|
tr ( "If the Make My Server Public check box is checked, this will show "
|
2020-05-22 08:36:25 +02:00
|
|
|
"whether registration with the central server is successful. If the "
|
|
|
|
"registration failed, please choose another server list." ) );
|
2020-04-14 22:00:08 +02:00
|
|
|
|
2020-05-22 08:36:25 +02:00
|
|
|
// custom central server address
|
|
|
|
QString strCentrServAddr = "<b>" + tr ( "Custom Central Server Address" ) + ":</b> " +
|
|
|
|
tr ( "The custom central server address is the IP address or URL of the central "
|
|
|
|
"server at which the server list of the connection dialog is managed." );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
|
|
|
lblCentralServerAddress->setWhatsThis ( strCentrServAddr );
|
|
|
|
edtCentralServerAddress->setWhatsThis ( strCentrServAddr );
|
2020-04-11 14:27:50 +02:00
|
|
|
edtCentralServerAddress->setAccessibleName ( tr ( "Central server address line edit" ) );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
2020-05-22 08:36:25 +02:00
|
|
|
cbxCentServAddrType->setWhatsThis ( "<b>" + tr ( "Server List Selection" ) + ":</b> " + tr (
|
|
|
|
"Selects the server list (i.e. central server address) in which your server will be added." ) );
|
|
|
|
cbxCentServAddrType->setAccessibleName ( tr ( "Server list selection combo box" ) );
|
|
|
|
|
2011-05-21 14:33:11 +02:00
|
|
|
// server name
|
2020-05-07 09:08:23 +02:00
|
|
|
QString strServName = "<b>" + tr ( "Server Name" ) + ":</b> " + tr ( "The server name identifies "
|
2020-06-05 13:39:54 +02:00
|
|
|
"your server in the connect dialog server list at the clients." );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
|
|
|
lblServerName->setWhatsThis ( strServName );
|
|
|
|
edtServerName->setWhatsThis ( strServName );
|
|
|
|
|
|
|
|
edtServerName->setAccessibleName ( tr ( "Server name line edit" ) );
|
|
|
|
|
|
|
|
// location city
|
2020-05-07 09:08:23 +02:00
|
|
|
QString strLocCity = "<b>" + tr ( "Location City" ) + ":</b> " + tr ( "The city in which this "
|
2011-05-21 14:33:11 +02:00
|
|
|
"server is located can be set here. If a city name is entered, it "
|
|
|
|
"will be shown in the connect dialog server list at the clients." );
|
|
|
|
|
|
|
|
lblLocationCity->setWhatsThis ( strLocCity );
|
|
|
|
edtLocationCity->setWhatsThis ( strLocCity );
|
|
|
|
|
2020-05-06 19:33:27 +02:00
|
|
|
edtLocationCity->setAccessibleName ( tr ( "City where the server is located line edit" ) );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
|
|
|
// location country
|
2020-05-07 09:08:23 +02:00
|
|
|
QString strLocCountry = "<b>" + tr ( "Location country" ) + ":</b> " + tr ( "The country in "
|
2011-05-21 14:33:11 +02:00
|
|
|
"which this server is located can be set here. If a country is "
|
|
|
|
"entered, it will be shown in the connect dialog server list at the "
|
|
|
|
"clients." );
|
|
|
|
|
|
|
|
lblLocationCountry->setWhatsThis ( strLocCountry );
|
|
|
|
cbxLocationCountry->setWhatsThis ( strLocCountry );
|
|
|
|
|
|
|
|
cbxLocationCountry->setAccessibleName ( tr (
|
|
|
|
"Country where the server is located combo box" ) );
|
|
|
|
|
2020-05-30 17:24:52 +02:00
|
|
|
// enable recorder
|
|
|
|
chbEnableRecorder->setAccessibleName( tr ( "Checkbox to turn on or off server recording" ) );
|
|
|
|
chbEnableRecorder->setWhatsThis( "<b>" + tr ( "Enable Recorder" ) + ":</b>"
|
|
|
|
+ tr ( "Checked when the recorder is enabled, otherwise unchecked. "
|
2020-06-05 13:10:59 +02:00
|
|
|
"The recorder will run when a session is in progress, if (set up correctly and) enabled." ) );
|
2020-05-30 17:24:52 +02:00
|
|
|
|
|
|
|
// current session directory
|
|
|
|
edtCurrentSessionDir->setAccessibleName( tr ( "Current session directory text box (read-only)" ) );
|
|
|
|
edtCurrentSessionDir->setWhatsThis( "<b>" + tr ( "Current Session Directory" ) + ":</b>"
|
|
|
|
+ tr ( "Enabled during recording and holds the current recording session directory. "
|
2020-06-05 13:10:59 +02:00
|
|
|
"Disabled after recording or when the recorder is not enabled." ) );
|
2020-05-30 17:24:52 +02:00
|
|
|
|
|
|
|
// recorder status
|
|
|
|
lblRecorderStatus->setAccessibleName ( tr ( "Recorder status label" ) );
|
|
|
|
lblRecorderStatus->setWhatsThis ( "<b>" + tr ( "Recorder Status" ) + ":</b>"
|
|
|
|
+ tr ( "Displays the current status of the recorder." ) );
|
|
|
|
|
|
|
|
// new recording
|
|
|
|
pbtNewRecording->setAccessibleName ( tr ( "Request new recording button" ) );
|
|
|
|
pbtNewRecording->setWhatsThis ( "<b>" + tr ( "New Recording" ) + ":</b>"
|
|
|
|
+ tr ( "During a recording session, the button can be used to start a new recording." ) );
|
|
|
|
|
2011-05-21 14:33:11 +02:00
|
|
|
|
|
|
|
// check if system tray icon can be used
|
|
|
|
bSystemTrayIconAvaialbe = SystemTrayIcon.isSystemTrayAvailable();
|
|
|
|
|
|
|
|
// init system tray icon
|
|
|
|
if ( bSystemTrayIconAvaialbe )
|
|
|
|
{
|
|
|
|
// prepare context menu to be added to the system tray icon
|
|
|
|
pSystemTrayIconMenu = new QMenu ( this );
|
|
|
|
|
|
|
|
pSystemTrayIconMenu->addAction ( tr ( "E&xit" ),
|
|
|
|
this, SLOT ( OnSysTrayMenuExit() ) );
|
|
|
|
|
|
|
|
pSystemTrayIconMenu->addSeparator();
|
|
|
|
|
|
|
|
pSystemTrayIconMenu->addAction (
|
|
|
|
tr ( "&Hide " ) + APP_NAME + tr ( " server" ),
|
|
|
|
this, SLOT ( OnSysTrayMenuHide() ) );
|
|
|
|
|
|
|
|
pSystemTrayIconMenu->setDefaultAction ( pSystemTrayIconMenu->addAction (
|
|
|
|
tr ( "&Open " ) + APP_NAME + tr ( " server" ),
|
|
|
|
this, SLOT ( OnSysTrayMenuOpen() ) ) );
|
|
|
|
|
|
|
|
SystemTrayIcon.setContextMenu ( pSystemTrayIconMenu );
|
|
|
|
|
|
|
|
// set tool text
|
|
|
|
SystemTrayIcon.setToolTip ( QString ( APP_NAME ) + tr ( " server" ) );
|
|
|
|
|
|
|
|
// show icon of state "inactive"
|
|
|
|
SystemTrayIcon.setIcon ( QIcon ( BitmapSystemTrayInactive ) );
|
|
|
|
SystemTrayIcon.show();
|
|
|
|
}
|
|
|
|
|
2011-05-21 21:05:57 +02:00
|
|
|
// act on "start minimized" flag (note, this has to be done after setting
|
|
|
|
// the correct value for the system tray icon availablility)
|
|
|
|
if ( bStartMinimized )
|
|
|
|
{
|
|
|
|
showMinimized();
|
|
|
|
}
|
|
|
|
|
2011-05-21 14:33:11 +02:00
|
|
|
// set text for version and application name
|
|
|
|
lblNameVersion->setText ( QString ( APP_NAME ) +
|
|
|
|
tr ( " server " ) + QString ( VERSION ) );
|
|
|
|
|
|
|
|
// set up list view for connected clients
|
|
|
|
lvwClients->setColumnWidth ( 0, 170 );
|
2020-04-13 19:26:15 +02:00
|
|
|
lvwClients->setColumnWidth ( 1, 200 );
|
2011-05-21 14:33:11 +02:00
|
|
|
lvwClients->clear();
|
|
|
|
|
|
|
|
|
|
|
|
// TEST workaround for resize problem of window after iconize in task bar
|
|
|
|
lvwClients->setMinimumWidth ( 170 + 130 + 60 + 205 );
|
|
|
|
lvwClients->setMinimumHeight ( 140 );
|
|
|
|
|
|
|
|
|
|
|
|
// insert items in reverse order because in Windows all of them are
|
|
|
|
// always visible -> put first item on the top
|
|
|
|
vecpListViewItems.Init ( MAX_NUM_CHANNELS );
|
2020-04-13 19:26:15 +02:00
|
|
|
|
2011-05-21 14:33:11 +02:00
|
|
|
for ( int i = MAX_NUM_CHANNELS - 1; i >= 0; i-- )
|
|
|
|
{
|
2014-01-03 09:54:49 +01:00
|
|
|
vecpListViewItems[i] = new QTreeWidgetItem ( lvwClients );
|
2011-05-21 14:33:11 +02:00
|
|
|
vecpListViewItems[i]->setHidden ( true );
|
|
|
|
}
|
|
|
|
|
2020-04-11 14:27:50 +02:00
|
|
|
// central server address type combo box
|
|
|
|
cbxCentServAddrType->clear();
|
2020-05-16 11:28:05 +02:00
|
|
|
cbxCentServAddrType->addItem ( csCentServAddrTypeToString ( AT_DEFAULT ) );
|
2020-05-22 06:25:38 +02:00
|
|
|
cbxCentServAddrType->addItem ( csCentServAddrTypeToString ( AT_ALL_GENRES ) );
|
2020-05-23 21:23:20 +02:00
|
|
|
cbxCentServAddrType->addItem ( csCentServAddrTypeToString ( AT_GENRE_ROCK ) );
|
|
|
|
cbxCentServAddrType->addItem ( csCentServAddrTypeToString ( AT_GENRE_JAZZ ) );
|
2020-05-22 09:48:58 +02:00
|
|
|
cbxCentServAddrType->addItem ( csCentServAddrTypeToString ( AT_GENRE_CLASSICAL_FOLK ) );
|
2020-05-22 06:25:38 +02:00
|
|
|
cbxCentServAddrType->addItem ( csCentServAddrTypeToString ( AT_CUSTOM ) );
|
2020-04-11 14:27:50 +02:00
|
|
|
cbxCentServAddrType->setCurrentIndex ( static_cast<int> ( pServer->GetCentralServerAddressType() ) );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
|
|
|
// update server name line edit
|
|
|
|
edtServerName->setText ( pServer->GetServerName() );
|
|
|
|
|
|
|
|
// update server city line edit
|
|
|
|
edtLocationCity->setText ( pServer->GetServerCity() );
|
|
|
|
|
|
|
|
// load country combo box with all available countries
|
|
|
|
cbxLocationCountry->setInsertPolicy ( QComboBox::NoInsert );
|
|
|
|
cbxLocationCountry->clear();
|
|
|
|
|
|
|
|
for ( int iCurCntry = static_cast<int> ( QLocale::AnyCountry );
|
|
|
|
iCurCntry < static_cast<int> ( QLocale::LastCountry ); iCurCntry++ )
|
|
|
|
{
|
|
|
|
// add all countries except of the "Default" country
|
|
|
|
if ( static_cast<QLocale::Country> ( iCurCntry ) != QLocale::AnyCountry )
|
|
|
|
{
|
|
|
|
// store the country enum index together with the string (this is
|
|
|
|
// important since we sort the combo box items later on)
|
|
|
|
cbxLocationCountry->addItem ( QLocale::countryToString (
|
|
|
|
static_cast<QLocale::Country> ( iCurCntry ) ), iCurCntry );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// sort country combo box items in alphabetical order
|
|
|
|
cbxLocationCountry->model()->sort ( 0, Qt::AscendingOrder );
|
|
|
|
|
|
|
|
// select current country
|
|
|
|
cbxLocationCountry->setCurrentIndex (
|
|
|
|
cbxLocationCountry->findData (
|
|
|
|
static_cast<int> ( pServer->GetServerCountry() ) ) );
|
|
|
|
|
|
|
|
// update register server check box
|
|
|
|
if ( pServer->GetServerListEnabled() )
|
|
|
|
{
|
|
|
|
chbRegisterServer->setCheckState ( Qt::Checked );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
chbRegisterServer->setCheckState ( Qt::Unchecked );
|
|
|
|
}
|
|
|
|
|
2020-04-08 15:30:32 +02:00
|
|
|
// update show Creative Commons licence check box
|
|
|
|
if ( pServer->GetLicenceType() == LT_CREATIVECOMMONS )
|
|
|
|
{
|
|
|
|
chbUseCCLicence->setCheckState ( Qt::Checked );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
chbUseCCLicence->setCheckState ( Qt::Unchecked );
|
|
|
|
}
|
|
|
|
|
2011-05-21 14:33:11 +02:00
|
|
|
// update start minimized check box (only available for Windows)
|
|
|
|
#ifndef _WIN32
|
|
|
|
chbStartOnOSStart->setVisible ( false );
|
|
|
|
#else
|
|
|
|
const bool bCurAutoStartMinState = pServer->GetAutoRunMinimized();
|
|
|
|
|
|
|
|
if ( bCurAutoStartMinState )
|
|
|
|
{
|
|
|
|
chbStartOnOSStart->setCheckState ( Qt::Checked );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
chbStartOnOSStart->setCheckState ( Qt::Unchecked );
|
|
|
|
}
|
|
|
|
|
|
|
|
// modify registry according to setting (this is just required in case a
|
|
|
|
// user has changed the registry by hand)
|
|
|
|
ModifyAutoStartEntry ( bCurAutoStartMinState );
|
|
|
|
#endif
|
|
|
|
|
2020-05-15 23:04:55 +02:00
|
|
|
// Recorder controls
|
2020-05-30 17:24:52 +02:00
|
|
|
if ( !pServer->GetRecorderInitialised() )
|
2020-05-15 23:04:55 +02:00
|
|
|
{
|
2020-05-30 17:24:52 +02:00
|
|
|
// The recorder was not initialised successfully from the command line
|
|
|
|
// TODO: Once initialising from the GUI is implemented, remove
|
|
|
|
chbEnableRecorder->setVisible ( false );
|
|
|
|
edtCurrentSessionDir->setVisible ( false );
|
2020-05-15 23:04:55 +02:00
|
|
|
lblRecorderStatus->setVisible ( false );
|
|
|
|
pbtNewRecording->setVisible ( false );
|
|
|
|
}
|
|
|
|
|
2020-05-30 17:24:52 +02:00
|
|
|
edtCurrentSessionDir->setText ( "" );
|
|
|
|
pbtNewRecording->setAutoDefault ( false );
|
|
|
|
|
2020-05-15 23:04:55 +02:00
|
|
|
// TODO: Not yet implemented, so hide them!
|
|
|
|
pbtRecordingDir->setVisible ( false );
|
|
|
|
edtRecordingsDir->setVisible ( false );
|
|
|
|
|
2020-05-30 17:24:52 +02:00
|
|
|
UpdateRecorderStatus ( QString::null );
|
|
|
|
|
2011-05-21 14:33:11 +02:00
|
|
|
// update GUI dependencies
|
|
|
|
UpdateGUIDependencies();
|
|
|
|
|
2013-02-18 19:20:37 +01:00
|
|
|
// set window title
|
|
|
|
setWindowTitle ( APP_NAME + tr ( " Server" ) );
|
|
|
|
|
2011-05-21 14:33:11 +02:00
|
|
|
|
|
|
|
// View menu --------------------------------------------------------------
|
2020-05-06 19:33:27 +02:00
|
|
|
QMenu* pViewMenu = new QMenu ( tr ( "&Window" ), this );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
|
|
|
pViewMenu->addAction ( tr ( "E&xit" ), this,
|
|
|
|
SLOT ( close() ), QKeySequence ( Qt::CTRL + Qt::Key_Q ) );
|
|
|
|
|
|
|
|
|
|
|
|
// Main menu bar -----------------------------------------------------------
|
|
|
|
pMenu = new QMenuBar ( this );
|
|
|
|
|
|
|
|
pMenu->addMenu ( pViewMenu );
|
2020-05-02 08:24:01 +02:00
|
|
|
pMenu->addMenu ( new CHelpMenu ( false, this ) );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
|
|
|
// Now tell the layout about the menu
|
|
|
|
layout()->setMenuBar ( pMenu );
|
|
|
|
|
|
|
|
|
|
|
|
// Connections -------------------------------------------------------------
|
|
|
|
// check boxes
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( chbRegisterServer, &QCheckBox::stateChanged,
|
|
|
|
this, &CServerDlg::OnRegisterServerStateChanged );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( chbStartOnOSStart, &QCheckBox::stateChanged,
|
|
|
|
this, &CServerDlg::OnStartOnOSStartStateChanged );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( chbUseCCLicence, &QCheckBox::stateChanged,
|
|
|
|
this, &CServerDlg::OnUseCCLicenceStateChanged );
|
2020-04-08 15:30:32 +02:00
|
|
|
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( chbEnableRecorder, &QCheckBox::stateChanged,
|
|
|
|
this, &CServerDlg::OnEnableRecorderStateChanged );
|
2020-05-30 17:24:52 +02:00
|
|
|
|
2011-05-21 14:33:11 +02:00
|
|
|
// line edits
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( edtCentralServerAddress, &QLineEdit::editingFinished,
|
|
|
|
this, &CServerDlg::OnCentralServerAddressEditingFinished );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( edtServerName, &QLineEdit::textChanged,
|
|
|
|
this, &CServerDlg::OnServerNameTextChanged );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( edtLocationCity, &QLineEdit::textChanged,
|
|
|
|
this, &CServerDlg::OnLocationCityTextChanged );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
|
|
|
// combo boxes
|
2020-06-07 09:01:52 +02:00
|
|
|
QObject::connect ( cbxLocationCountry, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
|
|
|
|
this, &CServerDlg::OnLocationCountryActivated );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
2020-06-07 09:01:52 +02:00
|
|
|
QObject::connect ( cbxCentServAddrType, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
|
|
|
|
this, &CServerDlg::OnCentServAddrTypeActivated );
|
2020-04-11 14:27:50 +02:00
|
|
|
|
2020-05-15 23:04:55 +02:00
|
|
|
// push buttons
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( pbtNewRecording, &QPushButton::released,
|
|
|
|
this, &CServerDlg::OnNewRecordingClicked );
|
2020-05-15 23:04:55 +02:00
|
|
|
|
2011-05-21 14:33:11 +02:00
|
|
|
// timers
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( &Timer, &QTimer::timeout,
|
|
|
|
this, &CServerDlg::OnTimer );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
|
|
|
// other
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( pServer, &CServer::Started,
|
|
|
|
this, &CServerDlg::OnServerStarted );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( pServer, &CServer::Stopped,
|
|
|
|
this, &CServerDlg::OnServerStopped );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( pServer, &CServer::SvrRegStatusChanged,
|
|
|
|
this, &CServerDlg::OnSvrRegStatusChanged );
|
2020-04-14 22:00:08 +02:00
|
|
|
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( pServer, &CServer::RecordingSessionStarted,
|
|
|
|
this, &CServerDlg::OnRecordingSessionStarted );
|
2020-05-15 23:04:55 +02:00
|
|
|
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( pServer, &CServer::StopRecorder,
|
|
|
|
this, &CServerDlg::OnStopRecorder );
|
2020-05-30 17:24:52 +02:00
|
|
|
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( QCoreApplication::instance(), &QCoreApplication::aboutToQuit,
|
|
|
|
this, &CServerDlg::OnAboutToQuit );
|
2011-05-21 19:06:30 +02:00
|
|
|
|
2020-06-06 22:15:33 +02:00
|
|
|
QObject::connect ( &SystemTrayIcon, &QSystemTrayIcon::activated,
|
|
|
|
this, &CServerDlg::OnSysTrayActivated );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
// Timers ------------------------------------------------------------------
|
|
|
|
// start timer for GUI controls
|
|
|
|
Timer.start ( GUI_CONTRL_UPDATE_TIME );
|
|
|
|
}
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
void CServerDlg::OnStartOnOSStartStateChanged ( int value )
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
const bool bCurAutoStartMinState = ( value == Qt::Checked );
|
|
|
|
|
|
|
|
// update registry and server setting (for ini file)
|
|
|
|
pServer->SetAutoRunMinimized ( bCurAutoStartMinState );
|
|
|
|
ModifyAutoStartEntry ( bCurAutoStartMinState );
|
|
|
|
}
|
|
|
|
|
2020-04-08 15:30:32 +02:00
|
|
|
void CServerDlg::OnUseCCLicenceStateChanged ( int value )
|
|
|
|
{
|
|
|
|
if ( value == Qt::Checked )
|
|
|
|
{
|
|
|
|
pServer->SetLicenceType ( LT_CREATIVECOMMONS );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pServer->SetLicenceType ( LT_NO_LICENCE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
void CServerDlg::OnRegisterServerStateChanged ( int value )
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
const bool bRegState = ( value == Qt::Checked );
|
|
|
|
|
|
|
|
// apply new setting to the server and update it
|
|
|
|
pServer->SetServerListEnabled ( bRegState );
|
|
|
|
|
2012-07-06 18:54:50 +02:00
|
|
|
// if registering is disabled, unregister slave server
|
|
|
|
if ( !bRegState )
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
pServer->UnregisterSlaveServer();
|
|
|
|
}
|
|
|
|
|
2012-07-06 18:54:50 +02:00
|
|
|
pServer->UpdateServerList();
|
|
|
|
|
2011-05-21 14:33:11 +02:00
|
|
|
// update GUI dependencies
|
|
|
|
UpdateGUIDependencies();
|
|
|
|
}
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
void CServerDlg::OnCentralServerAddressEditingFinished()
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
// apply new setting to the server and update it
|
|
|
|
pServer->SetServerListCentralServerAddress (
|
|
|
|
edtCentralServerAddress->text() );
|
|
|
|
|
|
|
|
pServer->UpdateServerList();
|
|
|
|
}
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
void CServerDlg::OnServerNameTextChanged ( const QString& strNewName )
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
// check length
|
|
|
|
if ( strNewName.length() <= MAX_LEN_SERVER_NAME )
|
|
|
|
{
|
|
|
|
// apply new setting to the server and update it
|
|
|
|
pServer->SetServerName ( strNewName );
|
|
|
|
pServer->UpdateServerList();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// text is too long, update control with shortend text
|
|
|
|
edtServerName->setText ( strNewName.left ( MAX_LEN_SERVER_NAME ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
void CServerDlg::OnLocationCityTextChanged ( const QString& strNewCity )
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
// check length
|
|
|
|
if ( strNewCity.length() <= MAX_LEN_SERVER_CITY )
|
|
|
|
{
|
|
|
|
// apply new setting to the server and update it
|
|
|
|
pServer->SetServerCity ( strNewCity );
|
|
|
|
pServer->UpdateServerList();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// text is too long, update control with shortend text
|
|
|
|
edtLocationCity->setText ( strNewCity.left ( MAX_LEN_SERVER_CITY ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
void CServerDlg::OnLocationCountryActivated ( int iCntryListItem )
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
// apply new setting to the server and update it
|
|
|
|
pServer->SetServerCountry ( static_cast<QLocale::Country> (
|
|
|
|
cbxLocationCountry->itemData ( iCntryListItem ).toInt() ) );
|
|
|
|
|
|
|
|
pServer->UpdateServerList();
|
|
|
|
}
|
|
|
|
|
2020-04-11 14:27:50 +02:00
|
|
|
void CServerDlg::OnCentServAddrTypeActivated ( int iTypeIdx )
|
|
|
|
{
|
2020-05-01 20:21:33 +02:00
|
|
|
// if server was registered, unregister first
|
|
|
|
if ( pServer->GetServerListEnabled() )
|
|
|
|
{
|
|
|
|
pServer->UnregisterSlaveServer();
|
|
|
|
}
|
|
|
|
|
2020-04-11 14:27:50 +02:00
|
|
|
// apply new setting to the server and update it
|
|
|
|
pServer->SetCentralServerAddressType ( static_cast<ECSAddType> ( iTypeIdx ) );
|
|
|
|
pServer->UpdateServerList();
|
|
|
|
|
|
|
|
// update GUI dependencies
|
|
|
|
UpdateGUIDependencies();
|
|
|
|
}
|
|
|
|
|
2020-05-30 17:24:52 +02:00
|
|
|
void CServerDlg::OnServerStarted()
|
|
|
|
{
|
|
|
|
UpdateSystemTrayIcon ( true );
|
|
|
|
UpdateRecorderStatus ( QString::null );
|
|
|
|
}
|
|
|
|
|
2020-05-26 07:01:55 +02:00
|
|
|
void CServerDlg::OnServerStopped()
|
2020-05-25 22:55:45 +02:00
|
|
|
{
|
|
|
|
UpdateSystemTrayIcon ( false );
|
|
|
|
UpdateRecorderStatus ( QString::null );
|
|
|
|
}
|
|
|
|
|
2020-05-30 17:24:52 +02:00
|
|
|
void CServerDlg::OnStopRecorder()
|
|
|
|
{
|
|
|
|
UpdateRecorderStatus ( QString::null );
|
|
|
|
}
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
void CServerDlg::OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ActReason )
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
// on double click on the icon, show window in fore ground
|
|
|
|
if ( ActReason == QSystemTrayIcon::DoubleClick )
|
|
|
|
{
|
|
|
|
ShowWindowInForeground();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
void CServerDlg::OnTimer()
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
CVector<CHostAddress> vecHostAddresses;
|
|
|
|
CVector<QString> vecsName;
|
|
|
|
CVector<int> veciJitBufNumFrames;
|
|
|
|
CVector<int> veciNetwFrameSizeFact;
|
|
|
|
|
|
|
|
ListViewMutex.lock();
|
|
|
|
{
|
|
|
|
pServer->GetConCliParam ( vecHostAddresses,
|
|
|
|
vecsName,
|
|
|
|
veciJitBufNumFrames,
|
|
|
|
veciNetwFrameSizeFact );
|
|
|
|
|
|
|
|
// we assume that all vectors have the same length
|
|
|
|
const int iNumChannels = vecHostAddresses.Size();
|
|
|
|
|
|
|
|
// fill list with connected clients
|
|
|
|
for ( int i = 0; i < iNumChannels; i++ )
|
|
|
|
{
|
2019-05-17 22:55:46 +02:00
|
|
|
if ( !( vecHostAddresses[i].InetAddr == QHostAddress ( static_cast<quint32> ( 0 ) ) ) )
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
// IP, port number
|
|
|
|
vecpListViewItems[i]->setText ( 0,
|
|
|
|
vecHostAddresses[i].toString ( CHostAddress::SM_IP_PORT ) );
|
|
|
|
|
|
|
|
// name
|
|
|
|
vecpListViewItems[i]->setText ( 1, vecsName[i] );
|
|
|
|
|
|
|
|
// jitter buffer size (polling for updates)
|
2014-01-03 09:54:49 +01:00
|
|
|
vecpListViewItems[i]->setText ( 2,
|
2011-05-21 14:33:11 +02:00
|
|
|
QString().setNum ( veciJitBufNumFrames[i] ) );
|
|
|
|
|
|
|
|
vecpListViewItems[i]->setHidden ( false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vecpListViewItems[i]->setHidden ( true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ListViewMutex.unlock();
|
|
|
|
}
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
void CServerDlg::UpdateGUIDependencies()
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
// get the states which define the GUI dependencies from the server
|
|
|
|
const bool bCurSerListEnabled = pServer->GetServerListEnabled();
|
|
|
|
|
2020-05-17 11:00:56 +02:00
|
|
|
const bool bCurUseDefCentServAddr = ( pServer->GetCentralServerAddressType() != AT_CUSTOM );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
2020-04-14 22:00:08 +02:00
|
|
|
const ESvrRegStatus eSvrRegStatus = pServer->GetSvrRegStatus();
|
|
|
|
|
2011-05-21 14:33:11 +02:00
|
|
|
// if register server is not enabled, we disable all the configuration
|
|
|
|
// controls for the server list
|
2020-04-11 14:27:50 +02:00
|
|
|
cbxCentServAddrType->setEnabled ( bCurSerListEnabled );
|
|
|
|
grbServerInfo->setEnabled ( bCurSerListEnabled );
|
2011-05-21 14:33:11 +02:00
|
|
|
|
2015-10-18 21:07:43 +02:00
|
|
|
// make sure the line edit does not fire signals when we update the text
|
2011-05-21 14:33:11 +02:00
|
|
|
edtCentralServerAddress->blockSignals ( true );
|
|
|
|
{
|
2015-10-18 21:07:43 +02:00
|
|
|
if ( bCurUseDefCentServAddr )
|
|
|
|
{
|
|
|
|
// if the default central server is used, just show a text of the
|
|
|
|
// server name
|
2020-05-16 11:24:50 +02:00
|
|
|
edtCentralServerAddress->setText ( tr ( "Predefined Address" ) );
|
2015-10-18 21:07:43 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// show the current user defined server address
|
|
|
|
edtCentralServerAddress->setText (
|
|
|
|
pServer->GetServerListCentralServerAddress() );
|
|
|
|
}
|
2011-05-21 14:33:11 +02:00
|
|
|
}
|
|
|
|
edtCentralServerAddress->blockSignals ( false );
|
|
|
|
|
|
|
|
// the line edit of the central server address is only enabled, if the
|
|
|
|
// server list is enabled and not the default address is used
|
|
|
|
edtCentralServerAddress->setEnabled (
|
|
|
|
!bCurUseDefCentServAddr && bCurSerListEnabled );
|
2020-04-14 22:00:08 +02:00
|
|
|
|
2020-04-19 00:12:20 +02:00
|
|
|
QString strStatus = svrRegStatusToString ( eSvrRegStatus );
|
2020-04-18 08:39:08 +02:00
|
|
|
|
2020-04-14 22:00:08 +02:00
|
|
|
switch ( eSvrRegStatus )
|
|
|
|
{
|
|
|
|
case SRS_BAD_ADDRESS:
|
|
|
|
case SRS_TIME_OUT:
|
2020-04-19 00:12:20 +02:00
|
|
|
case SRS_CENTRAL_SVR_FULL:
|
|
|
|
strStatus = "<font color=""red""><b>" + strStatus + "</b></font>";
|
2020-04-14 22:00:08 +02:00
|
|
|
break;
|
2020-04-18 08:39:08 +02:00
|
|
|
|
2020-04-14 22:00:08 +02:00
|
|
|
case SRS_REGISTERED:
|
2020-04-19 00:12:20 +02:00
|
|
|
strStatus = "<font color=""darkGreen""><b>" + strStatus + "</b></font>";
|
2020-04-14 22:00:08 +02:00
|
|
|
break;
|
2020-04-18 08:39:08 +02:00
|
|
|
|
2020-04-19 00:12:20 +02:00
|
|
|
default:
|
2020-04-14 22:00:08 +02:00
|
|
|
break;
|
|
|
|
}
|
2020-04-19 12:23:25 +02:00
|
|
|
|
2020-04-18 09:20:05 +02:00
|
|
|
lblRegSvrStatus->setText ( strStatus );
|
2011-05-21 14:33:11 +02:00
|
|
|
}
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
void CServerDlg::UpdateSystemTrayIcon ( const bool bIsActive )
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
if ( bSystemTrayIconAvaialbe )
|
|
|
|
{
|
|
|
|
if ( bIsActive )
|
|
|
|
{
|
|
|
|
SystemTrayIcon.setIcon ( QIcon ( BitmapSystemTrayActive ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SystemTrayIcon.setIcon ( QIcon ( BitmapSystemTrayInactive ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
void CServerDlg::ModifyAutoStartEntry ( const bool bDoAutoStart )
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
// auto start is currently only supported for Windows
|
|
|
|
#ifdef _WIN32
|
|
|
|
// init settings object so that it points to the correct place in the
|
|
|
|
// Windows registry for the auto run entry
|
|
|
|
QSettings RegSettings ( "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
|
|
|
|
QSettings::NativeFormat );
|
|
|
|
|
|
|
|
// create start string of auto run entry
|
|
|
|
QString strRegValue =
|
|
|
|
QCoreApplication::applicationFilePath().replace ( "/", "\\" ) +
|
|
|
|
" -s --startminimized";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ( bDoAutoStart )
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
// ckeck if registry entry is correctly present, if not, correct
|
|
|
|
const bool bWriteRegValue = strRegValue.compare (
|
|
|
|
RegSettings.value ( AUTORUN_SERVER_REG_NAME ).toString() );
|
|
|
|
|
|
|
|
if ( bWriteRegValue )
|
|
|
|
{
|
|
|
|
// write reg key in the registry
|
|
|
|
RegSettings.setValue ( AUTORUN_SERVER_REG_NAME, strRegValue );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
// delete reg key if present
|
|
|
|
if ( RegSettings.contains ( AUTORUN_SERVER_REG_NAME ) )
|
|
|
|
{
|
|
|
|
RegSettings.remove ( AUTORUN_SERVER_REG_NAME );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 23:04:55 +02:00
|
|
|
void CServerDlg::UpdateRecorderStatus ( QString sessionDir )
|
|
|
|
{
|
2020-05-30 17:24:52 +02:00
|
|
|
if ( !pServer->GetRecorderInitialised() )
|
|
|
|
{
|
|
|
|
// everything should be hidden.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Qt::CheckState csIsEnabled;
|
2020-06-01 09:55:31 +02:00
|
|
|
QString currentSessionDir = edtCurrentSessionDir->text();
|
|
|
|
bool bIsRecording = false;
|
|
|
|
QString strRecorderStatus;
|
2020-05-15 23:04:55 +02:00
|
|
|
|
|
|
|
if ( pServer->GetRecordingEnabled() )
|
|
|
|
{
|
2020-05-30 17:24:52 +02:00
|
|
|
csIsEnabled = Qt::CheckState::Checked;
|
2020-05-15 23:04:55 +02:00
|
|
|
if ( pServer->IsRunning() )
|
|
|
|
{
|
|
|
|
currentSessionDir = sessionDir != QString::null ? sessionDir : "";
|
|
|
|
strRecorderStatus = tr ( "Recording" );
|
2020-05-26 07:01:55 +02:00
|
|
|
bIsRecording = true;
|
2020-05-15 23:04:55 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strRecorderStatus = tr ( "Not recording" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-01 09:55:31 +02:00
|
|
|
csIsEnabled = Qt::CheckState::Unchecked;
|
2020-05-15 23:04:55 +02:00
|
|
|
strRecorderStatus = tr ( "Not enabled" );
|
|
|
|
}
|
|
|
|
|
2020-05-30 17:24:52 +02:00
|
|
|
chbEnableRecorder->setCheckState ( csIsEnabled );
|
|
|
|
|
2020-05-15 23:04:55 +02:00
|
|
|
edtCurrentSessionDir->setEnabled ( bIsRecording );
|
2020-05-26 07:01:55 +02:00
|
|
|
edtCurrentSessionDir->setText ( currentSessionDir );
|
2020-05-15 23:04:55 +02:00
|
|
|
|
|
|
|
lblRecorderStatus->setText ( strRecorderStatus );
|
|
|
|
|
|
|
|
pbtNewRecording->setEnabled ( bIsRecording );
|
|
|
|
}
|
|
|
|
|
2013-03-24 16:42:23 +01:00
|
|
|
void CServerDlg::changeEvent ( QEvent* pEvent )
|
2011-05-21 14:33:11 +02:00
|
|
|
{
|
|
|
|
// if we have a system tray icon, we make the window invisible if it is
|
|
|
|
// minimized
|
|
|
|
if ( bSystemTrayIconAvaialbe &&
|
|
|
|
( pEvent->type() == QEvent::WindowStateChange ) )
|
|
|
|
{
|
|
|
|
if ( isMinimized() )
|
|
|
|
{
|
|
|
|
// we have to call the hide function from another thread -> use
|
|
|
|
// the timer for this purpose
|
|
|
|
QTimer::singleShot ( 0, this, SLOT ( hide() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|