#include "updatenotifywidget.h" #include "ui_updatenotifywidget.h" #include "mainwindow.h" #include UpdateNotifyWidget::UpdateNotifyWidget(QWidget *) : ui(new Ui::UpdateNotifyWidget) { ui->setupUi(this); // setWindowFlag(Qt::FramelessWindowHint); // setAttribute(Qt::WA_ShowModal,true); } void UpdateNotifyWidget::initialize(MainWindow *mainWindow,VersionContainer *verContainer) { this->mainWindow = mainWindow; this->versionContainer = verContainer; currentLoadingCount = 0; hide(); auto pos = mainWindow->pos(); pos.setY(pos.y() + 40); move(pos); } void UpdateNotifyWidget::addToList(FileData fileData) { QString itemName = fileData.path; itemName = itemName.remove(streamingAssetsPath); ui->updateListWidget->addItem(itemName); } void UpdateNotifyWidget::showTryChangeBase() { QString path = QDir::currentPath() + streamingAssetsPath; QString link = "папку"; ui->labelsLayout->addWidget(createLabel(tr("Данные изменения нельзя выгрузить на сервер, так как версия сервера не изменяема \n"))); ui->labelsLayout->addWidget(createLabel(tr("Чтобы выгрузить на сервер нужно:"))); ui->labelsLayout->addWidget(createLabel(tr("1. Скопировать измененные или созданные файлы в временную папку"))); QLabel *labelStorage = new QLabel; QString link2 = "тут"; labelStorage->setText(tr("Файлы можно найти в ") + link2 ); labelStorage->setOpenExternalLinks(true); ui->labelsLayout->addWidget(labelStorage); ui->labelsLayout->addWidget(createLabel(tr("2. Нажать Отменить изменения и дождатся окончания операции"))); ui->labelsLayout->addWidget(createLabel(tr("3. Изменить версию сервера на изменяемую"))); ui->labelsLayout->addWidget(createLabel(tr("4. Нажать обновить"))); //СОЗДАНИЕ QLabel *linkLabel = new QLabel; linkLabel->setText(tr("5. Скопировать файлы из временной папки в эту ") + link); linkLabel->setOpenExternalLinks(true); ui->labelsLayout->addWidget(linkLabel); ui->labelsLayout->addWidget(createLabel(tr("6.Перезапустить клиент и выгрузить изменения на сервер"))); setCantUpdateState(); } void UpdateNotifyWidget::showWithFill() { clearList(); if(!versionContainer->getLocalVersionData()->getIsChangeable()) { showTryChangeBase(); } else if(!versionContainer->getServerVersionData()->getIsChangeable()) { showTryChangeBase(); } else { ui->labelsLayout->addWidget(createLabel(tr("Возможные действия:"))); ui->labelsLayout->addWidget(createLabel(tr(" 1. Выгрузить изменения на сервер"))); ui->labelsLayout->addWidget(createLabel(tr(" 2. Отменить изменения с загрузкой версии с сервера"))); ui->labelsLayout->addWidget(createLabel(tr(" 3. Запустить без отправки файлов, но с текущими изменениями"))); setUpdateState(); } show(); } void UpdateNotifyWidget::clearList() { QLayoutItem* item; while ( ( item = ui->labelsLayout->layout()->takeAt( 0 ) ) != NULL ) { delete item->widget(); delete item; } } QLabel* UpdateNotifyWidget::createLabel(QString text) { QLabel *label = new QLabel; label->setText(text); return label; } void UpdateNotifyWidget::on_loadToServerButton_clicked() { mainWindow->loadToServer(); } void UpdateNotifyWidget::on_undoChangesButton_clicked() { mainWindow->undoCurrentChanges(); } void UpdateNotifyWidget::on_startWithCurrentChangesButton_clicked() { mainWindow->startUnityClient(); } void UpdateNotifyWidget::setUpdateState() { ui->undoChangesButton->show(); ui->loadToServerButton->show(); ui->startWithCurrentChangesButton->show(); } void UpdateNotifyWidget::setCantUpdateState() { ui->undoChangesButton->show(); ui->loadToServerButton->hide(); ui->startWithCurrentChangesButton->hide(); } UpdateNotifyWidget::~UpdateNotifyWidget() { delete ui; } void UpdateNotifyWidget::on_closeButton_clicked() { mainWindow->showMainFrame(true); close(); } void UpdateNotifyWidget::on_updateActionListLabel_linkActivated(const QString &link) { }