Files
RRJClient/Widgets/updatenotifywidget.cpp
2025-12-12 11:34:02 +03:00

152 lines
4.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "updatenotifywidget.h"
#include "ui_updatenotifywidget.h"
#include "Core/tools.h"
#include <QMessageBox>
#include <QTextDocumentFragment>
UpdateNotifyWidget::UpdateNotifyWidget(QWidget *) :
ui(new Ui::UpdateNotifyWidget)
{
ui->setupUi(this);
// setWindowFlag(Qt::FramelessWindowHint);
// setAttribute(Qt::WA_ShowModal,true);
}
void UpdateNotifyWidget::initialize(QPoint startPos)
{
currentLoadingCount = 0;
hide();
QPoint pos = startPos;
pos.setY(pos.y() + 40);
move(pos);
}
void UpdateNotifyWidget::setVersionContainer(VersionContainer *versionContainer)
{
this->versionContainer = versionContainer;
}
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 = "<a href=\""+ path + "\"style=\"color:lightblue; text-decoration: underline;\">папку</a>";
ui->labelsLayout->addWidget(createLabel(tr("Данные изменения нельзя выгрузить на сервер, так как версия сервера не изменяема \n")));
ui->labelsLayout->addWidget(createLabel(tr("Чтобы выгрузить на сервер нужно:")));
ui->labelsLayout->addWidget(createLabel(tr("1. Скопировать измененные или созданные файлы в временную папку")));
QLabel *labelStorage = new QLabel;
QString link2 = "<a href=\""+ path + "\"style=\"color:lightblue; text-decoration: underline;\">тут</a>";
labelStorage->setText(tr("Файлы можно найти в ") + link2);
labelStorage->setTextFormat(Qt::RichText);
labelStorage->setTextInteractionFlags(Qt::TextBrowserInteraction);
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);
linkLabel->setTextFormat(Qt::RichText);
linkLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->labelsLayout->addWidget(linkLabel);
ui->labelsLayout->addWidget(createLabel(tr("6.Перезапустить клиент и выгрузить изменения на сервер")));
setCantUpdateState();
}
void UpdateNotifyWidget::showWithFill()
{
clearList();
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()
{
emit sigLoadToServerBehaviour();
}
void UpdateNotifyWidget::on_undoChangesButton_clicked()
{
emit sigUndoCurrentChanges();
}
void UpdateNotifyWidget::on_startWithCurrentChangesButton_clicked()
{
emit sigStartUnityClient();
}
void UpdateNotifyWidget::closeWindow()
{
on_closeButton_clicked();
}
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()
{
emit sigShowMainFrame(true);
close();
}