diff --git a/Core/recognizesystem.cpp b/Core/recognizesystem.cpp index df674e1..35c33f2 100644 --- a/Core/recognizesystem.cpp +++ b/Core/recognizesystem.cpp @@ -157,7 +157,7 @@ void RecognizeSystem::recognize(QTcpSocket *socket) emit sigSendDebugLog(Tools::getTime() + "FINAL Count send: " + QString::number(countSend)); emit sigSendDebugLog(Tools::getTime() + "FINAL Size received: " + QString::number(sizeReceiveData)); emit sigSendDebugLog(Tools::getTime() + "FINAL File size" + QString::number(fileSize)); - emit sigUpdateBytesAvailable(fileSize,sizeReceiveData); + emit sigUpdateBytesAvailable(); break; } } diff --git a/Core/recognizesystem.h b/Core/recognizesystem.h index 35c0fa5..ec595e1 100644 --- a/Core/recognizesystem.h +++ b/Core/recognizesystem.h @@ -23,7 +23,7 @@ public: void recognize(QTcpSocket *socket); signals: - void sigUpdateBytesAvailable(qint64 size,quint64 sended); + void sigUpdateBytesAvailable(); void sigLoadComplete(); void sigNeedUpdate(bool flag,qint64 size,quint64 fileCount); void sigSendDebugLog(QString message); diff --git a/Core/sendsystem.cpp b/Core/sendsystem.cpp index 1132cbc..a67fb37 100644 --- a/Core/sendsystem.cpp +++ b/Core/sendsystem.cpp @@ -65,7 +65,8 @@ void SendSystem::sendFileBlock(QString path) stream << PacketType::TYPE_FILE; //Отправляем тип блока stream << path << fileSize; - socket->waitForBytesWritten(); + socket->waitForReadyRead(20); + //socket->waitForBytesWritten(); if(file.open(QFile::ReadOnly)){ while(!file.atEnd()){ @@ -80,10 +81,11 @@ void SendSystem::sendFileBlock(QString path) file.close(); + emit sigSend(); //qDebug() << "Transaction after send file: " << socket->isTransactionStarted(); countSend = 0; - socket->waitForBytesWritten(); - socket->waitForReadyRead(100); + //socket->waitForBytesWritten(); + socket->waitForReadyRead(20); } void SendSystem::sendFolderBlock(QString path) @@ -93,6 +95,7 @@ void SendSystem::sendFolderBlock(QString path) stream << PacketType::TYPE_FOLDER; stream << path; + emit sigSend(); socket->waitForReadyRead(100); } @@ -113,16 +116,16 @@ void SendSystem::sendXMLAnswer(QByteArray array) stream << array; socket->waitForBytesWritten(); + socket->waitForReadyRead(100); } void SendSystem::sendFinish() { - socket->waitForReadyRead(); + socket->waitForReadyRead(100); QDataStream stream(socket); stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); stream << PacketType::TYPE_FINISH; - socket->waitForReadyRead(100); } diff --git a/Core/sendsystem.h b/Core/sendsystem.h index 506b622..020637b 100644 --- a/Core/sendsystem.h +++ b/Core/sendsystem.h @@ -20,7 +20,7 @@ public: ~SendSystem(); void sendFinish(); signals: - + void sigSend(); QByteArray sigGetXmlAnswer(QString); private: diff --git a/RRJClient.pro.user b/RRJClient.pro.user index 0a5680e..d4f756d 100644 --- a/RRJClient.pro.user +++ b/RRJClient.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/StaticData/clientHash.xml b/StaticData/clientHash.xml index a43e090..666983d 100644 --- a/StaticData/clientHash.xml +++ b/StaticData/clientHash.xml @@ -24,8 +24,793 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/debug/RRJClient.exe b/debug/RRJClient.exe index 930e4f5..59da302 100644 Binary files a/debug/RRJClient.exe and b/debug/RRJClient.exe differ diff --git a/debug/main.o b/debug/main.o index d0b7149..3366a84 100644 Binary files a/debug/main.o and b/debug/main.o differ diff --git a/debug/mainwindow.o b/debug/mainwindow.o index 4ce3fd6..dd4f81f 100644 Binary files a/debug/mainwindow.o and b/debug/mainwindow.o differ diff --git a/debug/moc_mainwindow.o b/debug/moc_mainwindow.o index dbfdff4..3c857ba 100644 Binary files a/debug/moc_mainwindow.o and b/debug/moc_mainwindow.o differ diff --git a/debug/moc_recognizesystem.cpp b/debug/moc_recognizesystem.cpp index 57a6012..d2e5d25 100644 --- a/debug/moc_recognizesystem.cpp +++ b/debug/moc_recognizesystem.cpp @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_RecognizeSystem_t { - QByteArrayData data[19]; - char stringdata0[257]; + QByteArrayData data[18]; + char stringdata0[250]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -35,27 +35,26 @@ static const qt_meta_stringdata_RecognizeSystem_t qt_meta_stringdata_RecognizeSy QT_MOC_LITERAL(0, 0, 15), // "RecognizeSystem" QT_MOC_LITERAL(1, 16, 23), // "sigUpdateBytesAvailable" QT_MOC_LITERAL(2, 40, 0), // "" -QT_MOC_LITERAL(3, 41, 4), // "size" -QT_MOC_LITERAL(4, 46, 6), // "sended" -QT_MOC_LITERAL(5, 53, 15), // "sigLoadComplete" -QT_MOC_LITERAL(6, 69, 13), // "sigNeedUpdate" -QT_MOC_LITERAL(7, 83, 4), // "flag" -QT_MOC_LITERAL(8, 88, 9), // "fileCount" -QT_MOC_LITERAL(9, 98, 15), // "sigSendDebugLog" -QT_MOC_LITERAL(10, 114, 7), // "message" -QT_MOC_LITERAL(11, 122, 17), // "sigSocketDisabled" -QT_MOC_LITERAL(12, 140, 16), // "sigServerBlocked" -QT_MOC_LITERAL(13, 157, 16), // "sigSaveLoginData" -QT_MOC_LITERAL(14, 174, 20), // "ServerAuthorization*" -QT_MOC_LITERAL(15, 195, 10), // "serverAuth" -QT_MOC_LITERAL(16, 206, 25), // "sigSocketWaitForReadyRead" -QT_MOC_LITERAL(17, 232, 8), // "waitTime" -QT_MOC_LITERAL(18, 241, 15) // "sigStartCompare" +QT_MOC_LITERAL(3, 41, 15), // "sigLoadComplete" +QT_MOC_LITERAL(4, 57, 13), // "sigNeedUpdate" +QT_MOC_LITERAL(5, 71, 4), // "flag" +QT_MOC_LITERAL(6, 76, 4), // "size" +QT_MOC_LITERAL(7, 81, 9), // "fileCount" +QT_MOC_LITERAL(8, 91, 15), // "sigSendDebugLog" +QT_MOC_LITERAL(9, 107, 7), // "message" +QT_MOC_LITERAL(10, 115, 17), // "sigSocketDisabled" +QT_MOC_LITERAL(11, 133, 16), // "sigServerBlocked" +QT_MOC_LITERAL(12, 150, 16), // "sigSaveLoginData" +QT_MOC_LITERAL(13, 167, 20), // "ServerAuthorization*" +QT_MOC_LITERAL(14, 188, 10), // "serverAuth" +QT_MOC_LITERAL(15, 199, 25), // "sigSocketWaitForReadyRead" +QT_MOC_LITERAL(16, 225, 8), // "waitTime" +QT_MOC_LITERAL(17, 234, 15) // "sigStartCompare" }, "RecognizeSystem\0sigUpdateBytesAvailable\0" - "\0size\0sended\0sigLoadComplete\0sigNeedUpdate\0" - "flag\0fileCount\0sigSendDebugLog\0message\0" + "\0sigLoadComplete\0sigNeedUpdate\0flag\0" + "size\0fileCount\0sigSendDebugLog\0message\0" "sigSocketDisabled\0sigServerBlocked\0" "sigSaveLoginData\0ServerAuthorization*\0" "serverAuth\0sigSocketWaitForReadyRead\0" @@ -77,25 +76,25 @@ static const uint qt_meta_data_RecognizeSystem[] = { 9, // signalCount // signals: name, argc, parameters, tag, flags - 1, 2, 59, 2, 0x06 /* Public */, - 5, 0, 64, 2, 0x06 /* Public */, - 6, 3, 65, 2, 0x06 /* Public */, - 9, 1, 72, 2, 0x06 /* Public */, - 11, 0, 75, 2, 0x06 /* Public */, - 12, 0, 76, 2, 0x06 /* Public */, - 13, 1, 77, 2, 0x06 /* Public */, - 16, 1, 80, 2, 0x06 /* Public */, - 18, 0, 83, 2, 0x06 /* Public */, + 1, 0, 59, 2, 0x06 /* Public */, + 3, 0, 60, 2, 0x06 /* Public */, + 4, 3, 61, 2, 0x06 /* Public */, + 8, 1, 68, 2, 0x06 /* Public */, + 10, 0, 71, 2, 0x06 /* Public */, + 11, 0, 72, 2, 0x06 /* Public */, + 12, 1, 73, 2, 0x06 /* Public */, + 15, 1, 76, 2, 0x06 /* Public */, + 17, 0, 79, 2, 0x06 /* Public */, // signals: parameters - QMetaType::Void, QMetaType::LongLong, QMetaType::ULongLong, 3, 4, - QMetaType::Void, - QMetaType::Void, QMetaType::Bool, QMetaType::LongLong, QMetaType::ULongLong, 7, 3, 8, - QMetaType::Void, QMetaType::QString, 10, QMetaType::Void, QMetaType::Void, - QMetaType::Void, 0x80000000 | 14, 15, - QMetaType::Void, QMetaType::Int, 17, + QMetaType::Void, QMetaType::Bool, QMetaType::LongLong, QMetaType::ULongLong, 5, 6, 7, + QMetaType::Void, QMetaType::QString, 9, + QMetaType::Void, + QMetaType::Void, + QMetaType::Void, 0x80000000 | 13, 14, + QMetaType::Void, QMetaType::Int, 16, QMetaType::Void, 0 // eod @@ -107,7 +106,7 @@ void RecognizeSystem::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int auto *_t = static_cast(_o); Q_UNUSED(_t) switch (_id) { - case 0: _t->sigUpdateBytesAvailable((*reinterpret_cast< qint64(*)>(_a[1])),(*reinterpret_cast< quint64(*)>(_a[2]))); break; + case 0: _t->sigUpdateBytesAvailable(); break; case 1: _t->sigLoadComplete(); break; case 2: _t->sigNeedUpdate((*reinterpret_cast< bool(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2])),(*reinterpret_cast< quint64(*)>(_a[3]))); break; case 3: _t->sigSendDebugLog((*reinterpret_cast< QString(*)>(_a[1]))); break; @@ -121,7 +120,7 @@ void RecognizeSystem::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int } else if (_c == QMetaObject::IndexOfMethod) { int *result = reinterpret_cast(_a[0]); { - using _t = void (RecognizeSystem::*)(qint64 , quint64 ); + using _t = void (RecognizeSystem::*)(); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&RecognizeSystem::sigUpdateBytesAvailable)) { *result = 0; return; @@ -227,10 +226,9 @@ int RecognizeSystem::qt_metacall(QMetaObject::Call _c, int _id, void **_a) } // SIGNAL 0 -void RecognizeSystem::sigUpdateBytesAvailable(qint64 _t1, quint64 _t2) +void RecognizeSystem::sigUpdateBytesAvailable() { - void *_a[] = { nullptr, const_cast(reinterpret_cast(std::addressof(_t1))), const_cast(reinterpret_cast(std::addressof(_t2))) }; - QMetaObject::activate(this, &staticMetaObject, 0, _a); + QMetaObject::activate(this, &staticMetaObject, 0, nullptr); } // SIGNAL 1 diff --git a/debug/moc_recognizesystem.o b/debug/moc_recognizesystem.o index b128705..d204b33 100644 Binary files a/debug/moc_recognizesystem.o and b/debug/moc_recognizesystem.o differ diff --git a/debug/moc_sendsystem.cpp b/debug/moc_sendsystem.cpp index 8dacc5a..5e42067 100644 --- a/debug/moc_sendsystem.cpp +++ b/debug/moc_sendsystem.cpp @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_SendSystem_t { - QByteArrayData data[3]; - char stringdata0[28]; + QByteArrayData data[4]; + char stringdata0[36]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -33,11 +33,12 @@ struct qt_meta_stringdata_SendSystem_t { static const qt_meta_stringdata_SendSystem_t qt_meta_stringdata_SendSystem = { { QT_MOC_LITERAL(0, 0, 10), // "SendSystem" -QT_MOC_LITERAL(1, 11, 15), // "sigGetXmlAnswer" -QT_MOC_LITERAL(2, 27, 0) // "" +QT_MOC_LITERAL(1, 11, 7), // "sigSend" +QT_MOC_LITERAL(2, 19, 0), // "" +QT_MOC_LITERAL(3, 20, 15) // "sigGetXmlAnswer" }, - "SendSystem\0sigGetXmlAnswer\0" + "SendSystem\0sigSend\0\0sigGetXmlAnswer" }; #undef QT_MOC_LITERAL @@ -47,17 +48,19 @@ static const uint qt_meta_data_SendSystem[] = { 8, // revision 0, // classname 0, 0, // classinfo - 1, 14, // methods + 2, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags - 1, // signalCount + 2, // signalCount // signals: name, argc, parameters, tag, flags - 1, 1, 19, 2, 0x06 /* Public */, + 1, 0, 24, 2, 0x06 /* Public */, + 3, 1, 25, 2, 0x06 /* Public */, // signals: parameters + QMetaType::Void, QMetaType::QByteArray, QMetaType::QString, 2, 0 // eod @@ -69,16 +72,24 @@ void SendSystem::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, auto *_t = static_cast(_o); Q_UNUSED(_t) switch (_id) { - case 0: { QByteArray _r = _t->sigGetXmlAnswer((*reinterpret_cast< QString(*)>(_a[1]))); + case 0: _t->sigSend(); break; + case 1: { QByteArray _r = _t->sigGetXmlAnswer((*reinterpret_cast< QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< QByteArray*>(_a[0]) = std::move(_r); } break; default: ; } } else if (_c == QMetaObject::IndexOfMethod) { int *result = reinterpret_cast(_a[0]); + { + using _t = void (SendSystem::*)(); + if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&SendSystem::sigSend)) { + *result = 0; + return; + } + } { using _t = QByteArray (SendSystem::*)(QString ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&SendSystem::sigGetXmlAnswer)) { - *result = 0; + *result = 1; return; } } @@ -114,23 +125,29 @@ int SendSystem::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 1) + if (_id < 2) qt_static_metacall(this, _c, _id, _a); - _id -= 1; + _id -= 2; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 1) + if (_id < 2) *reinterpret_cast(_a[0]) = -1; - _id -= 1; + _id -= 2; } return _id; } // SIGNAL 0 +void SendSystem::sigSend() +{ + QMetaObject::activate(this, &staticMetaObject, 0, nullptr); +} + +// SIGNAL 1 QByteArray SendSystem::sigGetXmlAnswer(QString _t1) { QByteArray _t0{}; void *_a[] = { const_cast(reinterpret_cast(std::addressof(_t0))), const_cast(reinterpret_cast(std::addressof(_t1))) }; - QMetaObject::activate(this, &staticMetaObject, 0, _a); + QMetaObject::activate(this, &staticMetaObject, 1, _a); return _t0; } QT_WARNING_POP diff --git a/debug/moc_sendsystem.o b/debug/moc_sendsystem.o index 4a8b823..4971837 100644 Binary files a/debug/moc_sendsystem.o and b/debug/moc_sendsystem.o differ diff --git a/debug/moc_updatenotifywidget.o b/debug/moc_updatenotifywidget.o index 1f4921e..76a33ad 100644 Binary files a/debug/moc_updatenotifywidget.o and b/debug/moc_updatenotifywidget.o differ diff --git a/debug/recognizesystem.o b/debug/recognizesystem.o index b7cf42c..a461a80 100644 Binary files a/debug/recognizesystem.o and b/debug/recognizesystem.o differ diff --git a/debug/sendsystem.o b/debug/sendsystem.o index 6bbd018..77f6a66 100644 Binary files a/debug/sendsystem.o and b/debug/sendsystem.o differ diff --git a/debug/updatenotifywidget.o b/debug/updatenotifywidget.o index 2b300cf..28f0cb7 100644 Binary files a/debug/updatenotifywidget.o and b/debug/updatenotifywidget.o differ diff --git a/mainwindow.cpp b/mainwindow.cpp index 74c2fa1..8b3365c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -13,6 +13,39 @@ MainWindow::MainWindow(QWidget *parent) } +void MainWindow::initialize() +{ + ui->loadingProgressBar->setValue(0); + ui->settingsWidget->hide(); + ui->notificationLabel->hide(); + ui->loadingProgressBar->hide(); + ui->updateButton->hide(); + ui->connectButton->hide(); + ui->startButton->setEnabled(false); + ui->debugText->hide(); + ui->displayGroupWidget->hide(); + ui->autostartCheckBox->hide(); + ui->updateButton->setEnabled(false); + ui->startButton->setEnabled(false); + + createObjects(); + + bindConnection(); + + emit sigCalculateHash(); + emit sigInitializeClient(recognizeSystem,externalExecuter,sendSystem,connectionThread); + + recognizeSystem->initialize(updateController,dataParser,this); + + screenChecker->check(); + + loadStaticData(); + emit sigSetConnect(dataParser->getServerSettings(),connectionThread); + + checkAppAvailable(); + +} + void MainWindow::createObjects() { connectionThread = new QThread; @@ -55,6 +88,7 @@ void MainWindow::bindConnection() connect(recognizeSystem,&RecognizeSystem::sigSaveLoginData,this,&MainWindow::checkLoginResult); connect(recognizeSystem,&RecognizeSystem::sigSocketWaitForReadyRead,client,&TCPClient::waitRead,Qt::AutoConnection); connect(recognizeSystem,&RecognizeSystem::sigServerBlocked,this,&MainWindow::serverBlocked); + connect(hashComparer,&HashComparer::sigCallCheck,this,&MainWindow::checkUpdate); connect(sendSystem,&SendSystem::sigGetXmlAnswer,dataParser,&DataParser::slotGetXmlAnswer); @@ -72,80 +106,46 @@ void MainWindow::bindConnection() connect(this,&MainWindow::sigSendAutorization,sendSystem,&SendSystem::sendClientAutorization); } -void MainWindow::initialize() +void MainWindow::updateProgress() { - maxBytesAvailable = 0; - globalValue = 0; - - ui->loadingProgressBar->setValue(0); - ui->settingsWidget->hide(); - ui->notificationLabel->hide(); - ui->loadingProgressBar->hide(); - ui->updateButton->hide(); - ui->connectButton->hide(); - ui->startButton->setEnabled(false); - ui->debugText->hide(); - ui->displayGroupWidget->hide(); - ui->autostartCheckBox->hide(); - ui->updateButton->setEnabled(false); - ui->startButton->setEnabled(false); - - createObjects(); - - bindConnection(); - - emit sigCalculateHash(); - emit sigInitializeClient(recognizeSystem,externalExecuter,sendSystem,connectionThread); - - recognizeSystem->initialize(updateController,dataParser,this); - - screenChecker->check(); - - loadStaticData(); - emit sigSetConnect(dataParser->getServerSettings(),connectionThread); - - checkAppAvailable(); - -} - -void MainWindow::updateProgress(qint64 size,quint64 sended) -{ - float currentValue = 100.00 / (maxBytesAvailable / size); - globalValue += currentValue; - - ui->loadingProgressBar->setValue(globalValue); + filesLoaded++; + ui->loadingProgressBar->setValue(filesLoaded); } void MainWindow::loadComplete() { - ui->loadingProgressBar->setValue(100); - ui->updateButton->setEnabled(false); externalExecuter->findApp(); + ui->updateButton->setEnabled(false); ui->startButton->setEnabled(true); autoStart(); ui->inlineTextDebug->setText(tr("Обновление завершено...")); + ui->loadingProgressBar->setMaximum(fileCountForUpdate); + ui->loadingProgressBar->setValue(fileCountForUpdate); } void MainWindow::setNeedUpdate(bool flag,quint64 size, quint64 fileCount) { - maxBytesAvailable = 0; + fileCountForUpdate = 0; + filesLoaded = 0; + fileCountForUpdate = fileCount; QString availableSizeText; if (flag){ QString result = tr("Доступно обновление: ") + Tools::convertFileSize(size); result += tr("Количество файлов: ") + QString::number(fileCount); ui->inlineTextDebug->setText(result); - maxBytesAvailable = size; } else { ui->inlineTextDebug->setText(tr("Установлена последняя версия")); + + ui->loadingProgressBar->setMaximum(100); + ui->loadingProgressBar->setValue(100); autoStart(); } ui->updateButton->setEnabled(flag); ui->startButton->setEnabled(!flag); - ui->loadingProgressBar->setRange(0,100); } void MainWindow::lostConnection() @@ -166,7 +166,6 @@ void MainWindow::serverBlocked() timer->start(3000); } - void MainWindow::checkLoginResult(ServerAuthorization *serverAuth) { if (serverAuth->Result) @@ -177,7 +176,6 @@ void MainWindow::checkLoginResult(ServerAuthorization *serverAuth) checkUpdate(); } - ui->loadingProgressBar->show(); ui->updateButton->show(); ui->displayGroupWidget->show(); ui->autostartCheckBox->show(); @@ -275,7 +273,6 @@ void MainWindow::slotServerDisconnect() slotConnectionState(false); } - void MainWindow::slotDisableNotify() { ui->notificationLabel->hide(); @@ -309,6 +306,7 @@ void MainWindow::callUpdateList() void MainWindow::bindNotifyWidget(UpdateNotifyWidget *widget) { updateWidget = widget; + connect(sendSystem,&SendSystem::sigSend,updateWidget,&UpdateNotifyWidget::updateCount); } void MainWindow::on_loginButton_clicked() @@ -338,7 +336,6 @@ void MainWindow::on_startButton_clicked() sendSystem->sendDisable(); } - void MainWindow::on_saveServerButton_clicked() { ui->settingsWidget->hide(); @@ -358,7 +355,6 @@ void MainWindow::on_settingsButton_clicked() ui->loginWidget->hide(); } - void MainWindow::on_connectButton_clicked() { emit sigSetConnect(dataParser->getServerSettings(),connectionThread); @@ -372,9 +368,10 @@ void MainWindow::on_languageComboBox_activated(const QString &arg1) ui->retranslateUi(this); } - void MainWindow::checkUpdate() { + ui->loadingProgressBar->setValue(0); + ui->loadingProgressBar->show(); emit sigSendCommand("check"); ui->inlineTextDebug->setText(tr("Проверка обновлений...")); } diff --git a/mainwindow.h b/mainwindow.h index 63d473a..4d8cb09 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -84,13 +84,14 @@ private: SendSystem *sendSystem; HashComparer *hashComparer; QThread *connectionThread; - quint64 maxBytesAvailable; QTimer *timer; - float globalValue; + + int fileCountForUpdate; + int filesLoaded; void debugLog(QString message); void initialize(); - void updateProgress(qint64 size,quint64 sended); + void updateProgress(); void loadComplete(); void setNeedUpdate(bool flag,quint64 size,quint64 fileCount); void lostConnection(); diff --git a/ui_updatenotifywidget.h b/ui_updatenotifywidget.h index c895655..810bd44 100644 --- a/ui_updatenotifywidget.h +++ b/ui_updatenotifywidget.h @@ -15,7 +15,9 @@ #include #include #include +#include #include +#include #include QT_BEGIN_NAMESPACE @@ -24,6 +26,9 @@ class Ui_UpdateNotifyWidget { public: QGridLayout *gridLayout; + QWidget *DynamicWidget; + QVBoxLayout *verticalLayout; + QProgressBar *LoadingBar; QHBoxLayout *ButtonsLayout; QPushButton *StartLoadButton; QPushButton *CancelButton; @@ -37,20 +42,40 @@ public: UpdateNotifyWidget->resize(726, 429); gridLayout = new QGridLayout(UpdateNotifyWidget); gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + DynamicWidget = new QWidget(UpdateNotifyWidget); + DynamicWidget->setObjectName(QString::fromUtf8("DynamicWidget")); + DynamicWidget->setEnabled(true); + QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(DynamicWidget->sizePolicy().hasHeightForWidth()); + DynamicWidget->setSizePolicy(sizePolicy); + DynamicWidget->setMinimumSize(QSize(0, 40)); + verticalLayout = new QVBoxLayout(DynamicWidget); + verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); + LoadingBar = new QProgressBar(DynamicWidget); + LoadingBar->setObjectName(QString::fromUtf8("LoadingBar")); + LoadingBar->setValue(24); + + verticalLayout->addWidget(LoadingBar); + ButtonsLayout = new QHBoxLayout(); ButtonsLayout->setObjectName(QString::fromUtf8("ButtonsLayout")); - StartLoadButton = new QPushButton(UpdateNotifyWidget); + StartLoadButton = new QPushButton(DynamicWidget); StartLoadButton->setObjectName(QString::fromUtf8("StartLoadButton")); ButtonsLayout->addWidget(StartLoadButton); - CancelButton = new QPushButton(UpdateNotifyWidget); + CancelButton = new QPushButton(DynamicWidget); CancelButton->setObjectName(QString::fromUtf8("CancelButton")); ButtonsLayout->addWidget(CancelButton); - gridLayout->addLayout(ButtonsLayout, 2, 0, 1, 1); + verticalLayout->addLayout(ButtonsLayout); + + + gridLayout->addWidget(DynamicWidget, 3, 0, 1, 1); NotificationLabel = new QLabel(UpdateNotifyWidget); NotificationLabel->setObjectName(QString::fromUtf8("NotificationLabel")); diff --git a/updatenotifywidget.cpp b/updatenotifywidget.cpp index e00d1f9..d0030c5 100644 --- a/updatenotifywidget.cpp +++ b/updatenotifywidget.cpp @@ -9,13 +9,17 @@ UpdateNotifyWidget::UpdateNotifyWidget(QWidget *parent) : { ui->setupUi(this); setWindowFlag(Qt::SubWindow); + setAttribute(Qt::WA_ShowModal,true); } void UpdateNotifyWidget::initialize(MainWindow *mainWindow,UpdateController *updateController) { setWindowTitle("Отправка новых файлов"); + + ui->LoadingBar->hide(); this->mainWindow = mainWindow; this->updateController = updateController; + currentLoadingCount = 0; fillList(); connect(updateController,&UpdateController::sigUpdateComplete,this,&UpdateNotifyWidget::showCompleteDialogBox); @@ -24,18 +28,32 @@ void UpdateNotifyWidget::initialize(MainWindow *mainWindow,UpdateController *upd void UpdateNotifyWidget::setUpdateList(QList *fileDataList) { + int listCount = fileDataList->count(); this->updateList = fileDataList; + + ui->LoadingBar->setRange(0,listCount); +} + +void UpdateNotifyWidget::updateCount() +{ + currentLoadingCount++; + ui->LoadingBar->setValue(currentLoadingCount); } void UpdateNotifyWidget::addToList(FileData fileData) { - ui->updateListWidget->addItem(fileData.path); + QString itemName = fileData.path; + itemName = itemName.remove(streamingAssetsPath); + ui->updateListWidget->addItem(itemName); } void UpdateNotifyWidget::on_StartLoadButton_clicked() { emit sigUpdateFilesOnServer(updateList); + ui->StartLoadButton->setEnabled(false); + ui->CancelButton->setEnabled(false); + ui->LoadingBar->show(); } void UpdateNotifyWidget::on_CancelButton_clicked() @@ -56,7 +74,7 @@ UpdateNotifyWidget::~UpdateNotifyWidget() void UpdateNotifyWidget::showCompleteDialogBox(bool flag) { - QMessageBox *messageBox = new QMessageBox; + QMessageBox *messageBox = new QMessageBox(this); if(flag) { @@ -64,7 +82,6 @@ void UpdateNotifyWidget::showCompleteDialogBox(bool flag) messageBox->setWindowTitle("Информация"); messageBox->addButton(QMessageBox::Ok); messageBox->setText("Загрузка завершена"); - } else { @@ -76,6 +93,5 @@ void UpdateNotifyWidget::showCompleteDialogBox(bool flag) connect(messageBox,&QMessageBox::accepted,this,&UpdateNotifyWidget::hide); connect(messageBox,&QMessageBox::accepted,this,&UpdateNotifyWidget::on_CancelButton_clicked); - messageBox->show(); } diff --git a/updatenotifywidget.h b/updatenotifywidget.h index ba42aff..98e7eb6 100644 --- a/updatenotifywidget.h +++ b/updatenotifywidget.h @@ -23,6 +23,7 @@ public: void initialize(MainWindow *mainWindow, UpdateController *updateController); void addToList(FileData fileData); void setUpdateList(QList *fileDataList); + void updateCount(); ~UpdateNotifyWidget(); signals: @@ -39,6 +40,8 @@ private: UpdateController *updateController; QList *updateList; void fillList(); + + int currentLoadingCount; }; #endif // UPDATENOTIFYWIDGET_H diff --git a/updatenotifywidget.ui b/updatenotifywidget.ui index 76b8071..68ebef3 100644 --- a/updatenotifywidget.ui +++ b/updatenotifywidget.ui @@ -14,23 +14,51 @@ Form - - - - - - Загрузить на сервер - - - - - - - Отмена - - - - + + + + true + + + + 0 + 0 + + + + + 0 + 40 + + + + + + + 24 + + + + + + + + + Загрузить на сервер + + + + + + + Отмена + + + + + + +