diff --git a/Core/recognizesystem.cpp b/Core/recognizesystem.cpp
index 35c33f2..cf52102 100644
--- a/Core/recognizesystem.cpp
+++ b/Core/recognizesystem.cpp
@@ -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
//ОЧИСТКА ПОСЛЕ ПЕРЕДАЧИ
diff --git a/Core/tcpclient.cpp b/Core/tcpclient.cpp
index 6b3561e..5ad8259 100644
--- a/Core/tcpclient.cpp
+++ b/Core/tcpclient.cpp
@@ -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()
{
diff --git a/Core/tcpclient.h b/Core/tcpclient.h
index 9a19cbd..204283b 100644
--- a/Core/tcpclient.h
+++ b/Core/tcpclient.h
@@ -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();
};
diff --git a/QtLanguage_eng.ts b/QtLanguage_eng.ts
index ef1f0ea..85537db 100644
--- a/QtLanguage_eng.ts
+++ b/QtLanguage_eng.ts
@@ -99,47 +99,48 @@
ENG
-
+
Обновление завершено...
Update complete...
-
+
Доступно обновление:
Update available:
-
+
Количество файлов:
Files for update:
-
+
Установлена последняя версия
Latest version installed
-
+
Сервер заблокирован
Server is blocked
-
+
Проверка обновлений...
Checking for updates...
-
+
Неверный логин/пароль
Invalid login/password
-
+
Соединение установлено
Connection complete
-
+
+
Соединение отсутсвует
No connection
diff --git a/QtLanguage_ru.ts b/QtLanguage_ru.ts
index 68201d4..f941188 100644
--- a/QtLanguage_ru.ts
+++ b/QtLanguage_ru.ts
@@ -99,47 +99,48 @@
ENG
-
+
Обновление завершено...
Обновление завершено...
-
+
Доступно обновление:
Доступно обновление:
-
+
Количество файлов:
Количество файлов:
-
+
Установлена последняя версия
Установлена последняя версия
-
+
Сервер заблокирован
Сервер заблокирован
-
+
Проверка обновлений...
Проверка обновлений...
-
+
Неверный логин/пароль
Неверный логин/пароль
-
+
Соединение установлено
Соединение установлено
-
+
+
Соединение отсутсвует
Соединение отсутсвует
diff --git a/RRJClient.pro.user b/RRJClient.pro.user
index 5554147..367dc7c 100644
--- a/RRJClient.pro.user
+++ b/RRJClient.pro.user
@@ -1,6 +1,6 @@
-
+
EnvironmentId
diff --git a/debug/RRJClient.exe b/debug/RRJClient.exe
index a8c2d55..e2394e1 100644
Binary files a/debug/RRJClient.exe and b/debug/RRJClient.exe differ
diff --git a/debug/mainwindow.o b/debug/mainwindow.o
index dd4f81f..85f7485 100644
Binary files a/debug/mainwindow.o and b/debug/mainwindow.o differ
diff --git a/debug/moc_mainwindow.cpp b/debug/moc_mainwindow.cpp
index ce42c53..90698ce 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[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(reinterpret_cast(std::addressof(_t0))) };
+ QMetaObject::activate(this, &staticMetaObject, 5, _a);
+ return _t0;
+}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
diff --git a/debug/moc_mainwindow.o b/debug/moc_mainwindow.o
index 3c857ba..16a07d1 100644
Binary files a/debug/moc_mainwindow.o and b/debug/moc_mainwindow.o differ
diff --git a/debug/moc_tcpclient.o b/debug/moc_tcpclient.o
index c189900..5b17483 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 a461a80..16f6fe0 100644
Binary files a/debug/recognizesystem.o and b/debug/recognizesystem.o differ
diff --git a/debug/tcpclient.o b/debug/tcpclient.o
index a91885e..714bce3 100644
Binary files a/debug/tcpclient.o and b/debug/tcpclient.o differ
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 8b3365c..34cb492 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -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();
diff --git a/mainwindow.h b/mainwindow.h
index 4d8cb09..cf29f09 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -48,6 +48,7 @@ signals:
void sigCalculateHash();
void sigSendCommand(QString message);
void sigSendAutorization();
+ bool sigGetConnected();
private slots: