mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
103 lines
2.7 KiB
C++
103 lines
2.7 KiB
C++
#include "updatenotifywidget.h"
|
|
#include "ui_updatenotifywidget.h"
|
|
#include "mainwindow.h"
|
|
|
|
#include <QMessageBox>
|
|
|
|
UpdateNotifyWidget::UpdateNotifyWidget(QWidget *parent) :
|
|
ui(new Ui::UpdateNotifyWidget)
|
|
{
|
|
ui->setupUi(this);
|
|
setWindowFlag(Qt::SubWindow);
|
|
setAttribute(Qt::WA_ShowModal,true);
|
|
}
|
|
|
|
void UpdateNotifyWidget::initialize(MainWindow *mainWindow,UpdateController *updateController)
|
|
{
|
|
setWindowTitle(tr("Отправка новых файлов"));
|
|
|
|
//ui->LoadingBar->hide();
|
|
this->mainWindow = mainWindow;
|
|
this->updateController = updateController;
|
|
currentLoadingCount = 0;
|
|
fillList();
|
|
|
|
connect(updateController,&UpdateController::sigUpdateComplete,this,&UpdateNotifyWidget::showCompleteDialogBox);
|
|
connect(this,&UpdateNotifyWidget::sigUpdateFilesOnServer,updateController,&UpdateController::updateFilesOnServer);
|
|
}
|
|
|
|
void UpdateNotifyWidget::setUpdateList(QList<FileData> *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)
|
|
{
|
|
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()
|
|
{
|
|
mainWindow->checkUpdate();
|
|
|
|
}
|
|
|
|
void UpdateNotifyWidget::fillList()
|
|
{
|
|
|
|
}
|
|
|
|
UpdateNotifyWidget::~UpdateNotifyWidget()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void UpdateNotifyWidget::showCompleteDialogBox(bool flag)
|
|
{
|
|
QMessageBox *messageBox = new QMessageBox(this);
|
|
|
|
if(flag)
|
|
{
|
|
messageBox->setIcon(QMessageBox::Information);
|
|
messageBox->setWindowTitle(tr("Информация"));
|
|
messageBox->addButton(QMessageBox::Ok);
|
|
messageBox->setText(tr("Загрузка завершена"));
|
|
}
|
|
else
|
|
{
|
|
messageBox->setIcon(QMessageBox::Warning);
|
|
messageBox->setWindowTitle(tr("Ошибка"));
|
|
messageBox->addButton(QMessageBox::Ok);
|
|
messageBox->setText(tr("Произошла ошибка при загрузке"));
|
|
}
|
|
|
|
connect(messageBox,&QMessageBox::accepted,this,&UpdateNotifyWidget::hide);
|
|
connect(messageBox,&QMessageBox::accepted,this,&UpdateNotifyWidget::on_CancelButton_clicked);
|
|
messageBox->show();
|
|
}
|
|
|
|
void UpdateNotifyWidget::on_closeButton_clicked()
|
|
{
|
|
close();
|
|
}
|