diff --git a/Core/dataparser.cpp b/Core/dataparser.cpp index 0a929e3..8f74a1e 100644 --- a/Core/dataparser.cpp +++ b/Core/dataparser.cpp @@ -13,9 +13,11 @@ DataParser::DataParser(QObject *parent) : } } -DataParser::~DataParser() +QByteArray DataParser::slotGetXmlAnswer(QString answerCode) { - + if(answerCode == "END"){ + return xmlAnswer_notify(answerCode); + } } void DataParser::CreateXML(QList fileDataList) @@ -85,6 +87,8 @@ void DataParser::CreateServerSettings(QString address, QString port) xmlWriter.writeAttribute("Address",address); xmlWriter.writeAttribute("Port",port); + xmlWriter.writeAttribute("Language","RUS"); + xmlWriter.writeAttribute("AutoStart",QString::number(false)); xmlWriter.writeEndElement(); xmlWriter.writeEndElement(); @@ -116,6 +120,20 @@ void DataParser::CreateAuthData(ServerAuthorization *serverAuth) } +QByteArray DataParser::xmlAnswer_notify(QString code) +{ + + QList listTag; + + SAttribute attribute1 = {"Code", code}; + QList listAttr = {attribute1}; + SXmlAnswerTag tag = {"ServerNotify", listAttr}; + + listTag.append(tag); + + return xmlAnswer(listTag); +} + void DataParser::AddRunData(QList displays) { QFile file(displayTemp); @@ -155,6 +173,14 @@ ServerSettings *DataParser::GetServerSettings() settings->Port = value; } + if(name == "Language"){ + settings->Language = value; + } + + if(name == "AutoStart"){ + settings->isAutoStart = value.toInt(); + } + } } } @@ -165,3 +191,91 @@ ServerSettings *DataParser::GetServerSettings() return settings; } +void DataParser::saveClientSettrings(QString language, bool isAutoStart) +{ + QFile file(settingsName); + file.open(QIODevice::ReadOnly | QIODevice::Text); + + QString settings = file.readAll(); + + file.close(); + file.remove(); + + file.open(QIODevice::WriteOnly | QIODevice::Text); + + auto languagePos = settings.indexOf(XMLLanguageProperty) + XMLLanguageProperty.length(); + settings = settings.replace(languagePos,language.size(),language); + + auto autoStartPos = settings.indexOf(XMLAutoStartProperty) + XMLAutoStartProperty.length(); + settings = settings.replace(autoStartPos,1,QString::number(isAutoStart)); + + file.write(settings.toUtf8()); + file.close(); +} + + +QByteArray DataParser::xmlAnswer(QList listTag, QString elemUp1, QString elemUp2) +{ + /* Открываем файл для Записи*/ + QFile file("save.xml"); + file.open(QIODevice::WriteOnly); + + /* Создаем объект, с помощью которого осуществляется запись в файл */ + QXmlStreamWriter xmlWriter(&file); + + xmlWriter.setAutoFormatting(true); // Устанавливаем автоформатирование текста + + xmlWriter.writeStartDocument(); // Запускаем запись в документ + + if(elemUp1 != "") + xmlWriter.writeStartElement(elemUp1); // Записываем тег + + if(elemUp2 != "") + xmlWriter.writeStartElement(elemUp2); // Записываем тег + + //Записываем все элементы + foreach(SXmlAnswerTag tag, listTag) + { + xmlWriter.writeStartElement(tag.elementName); // Записываем тег + + // Записываем атрибуты + foreach(SAttribute attr, tag.attr) + xmlWriter.writeAttribute(attr.name, attr.value); + + xmlWriter.writeEndElement(); // Закрываем тег + } + + if(elemUp1 != "") + xmlWriter.writeEndElement(); // Закрываем тег + + if(elemUp1 != "") + xmlWriter.writeEndElement(); // Закрываем тег + + /* Завершаем запись в документ*/ + xmlWriter.writeEndDocument(); + + file.close(); // Закрываем файл + + QByteArray array; + + /* Открываем файл для Чтения*/ + QFile fileR("save.xml"); + if (!fileR.open(QFile::ReadOnly | QFile::Text)) + { + QString str = "Не удалось открыть файл"; + qDebug() << "xmlAnswer: " << str; + } + else + { + array = fileR.readAll(); + fileR.close(); // Закрываем файл + } + + return array; +} + + +DataParser::~DataParser() +{ + +} diff --git a/Core/dataparser.h b/Core/dataparser.h index f39e0b7..d15efc7 100644 --- a/Core/dataparser.h +++ b/Core/dataparser.h @@ -8,7 +8,6 @@ #include #include - class DataParser : public QObject { @@ -19,12 +18,21 @@ public: ~DataParser(); ServerSettings* GetServerSettings(); void CreateServerSettings(QString server,QString port); + void saveClientSettrings(QString language,bool isAutoStart); void CreateXML(QList fileDataList); void CreateAuthMessage(ClientAutorization *auth); void CreateAuthData(ServerAuthorization *serverAuth); void AddRunData(QList displays); + QByteArray xmlAnswer_notify(QString code); + QByteArray xmlAnswer(QList listTag, QString elemUp1 = "", QString elemUp2 = ""); + +public slots: + QByteArray slotGetXmlAnswer(QString); + private: + const QString XMLLanguageProperty = "Language=\""; + const QString XMLAutoStartProperty = "AutoStart=\""; ClientAutorization *authPassCache; }; diff --git a/Core/tcpclient.cpp b/Core/tcpclient.cpp index 34357c8..9c06a4b 100644 --- a/Core/tcpclient.cpp +++ b/Core/tcpclient.cpp @@ -111,7 +111,20 @@ void TCPClient::SetDisconnect() emit onSendDebugLog("Server disabled"); } -void TCPClient::WaitWrites() +void TCPClient::sendDisable() +{ + QDataStream stream(socket); + stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); + + QByteArray data; + data = emit signalGetXmlAnswer("END"); + + stream << PacketType::TYPE_XMLANSWER; + stream << data; + waitWrites(); +} + +void TCPClient::waitWrites() { socket->waitForBytesWritten(); } diff --git a/Core/tcpclient.h b/Core/tcpclient.h index 4ea5546..39505e3 100644 --- a/Core/tcpclient.h +++ b/Core/tcpclient.h @@ -29,7 +29,8 @@ public: void SendFile(); void SendUnityConnect(); void SetDisconnect(); - void WaitWrites(); + void sendDisable(); + void waitWrites(); void WaitRead(int time); QTcpSocket* GetSocket(); ~TCPClient(); @@ -38,6 +39,7 @@ signals: void onSendDebugLog(QString message); void Recognize(QTcpSocket *socket); void ConnectionState(bool flag); + QByteArray signalGetXmlAnswer(QString); public slots: void MessageEntered(QString message); diff --git a/Datas.h b/Datas.h index 29e369b..1b3a8ae 100644 --- a/Datas.h +++ b/Datas.h @@ -7,6 +7,8 @@ class ServerSettings{ public: QString Address; QString Port; + QString Language; + bool isAutoStart; }; class ServerAuthorization{ diff --git a/RRJClient.pro.user b/RRJClient.pro.user index 8a957bb..7e92112 100644 --- a/RRJClient.pro.user +++ b/RRJClient.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/StaticData/settings.xml b/StaticData/settings.xml index 6ef37e2..87e3d5f 100644 --- a/StaticData/settings.xml +++ b/StaticData/settings.xml @@ -1,4 +1,4 @@ - + diff --git a/debug/RRJClient.exe b/debug/RRJClient.exe index d666c87..e8c03e1 100644 Binary files a/debug/RRJClient.exe and b/debug/RRJClient.exe differ diff --git a/debug/dataparser.o b/debug/dataparser.o index dbc0141..882769c 100644 Binary files a/debug/dataparser.o and b/debug/dataparser.o differ diff --git a/debug/mainwindow.o b/debug/mainwindow.o index e5015ac..fe6c8a6 100644 Binary files a/debug/mainwindow.o and b/debug/mainwindow.o differ diff --git a/debug/moc_dataparser.cpp b/debug/moc_dataparser.cpp index 206dc95..76855c3 100644 --- a/debug/moc_dataparser.cpp +++ b/debug/moc_dataparser.cpp @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_DataParser_t { - QByteArrayData data[1]; - char stringdata0[11]; + QByteArrayData data[3]; + char stringdata0[29]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -32,10 +32,12 @@ struct qt_meta_stringdata_DataParser_t { ) static const qt_meta_stringdata_DataParser_t qt_meta_stringdata_DataParser = { { -QT_MOC_LITERAL(0, 0, 10) // "DataParser" +QT_MOC_LITERAL(0, 0, 10), // "DataParser" +QT_MOC_LITERAL(1, 11, 16), // "slotGetXmlAnswer" +QT_MOC_LITERAL(2, 28, 0) // "" }, - "DataParser" + "DataParser\0slotGetXmlAnswer\0" }; #undef QT_MOC_LITERAL @@ -45,22 +47,33 @@ static const uint qt_meta_data_DataParser[] = { 8, // revision 0, // classname 0, 0, // classinfo - 0, 0, // methods + 1, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount + // slots: name, argc, parameters, tag, flags + 1, 1, 19, 2, 0x0a /* Public */, + + // slots: parameters + QMetaType::QByteArray, QMetaType::QString, 2, + 0 // eod }; void DataParser::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { - Q_UNUSED(_o); - Q_UNUSED(_id); - Q_UNUSED(_c); - Q_UNUSED(_a); + if (_c == QMetaObject::InvokeMetaMethod) { + auto *_t = static_cast(_o); + Q_UNUSED(_t) + switch (_id) { + case 0: { QByteArray _r = _t->slotGetXmlAnswer((*reinterpret_cast< QString(*)>(_a[1]))); + if (_a[0]) *reinterpret_cast< QByteArray*>(_a[0]) = std::move(_r); } break; + default: ; + } + } } QT_INIT_METAOBJECT const QMetaObject DataParser::staticMetaObject = { { @@ -89,6 +102,17 @@ void *DataParser::qt_metacast(const char *_clname) int DataParser::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + if (_id < 1) + qt_static_metacall(this, _c, _id, _a); + _id -= 1; + } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { + if (_id < 1) + *reinterpret_cast(_a[0]) = -1; + _id -= 1; + } return _id; } QT_WARNING_POP diff --git a/debug/moc_dataparser.o b/debug/moc_dataparser.o index 9cf9400..d210923 100644 Binary files a/debug/moc_dataparser.o and b/debug/moc_dataparser.o differ diff --git a/debug/moc_mainwindow.cpp b/debug/moc_mainwindow.cpp index 6bdd1cf..6de5a1a 100644 --- a/debug/moc_mainwindow.cpp +++ b/debug/moc_mainwindow.cpp @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_MainWindow_t { - QByteArrayData data[23]; - char stringdata0[391]; + QByteArrayData data[25]; + char stringdata0[426]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -54,7 +54,9 @@ QT_MOC_LITERAL(18, 303, 25), // "on_settingsButton_clicked" QT_MOC_LITERAL(19, 329, 13), // "disableNotify" QT_MOC_LITERAL(20, 343, 17), // "onConnectionState" QT_MOC_LITERAL(21, 361, 4), // "flag" -QT_MOC_LITERAL(22, 366, 24) // "on_connectButton_clicked" +QT_MOC_LITERAL(22, 366, 24), // "on_connectButton_clicked" +QT_MOC_LITERAL(23, 391, 29), // "on_languageComboBox_activated" +QT_MOC_LITERAL(24, 421, 4) // "arg1" }, "MainWindow\0onInitializeClient\0\0" @@ -67,7 +69,8 @@ QT_MOC_LITERAL(22, 366, 24) // "on_connectButton_clicked" "on_updateButton_clicked\0on_startButton_clicked\0" "on_saveServerButton_clicked\0" "on_settingsButton_clicked\0disableNotify\0" - "onConnectionState\0flag\0on_connectButton_clicked" + "onConnectionState\0flag\0on_connectButton_clicked\0" + "on_languageComboBox_activated\0arg1" }; #undef QT_MOC_LITERAL @@ -77,7 +80,7 @@ static const uint qt_meta_data_MainWindow[] = { 8, // revision 0, // classname 0, 0, // classinfo - 13, 14, // methods + 14, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors @@ -85,21 +88,22 @@ static const uint qt_meta_data_MainWindow[] = { 5, // signalCount // signals: name, argc, parameters, tag, flags - 1, 2, 79, 2, 0x06 /* Public */, - 7, 1, 84, 2, 0x06 /* Public */, - 10, 0, 87, 2, 0x06 /* Public */, - 11, 0, 88, 2, 0x06 /* Public */, - 12, 1, 89, 2, 0x06 /* Public */, + 1, 2, 84, 2, 0x06 /* Public */, + 7, 1, 89, 2, 0x06 /* Public */, + 10, 0, 92, 2, 0x06 /* Public */, + 11, 0, 93, 2, 0x06 /* Public */, + 12, 1, 94, 2, 0x06 /* Public */, // slots: name, argc, parameters, tag, flags - 14, 0, 92, 2, 0x08 /* Private */, - 15, 0, 93, 2, 0x08 /* Private */, - 16, 0, 94, 2, 0x08 /* Private */, - 17, 0, 95, 2, 0x08 /* Private */, - 18, 0, 96, 2, 0x08 /* Private */, - 19, 0, 97, 2, 0x08 /* Private */, - 20, 1, 98, 2, 0x08 /* Private */, - 22, 0, 101, 2, 0x08 /* Private */, + 14, 0, 97, 2, 0x08 /* Private */, + 15, 0, 98, 2, 0x08 /* Private */, + 16, 0, 99, 2, 0x08 /* Private */, + 17, 0, 100, 2, 0x08 /* Private */, + 18, 0, 101, 2, 0x08 /* Private */, + 19, 0, 102, 2, 0x08 /* Private */, + 20, 1, 103, 2, 0x08 /* Private */, + 22, 0, 106, 2, 0x08 /* Private */, + 23, 1, 107, 2, 0x08 /* Private */, // signals: parameters QMetaType::Void, 0x80000000 | 3, 0x80000000 | 5, 4, 6, @@ -117,6 +121,7 @@ static const uint qt_meta_data_MainWindow[] = { QMetaType::Void, QMetaType::Void, QMetaType::Bool, 21, QMetaType::Void, + QMetaType::Void, QMetaType::QString, 24, 0 // eod }; @@ -140,6 +145,7 @@ void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, case 10: _t->disableNotify(); break; case 11: _t->onConnectionState((*reinterpret_cast< bool(*)>(_a[1]))); break; case 12: _t->on_connectButton_clicked(); break; + case 13: _t->on_languageComboBox_activated((*reinterpret_cast< const QString(*)>(_a[1]))); break; default: ; } } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { @@ -224,13 +230,13 @@ int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 13) + if (_id < 14) qt_static_metacall(this, _c, _id, _a); - _id -= 13; + _id -= 14; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 13) + if (_id < 14) qt_static_metacall(this, _c, _id, _a); - _id -= 13; + _id -= 14; } return _id; } diff --git a/debug/moc_mainwindow.o b/debug/moc_mainwindow.o index 108efe9..e210bbe 100644 Binary files a/debug/moc_mainwindow.o and b/debug/moc_mainwindow.o differ diff --git a/debug/moc_recognizesystem.o b/debug/moc_recognizesystem.o index 621ce0e..98f5810 100644 Binary files a/debug/moc_recognizesystem.o and b/debug/moc_recognizesystem.o differ diff --git a/debug/moc_tcpclient.cpp b/debug/moc_tcpclient.cpp index 77ab0ee..d5ea40a 100644 --- a/debug/moc_tcpclient.cpp +++ b/debug/moc_tcpclient.cpp @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_TCPClient_t { - QByteArrayData data[11]; - char stringdata0[111]; + QByteArrayData data[12]; + char stringdata0[130]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -41,14 +41,15 @@ QT_MOC_LITERAL(5, 44, 11), // "QTcpSocket*" QT_MOC_LITERAL(6, 56, 6), // "socket" QT_MOC_LITERAL(7, 63, 15), // "ConnectionState" QT_MOC_LITERAL(8, 79, 4), // "flag" -QT_MOC_LITERAL(9, 84, 14), // "MessageEntered" -QT_MOC_LITERAL(10, 99, 11) // "onReadyRead" +QT_MOC_LITERAL(9, 84, 18), // "signalGetXmlAnswer" +QT_MOC_LITERAL(10, 103, 14), // "MessageEntered" +QT_MOC_LITERAL(11, 118, 11) // "onReadyRead" }, "TCPClient\0onSendDebugLog\0\0message\0" "Recognize\0QTcpSocket*\0socket\0" - "ConnectionState\0flag\0MessageEntered\0" - "onReadyRead" + "ConnectionState\0flag\0signalGetXmlAnswer\0" + "MessageEntered\0onReadyRead" }; #undef QT_MOC_LITERAL @@ -58,26 +59,28 @@ static const uint qt_meta_data_TCPClient[] = { 8, // revision 0, // classname 0, 0, // classinfo - 5, 14, // methods + 6, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags - 3, // signalCount + 4, // signalCount // signals: name, argc, parameters, tag, flags - 1, 1, 39, 2, 0x06 /* Public */, - 4, 1, 42, 2, 0x06 /* Public */, - 7, 1, 45, 2, 0x06 /* Public */, + 1, 1, 44, 2, 0x06 /* Public */, + 4, 1, 47, 2, 0x06 /* Public */, + 7, 1, 50, 2, 0x06 /* Public */, + 9, 1, 53, 2, 0x06 /* Public */, // slots: name, argc, parameters, tag, flags - 9, 1, 48, 2, 0x0a /* Public */, - 10, 0, 51, 2, 0x08 /* Private */, + 10, 1, 56, 2, 0x0a /* Public */, + 11, 0, 59, 2, 0x08 /* Private */, // signals: parameters QMetaType::Void, QMetaType::QString, 3, QMetaType::Void, 0x80000000 | 5, 6, QMetaType::Void, QMetaType::Bool, 8, + QMetaType::QByteArray, QMetaType::QString, 2, // slots: parameters QMetaType::Void, QMetaType::QString, 3, @@ -95,8 +98,10 @@ void TCPClient::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, v case 0: _t->onSendDebugLog((*reinterpret_cast< QString(*)>(_a[1]))); break; case 1: _t->Recognize((*reinterpret_cast< QTcpSocket*(*)>(_a[1]))); break; case 2: _t->ConnectionState((*reinterpret_cast< bool(*)>(_a[1]))); break; - case 3: _t->MessageEntered((*reinterpret_cast< QString(*)>(_a[1]))); break; - case 4: _t->onReadyRead(); break; + case 3: { QByteArray _r = _t->signalGetXmlAnswer((*reinterpret_cast< QString(*)>(_a[1]))); + if (_a[0]) *reinterpret_cast< QByteArray*>(_a[0]) = std::move(_r); } break; + case 4: _t->MessageEntered((*reinterpret_cast< QString(*)>(_a[1]))); break; + case 5: _t->onReadyRead(); break; default: ; } } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { @@ -133,6 +138,13 @@ void TCPClient::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, v return; } } + { + using _t = QByteArray (TCPClient::*)(QString ); + if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&TCPClient::signalGetXmlAnswer)) { + *result = 3; + return; + } + } } } @@ -165,13 +177,13 @@ int TCPClient::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 5) + if (_id < 6) qt_static_metacall(this, _c, _id, _a); - _id -= 5; + _id -= 6; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 5) + if (_id < 6) qt_static_metacall(this, _c, _id, _a); - _id -= 5; + _id -= 6; } return _id; } @@ -196,5 +208,14 @@ void TCPClient::ConnectionState(bool _t1) void *_a[] = { nullptr, const_cast(reinterpret_cast(std::addressof(_t1))) }; QMetaObject::activate(this, &staticMetaObject, 2, _a); } + +// SIGNAL 3 +QByteArray TCPClient::signalGetXmlAnswer(QString _t1) +{ + QByteArray _t0{}; + void *_a[] = { const_cast(reinterpret_cast(std::addressof(_t0))), const_cast(reinterpret_cast(std::addressof(_t1))) }; + QMetaObject::activate(this, &staticMetaObject, 3, _a); + return _t0; +} QT_WARNING_POP QT_END_MOC_NAMESPACE diff --git a/debug/moc_tcpclient.o b/debug/moc_tcpclient.o index 954d80d..ccf7bd2 100644 Binary files a/debug/moc_tcpclient.o and b/debug/moc_tcpclient.o differ diff --git a/debug/recognizesystem.o b/debug/recognizesystem.o index 3e2a9b9..a1daab7 100644 Binary files a/debug/recognizesystem.o and b/debug/recognizesystem.o differ diff --git a/debug/tcpclient.o b/debug/tcpclient.o index 012a2e6..0e75d5f 100644 Binary files a/debug/tcpclient.o and b/debug/tcpclient.o differ diff --git a/mainwindow.cpp b/mainwindow.cpp index b487b58..ba7d8b3 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -26,6 +26,7 @@ void MainWindow::Initialize() ui->startButton->setEnabled(false); ui->debugText->hide(); ui->displayGroupWidget->hide(); + ui->autostartCheckBox->hide(); updateControllerThread = new QThread; connectionThread = new QThread; @@ -53,6 +54,8 @@ void MainWindow::Initialize() connect(recognizeSystem,&RecognizeSystem::SaveLoginData,this,&MainWindow::CheckLoginResult); connect(recognizeSystem,&RecognizeSystem::SocketWaitForReadyRead,client,&TCPClient::WaitRead,Qt::AutoConnection); + connect(client,&TCPClient::signalGetXmlAnswer,dataParser,&DataParser::slotGetXmlAnswer); + connectionThread->start(); updateControllerThread->start(); @@ -80,11 +83,14 @@ void MainWindow::Initialize() maxBytesAvailable = 0; globalValue = 0; + ui->loadingProgressBar->setValue(0); + loadStaticData(); emit onSetConnect(dataParser->GetServerSettings()); CheckAppAvailable(); + } void MainWindow::UpdateProgress(qint64 size,quint64 sended) @@ -101,6 +107,8 @@ void MainWindow::LoadComplete() ui->updateButton->setEnabled(false); externalExecuter->FindApp(); ui->startButton->setEnabled(true); + autoStart(); + ui->inlineTextDebug->setText("Обновление завершено..."); } void MainWindow::SetNeedUpdate(bool flag,quint64 size, quint64 fileCount) @@ -117,6 +125,7 @@ void MainWindow::SetNeedUpdate(bool flag,quint64 size, quint64 fileCount) else { ui->inlineTextDebug->setText("Установлена последняя версия"); + autoStart(); } ui->updateButton->setEnabled(flag); @@ -135,11 +144,14 @@ void MainWindow::CheckLoginResult(ServerAuthorization *serverAuth) emit onSendMessage("check"); ui->inlineTextDebug->setText("Проверка обновлений..."); + ui->loadingProgressBar->show(); ui->updateButton->show(); + ui->displayGroupWidget->show(); + ui->autostartCheckBox->show(); + dataParser->CreateAuthData(serverAuth); ui->loginWidget->hide(); - ui->displayGroupWidget->show(); } else { @@ -162,6 +174,23 @@ void MainWindow::CheckAppAvailable() ui->startButton->setEnabled(isAvailable); } +void MainWindow::autoStart() +{ + if(ui->autostartCheckBox->isChecked()){ + on_startButton_clicked(); + } +} + +void MainWindow::loadStaticData() +{ + ServerSettings *currentSettings = dataParser->GetServerSettings(); + + ui->serverInputField->setText(currentSettings->Address); + ui->portInputField->setText(currentSettings->Port); + ui->languageComboBox->setCurrentText(currentSettings->Language); + ui->autostartCheckBox->setChecked(currentSettings->isAutoStart); +} + void MainWindow::on_loginButton_clicked() { @@ -207,11 +236,6 @@ void MainWindow::on_settingsButton_clicked() { ui->settingsWidget->show(); ui->loginWidget->hide(); - - ServerSettings *currentSettings = dataParser->GetServerSettings(); - - ui->serverInputField->setText(currentSettings->Address); - ui->portInputField->setText(currentSettings->Port); } void MainWindow::disableNotify() @@ -261,6 +285,8 @@ MainWindow::~MainWindow() updateControllerThread->quit(); updateControllerThread->wait(); + client->sendDisable(); + delete connectionThread; delete updateControllerThread; delete ui; @@ -270,3 +296,9 @@ void MainWindow::on_connectButton_clicked() { emit onSetConnect(dataParser->GetServerSettings()); } + +void MainWindow::on_languageComboBox_activated(const QString &arg1) +{ + qDebug() << arg1; + dataParser->saveClientSettrings(arg1,ui->autostartCheckBox->isChecked()); +} diff --git a/mainwindow.h b/mainwindow.h index 7917d9a..03d9322 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -54,6 +54,8 @@ private slots: void on_connectButton_clicked(); + void on_languageComboBox_activated(const QString &arg1); + private: Ui::MainWindow *ui; TCPClient *client; @@ -76,5 +78,7 @@ private: void LostConnection(); void CheckLoginResult(ServerAuthorization * serverAuth); void CheckAppAvailable(); + void autoStart(); + void loadStaticData(); }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 053f2e5..300a49e 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -206,9 +206,9 @@ 10 - 430 + 400 681 - 61 + 88 @@ -219,6 +219,9 @@ + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + @@ -243,7 +246,7 @@ - + QLayout::SetFixedSize @@ -253,7 +256,7 @@ 0 - + true @@ -287,7 +290,35 @@ - + + + + true + + + + 0 + 0 + + + + + 100 + 30 + + + + + 100 + 30 + + + + Запуск + + + + true @@ -318,31 +349,16 @@ - - + + true - - - 0 - 0 - - - - - 100 - 30 - - - - - 100 - 30 - - - Запуск + Автозапуск + + + false @@ -451,7 +467,7 @@ - Выберите активные мониторы + Выберите активные мониторы: Qt::AlignHCenter|Qt::AlignTop @@ -469,6 +485,57 @@ + + + + 0 + 10 + 171 + 30 + + + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Язык + + + + + + + + 0 + 0 + + + + + RUS + + + + + ENG + + + + + + diff --git a/save.xml b/save.xml new file mode 100644 index 0000000..4902929 --- /dev/null +++ b/save.xml @@ -0,0 +1,2 @@ + + diff --git a/ui_mainwindow.h b/ui_mainwindow.h index db64825..8beebc4 100644 --- a/ui_mainwindow.h +++ b/ui_mainwindow.h @@ -11,6 +11,9 @@ #include #include +#include +#include +#include #include #include #include @@ -52,10 +55,11 @@ public: QVBoxLayout *downLayoutLoadingSlider; QLabel *inlineTextDebug; QProgressBar *loadingProgressBar; - QHBoxLayout *downLayoutButtons; + QGridLayout *gridLayout; QPushButton *connectButton; - QPushButton *updateButton; QPushButton *startButton; + QPushButton *updateButton; + QCheckBox *autostartCheckBox; QLabel *notificationLabel; QTextEdit *debugText; QWidget *displayGroupWidget; @@ -64,6 +68,10 @@ public: QWidget *screenWidget; QHBoxLayout *displayWidget; QHBoxLayout *displayLayout; + QWidget *widget; + QHBoxLayout *horizontalLayout_2; + QLabel *languageTite; + QComboBox *languageComboBox; void setupUi(QMainWindow *MainWindow) { @@ -189,7 +197,7 @@ public: layoutWidget = new QWidget(centralwidget); layoutWidget->setObjectName(QString::fromUtf8("layoutWidget")); - layoutWidget->setGeometry(QRect(10, 430, 681, 61)); + layoutWidget->setGeometry(QRect(10, 400, 681, 88)); downlayout = new QHBoxLayout(layoutWidget); downlayout->setObjectName(QString::fromUtf8("downlayout")); downlayout->setContentsMargins(0, 0, 0, 0); @@ -197,6 +205,7 @@ public: downLayoutLoadingSlider->setObjectName(QString::fromUtf8("downLayoutLoadingSlider")); inlineTextDebug = new QLabel(layoutWidget); inlineTextDebug->setObjectName(QString::fromUtf8("inlineTextDebug")); + inlineTextDebug->setAlignment(Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft); downLayoutLoadingSlider->addWidget(inlineTextDebug); @@ -211,10 +220,10 @@ public: downlayout->addLayout(downLayoutLoadingSlider); - downLayoutButtons = new QHBoxLayout(); - downLayoutButtons->setObjectName(QString::fromUtf8("downLayoutButtons")); - downLayoutButtons->setSizeConstraint(QLayout::SetFixedSize); - downLayoutButtons->setContentsMargins(-1, 27, -1, 0); + gridLayout = new QGridLayout(); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + gridLayout->setSizeConstraint(QLayout::SetFixedSize); + gridLayout->setContentsMargins(-1, 27, -1, 0); connectButton = new QPushButton(layoutWidget); connectButton->setObjectName(QString::fromUtf8("connectButton")); connectButton->setEnabled(true); @@ -228,7 +237,17 @@ public: connectButton->setCheckable(false); connectButton->setChecked(false); - downLayoutButtons->addWidget(connectButton); + gridLayout->addWidget(connectButton, 1, 0, 1, 1); + + startButton = new QPushButton(layoutWidget); + startButton->setObjectName(QString::fromUtf8("startButton")); + startButton->setEnabled(true); + sizePolicy2.setHeightForWidth(startButton->sizePolicy().hasHeightForWidth()); + startButton->setSizePolicy(sizePolicy2); + startButton->setMinimumSize(QSize(100, 30)); + startButton->setMaximumSize(QSize(100, 30)); + + gridLayout->addWidget(startButton, 1, 2, 1, 1); updateButton = new QPushButton(layoutWidget); updateButton->setObjectName(QString::fromUtf8("updateButton")); @@ -239,20 +258,17 @@ public: updateButton->setMaximumSize(QSize(100, 30)); updateButton->setFlat(false); - downLayoutButtons->addWidget(updateButton); + gridLayout->addWidget(updateButton, 1, 1, 1, 1); - startButton = new QPushButton(layoutWidget); - startButton->setObjectName(QString::fromUtf8("startButton")); - startButton->setEnabled(true); - sizePolicy2.setHeightForWidth(startButton->sizePolicy().hasHeightForWidth()); - startButton->setSizePolicy(sizePolicy2); - startButton->setMinimumSize(QSize(100, 30)); - startButton->setMaximumSize(QSize(100, 30)); + autostartCheckBox = new QCheckBox(layoutWidget); + autostartCheckBox->setObjectName(QString::fromUtf8("autostartCheckBox")); + autostartCheckBox->setEnabled(true); + autostartCheckBox->setChecked(false); - downLayoutButtons->addWidget(startButton); + gridLayout->addWidget(autostartCheckBox, 0, 2, 1, 1); - downlayout->addLayout(downLayoutButtons); + downlayout->addLayout(gridLayout); notificationLabel = new QLabel(centralwidget); notificationLabel->setObjectName(QString::fromUtf8("notificationLabel")); @@ -304,6 +320,34 @@ public: verticalLayout_4->addWidget(screenWidget); + widget = new QWidget(centralwidget); + widget->setObjectName(QString::fromUtf8("widget")); + widget->setGeometry(QRect(0, 10, 171, 30)); + horizontalLayout_2 = new QHBoxLayout(widget); + horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2")); + horizontalLayout_2->setContentsMargins(-1, 0, -1, 0); + languageTite = new QLabel(widget); + languageTite->setObjectName(QString::fromUtf8("languageTite")); + QSizePolicy sizePolicy4(QSizePolicy::Expanding, QSizePolicy::Expanding); + sizePolicy4.setHorizontalStretch(0); + sizePolicy4.setVerticalStretch(0); + sizePolicy4.setHeightForWidth(languageTite->sizePolicy().hasHeightForWidth()); + languageTite->setSizePolicy(sizePolicy4); + + horizontalLayout_2->addWidget(languageTite); + + languageComboBox = new QComboBox(widget); + languageComboBox->addItem(QString()); + languageComboBox->addItem(QString()); + languageComboBox->setObjectName(QString::fromUtf8("languageComboBox")); + QSizePolicy sizePolicy5(QSizePolicy::Maximum, QSizePolicy::Expanding); + sizePolicy5.setHorizontalStretch(0); + sizePolicy5.setVerticalStretch(0); + sizePolicy5.setHeightForWidth(languageComboBox->sizePolicy().hasHeightForWidth()); + languageComboBox->setSizePolicy(sizePolicy5); + + horizontalLayout_2->addWidget(languageComboBox); + MainWindow->setCentralWidget(centralwidget); retranslateUi(MainWindow); @@ -326,10 +370,15 @@ public: saveServerButton->setText(QCoreApplication::translate("MainWindow", "\320\241\320\276\321\205\321\200\320\260\320\275\320\270\321\202\321\214", nullptr)); inlineTextDebug->setText(QString()); connectButton->setText(QCoreApplication::translate("MainWindow", "\320\241\320\276\320\265\320\264\320\270\320\275\320\270\321\202\321\214\321\201\321\217", nullptr)); - updateButton->setText(QCoreApplication::translate("MainWindow", "\320\236\320\261\320\275\320\276\320\262\320\270\321\202\321\214", nullptr)); startButton->setText(QCoreApplication::translate("MainWindow", "\320\227\320\260\320\277\321\203\321\201\320\272", nullptr)); + updateButton->setText(QCoreApplication::translate("MainWindow", "\320\236\320\261\320\275\320\276\320\262\320\270\321\202\321\214", nullptr)); + autostartCheckBox->setText(QCoreApplication::translate("MainWindow", "\320\220\320\262\321\202\320\276\320\267\320\260\320\277\321\203\321\201\320\272", nullptr)); notificationLabel->setText(QCoreApplication::translate("MainWindow", "\320\232\320\260\320\272\320\260\321\217-\321\202\320\276 \320\276\321\210\320\270\320\261\320\272\320\260", nullptr)); - displayChoiceTitle->setText(QCoreApplication::translate("MainWindow", "\320\222\321\213\320\261\320\265\321\200\320\270\321\202\320\265 \320\260\320\272\321\202\320\270\320\262\320\275\321\213\320\265 \320\274\320\276\320\275\320\270\321\202\320\276\321\200\321\213", nullptr)); + displayChoiceTitle->setText(QCoreApplication::translate("MainWindow", "\320\222\321\213\320\261\320\265\321\200\320\270\321\202\320\265 \320\260\320\272\321\202\320\270\320\262\320\275\321\213\320\265 \320\274\320\276\320\275\320\270\321\202\320\276\321\200\321\213:", nullptr)); + languageTite->setText(QCoreApplication::translate("MainWindow", "\320\257\320\267\321\213\320\272", nullptr)); + languageComboBox->setItemText(0, QCoreApplication::translate("MainWindow", "RUS", nullptr)); + languageComboBox->setItemText(1, QCoreApplication::translate("MainWindow", "ENG", nullptr)); + } // retranslateUi };