first working version of the connect dialog
This commit is contained in:
parent
b6ba0cc93b
commit
7392762f6c
4 changed files with 261 additions and 312 deletions
|
@ -28,7 +28,9 @@
|
||||||
/* Implementation *************************************************************/
|
/* Implementation *************************************************************/
|
||||||
CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
|
CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
|
||||||
: QDialog ( parent, f ),
|
: QDialog ( parent, f ),
|
||||||
bServerListReceived ( false )
|
strSelectedAddress ( "" ),
|
||||||
|
bServerListReceived ( false ),
|
||||||
|
bCancelPressed ( false )
|
||||||
{
|
{
|
||||||
setupUi ( this );
|
setupUi ( this );
|
||||||
|
|
||||||
|
@ -38,8 +40,7 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
|
||||||
QString strServAddrH = tr ( "<b>Server Address:</b> The IP address or URL "
|
QString strServAddrH = tr ( "<b>Server Address:</b> The IP address or URL "
|
||||||
"of the server running the llcon server software must be set here. "
|
"of the server running the llcon server software must be set here. "
|
||||||
"A list of the most recent used server URLs is available for "
|
"A list of the most recent used server URLs is available for "
|
||||||
"selection. If an invalid address was chosen, an error message is "
|
"selection." );
|
||||||
"shown in the status bar." );
|
|
||||||
|
|
||||||
TextLabelServerAddr->setWhatsThis ( strServAddrH );
|
TextLabelServerAddr->setWhatsThis ( strServAddrH );
|
||||||
LineEditServerAddr->setWhatsThis ( strServAddrH );
|
LineEditServerAddr->setWhatsThis ( strServAddrH );
|
||||||
|
@ -51,7 +52,7 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
|
||||||
|
|
||||||
// init server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries)
|
// init server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries)
|
||||||
LineEditServerAddr->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS );
|
LineEditServerAddr->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS );
|
||||||
LineEditServerAddr->setInsertPolicy ( QComboBox::InsertAtTop );
|
LineEditServerAddr->setInsertPolicy ( QComboBox::NoInsert );
|
||||||
|
|
||||||
// set up list view for connected clients
|
// set up list view for connected clients
|
||||||
ListViewServers->setColumnWidth ( 0, 170 );
|
ListViewServers->setColumnWidth ( 0, 170 );
|
||||||
|
@ -67,13 +68,8 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
|
||||||
QObject::connect ( CancelButton, SIGNAL ( clicked() ),
|
QObject::connect ( CancelButton, SIGNAL ( clicked() ),
|
||||||
this, SLOT ( OnCancelButtonClicked() ) );
|
this, SLOT ( OnCancelButtonClicked() ) );
|
||||||
|
|
||||||
// line edits
|
QObject::connect ( ConnectButton, SIGNAL ( clicked() ),
|
||||||
QObject::connect ( LineEditServerAddr, SIGNAL ( editTextChanged ( const QString ) ),
|
this, SLOT ( close() ) );
|
||||||
this, SLOT ( OnLineEditServerAddrTextChanged ( const QString ) ) );
|
|
||||||
|
|
||||||
QObject::connect ( LineEditServerAddr, SIGNAL ( activated ( int ) ),
|
|
||||||
this, SLOT ( OnLineEditServerAddrActivated ( int ) ) );
|
|
||||||
|
|
||||||
|
|
||||||
// timers
|
// timers
|
||||||
QObject::connect ( &TimerPing, SIGNAL ( timeout() ),
|
QObject::connect ( &TimerPing, SIGNAL ( timeout() ),
|
||||||
|
@ -83,14 +79,14 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
|
||||||
this, SLOT ( OnTimerReRequestServList() ) );
|
this, SLOT ( OnTimerReRequestServList() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConnectDlg::LoadStoredServers ( const CVector<QString>& vstrIPAddress )
|
void CConnectDlg::LoadStoredServers ( const CVector<QString>& vstrIPAddresses )
|
||||||
{
|
{
|
||||||
// load stored IP addresses in combo box
|
// load stored IP addresses in combo box
|
||||||
for ( int iLEIdx = 0; iLEIdx < MAX_NUM_SERVER_ADDR_ITEMS; iLEIdx++ )
|
for ( int iLEIdx = 0; iLEIdx < MAX_NUM_SERVER_ADDR_ITEMS; iLEIdx++ )
|
||||||
{
|
{
|
||||||
if ( !vstrIPAddress[iLEIdx].isEmpty() )
|
if ( !vstrIPAddresses[iLEIdx].isEmpty() )
|
||||||
{
|
{
|
||||||
LineEditServerAddr->addItem ( vstrIPAddress[iLEIdx] );
|
LineEditServerAddr->addItem ( vstrIPAddresses[iLEIdx] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,6 +98,9 @@ void CConnectDlg::showEvent ( QShowEvent* )
|
||||||
bServerListReceived = false;
|
bServerListReceived = false;
|
||||||
bCancelPressed = false;
|
bCancelPressed = false;
|
||||||
|
|
||||||
|
// clear current address
|
||||||
|
strSelectedAddress = "";
|
||||||
|
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
QString strNAddr = "llcon.dyndns.org:22122";
|
QString strNAddr = "llcon.dyndns.org:22122";
|
||||||
|
@ -124,20 +123,25 @@ QString strNAddr = "llcon.dyndns.org:22122";
|
||||||
|
|
||||||
void CConnectDlg::hideEvent ( QHideEvent* )
|
void CConnectDlg::hideEvent ( QHideEvent* )
|
||||||
{
|
{
|
||||||
|
// get the IP address to be used according to the following definitions:
|
||||||
|
// - if the list has focus and a line is selected, use this line
|
||||||
|
// - if the list has no focus, use the current combo box text
|
||||||
|
QList<QTreeWidgetItem*> CurSelListItemList =
|
||||||
|
ListViewServers->selectedItems();
|
||||||
|
|
||||||
|
if ( CurSelListItemList.count() > 0 )
|
||||||
|
{
|
||||||
|
strSelectedAddress =
|
||||||
|
CurSelListItemList[0]->data ( 0, Qt::UserRole ).toString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strSelectedAddress = LineEditServerAddr->currentText();
|
||||||
|
}
|
||||||
|
|
||||||
// if window is closed, stop timers
|
// if window is closed, stop timers
|
||||||
TimerPing.stop();
|
TimerPing.stop();
|
||||||
TimerReRequestServList.stop();
|
TimerReRequestServList.stop();
|
||||||
|
|
||||||
// TODO
|
|
||||||
/*
|
|
||||||
// store IP addresses
|
|
||||||
for ( int iLEIdx = 0; iLEIdx < LineEditServerAddr->count(); iLEIdx++ )
|
|
||||||
{
|
|
||||||
pClient->vstrIPAddress[iLEIdx] =
|
|
||||||
LineEditServerAddr->itemText ( iLEIdx );
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConnectDlg::OnTimerReRequestServList()
|
void CConnectDlg::OnTimerReRequestServList()
|
||||||
|
@ -228,17 +232,6 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr,
|
||||||
TimerPing.start ( PING_UPDATE_TIME_SERVER_LIST_MS );
|
TimerPing.start ( PING_UPDATE_TIME_SERVER_LIST_MS );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConnectDlg::OnLineEditServerAddrTextChanged ( const QString )
|
|
||||||
{
|
|
||||||
// if the maximum number of items in the combo box is reached,
|
|
||||||
// delete the last item so that the new item can be added (first
|
|
||||||
// in - first out)
|
|
||||||
if ( LineEditServerAddr->count() == MAX_NUM_SERVER_ADDR_ITEMS )
|
|
||||||
{
|
|
||||||
LineEditServerAddr->removeItem ( MAX_NUM_SERVER_ADDR_ITEMS - 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CConnectDlg::OnCancelButtonClicked()
|
void CConnectDlg::OnCancelButtonClicked()
|
||||||
{
|
{
|
||||||
// set cancel flag
|
// set cancel flag
|
||||||
|
@ -248,15 +241,6 @@ void CConnectDlg::OnCancelButtonClicked()
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConnectDlg::OnLineEditServerAddrActivated ( int index )
|
|
||||||
{
|
|
||||||
// move activated list item to the top
|
|
||||||
const QString strCurIPAddress = LineEditServerAddr->itemText ( index );
|
|
||||||
LineEditServerAddr->removeItem ( index );
|
|
||||||
LineEditServerAddr->insertItem ( 0, strCurIPAddress );
|
|
||||||
LineEditServerAddr->setCurrentIndex ( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CConnectDlg::OnTimerPing()
|
void CConnectDlg::OnTimerPing()
|
||||||
{
|
{
|
||||||
// send ping messages to the servers in the list
|
// send ping messages to the servers in the list
|
||||||
|
|
|
@ -59,12 +59,15 @@ public:
|
||||||
void SetServerList ( const CHostAddress& InetAddr,
|
void SetServerList ( const CHostAddress& InetAddr,
|
||||||
const CVector<CServerInfo>& vecServerInfo );
|
const CVector<CServerInfo>& vecServerInfo );
|
||||||
|
|
||||||
void LoadStoredServers ( const CVector<QString>& vstrIPAddress );
|
void LoadStoredServers ( const CVector<QString>& vstrNewIPAddresses );
|
||||||
|
|
||||||
void SetPingTimeResult ( CHostAddress& InetAddr,
|
void SetPingTimeResult ( CHostAddress& InetAddr,
|
||||||
const int iPingTime,
|
const int iPingTime,
|
||||||
const int iPingTimeLEDColor );
|
const int iPingTimeLEDColor );
|
||||||
|
|
||||||
|
bool GetCancelPressed() const { return bCancelPressed; }
|
||||||
|
QString GetSelectedAddress() const { return strSelectedAddress; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void showEvent ( QShowEvent* );
|
virtual void showEvent ( QShowEvent* );
|
||||||
virtual void hideEvent ( QHideEvent* );
|
virtual void hideEvent ( QHideEvent* );
|
||||||
|
@ -72,13 +75,13 @@ protected:
|
||||||
QTimer TimerPing;
|
QTimer TimerPing;
|
||||||
QTimer TimerReRequestServList;
|
QTimer TimerReRequestServList;
|
||||||
CHostAddress CentralServerAddress;
|
CHostAddress CentralServerAddress;
|
||||||
|
CVector<QString> vstrIPAddresses;
|
||||||
|
QString strSelectedAddress;
|
||||||
bool bServerListReceived;
|
bool bServerListReceived;
|
||||||
bool bCancelPressed;
|
bool bCancelPressed;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnCancelButtonClicked();
|
void OnCancelButtonClicked();
|
||||||
void OnLineEditServerAddrTextChanged ( const QString );
|
|
||||||
void OnLineEditServerAddrActivated ( int index );
|
|
||||||
void OnTimerPing();
|
void OnTimerPing();
|
||||||
void OnTimerReRequestServList();
|
void OnTimerReRequestServList();
|
||||||
|
|
||||||
|
|
|
@ -105,20 +105,6 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
|
||||||
"Disconnect, i.e., it implements a toggle functionality for connecting "
|
"Disconnect, i.e., it implements a toggle functionality for connecting "
|
||||||
"and disconnecting the llcon software." ) );
|
"and disconnecting the llcon software." ) );
|
||||||
|
|
||||||
// server address
|
|
||||||
QString strServAddrH = tr ( "<b>Server Address:</b> The IP address or URL "
|
|
||||||
"of the server running the llcon server software must be set here. "
|
|
||||||
"A list of the most recent used server URLs is available for "
|
|
||||||
"selection. If an invalid address was chosen, an error message is "
|
|
||||||
"shown in the status bar." );
|
|
||||||
|
|
||||||
TextLabelServerAddr->setWhatsThis ( strServAddrH );
|
|
||||||
LineEditServerAddr->setWhatsThis ( strServAddrH );
|
|
||||||
|
|
||||||
LineEditServerAddr->setAccessibleName ( tr ( "Server address edit box" ) );
|
|
||||||
LineEditServerAddr->setAccessibleDescription ( tr ( "Holds the current server "
|
|
||||||
"URL. It also stores old URLs in the combo box list." ) );
|
|
||||||
|
|
||||||
// fader tag
|
// fader tag
|
||||||
QString strFaderTag = tr ( "<b>Fader Tag:</b> The fader tag of the local "
|
QString strFaderTag = tr ( "<b>Fader Tag:</b> The fader tag of the local "
|
||||||
"client is set in the fader tag edit box. This tag will appear "
|
"client is set in the fader tag edit box. This tag will appear "
|
||||||
|
@ -253,22 +239,6 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
|
||||||
// init fader tag line edit
|
// init fader tag line edit
|
||||||
LineEditFaderTag->setText ( pClient->strName );
|
LineEditFaderTag->setText ( pClient->strName );
|
||||||
|
|
||||||
// init server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries)
|
|
||||||
LineEditServerAddr->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS );
|
|
||||||
LineEditServerAddr->setInsertPolicy ( QComboBox::InsertAtTop );
|
|
||||||
|
|
||||||
// load data from ini file
|
|
||||||
for ( int iLEIdx = 0; iLEIdx < MAX_NUM_SERVER_ADDR_ITEMS; iLEIdx++ )
|
|
||||||
{
|
|
||||||
if ( !pClient->vstrIPAddress[iLEIdx].isEmpty() )
|
|
||||||
{
|
|
||||||
LineEditServerAddr->addItem ( pClient->vstrIPAddress[iLEIdx] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// we want the cursor to be at IP address line edit at startup
|
|
||||||
LineEditServerAddr->setFocus();
|
|
||||||
|
|
||||||
// init status label
|
// init status label
|
||||||
OnTimerStatus();
|
OnTimerStatus();
|
||||||
|
|
||||||
|
@ -395,12 +365,6 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
|
||||||
QObject::connect ( LineEditFaderTag, SIGNAL ( textChanged ( const QString& ) ),
|
QObject::connect ( LineEditFaderTag, SIGNAL ( textChanged ( const QString& ) ),
|
||||||
this, SLOT ( OnFaderTagTextChanged ( const QString& ) ) );
|
this, SLOT ( OnFaderTagTextChanged ( const QString& ) ) );
|
||||||
|
|
||||||
QObject::connect ( LineEditServerAddr, SIGNAL ( editTextChanged ( const QString ) ),
|
|
||||||
this, SLOT ( OnLineEditServerAddrTextChanged ( const QString ) ) );
|
|
||||||
|
|
||||||
QObject::connect ( LineEditServerAddr, SIGNAL ( activated ( int ) ),
|
|
||||||
this, SLOT ( OnLineEditServerAddrActivated ( int ) ) );
|
|
||||||
|
|
||||||
// other
|
// other
|
||||||
QObject::connect ( pClient,
|
QObject::connect ( pClient,
|
||||||
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ),
|
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ),
|
||||||
|
@ -453,13 +417,6 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
|
||||||
// Timers ------------------------------------------------------------------
|
// Timers ------------------------------------------------------------------
|
||||||
// start timer for status bar
|
// start timer for status bar
|
||||||
TimerStatus.start ( LED_BAR_UPDATE_TIME_MS );
|
TimerStatus.start ( LED_BAR_UPDATE_TIME_MS );
|
||||||
|
|
||||||
|
|
||||||
// TEST
|
|
||||||
ConnectDlg.LoadStoredServers ( pClient->vstrIPAddress );
|
|
||||||
ConnectDlg.setModal ( true );
|
|
||||||
ConnectDlg.show();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLlconClientDlg::closeEvent ( QCloseEvent* Event )
|
void CLlconClientDlg::closeEvent ( QCloseEvent* Event )
|
||||||
|
@ -475,13 +432,6 @@ void CLlconClientDlg::closeEvent ( QCloseEvent* Event )
|
||||||
pClient->Stop();
|
pClient->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// store IP addresses
|
|
||||||
for ( int iLEIdx = 0; iLEIdx < LineEditServerAddr->count(); iLEIdx++ )
|
|
||||||
{
|
|
||||||
pClient->vstrIPAddress[iLEIdx] =
|
|
||||||
LineEditServerAddr->itemText ( iLEIdx );
|
|
||||||
}
|
|
||||||
|
|
||||||
// store fader tag
|
// store fader tag
|
||||||
pClient->strName = LineEditFaderTag->text();
|
pClient->strName = LineEditFaderTag->text();
|
||||||
|
|
||||||
|
@ -551,26 +501,6 @@ void CLlconClientDlg::OnSliderAudInFader ( int value )
|
||||||
UpdateAudioFaderSlider();
|
UpdateAudioFaderSlider();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLlconClientDlg::OnLineEditServerAddrTextChanged ( const QString )
|
|
||||||
{
|
|
||||||
// if the maximum number of items in the combo box is reached,
|
|
||||||
// delete the last item so that the new item can be added (first
|
|
||||||
// in - first out)
|
|
||||||
if ( LineEditServerAddr->count() == MAX_NUM_SERVER_ADDR_ITEMS )
|
|
||||||
{
|
|
||||||
LineEditServerAddr->removeItem ( MAX_NUM_SERVER_ADDR_ITEMS - 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CLlconClientDlg::OnLineEditServerAddrActivated ( int index )
|
|
||||||
{
|
|
||||||
// move activated list item to the top
|
|
||||||
const QString strCurIPAddress = LineEditServerAddr->itemText ( index );
|
|
||||||
LineEditServerAddr->removeItem ( index );
|
|
||||||
LineEditServerAddr->insertItem ( 0, strCurIPAddress );
|
|
||||||
LineEditServerAddr->setCurrentIndex ( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CLlconClientDlg::OnConnectDisconBut()
|
void CLlconClientDlg::OnConnectDisconBut()
|
||||||
{
|
{
|
||||||
// the connect/disconnect button implements a toggle functionality
|
// the connect/disconnect button implements a toggle functionality
|
||||||
|
@ -800,8 +730,40 @@ void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart )
|
||||||
// start/stop client, set button text
|
// start/stop client, set button text
|
||||||
if ( bDoStart )
|
if ( bDoStart )
|
||||||
{
|
{
|
||||||
|
// init the connect dialog and execute it (modal dialog)
|
||||||
|
ConnectDlg.LoadStoredServers ( pClient->vstrIPAddress );
|
||||||
|
ConnectDlg.exec();
|
||||||
|
|
||||||
|
// check if cancel was pressed
|
||||||
|
if ( !ConnectDlg.GetCancelPressed() )
|
||||||
|
{
|
||||||
|
const QString strSelectedAddress = ConnectDlg.GetSelectedAddress();
|
||||||
|
|
||||||
|
if ( !strSelectedAddress.isEmpty() )
|
||||||
|
{
|
||||||
|
CVector<QString> vstrTempList ( 0 );
|
||||||
|
|
||||||
|
// store the new address in the current server storage list at
|
||||||
|
// the top, make sure we do not have more than allowed stored
|
||||||
|
// servers
|
||||||
|
vstrTempList.Add ( strSelectedAddress );
|
||||||
|
for ( int iIdx = 0; ( iIdx < pClient->vstrIPAddress.Size() ) &&
|
||||||
|
( iIdx < ( MAX_NUM_SERVER_ADDR_ITEMS - 1 ) ); iIdx++ )
|
||||||
|
{
|
||||||
|
// only add old server address if it is not the same as the
|
||||||
|
// selected one
|
||||||
|
if ( pClient->vstrIPAddress[iIdx].compare ( strSelectedAddress ) )
|
||||||
|
{
|
||||||
|
vstrTempList.Add ( pClient->vstrIPAddress[iIdx] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy new generated list to client
|
||||||
|
pClient->vstrIPAddress = vstrTempList;
|
||||||
|
}
|
||||||
|
|
||||||
// set address and check if address is valid
|
// set address and check if address is valid
|
||||||
if ( pClient->SetServerAddr ( LineEditServerAddr->currentText() ) )
|
if ( pClient->SetServerAddr ( strSelectedAddress ) )
|
||||||
{
|
{
|
||||||
bool bStartOk = true;
|
bool bStartOk = true;
|
||||||
|
|
||||||
|
@ -834,6 +796,8 @@ void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart )
|
||||||
// show the error as red light
|
// show the error as red light
|
||||||
LEDConnection->SetLight ( MUL_COL_LED_RED );
|
LEDConnection->SetLight ( MUL_COL_LED_RED );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -152,8 +152,6 @@ public slots:
|
||||||
CVector<CServerInfo> vecServerInfo )
|
CVector<CServerInfo> vecServerInfo )
|
||||||
{ ConnectDlg.SetServerList ( InetAddr, vecServerInfo ); }
|
{ ConnectDlg.SetServerList ( InetAddr, vecServerInfo ); }
|
||||||
|
|
||||||
void OnLineEditServerAddrTextChanged ( const QString );
|
|
||||||
void OnLineEditServerAddrActivated ( int index );
|
|
||||||
void OnDisconnected();
|
void OnDisconnected();
|
||||||
void OnStopped();
|
void OnStopped();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue