feat: stable loading

This commit is contained in:
semenov
2024-09-27 13:01:03 +03:00
parent 95c54536fe
commit 7493f40f98
15 changed files with 125 additions and 73 deletions

View File

@@ -76,6 +76,7 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
}
packetType = PacketType::TYPE_NONE;
emit sigUpdateBytesAvailable();
continue;
}
@@ -164,7 +165,6 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
file.close();
emit sigSendDebugLog(Tools::getTime() + "File loaded");
emit
//ОЧИСТКА ПОСЛЕ ПЕРЕДАЧИ

View File

@@ -14,6 +14,7 @@ void TCPClient::initialize(RecognizeSystem *recognize,ExternalExecuter *external
this->recognizeSystem = recognize;
this->externalExecuter = externalExecuter;
this->sendSystem = sendSystem;
isConnected = false;
emit sigSendDebugLog(Tools::getTime() + " Client started");
}
@@ -31,6 +32,7 @@ void TCPClient::setConnect(ServerSettings *serverSettings,QThread *th)
socket->connectToHost(serverSettings->Address,serverSettings->Port.toShort());
emit sigSendDebugLog("Try connect...");
isConnected = true;
if (socket->waitForConnected(2000))
{
@@ -46,6 +48,7 @@ void TCPClient::setConnect(ServerSettings *serverSettings,QThread *th)
}
else
{
isConnected = false;
emit sigServerDisconnect();
}
}
@@ -54,6 +57,7 @@ void TCPClient::setConnect(ServerSettings *serverSettings,QThread *th)
void TCPClient::setDisconnect()
{
socket->disconnect();
isConnected = false;
emit sigServerDisconnect();
emit sigSendDebugLog("Server disabled");
}
@@ -106,12 +110,14 @@ void TCPClient::slotConnectNotify()
{
if(socket->state() != QTcpSocket::ConnectedState)
{
isConnected = false;
emit sigSendDebugLog("Connect invalid");
emit sigConnectionState(false);
return;
}
else
{
isConnected = true;
emit sigSendDebugLog("Connect complete");
emit sigConnectionState(true);
sendSystem->sendQTConnect();
@@ -128,6 +134,11 @@ void TCPClient::slotReadyRead()
emit sigRecognize(socket);
}
bool TCPClient::getIsConnected() const
{
return isConnected;
}
TCPClient::~TCPClient()
{

View File

@@ -31,6 +31,8 @@ public:
QTcpSocket* getSocket();
~TCPClient();
bool getIsConnected() const;
signals:
void sigSendDebugLog(QString message);
void sigRecognize(QTcpSocket *socket);
@@ -45,11 +47,13 @@ public slots:
private slots:
void slotReadyRead();
private:
SendSystem *sendSystem;
QTcpSocket *socket;
RecognizeSystem *recognizeSystem;
ExternalExecuter * externalExecuter;
bool isConnected;
void setDisconnect();
};

View File

@@ -99,47 +99,48 @@
<translation>ENG</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="121"/>
<location filename="mainwindow.cpp" line="123"/>
<source>Обновление завершено...</source>
<translation>Update complete...</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="134"/>
<location filename="mainwindow.cpp" line="135"/>
<source>Доступно обновление: </source>
<translation>Update available: </translation>
</message>
<message>
<location filename="mainwindow.cpp" line="135"/>
<location filename="mainwindow.cpp" line="136"/>
<source>Количество файлов: </source>
<translation>Files for update: </translation>
</message>
<message>
<location filename="mainwindow.cpp" line="140"/>
<location filename="mainwindow.cpp" line="141"/>
<source>Установлена последняя версия</source>
<translation>Latest version installed</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="163"/>
<location filename="mainwindow.cpp" line="164"/>
<source>Сервер заблокирован</source>
<translation>Server is blocked</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="376"/>
<location filename="mainwindow.cpp" line="387"/>
<source>Проверка обновлений...</source>
<translation>Checking for updates...</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="188"/>
<location filename="mainwindow.cpp" line="189"/>
<source>Неверный логин/пароль</source>
<translation>Invalid login/password</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="249"/>
<location filename="mainwindow.cpp" line="250"/>
<source>Соединение установлено</source>
<translation>Connection complete</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="255"/>
<location filename="mainwindow.cpp" line="256"/>
<location filename="mainwindow.cpp" line="319"/>
<source>Соединение отсутсвует</source>
<translation>No connection</translation>
</message>

View File

@@ -99,47 +99,48 @@
<translation>ENG</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="121"/>
<location filename="mainwindow.cpp" line="123"/>
<source>Обновление завершено...</source>
<translation>Обновление завершено...</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="134"/>
<location filename="mainwindow.cpp" line="135"/>
<source>Доступно обновление: </source>
<translation>Доступно обновление: </translation>
</message>
<message>
<location filename="mainwindow.cpp" line="135"/>
<location filename="mainwindow.cpp" line="136"/>
<source>Количество файлов: </source>
<translation>Количество файлов: </translation>
</message>
<message>
<location filename="mainwindow.cpp" line="140"/>
<location filename="mainwindow.cpp" line="141"/>
<source>Установлена последняя версия</source>
<translation>Установлена последняя версия</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="163"/>
<location filename="mainwindow.cpp" line="164"/>
<source>Сервер заблокирован</source>
<translation>Сервер заблокирован</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="376"/>
<location filename="mainwindow.cpp" line="387"/>
<source>Проверка обновлений...</source>
<translation>Проверка обновлений...</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="188"/>
<location filename="mainwindow.cpp" line="189"/>
<source>Неверный логин/пароль</source>
<translation>Неверный логин/пароль</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="249"/>
<location filename="mainwindow.cpp" line="250"/>
<source>Соединение установлено</source>
<translation>Соединение установлено</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="255"/>
<location filename="mainwindow.cpp" line="256"/>
<location filename="mainwindow.cpp" line="319"/>
<source>Соединение отсутсвует</source>
<translation>Соединение отсутсвует</translation>
</message>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.1, 2024-09-26T15:31:56. -->
<!-- Written by QtCreator 4.11.1, 2024-09-27T11:32:58. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

Binary file not shown.

Binary file not shown.

View File

@@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_MainWindow_t {
QByteArrayData data[30];
char stringdata0[492];
QByteArrayData data[31];
char stringdata0[508];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
@@ -50,18 +50,19 @@ QT_MOC_LITERAL(14, 184, 16), // "sigCalculateHash"
QT_MOC_LITERAL(15, 201, 14), // "sigSendCommand"
QT_MOC_LITERAL(16, 216, 7), // "message"
QT_MOC_LITERAL(17, 224, 19), // "sigSendAutorization"
QT_MOC_LITERAL(18, 244, 22), // "on_loginButton_clicked"
QT_MOC_LITERAL(19, 267, 23), // "on_updateButton_clicked"
QT_MOC_LITERAL(20, 291, 22), // "on_startButton_clicked"
QT_MOC_LITERAL(21, 314, 27), // "on_saveServerButton_clicked"
QT_MOC_LITERAL(22, 342, 25), // "on_settingsButton_clicked"
QT_MOC_LITERAL(23, 368, 24), // "on_connectButton_clicked"
QT_MOC_LITERAL(24, 393, 29), // "on_languageComboBox_activated"
QT_MOC_LITERAL(25, 423, 4), // "arg1"
QT_MOC_LITERAL(26, 428, 17), // "slotDisableNotify"
QT_MOC_LITERAL(27, 446, 19), // "slotConnectionState"
QT_MOC_LITERAL(28, 466, 4), // "flag"
QT_MOC_LITERAL(29, 471, 20) // "slotServerDisconnect"
QT_MOC_LITERAL(18, 244, 15), // "sigGetConnected"
QT_MOC_LITERAL(19, 260, 22), // "on_loginButton_clicked"
QT_MOC_LITERAL(20, 283, 23), // "on_updateButton_clicked"
QT_MOC_LITERAL(21, 307, 22), // "on_startButton_clicked"
QT_MOC_LITERAL(22, 330, 27), // "on_saveServerButton_clicked"
QT_MOC_LITERAL(23, 358, 25), // "on_settingsButton_clicked"
QT_MOC_LITERAL(24, 384, 24), // "on_connectButton_clicked"
QT_MOC_LITERAL(25, 409, 29), // "on_languageComboBox_activated"
QT_MOC_LITERAL(26, 439, 4), // "arg1"
QT_MOC_LITERAL(27, 444, 17), // "slotDisableNotify"
QT_MOC_LITERAL(28, 462, 19), // "slotConnectionState"
QT_MOC_LITERAL(29, 482, 4), // "flag"
QT_MOC_LITERAL(30, 487, 20) // "slotServerDisconnect"
},
"MainWindow\0sigInitializeClient\0\0"
@@ -71,8 +72,8 @@ QT_MOC_LITERAL(29, 471, 20) // "slotServerDisconnect"
"sigSetConnect\0ServerSettings*\0"
"serverSettings\0sigCalculateHash\0"
"sigSendCommand\0message\0sigSendAutorization\0"
"on_loginButton_clicked\0on_updateButton_clicked\0"
"on_startButton_clicked\0"
"sigGetConnected\0on_loginButton_clicked\0"
"on_updateButton_clicked\0on_startButton_clicked\0"
"on_saveServerButton_clicked\0"
"on_settingsButton_clicked\0"
"on_connectButton_clicked\0"
@@ -88,31 +89,32 @@ static const uint qt_meta_data_MainWindow[] = {
8, // revision
0, // classname
0, 0, // classinfo
15, 14, // methods
16, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
5, // signalCount
6, // signalCount
// signals: name, argc, parameters, tag, flags
1, 4, 89, 2, 0x06 /* Public */,
11, 2, 98, 2, 0x06 /* Public */,
14, 0, 103, 2, 0x06 /* Public */,
15, 1, 104, 2, 0x06 /* Public */,
17, 0, 107, 2, 0x06 /* Public */,
1, 4, 94, 2, 0x06 /* Public */,
11, 2, 103, 2, 0x06 /* Public */,
14, 0, 108, 2, 0x06 /* Public */,
15, 1, 109, 2, 0x06 /* Public */,
17, 0, 112, 2, 0x06 /* Public */,
18, 0, 113, 2, 0x06 /* Public */,
// slots: name, argc, parameters, tag, flags
18, 0, 108, 2, 0x08 /* Private */,
19, 0, 109, 2, 0x08 /* Private */,
20, 0, 110, 2, 0x08 /* Private */,
21, 0, 111, 2, 0x08 /* Private */,
22, 0, 112, 2, 0x08 /* Private */,
23, 0, 113, 2, 0x08 /* Private */,
24, 1, 114, 2, 0x08 /* Private */,
26, 0, 117, 2, 0x08 /* Private */,
27, 1, 118, 2, 0x08 /* Private */,
29, 0, 121, 2, 0x08 /* Private */,
19, 0, 114, 2, 0x08 /* Private */,
20, 0, 115, 2, 0x08 /* Private */,
21, 0, 116, 2, 0x08 /* Private */,
22, 0, 117, 2, 0x08 /* Private */,
23, 0, 118, 2, 0x08 /* Private */,
24, 0, 119, 2, 0x08 /* Private */,
25, 1, 120, 2, 0x08 /* Private */,
27, 0, 123, 2, 0x08 /* Private */,
28, 1, 124, 2, 0x08 /* Private */,
30, 0, 127, 2, 0x08 /* Private */,
// signals: parameters
QMetaType::Void, 0x80000000 | 3, 0x80000000 | 5, 0x80000000 | 7, 0x80000000 | 9, 4, 6, 8, 10,
@@ -120,6 +122,7 @@ static const uint qt_meta_data_MainWindow[] = {
QMetaType::Void,
QMetaType::Void, QMetaType::QString, 16,
QMetaType::Void,
QMetaType::Bool,
// slots: parameters
QMetaType::Void,
@@ -128,9 +131,9 @@ static const uint qt_meta_data_MainWindow[] = {
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void, QMetaType::QString, 25,
QMetaType::Void, QMetaType::QString, 26,
QMetaType::Void,
QMetaType::Void, QMetaType::Bool, 28,
QMetaType::Void, QMetaType::Bool, 29,
QMetaType::Void,
0 // eod
@@ -147,16 +150,18 @@ void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id,
case 2: _t->sigCalculateHash(); break;
case 3: _t->sigSendCommand((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 4: _t->sigSendAutorization(); break;
case 5: _t->on_loginButton_clicked(); break;
case 6: _t->on_updateButton_clicked(); break;
case 7: _t->on_startButton_clicked(); break;
case 8: _t->on_saveServerButton_clicked(); break;
case 9: _t->on_settingsButton_clicked(); break;
case 10: _t->on_connectButton_clicked(); break;
case 11: _t->on_languageComboBox_activated((*reinterpret_cast< const QString(*)>(_a[1]))); break;
case 12: _t->slotDisableNotify(); break;
case 13: _t->slotConnectionState((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 14: _t->slotServerDisconnect(); break;
case 5: { bool _r = _t->sigGetConnected();
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = std::move(_r); } break;
case 6: _t->on_loginButton_clicked(); break;
case 7: _t->on_updateButton_clicked(); break;
case 8: _t->on_startButton_clicked(); break;
case 9: _t->on_saveServerButton_clicked(); break;
case 10: _t->on_settingsButton_clicked(); break;
case 11: _t->on_connectButton_clicked(); break;
case 12: _t->on_languageComboBox_activated((*reinterpret_cast< const QString(*)>(_a[1]))); break;
case 13: _t->slotDisableNotify(); break;
case 14: _t->slotConnectionState((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 15: _t->slotServerDisconnect(); break;
default: ;
}
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
@@ -220,6 +225,13 @@ void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id,
return;
}
}
{
using _t = bool (MainWindow::*)();
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&MainWindow::sigGetConnected)) {
*result = 5;
return;
}
}
}
}
@@ -252,13 +264,13 @@ int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 15)
if (_id < 16)
qt_static_metacall(this, _c, _id, _a);
_id -= 15;
_id -= 16;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 15)
if (_id < 16)
qt_static_metacall(this, _c, _id, _a);
_id -= 15;
_id -= 16;
}
return _id;
}
@@ -295,5 +307,14 @@ void MainWindow::sigSendAutorization()
{
QMetaObject::activate(this, &staticMetaObject, 4, nullptr);
}
// SIGNAL 5
bool MainWindow::sigGetConnected()
{
bool _t0{};
void *_a[] = { const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t0))) };
QMetaObject::activate(this, &staticMetaObject, 5, _a);
return _t0;
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -80,7 +80,7 @@ void MainWindow::bindConnection()
connect(timer,&QTimer::timeout,this,&MainWindow::slotDisableNotify);
connect(recognizeSystem,&RecognizeSystem::sigStartCompare,hashComparer,&HashComparer::CompareDeltas);
connect(recognizeSystem,&RecognizeSystem::sigUpdateBytesAvailable,this,&MainWindow::updateProgress);
connect(recognizeSystem,&RecognizeSystem::sigUpdateBytesAvailable,this,&MainWindow::updateProgress,Qt::QueuedConnection);
connect(recognizeSystem,&RecognizeSystem::sigLoadComplete,this,&MainWindow::loadComplete);
connect(recognizeSystem,&RecognizeSystem::sigNeedUpdate,this,&MainWindow::setNeedUpdate);
connect(recognizeSystem,&RecognizeSystem::sigSendDebugLog,this,&MainWindow::debugLog);
@@ -102,6 +102,7 @@ void MainWindow::bindConnection()
connect(client,&TCPClient::sigConnectionState,this,&MainWindow::slotConnectionState,Qt::AutoConnection);
connect(client,&TCPClient::sigServerDisconnect,this,&MainWindow::slotServerDisconnect);
connect(this,&MainWindow::sigGetConnected,client,&TCPClient::getIsConnected);
connect(this,&MainWindow::sigCalculateHash,updateController,&UpdateController::calculateCommonHash);
connect(this,&MainWindow::sigSendAutorization,sendSystem,&SendSystem::sendClientAutorization);
}
@@ -109,7 +110,8 @@ void MainWindow::bindConnection()
void MainWindow::updateProgress()
{
filesLoaded++;
ui->loadingProgressBar->setValue(filesLoaded);
float value = 100 / ((float)fileCountForUpdate / filesLoaded);
ui->loadingProgressBar->setValue(value);
}
void MainWindow::loadComplete()
@@ -119,8 +121,7 @@ void MainWindow::loadComplete()
ui->startButton->setEnabled(true);
autoStart();
ui->inlineTextDebug->setText(tr("Обновление завершено..."));
ui->loadingProgressBar->setMaximum(fileCountForUpdate);
ui->loadingProgressBar->setValue(fileCountForUpdate);
ui->loadingProgressBar->setValue(100);
}
void MainWindow::setNeedUpdate(bool flag,quint64 size, quint64 fileCount)
@@ -311,6 +312,16 @@ void MainWindow::bindNotifyWidget(UpdateNotifyWidget *widget)
void MainWindow::on_loginButton_clicked()
{
if (!client->getIsConnected())
{
QPalette palette = ui->notificationLabel->palette();
palette.setColor(ui->notificationLabel->foregroundRole(),Qt::red);
ui->notificationLabel->setText(tr("Соединение отсутсвует"));
ui->notificationLabel->setPalette(palette);
ui->notificationLabel->show();
return;
}
QString username = ui->loginInputField->text();
QString password = ui->passwordInputField->text();
@@ -338,9 +349,11 @@ void MainWindow::on_startButton_clicked()
void MainWindow::on_saveServerButton_clicked()
{
ui->settingsWidget->hide();
ui->loginWidget->show();
if(client->getIsConnected()) return;
QString server = ui->serverInputField->text();
QString port = ui->portInputField->text();

View File

@@ -48,6 +48,7 @@ signals:
void sigCalculateHash();
void sigSendCommand(QString message);
void sigSendAutorization();
bool sigGetConnected();
private slots: