mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
GUI. автоматические 10 попыток подкл к Серверу
This commit is contained in:
@@ -88,7 +88,7 @@ void ConnectorToServer::initialize()
|
||||
|
||||
emit sigInitializeClient(recognizeSystem,sendSystem,connectionThread);
|
||||
|
||||
SetConnectToServer();
|
||||
//SetConnectToServer();
|
||||
}
|
||||
|
||||
void ConnectorToServer::bindConnection()
|
||||
|
||||
@@ -14,6 +14,7 @@ const QString InstructorsAndTraineesWidget::languageRUS = "ru_RU";
|
||||
|
||||
InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
waitAnimationWidget(nullptr),
|
||||
connectorToServer(nullptr),
|
||||
viewerTrainees(nullptr),
|
||||
viewerInstructors(nullptr),
|
||||
@@ -26,6 +27,8 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
idInstructorLoggedInLocal("0"),
|
||||
language(languageENG),
|
||||
flSettingsServerIsChanged(false),
|
||||
flTryConnectToServer(false),
|
||||
cntTryConnectToServer(0),
|
||||
ui(new Ui::InstructorsAndTraineesWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -86,6 +89,13 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
ui->btnEditorTrainees->setEnabled(false);
|
||||
ui->btnEditorInstructors->setEnabled(false);
|
||||
ui->btnPersonalCard->setEnabled(false);
|
||||
|
||||
waitAnimationWidget = new WaitAnimationWidget;
|
||||
QMovie *movie = new QMovie(":/resources/icons/762.gif");
|
||||
waitAnimationWidget->setParent(this);
|
||||
waitAnimationWidget->initialize(movie,this);
|
||||
|
||||
ui->btnConnectionToServer->click();
|
||||
}
|
||||
|
||||
InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
|
||||
@@ -100,6 +110,10 @@ InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
|
||||
delete viewerInstructors;
|
||||
delete viewerTrainees;
|
||||
delete connectorToServer;
|
||||
|
||||
waitAnimationWidget->hideWithStop();
|
||||
delete waitAnimationWidget;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -120,6 +134,12 @@ void InstructorsAndTraineesWidget::changeEvent(QEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void InstructorsAndTraineesWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QSize size = event->size();
|
||||
waitAnimationWidget->resize(size);
|
||||
}
|
||||
|
||||
void InstructorsAndTraineesWidget::updateMyStyleSheet()
|
||||
{
|
||||
QString styleSheet = loadStyleSheet();
|
||||
@@ -238,11 +258,18 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
|
||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
|
||||
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
|
||||
|
||||
flTryConnectToServer = false;
|
||||
cntTryConnectToServer = 0;
|
||||
waitAnimationWidget->hideWithStop();
|
||||
|
||||
updateLabelServer();
|
||||
|
||||
ui->btnAuthorizationInstructor->click();
|
||||
}
|
||||
else
|
||||
{//Сервер отключен
|
||||
ui->btnConnectionToServer->setEnabled(true);
|
||||
//ui->btnConnectionToServer->setEnabled(true);
|
||||
ui->btnAuthorizationInstructor->setEnabled(false);
|
||||
ui->btnAuthorizationInstructor->setChecked(false);
|
||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
|
||||
@@ -263,12 +290,41 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
|
||||
nameInstructorLoggedInLocal = "";
|
||||
|
||||
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
|
||||
updateLabelServer();
|
||||
|
||||
|
||||
if(flTryConnectToServer)
|
||||
{
|
||||
if(cntTryConnectToServer < 10)
|
||||
{
|
||||
QThread::sleep(1);
|
||||
cntTryConnectToServer++;
|
||||
connectorToServer->SetConnectToServer();
|
||||
}
|
||||
else
|
||||
{
|
||||
flTryConnectToServer = false;
|
||||
cntTryConnectToServer = 0;
|
||||
ui->btnConnectionToServer->setEnabled(true);
|
||||
waitAnimationWidget->hideWithStop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flTryConnectToServer = false;
|
||||
cntTryConnectToServer = 0;
|
||||
ui->btnConnectionToServer->setEnabled(true);
|
||||
}
|
||||
|
||||
if(!flSettingsServerIsChanged)
|
||||
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("The server is not available!")).exec();
|
||||
{
|
||||
if(!flTryConnectToServer)
|
||||
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("The server is not available!")).exec();
|
||||
}
|
||||
else
|
||||
flSettingsServerIsChanged = false;
|
||||
|
||||
|
||||
updateLabelServer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,6 +420,15 @@ bool InstructorsAndTraineesWidget::authorizationIsCompleted()
|
||||
|
||||
void InstructorsAndTraineesWidget::on_btnConnectionToServer_clicked()
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
|
||||
ui->btnConnectionToServer->setEnabled(false);
|
||||
|
||||
flTryConnectToServer = true;
|
||||
cntTryConnectToServer = 1;
|
||||
|
||||
updateLabelServer();
|
||||
|
||||
connectorToServer->SetConnectToServer();
|
||||
}
|
||||
|
||||
@@ -426,13 +491,20 @@ void InstructorsAndTraineesWidget::updateLabelServer()
|
||||
if(!connectorToServer)
|
||||
return;
|
||||
|
||||
if(connectorToServer->getIsConnected())
|
||||
if(flTryConnectToServer)
|
||||
{
|
||||
ServerSettings serverSettings = connectorToServer->getServerSettings();
|
||||
ui->lblServer->setText(tr("connected") + " " + serverSettings.Address + " : " +serverSettings.Port);
|
||||
ui->lblServer->setText(tr("Connection attempt") + QString(" %1 ").arg(cntTryConnectToServer) + "...");
|
||||
}
|
||||
else
|
||||
ui->lblServer->setText(tr("not connected"));
|
||||
{
|
||||
if(connectorToServer->getIsConnected())
|
||||
{
|
||||
ServerSettings serverSettings = connectorToServer->getServerSettings();
|
||||
ui->lblServer->setText(tr("connected") + " " + serverSettings.Address + " : " +serverSettings.Port);
|
||||
}
|
||||
else
|
||||
ui->lblServer->setText(tr("not connected"));
|
||||
}
|
||||
}
|
||||
|
||||
void InstructorsAndTraineesWidget::setLanguageInterfase()
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
|
||||
private:
|
||||
void changeEvent(QEvent * event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private:
|
||||
void updateMyStyleSheet();
|
||||
@@ -85,6 +86,8 @@ private:
|
||||
void setLanguageInterfase();
|
||||
|
||||
private:
|
||||
WaitAnimationWidget *waitAnimationWidget;
|
||||
|
||||
ConnectorToServer* connectorToServer;
|
||||
|
||||
ViewerTrainees* viewerTrainees;
|
||||
@@ -104,6 +107,9 @@ private:
|
||||
|
||||
bool flSettingsServerIsChanged;
|
||||
|
||||
bool flTryConnectToServer;
|
||||
int cntTryConnectToServer;
|
||||
|
||||
Ui::InstructorsAndTraineesWidget *ui;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user