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

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

View File

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

View File

@@ -68,7 +68,7 @@
<string>Start</string> <string>Start</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ServerLMS.qrc"> <iconset resource="Server.qrc">
<normaloff>:/resources/icons/rocket.png</normaloff>:/resources/icons/rocket.png</iconset> <normaloff>:/resources/icons/rocket.png</normaloff>:/resources/icons/rocket.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@@ -109,7 +109,7 @@
<string>Stop</string> <string>Stop</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ServerLMS.qrc"> <iconset resource="Server.qrc">
<normaloff>:/resources/icons/stop.png</normaloff>:/resources/icons/stop.png</iconset> <normaloff>:/resources/icons/stop.png</normaloff>:/resources/icons/stop.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@@ -148,7 +148,7 @@
<string>Settings</string> <string>Settings</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../InstructorsAndTrainees/InstructorsAndTrainees.qrc"> <iconset resource="../LibInstructorsAndTrainees/InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/settings.png</normaloff>:/resources/icons/settings.png</iconset> <normaloff>:/resources/icons/settings.png</normaloff>:/resources/icons/settings.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@@ -250,7 +250,7 @@
<string/> <string/>
</property> </property>
<property name="pixmap"> <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>
<property name="scaledContents"> <property name="scaledContents">
<bool>true</bool> <bool>true</bool>
@@ -268,7 +268,7 @@
<widget class="QLabel" name="lblOnOffText"> <widget class="QLabel" name="lblOnOffText">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>100</width> <width>200</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
@@ -305,7 +305,7 @@
<string/> <string/>
</property> </property>
<property name="pixmap"> <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>
</widget> </widget>
</item> </item>
@@ -374,61 +374,6 @@
</item> </item>
</layout> </layout>
</item> </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> </layout>
</item> </item>
</layout> </layout>
@@ -436,8 +381,8 @@
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="../InstructorsAndTrainees/InstructorsAndTrainees.qrc"/> <include location="../LibInstructorsAndTrainees/InstructorsAndTrainees.qrc"/>
<include location="ServerLMS.qrc"/> <include location="Server.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>