Рефакт

This commit is contained in:
2025-10-27 18:46:50 +03:00
parent ce65daea2e
commit 39c11897f8
7 changed files with 83 additions and 23 deletions

View File

@@ -15,5 +15,6 @@
<file>resources/icons/rocket.png</file>
<file>resources/icons/stop.png</file>
<file>resources/icons/settings.png</file>
<file>resources/icons/circleGray.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -40,11 +40,7 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
updateMyStyleSheet();
setLanguageInterfase();
startInitialization();
tryConnectionToDB();
setLanguageInterfase();
}
ServerLMSWidget::~ServerLMSWidget()
@@ -95,10 +91,12 @@ void ServerLMSWidget::changeEvent(QEvent *event)
dbSettings.dbHostName,
QString::number(dbSettings.dbPort));
ui->lblDBsettings->setText(strDBsettings);
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
}
else
{
ui->lblDBsettings->setText("");
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
}
}
}
@@ -126,17 +124,25 @@ void ServerLMSWidget::slot_AddMessageToLog(QString message)
ui->loggerTextField->appendPlainText(message);
}
void ServerLMSWidget::start()
{
startInitialization();
tryConnectionToDB();
}
void ServerLMSWidget::slot_BlockAutorization(bool block)
{
if(block)
{
server->blockAutorization();
ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/lock.png")));
//emit signal_Tray_ShowMessage(tr("Authorization blocked!"));
}
else
{
server->unBlockAutorization();
ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/open.png")));
//emit signal_Tray_ShowMessage(tr("Authorization unblocked!"));
}
}
@@ -197,6 +203,7 @@ void ServerLMSWidget::on_btnSettings_clicked()
providerDBLMS->DisConnectionFromDB();
ui->lblDBsettings->setText("");
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
QMessageBox::warning(this, tr("Warning!"), tr("Database settings have been changed.\nThe server will be restarted."));
@@ -315,9 +322,12 @@ 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"));
//QMessageBox::critical(this, tr("Error!"), tr("Database connection error!"));
emit signal_Tray_ShowMessage(tr("Database connection error!"));
}
else
{
@@ -330,6 +340,9 @@ void ServerLMSWidget::tryConnectionToDB()
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();
}

View File

@@ -62,6 +62,9 @@ signals:
//сигнал смены языка
void signal_LanguageChanged(QString language);
//сигнал вывода сообщения из трея
void signal_Tray_ShowMessage(QString textMsg);
void sigRecognize();
void sigCalculateFullHash();
void sigUpdateController(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager);
@@ -101,6 +104,8 @@ public:
void removeClient(int socketId);
void start();
private slots:
void on_btnStartServer_clicked();
void on_btnStopServer_clicked();

View File

@@ -223,6 +223,28 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_DBsettings">
<item>
<widget class="QLabel" name="lblDBisConnected">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../InstructorsAndTrainees/InstructorsAndTrainees.qrc">:/resources/icons/circleGray.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_DataBase">
<property name="sizePolicy">