This commit is contained in:
2025-11-01 13:19:52 +03:00
parent 0d1d851e3f
commit e9363c388b
22 changed files with 801 additions and 484 deletions

View File

@@ -40,7 +40,7 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
updateMyStyleSheet();
setLanguageInterfase();
setLanguageInterfase();
}
ServerLMSWidget::~ServerLMSWidget()
@@ -49,7 +49,6 @@ ServerLMSWidget::~ServerLMSWidget()
{
server->stopServer();
//updateThread->exit();
updateThread->quit();
updateThread->wait();
delete updateThread;
@@ -64,7 +63,6 @@ ServerLMSWidget::~ServerLMSWidget()
delete mutex;
//loggerThread->exit();
loggerThread->quit();
loggerThread->wait();
delete loggerThread;
@@ -82,20 +80,7 @@ void ServerLMSWidget::changeEvent(QEvent *event)
{
ui->retranslateUi(this); // переведём окно заново
if(providerDBLMS->DBisConnected())
{
//Настройки БД
DataBaseSettings dbSettings = providerDBLMS->getDBSettings();
QString strDBsettings = QString("%1 (%2) %3 : %4").arg(dbSettings.dbName,
dbSettings.dbType,
dbSettings.dbHostName,
QString::number(dbSettings.dbPort));
ui->lblDBsettings->setText(strDBsettings);
}
else
{
ui->lblDBsettings->setText("");
}
updateStateServer();
}
}
@@ -161,9 +146,11 @@ void ServerLMSWidget::on_btnStartServer_clicked()
ui->btnStartServer->setEnabled(false);
ui->btnStopServer->setEnabled(true);
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/switchOn.png")));
slot_BlockAutorization(false);
emit signal_Tray_ShowMessage(tr("Server is started!"));
}
updateStateServer();
}
void ServerLMSWidget::on_btnStopServer_clicked()
@@ -172,9 +159,11 @@ void ServerLMSWidget::on_btnStopServer_clicked()
{
ui->btnStopServer->setEnabled(false);
ui->btnStartServer->setEnabled(true);
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/switchOff.png")));
slot_BlockAutorization(true);
emit signal_Tray_ShowMessage(tr("Server is stoped!"));
}
updateStateServer();
}
void ServerLMSWidget::on_btnSettings_clicked()
@@ -200,8 +189,7 @@ void ServerLMSWidget::on_btnSettings_clicked()
providerDBLMS->DisConnectionFromDB();
ui->lblDBsettings->setText("");
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
updateStateServer();
QMessageBox::warning(this, tr("Warning!"), tr("Database settings have been changed.\nThe server will be restarted."));
@@ -313,19 +301,19 @@ void ServerLMSWidget::startInitialization()
ui->btnStartServer->setEnabled(true);
flStartInitialization = true;
updateStateServer();
}
void ServerLMSWidget::tryConnectionToDB()
{
if(! providerDBLMS->ConnectionToDB())
{
ui->lblDBsettings->setText("");
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
ui->btnStopServer->setEnabled(false);
ui->btnStartServer->setEnabled(false);
//QMessageBox::critical(this, tr("Error!"), tr("Database connection error!"));
emit signal_Tray_ShowMessage(tr("Database connection error!"), QSystemTrayIcon::Critical);
emit signal_Menu_ShowWindow();
QMessageBox::critical(this, tr("Error!"), tr("Database connection error!"));
}
else
{
@@ -337,11 +325,60 @@ void ServerLMSWidget::tryConnectionToDB()
dbSettings.dbType,
dbSettings.dbHostName,
QString::number(dbSettings.dbPort));
ui->lblDBsettings->setText(strDBsettings);
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
emit signal_Tray_ShowMessage(tr("Database connection OK!") + "\n" + strDBsettings);
on_btnStartServer_clicked();
}
updateStateServer();
}
void ServerLMSWidget::updateStateServer()
{
if(server)
{
if(server->getStateServer() == EStateServer::started)
{
ui->lblOnOffText->setText(tr("started"));
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
}
else
{
ui->lblOnOffText->setText(tr("stoped"));
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
}
if(server->getStateBlockAutorization() == EStateBlockAutorization::unblocked)
{
ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/open.png")));
}
else
{
ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/lock.png")));
}
}
if(providerDBLMS)
{
if(providerDBLMS->DBisConnected())
{
//Настройки БД
DataBaseSettings dbSettings = providerDBLMS->getDBSettings();
QString strDBsettings = tr("connected") + QString(" [%1 (%2) %3 : %4]").arg(dbSettings.dbName,
dbSettings.dbType,
dbSettings.dbHostName,
QString::number(dbSettings.dbPort));
ui->lblDBsettings->setText(strDBsettings);
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
}
else
{
ui->lblDBsettings->setText(tr("not connected"));
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
ui->btnStopServer->setEnabled(false);
ui->btnStartServer->setEnabled(false);
}
}
}