Кнопка Обновить версию в Настройках

This commit is contained in:
2025-05-29 09:48:58 +03:00
parent 2398ab609a
commit 030837bde8
9 changed files with 67 additions and 18 deletions

View File

@@ -13,6 +13,10 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Learning management system (LMS)</string> <string>Learning management system (LMS)</string>
</property> </property>
<property name="windowIcon">
<iconset resource="testDBpgSQL.qrc">
<normaloff>:/resources/lms.png</normaloff>:/resources/lms.png</iconset>
</property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="1"> <item row="1" column="1">
@@ -36,6 +40,8 @@
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
</widget> </widget>
<resources/> <resources>
<include location="testDBpgSQL.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -1,3 +1,5 @@
<RCC> <RCC>
<qresource prefix="/"/> <qresource prefix="/">
<file>resources/lms.png</file>
</qresource>
</RCC> </RCC>

View File

@@ -5,15 +5,17 @@
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <QRegExpValidator> #include <QRegExpValidator>
DialogSettings::DialogSettings(bool serverIsConnected, QWidget *parent) : DialogSettings::DialogSettings(ConnectorToServer* connectorToServer, bool instructorIsLogged, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::DialogSettings), ui(new Ui::DialogSettings),
settings(nullptr) settings(nullptr),
connectorToServer(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->btnUpdateStyle->setObjectName("btnUpdateStyle"); ui->btnUpdateStyle->setObjectName("btnUpdateStyle");
ui->btnSave->setObjectName("btnSave"); ui->btnSave->setObjectName("btnSave");
this->connectorToServer = connectorToServer;
/* Создаем строку для регулярного выражения */ /* Создаем строку для регулярного выражения */
QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"; QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";
@@ -49,11 +51,16 @@ DialogSettings::DialogSettings(bool serverIsConnected, QWidget *parent) :
ui->checkAutoStart->setChecked(settings->isAutoStart); ui->checkAutoStart->setChecked(settings->isAutoStart);
} }
if(serverIsConnected) ui->btnSetVersion->setEnabled(false);
if(connectorToServer)
if(connectorToServer->getIsConnected())
{ {
ui->editAddress->setEnabled(false); ui->editAddress->setEnabled(false);
ui->editPort->setEnabled(false); ui->editPort->setEnabled(false);
ui->checkAutoStart->setEnabled(false); ui->checkAutoStart->setEnabled(false);
if(instructorIsLogged)
ui->btnSetVersion->setEnabled(true);
} }
} }
@@ -199,3 +206,10 @@ void DialogSettings::on_DialogSettings_rejected()
emit signal_LanguageChanged(language); emit signal_LanguageChanged(language);
} }
void DialogSettings::on_btnSetVersion_clicked()
{
if(connectorToServer)
if(connectorToServer->getIsConnected())
connectorToServer->showVersionSelect();
}

View File

@@ -5,6 +5,7 @@
#include <QTranslator> #include <QTranslator>
#include <QEvent> #include <QEvent>
#include "Datas.h" #include "Datas.h"
#include "connectortoserver.h"
namespace Ui { namespace Ui {
class DialogSettings; class DialogSettings;
@@ -15,7 +16,7 @@ class DialogSettings : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit DialogSettings(bool serverIsConnected, QWidget *parent = nullptr); explicit DialogSettings(ConnectorToServer* connectorToServer, bool instructorIsLogged, QWidget *parent = nullptr);
~DialogSettings(); ~DialogSettings();
protected: protected:
@@ -35,6 +36,8 @@ private slots:
void on_DialogSettings_rejected(); void on_DialogSettings_rejected();
void on_btnSetVersion_clicked();
private: private:
bool loadSettings(); bool loadSettings();
bool saveSettings(); bool saveSettings();
@@ -44,6 +47,7 @@ private:
QTranslator qtLanguageTranslator; QTranslator qtLanguageTranslator;
ServerSettings *settings; ServerSettings *settings;
ConnectorToServer* connectorToServer;
}; };
#endif // DIALOGSETTINGS_H #endif // DIALOGSETTINGS_H

View File

@@ -225,6 +225,32 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QToolButton" name="btnSetVersion">
<property name="minimumSize">
<size>
<width>58</width>
<height>58</height>
</size>
</property>
<property name="text">
<string>Update version</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/resources/icons/updateVersion.png</normaloff>:/resources/icons/updateVersion.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QToolButton" name="btnUpdateStyle"> <widget class="QToolButton" name="btnUpdateStyle">
<property name="minimumSize"> <property name="minimumSize">

View File

@@ -212,7 +212,7 @@ void InstructorsAndTraineesWidget::checkLoginResult(ServerAuthorization *serverA
viewerTrainees->setAuthComplited(true); viewerTrainees->setAuthComplited(true);
Q_EMIT signal_NeedUpdateUI(true, true); Q_EMIT signal_NeedUpdateUI(true, true);
ui->btnSetVersion->show(); //ui->btnSetVersion->show();
ui->btnAuthorizationInstructor->setText(tr("Deauthorization Instructor")); ui->btnAuthorizationInstructor->setText(tr("Deauthorization Instructor"));
updateLabelLoggedInInstructor(serverAuth->Login, serverAuth->ClientName); updateLabelLoggedInInstructor(serverAuth->Login, serverAuth->ClientName);
@@ -275,7 +275,7 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
ui->btnAuthorizationInstructor->setEnabled(false); ui->btnAuthorizationInstructor->setEnabled(false);
ui->btnAuthorizationInstructor->setText(tr("Authorization Instructor")); ui->btnAuthorizationInstructor->setText(tr("Authorization Instructor"));
ui->btnAuthorizationInstructor->setChecked(false); ui->btnAuthorizationInstructor->setChecked(false);
ui->btnSetVersion->hide(); //ui->btnSetVersion->hide();
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png"))); ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
ui->lblServer->setText(tr("none")); ui->lblServer->setText(tr("none"));
@@ -470,11 +470,7 @@ void InstructorsAndTraineesWidget::on_tabWidget_currentChanged(int index)
void InstructorsAndTraineesWidget::on_btnSettings_clicked() void InstructorsAndTraineesWidget::on_btnSettings_clicked()
{ {
bool serverIsConnected = false; DialogSettings dlg(connectorToServer, (loginInstructorLoggedInLocal != ""), this);
if(connectorToServer)
serverIsConnected = connectorToServer->getIsConnected();
DialogSettings dlg(serverIsConnected, this);
connect(&dlg, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged); connect(&dlg, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged);
connect(&dlg, &DialogSettings::signal_UpdateStyleSheet, this, &InstructorsAndTraineesWidget::slot_UpdateStyleSheet); connect(&dlg, &DialogSettings::signal_UpdateStyleSheet, this, &InstructorsAndTraineesWidget::slot_UpdateStyleSheet);

View File

@@ -49,5 +49,6 @@
<file>resources/icons/circleYellow.png</file> <file>resources/icons/circleYellow.png</file>
<file>resources/icons/settings.png</file> <file>resources/icons/settings.png</file>
<file>resources/icons/style.png</file> <file>resources/icons/style.png</file>
<file>resources/icons/updateVersion.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB