From 068a4ee14a4d296ff9c598d54a187d97c7d3934d Mon Sep 17 00:00:00 2001 From: krivoshein Date: Mon, 20 Oct 2025 18:47:13 +0300 Subject: [PATCH] Settings 1 --- GUIdataBaseLMS/mainwindow.h | 3 +- InstructorsAndTrainees/dialogsettings.ui | 12 +- .../instructorsandtraineeswidget.ui | 18 +- ServerLMS/CMakeLists.txt | 3 + ServerLMS/ServerLMS.qrc | 1 + ServerLMS/dialogsettingstray.cpp | 163 ++++++++++++++++++ ServerLMS/dialogsettingstray.h | 56 ++++++ ServerLMS/dialogsettingstray.ui | 110 ++++++++++++ ServerLMS/resources/icons/settings.png | Bin 0 -> 4274 bytes ServerLMS/serverlmswidget.cpp | 50 +++++- ServerLMS/serverlmswidget.h | 12 ++ ServerLMS/serverlmswidget.ui | 61 +++++-- TrayServerLMS/mainwindow.cpp | 18 +- TrayServerLMS/mainwindow.h | 6 +- 14 files changed, 470 insertions(+), 43 deletions(-) create mode 100644 ServerLMS/dialogsettingstray.cpp create mode 100644 ServerLMS/dialogsettingstray.h create mode 100644 ServerLMS/dialogsettingstray.ui create mode 100644 ServerLMS/resources/icons/settings.png diff --git a/GUIdataBaseLMS/mainwindow.h b/GUIdataBaseLMS/mainwindow.h index b6e7afe..4bb13ad 100644 --- a/GUIdataBaseLMS/mainwindow.h +++ b/GUIdataBaseLMS/mainwindow.h @@ -28,8 +28,7 @@ public Q_SLOTS: private: Ui::MainWindow *ui; - QTranslator qtLanguageTranslator; - InstructorsAndTraineesWidget* instructorsAndTraineesWidget; + QTranslator qtLanguageTranslator; }; #endif // MAINWINDOW_H diff --git a/InstructorsAndTrainees/dialogsettings.ui b/InstructorsAndTrainees/dialogsettings.ui index a994d69..9c38188 100644 --- a/InstructorsAndTrainees/dialogsettings.ui +++ b/InstructorsAndTrainees/dialogsettings.ui @@ -26,7 +26,7 @@ Settings - + :/resources/icons/lms.png:/resources/icons/lms.png @@ -232,7 +232,7 @@ Save - + :/resources/icons/circleGreen.png:/resources/icons/circleGreen.png @@ -291,7 +291,7 @@ Version - + :/resources/icons/updateVersion.png:/resources/icons/updateVersion.png @@ -323,7 +323,7 @@ Style - + :/resources/icons/style.png:/resources/icons/style.png @@ -359,8 +359,6 @@ - - - + diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.ui b/InstructorsAndTrainees/instructorsandtraineeswidget.ui index 1588cc7..4621831 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.ui +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.ui @@ -53,7 +53,7 @@ Connection - + :/resources/icons/connectDB.png:/resources/icons/connectDB.png @@ -82,7 +82,7 @@ Authorization - + :/resources/icons/login-user.png:/resources/icons/login-user.png @@ -111,7 +111,7 @@ Trainee editor - + :/resources/icons/DB-trainees.png:/resources/icons/DB-trainees.png @@ -137,7 +137,7 @@ Instructor editor - + :/resources/icons/DB-instructors.png:/resources/icons/DB-instructors.png @@ -163,7 +163,7 @@ Personal card - + :/resources/icons/personalCard.png:/resources/icons/personalCard.png @@ -202,7 +202,7 @@ Settings - + :/resources/icons/settings.png:/resources/icons/settings.png @@ -323,7 +323,7 @@ - :/resources/icons/circleGray.png + :/resources/icons/circleGray.png true @@ -379,7 +379,7 @@ - :/resources/icons/circleGray.png + :/resources/icons/circleGray.png true @@ -427,7 +427,7 @@ - + diff --git a/ServerLMS/CMakeLists.txt b/ServerLMS/CMakeLists.txt index e35e17e..151a7bc 100644 --- a/ServerLMS/CMakeLists.txt +++ b/ServerLMS/CMakeLists.txt @@ -7,6 +7,9 @@ add_library(ServerLMS SHARED serverlmswidget.cpp serverlmswidget.h serverlmswidget.ui + dialogsettingstray.cpp + dialogsettingstray.h + dialogsettingstray.ui clienthandler.cpp clienthandler.h multithreadserver.cpp diff --git a/ServerLMS/ServerLMS.qrc b/ServerLMS/ServerLMS.qrc index ccce1a3..041e467 100644 --- a/ServerLMS/ServerLMS.qrc +++ b/ServerLMS/ServerLMS.qrc @@ -14,5 +14,6 @@ resources/icons/open.png resources/icons/rocket.png resources/icons/stop.png + resources/icons/settings.png diff --git a/ServerLMS/dialogsettingstray.cpp b/ServerLMS/dialogsettingstray.cpp new file mode 100644 index 0000000..8edbe4e --- /dev/null +++ b/ServerLMS/dialogsettingstray.cpp @@ -0,0 +1,163 @@ +#include "dialogsettingstray.h" +#include "ui_dialogsettingstray.h" + +DialogSettingsTray::DialogSettingsTray(QWidget *parent) : + QDialog(parent), + ui(new Ui::DialogSettingsTray), + settings(nullptr), + flSettingsServerChanged(false) +{ + ui->setupUi(this); + + settings = new DBSettings; + + //Задаём два пункта с текстом локалей в комбобоксе + ui->cmbLanguage->addItems(QStringList() << "English" << "Русский"); + + if(loadSettings(settings)) + { + if(settings->Language == "ENG") + ui->cmbLanguage->setCurrentText("English"); + else + ui->cmbLanguage->setCurrentText("Русский"); + + //ui->editAddress->setText(settings->Address); + //ui->editPort->setText(settings->Port); + } + + ui->btnSave->setEnabled(false); + flSettingsServerChanged = false; +} + +DialogSettingsTray::~DialogSettingsTray() +{ + delete ui; + delete settings; +} + +DBSettings DialogSettingsTray::getSettings() +{ + return *settings; +} + +bool DialogSettingsTray::loadSettings(DBSettings *settings) +{ + /* + QFile file(settingsName); + if(! file.open(QIODevice::ReadOnly)) + return false; + + QXmlStreamReader xmlReader(&file); + + while (!xmlReader.atEnd()){ + + if(xmlReader.isStartElement()){ + + if(xmlReader.name() == "ServerSettings") + { + + foreach(const QXmlStreamAttribute &attr, xmlReader.attributes()){ + QString name = attr.name().toString(); + QString value = attr.value().toString(); + + if(name == "Address"){ + settings->Address = value; + } + + if(name == "Port"){ + settings->Port = value; + } + + if(name == "Language"){ + settings->Language = value; + } + + if(name == "AutoStart"){ + settings->isAutoStart = value.toInt(); + } + + } + } + } + + xmlReader.readNext(); + } + + file.close(); + */ + + return true; +} + +void DialogSettingsTray::on_cmbLanguage_currentTextChanged(const QString &arg1) +{ + +} + +void DialogSettingsTray::on_btnSave_clicked() +{ + if(ui->cmbLanguage->currentText() == QStringLiteral("English")) + { + settings->Language = "ENG"; + } + else + { + settings->Language = "RUS"; + } + + //settings->Address = ui->editAddress->text(); + //settings->Port = ui->editPort->text(); + + saveSettings(); + + this->accept(); +} + +bool DialogSettingsTray::saveSettings() +{ + /* + QFile file(settingsName); + + if(! file.open(QIODevice::WriteOnly)) + return false; + + QXmlStreamWriter xmlWriter(&file); + + xmlWriter.setAutoFormatting(true); + xmlWriter.writeStartDocument(); + + xmlWriter.writeStartElement("ServerSettingsContainer"); + xmlWriter.writeStartElement("ServerSettings"); + + xmlWriter.writeAttribute("Address", settings->Address); + xmlWriter.writeAttribute("Port", settings->Port); + xmlWriter.writeAttribute("Language", settings->Language); + xmlWriter.writeAttribute("AutoStart", QString::number(settings->isAutoStart)); + + xmlWriter.writeEndElement(); + xmlWriter.writeEndElement(); + + xmlWriter.writeEndDocument(); + + file.close(); + */ + + return true; +} + +void DialogSettingsTray::on_cmbLanguage_currentIndexChanged(int index) +{ + ui->btnSave->setEnabled(true); +} + +void DialogSettingsTray::on_DialogSettingsTray_accepted() +{ + QString language; + + if(settings->Language == "ENG") + language = QString("en_EN"); + else + language = QString("ru_RU"); + + emit signal_LanguageChanged(language); +} diff --git a/ServerLMS/dialogsettingstray.h b/ServerLMS/dialogsettingstray.h new file mode 100644 index 0000000..103d990 --- /dev/null +++ b/ServerLMS/dialogsettingstray.h @@ -0,0 +1,56 @@ +#ifndef DIALOGSETTINGSTRAY_H +#define DIALOGSETTINGSTRAY_H + +#include +#include +#include + +class DBSettings{ +public: + QString Address; + QString Port; + QString Language; +}; + +namespace Ui { +class DialogSettingsTray; +} + +class DialogSettingsTray : public QDialog +{ + Q_OBJECT + +public: + explicit DialogSettingsTray(QWidget *parent = nullptr); + ~DialogSettingsTray(); + + DBSettings getSettings(); + + bool settingsServerIsChanged(){ return flSettingsServerChanged;} + + static bool loadSettings(DBSettings *settings); + +signals: + //сигнал об изменении языка интерфейса + void signal_LanguageChanged(QString language); + +private slots: + void on_cmbLanguage_currentTextChanged(const QString &arg1); + void on_btnSave_clicked(); + + void on_cmbLanguage_currentIndexChanged(int index); + + void on_DialogSettingsTray_accepted(); + +private: + bool saveSettings(); + +private: + Ui::DialogSettingsTray *ui; + + DBSettings *settings; + + bool flSettingsServerChanged; +}; + +#endif // DIALOGSETTINGSTRAY_H diff --git a/ServerLMS/dialogsettingstray.ui b/ServerLMS/dialogsettingstray.ui new file mode 100644 index 0000000..58f2fdf --- /dev/null +++ b/ServerLMS/dialogsettingstray.ui @@ -0,0 +1,110 @@ + + + DialogSettingsTray + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + + + + Main + + + + + + + + + + Language + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 58 + 58 + + + + Save + + + + :/resources/icons/circleGreen.png:/resources/icons/circleGreen.png + + + + 32 + 32 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + + + + + + + + + + + + diff --git a/ServerLMS/resources/icons/settings.png b/ServerLMS/resources/icons/settings.png new file mode 100644 index 0000000000000000000000000000000000000000..07376feb558d334b4bc1f175d39bec99f025262f GIT binary patch literal 4274 zcmbVQc{r49+aF7^W=q-17!+kT`%K0%;41_E+%-hBO_-8lLXUY9~%T(*Rnc<&TU_(1_G^7r{ec=_Trq-BnAyeBs2U0 zSU8O-K!ZT$mf=hyDG1B?yZ2=0^A(91nL^|V1kwGLB z8DePxHV;P&2xtI@2o9$O)7j{74CFg6TCiT-hC{&LA)Fu##ClaBcrVTsY|CH)U}KmG zl!P=g2AiT_NE1UN6iOd#fIynT5oU0tArxtXHbS5c48T7hh(H^Q9DsJm?)<4s@P&a; zI2YFs>nt!3u;UQ79A~VE{KUfC>;$b_AV642RO$TE7^u0Gq_3GC5QR9lXj& z^k;-}Fc5*IKU|=J1ZZ%L0fT1`E$%1pm4y*Iy=sZEaUC1_jpjqSDC>E?e&}G60sy0Wc5) zgn=;>fr28Dcq9^SghU&gZATcQ5r`j99D_^^i1=Hm5!%4;U!a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zd4BU=eC6vjd;8LArQnq5=h*ho+~KRm&D#&`sCi~~*!-CN)%>h%{_xQF+m|jKiRtv< z=a@Z2dV#;ixA*&y?@$3NcW_{2<%85-@vGiyCO%GnPUd z>ot_Fsg{zW`*2x(BVeobMnzYKFRN^yhx19P%I?u&aGt8Vcds&cSsHikt7k$7>D0_{CkTA=2S7Yjt2ZoQ)ode*9p zxg=cPc6Mh&`YTf>zuBI1uDWsK zRpLVK2M+^6OG^wUz@Wif=xAax-dVIbb+Shfvm^Z28n_;sHY=BhjgLyu(%Jcj;Hd;pep@YOc{w?ALt8<&f7QZ}HD=$i)1BN4?o}!4!8&*! zHLpaWRGq_R+fG9rCUbILc4|q+yX=MB!YOx(#k^f;x~=lr*F0>cbBn^sLz6qof}`K6 zC5FF#m;t0+HJ`WQ<}TdZOpYG^oW9da{KL5$#<*OeRNDOnbvvFr7>Wni>=Pr^%kMm! zN1Ipn9hLIUAs&k`unnF$t{W44dm|N_lvj1ffS{(Aw!wwJxV2)$Qb$!&#whMF)6#QF zanC`YiHkAZ!Ow>@r6U~d-`_41hRP>}CMB+{p`?CWLpR-OvHDlR(asrLYU3C8PdC{_ Aa{vGU literal 0 HcmV?d00001 diff --git a/ServerLMS/serverlmswidget.cpp b/ServerLMS/serverlmswidget.cpp index a7b4104..8f05e74 100644 --- a/ServerLMS/serverlmswidget.cpp +++ b/ServerLMS/serverlmswidget.cpp @@ -6,8 +6,12 @@ #include #include #include "serverlmswidget.h" +#include "dialogsettingstray.h" #include "ui_serverlmswidget.h" +const QString ServerLMSWidget::languageENG = "en_EN"; +const QString ServerLMSWidget::languageRUS = "ru_RU"; + ServerLMSWidget::ServerLMSWidget(QWidget *parent) : QWidget(parent), ui(new Ui::ServerLMSWidget), @@ -17,7 +21,8 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : dataParser(nullptr), processingSystem(nullptr), updateController(nullptr), - providerDBLMS(nullptr) + providerDBLMS(nullptr), + language(languageENG) { ui->setupUi(this); mutex = new QMutex; @@ -145,6 +150,8 @@ void ServerLMSWidget::slot_LanguageChanged(QString language) { qtLanguageTranslator.load(QString("translations/ServerLMS_") + language, "."); qApp->installTranslator(&qtLanguageTranslator); + + emit signal_LanguageChanged(language); } void ServerLMSWidget::on_btnStartServer_clicked() @@ -192,3 +199,44 @@ void ServerLMSWidget::changeEvent(QEvent *event) ui->lblDBsettings->setText(strDBsettings); } } + +void ServerLMSWidget::on_cmbLanguage_currentTextChanged(const QString &arg1) +{ + +} + +void ServerLMSWidget::on_btnSettings_clicked() +{ + DialogSettingsTray dlg(this); + dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint); + + connect(&dlg, &DialogSettingsTray::signal_LanguageChanged, this, &ServerLMSWidget::slot_LanguageChanged); + //connect(&dlg, &DialogSettingsTray::signal_UpdateStyleSheet, this, &InstructorsAndTraineesWidget::slot_UpdateStyleSheet); + + + switch( dlg.exec() ) + { + case QDialog::Accepted: + { + language = dlg.getSettings().Language; + + if(dlg.settingsServerIsChanged()) + { + //SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Server settings have been changed. Please reconnect to the server.")).exec(); + + //flSettingsServerIsChanged = true; + + //if(authorizationIsCompleted()) + //deAuthorizationInstructor(loginInstructorLoggedInLocal); + + //connectorToServer->StopConnectToServer(); + } + + break; + } + case QDialog::Rejected: + break; + default: + break; + } +} diff --git a/ServerLMS/serverlmswidget.h b/ServerLMS/serverlmswidget.h index e958583..c7d8dc1 100644 --- a/ServerLMS/serverlmswidget.h +++ b/ServerLMS/serverlmswidget.h @@ -49,6 +49,10 @@ public: explicit ServerLMSWidget(QWidget *parent = nullptr); ~ServerLMSWidget(); +public: + static const QString languageENG; + static const QString languageRUS; + void setError(int code); protected: @@ -63,6 +67,9 @@ signals: QTcpSocket* sigGetSocket(); + //сигнал смены языка + void signal_LanguageChanged(QString language); + public slots: void slot_LanguageChanged(QString language); void slotUpdateListClients(); @@ -87,6 +94,10 @@ private slots: void on_btnStartServer_clicked(); void on_btnStopServer_clicked(); + void on_cmbLanguage_currentTextChanged(const QString &arg1); + + void on_btnSettings_clicked(); + private: Ui::ServerLMSWidget *ui; @@ -108,6 +119,7 @@ private: bool first = true; // для тестов Unity QTranslator qtLanguageTranslator; + QString language; int errorCode; }; diff --git a/ServerLMS/serverlmswidget.ui b/ServerLMS/serverlmswidget.ui index f16ac45..da8f3ec 100644 --- a/ServerLMS/serverlmswidget.ui +++ b/ServerLMS/serverlmswidget.ui @@ -28,8 +28,8 @@ - 80 - 55 + 130 + 58 @@ -51,7 +51,7 @@ Start - + :/resources/icons/rocket.png:/resources/icons/rocket.png @@ -69,8 +69,8 @@ - 80 - 55 + 130 + 58 @@ -92,7 +92,7 @@ Stop - + :/resources/icons/stop.png:/resources/icons/stop.png @@ -106,6 +106,25 @@ + + + + + 40 + 40 + + + + + + + :/resources/icons/switchOff.png + + + true + + + @@ -120,21 +139,28 @@ - - + + - 40 - 40 + 130 + 58 - + Settings - - :/resources/icons/switchOff.png + + + :/resources/icons/settings.png:/resources/icons/settings.png - - true + + + 32 + 32 + + + + Qt::ToolButtonTextUnderIcon @@ -263,7 +289,7 @@ - :/resources/icons/open.png + :/resources/icons/open.png true @@ -279,7 +305,8 @@ - + + diff --git a/TrayServerLMS/mainwindow.cpp b/TrayServerLMS/mainwindow.cpp index 1d502f1..8d0f95c 100644 --- a/TrayServerLMS/mainwindow.cpp +++ b/TrayServerLMS/mainwindow.cpp @@ -6,7 +6,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), - m_serverLMSWidget(nullptr), + serverLMSWidget(nullptr), trayIcon(nullptr), menu(nullptr), action_ShowWindow(nullptr), @@ -18,11 +18,11 @@ MainWindow::MainWindow(QWidget *parent) : //Задаём два пункта с текстом локалей в комбобоксе ui->cmbLanguage->addItems(QStringList() << "English" << "Русский"); - m_serverLMSWidget = new ServerLMSWidget(this); + serverLMSWidget = new ServerLMSWidget(this); - ui->verticalLayout_1->addWidget(m_serverLMSWidget); + ui->verticalLayout_1->addWidget(serverLMSWidget); - connect(this, &MainWindow::signal_LanguageChanged, m_serverLMSWidget, &ServerLMSWidget::slot_LanguageChanged); + connect(serverLMSWidget, &ServerLMSWidget::signal_LanguageChanged, this, &MainWindow::slot_LanguageChanged); //this->move(0, 0); //this->showNormal(); @@ -115,7 +115,7 @@ void MainWindow::exit() MainWindow::~MainWindow() { - delete m_serverLMSWidget; + delete serverLMSWidget; delete trayIcon; delete ui; } @@ -146,7 +146,7 @@ void MainWindow::on_cmbLanguage_currentIndexChanged(const QString &arg1) void MainWindow::errorCheck() { - if(m_serverLMSWidget->hasError() == 100) + if(serverLMSWidget->hasError() == 100) { QMessageBox msgBox; @@ -193,3 +193,9 @@ void MainWindow::slot_Menu_Exit() this->hide(); this->close(); } + +void MainWindow::slot_LanguageChanged(QString language) +{ + qtLanguageTranslator.load(QString(QStringLiteral("translations/TrayServerLMS_")) + language, QStringLiteral(".")); + qApp->installTranslator(&qtLanguageTranslator); +} diff --git a/TrayServerLMS/mainwindow.h b/TrayServerLMS/mainwindow.h index ebe0ef7..be24c8b 100644 --- a/TrayServerLMS/mainwindow.h +++ b/TrayServerLMS/mainwindow.h @@ -36,6 +36,10 @@ protected: */ void closeEvent(QCloseEvent * event) override; +public slots: + //Слот обработки смены языка + void slot_LanguageChanged(QString language); + private slots: //Слот нажатия на иконку приложения в трее void slot_IconActivated(QSystemTrayIcon::ActivationReason reason); @@ -60,7 +64,7 @@ private: private: Ui::MainWindow *ui; - ServerLMSWidget* m_serverLMSWidget; + ServerLMSWidget* serverLMSWidget; QTranslator qtLanguageTranslator; QSystemTrayIcon* trayIcon;