Нотификация рефакт

This commit is contained in:
2025-12-17 15:15:34 +03:00
parent b7c246b3f6
commit 3953527795
7 changed files with 71 additions and 89 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -57,6 +57,8 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
waitAnimationWidget->initialize(movie,this);
waitAnimationWidget->showWithPlay();
updateStateOnlyVersion();
}
ServerLMSWidget::~ServerLMSWidget()
@@ -100,7 +102,9 @@ void ServerLMSWidget::changeEvent(QEvent *event)
{
ui->retranslateUi(this); // переведём окно заново
updateStateServer();
updateStateOnlyServer();
updateStateOnlyDB();
updateStateOnlyVersion();
}
}
@@ -161,7 +165,9 @@ void ServerLMSWidget::slot_startInitialization_step1()
flStartInitialization = true;
updateStateServer();
updateStateOnlyServer();
updateStateOnlyDB();
updateStateOnlyVersion();
QApplication::restoreOverrideCursor();
@@ -177,7 +183,7 @@ void ServerLMSWidget::slot_startInitialization_step1()
void ServerLMSWidget::slot_setVersion(QString versionStr)
{
this->versionStr = versionStr;
ui->lblVersionText->setText(versionStr);
updateStateOnlyVersion();
}
void ServerLMSWidget::start()
@@ -191,17 +197,41 @@ void ServerLMSWidget::slot_BlockAutorization(bool block)
if(block)
{
server->blockAutorization();
ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/lock.png")));
//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")));
//ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/open.png")));
//emit signal_Tray_ShowMessage(tr("Authorization unblocked!"));
}
//updateStateServer();
emit signal_updateStateServer(server->getStateServer(), server->getStateBlockAutorization());
//emit signal_updateStateServer(server->getStateServer(), server->getStateBlockAutorization());
if(server)
{
if(server->getStateServer() == EStateServer::started)
{
if(server->getStateBlockAutorization() == EStateBlockAutorization::unblocked)
{
ui->lblOnOffText->setText(tr("started"));
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
}
else
{
ui->lblOnOffText->setText(tr("started") + ", " + tr("locked"));
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/lock.png")));
}
}
else
{
ui->lblOnOffText->setText(tr("stoped"));
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/stop.png")));
}
emit signal_updateStateServer(server->getStateServer(), server->getStateBlockAutorization());
}
}
void ServerLMSWidget::slot_LanguageChanged(QString language)
@@ -223,7 +253,7 @@ void ServerLMSWidget::on_btnStartServer_clicked()
ui->btnStopServer->setEnabled(true);
slot_BlockAutorization(false);
updateStateServer();
updateStateOnlyServer();
emit signal_Tray_ShowMessage(tr("Server is started!"));
}
@@ -237,7 +267,7 @@ void ServerLMSWidget::on_btnStopServer_clicked()
ui->btnStartServer->setEnabled(true);
slot_BlockAutorization(true);
updateStateServer();
updateStateOnlyServer();
emit signal_Tray_ShowMessage(tr("Server is stoped!"));
}
@@ -275,7 +305,7 @@ void ServerLMSWidget::on_btnSettings_clicked()
providerDBLMS->DisConnectionFromDB();
updateStateServer();
updateStateOnlyDB();
SpecMsgBox::WarningClose(this, tr("Database settings have been changed.\nThe server will be restarted."));
@@ -296,12 +326,12 @@ void ServerLMSWidget::slot_trySetServerState(PacketType packetType)
if (packetType == PacketType::BUSY)
{
server->blockAutorization();
updateStateServer();
updateStateOnlyServer();
}
else if (packetType == PacketType::FREE)
{
server->unBlockAutorization();
updateStateServer();
updateStateOnlyServer();
}
}
@@ -440,36 +470,38 @@ void ServerLMSWidget::tryConnectionToDB()
on_btnStartServer_clicked();
}
updateStateServer();
updateStateOnlyDB();
}
void ServerLMSWidget::updateStateServer()
void ServerLMSWidget::updateStateOnlyServer()
{
if(server)
{
if(server->getStateServer() == EStateServer::started)
{
ui->lblOnOffText->setText(tr("started"));
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
if(server->getStateBlockAutorization() == EStateBlockAutorization::unblocked)
{
ui->lblOnOffText->setText(tr("started"));
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
}
else
{
ui->lblOnOffText->setText(tr("started") + ", " + tr("locked"));
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/lock.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")));
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/stop.png")));
}
emit signal_updateStateServer(server->getStateServer(), server->getStateBlockAutorization());
}
}
void ServerLMSWidget::updateStateOnlyDB()
{
if(providerDBLMS)
{
if(providerDBLMS->DBisConnected())
@@ -492,6 +524,9 @@ void ServerLMSWidget::updateStateServer()
ui->btnStartServer->setEnabled(false);
}
}
}
void ServerLMSWidget::updateStateOnlyVersion()
{
ui->lblVersionText->setText(versionStr);
}

View File

@@ -155,7 +155,9 @@ private:
void tryConnectionToDB();
void updateStateServer();
void updateStateOnlyServer();
void updateStateOnlyDB();
void updateStateOnlyVersion();
private:
Ui::ServerLMSWidget *ui;

View File

@@ -68,7 +68,7 @@
<string>Start</string>
</property>
<property name="icon">
<iconset resource="ServerLMS.qrc">
<iconset resource="Server.qrc">
<normaloff>:/resources/icons/rocket.png</normaloff>:/resources/icons/rocket.png</iconset>
</property>
<property name="iconSize">
@@ -109,7 +109,7 @@
<string>Stop</string>
</property>
<property name="icon">
<iconset resource="ServerLMS.qrc">
<iconset resource="Server.qrc">
<normaloff>:/resources/icons/stop.png</normaloff>:/resources/icons/stop.png</iconset>
</property>
<property name="iconSize">
@@ -148,7 +148,7 @@
<string>Settings</string>
</property>
<property name="icon">
<iconset resource="../InstructorsAndTrainees/InstructorsAndTrainees.qrc">
<iconset resource="../LibInstructorsAndTrainees/InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/settings.png</normaloff>:/resources/icons/settings.png</iconset>
</property>
<property name="iconSize">
@@ -250,7 +250,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="../InstructorsAndTrainees/InstructorsAndTrainees.qrc">:/resources/icons/circleGray.png</pixmap>
<pixmap resource="../LibInstructorsAndTrainees/InstructorsAndTrainees.qrc">:/resources/icons/circleGray.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
@@ -268,7 +268,7 @@
<widget class="QLabel" name="lblOnOffText">
<property name="minimumSize">
<size>
<width>100</width>
<width>200</width>
<height>0</height>
</size>
</property>
@@ -305,7 +305,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="../InstructorsAndTrainees/InstructorsAndTrainees.qrc">:/resources/icons/circleGray.png</pixmap>
<pixmap resource="../LibInstructorsAndTrainees/InstructorsAndTrainees.qrc">:/resources/icons/circleGray.png</pixmap>
</property>
</widget>
</item>
@@ -374,61 +374,6 @@
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_Block">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Authorization</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblBlockAuth">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<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="ServerLMS.qrc">:/resources/icons/lock.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
@@ -436,8 +381,8 @@
</layout>
</widget>
<resources>
<include location="../InstructorsAndTrainees/InstructorsAndTrainees.qrc"/>
<include location="ServerLMS.qrc"/>
<include location="../LibInstructorsAndTrainees/InstructorsAndTrainees.qrc"/>
<include location="Server.qrc"/>
</resources>
<connections/>
</ui>