This commit is contained in:
zhaominyong 2022-01-19 18:08:43 +08:00
parent 6a4135825b
commit fb0489e359
9 changed files with 35 additions and 11 deletions

View File

@ -266,8 +266,8 @@ int MyBackupManager::ghostBackup(const BackupWrapper& backupWrapper)
switch (result) { switch (result) {
case int(BackupResult::CHECK_ENV_SUCCESS) : case int(BackupResult::CHECK_ENV_SUCCESS) :
case int(BackupResult::MKSQUASHFS_START_SUCCESS) :
case int(BackupResult::GHOST_START_SUCCESS) : case int(BackupResult::GHOST_START_SUCCESS) :
case int(BackupResult::MKSQUASHFS_DO_SUCCESS) :
case int(BackupResult::START_CANCEL) : case int(BackupResult::START_CANCEL) :
break; break;
default: default:

View File

@ -84,7 +84,7 @@ bool UDiskGhostImageProxy::checkEnvEx()
m_destPath = m_backupWrapper.m_prefixDestPath + GHOST_PATH; m_destPath = m_backupWrapper.m_prefixDestPath + GHOST_PATH;
m_destPath.replace("//", "/"); m_destPath.replace("//", "/");
Utils::mkpath(m_destPath); Utils::mkpath(m_destPath);
m_kyimg = Utils::getSysRootPath() + GHOST_PATH + "/" + m_backupWrapper.m_backupName; m_kyimg = m_destPath + "/" + m_backupWrapper.m_backupName;
m_kyimg.replace("//", "/"); m_kyimg.replace("//", "/");
QFile kyimg(m_kyimg); QFile kyimg(m_kyimg);
if (kyimg.exists()) if (kyimg.exists())
@ -103,6 +103,7 @@ bool UDiskGhostImageProxy::checkEnvEx()
QString path = it.key(); QString path = it.key();
qint64 leftSize = it.value(); qint64 leftSize = it.value();
if (itotalSize < leftSize / 2) { if (itotalSize < leftSize / 2) {
Utils::mkpath(path + GHOST_PATH);
m_kyimg = path + GHOST_PATH + "/" + m_backupWrapper.m_backupName; m_kyimg = path + GHOST_PATH + "/" + m_backupWrapper.m_backupName;
m_kyimg.replace("//", "/"); m_kyimg.replace("//", "/");
QFile kyimg(m_kyimg); QFile kyimg(m_kyimg);
@ -190,6 +191,7 @@ void UDiskGhostImageProxy::doGhostImage()
// 同步到U盘 // 同步到U盘
m_p = new RsyncPathToDirProcess(this); m_p = new RsyncPathToDirProcess(this);
connect(m_p, &RsyncPathToDirProcess::progress, this, &UDiskGhostImageProxy::progress);
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool resultRsync) { connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool resultRsync) {
// 如果是取消了操作,则不再发送其它信息 // 如果是取消了操作,则不再发送其它信息
if (m_bCancel) if (m_bCancel)
@ -214,10 +216,13 @@ void UDiskGhostImageProxy::doGhostImage()
}); });
QStringList arguments; QStringList arguments;
arguments << "-a"; arguments << "-av";
arguments << "--info=progress2";
arguments << m_kyimg; arguments << m_kyimg;
arguments << m_destPath + "/"; arguments << m_destPath + "/";
m_p->start(arguments, false); m_p->start(arguments, false);
emit this->checkResult(int(BackupResult::MKSQUASHFS_DO_SUCCESS));
emit this->progress(0);
} else { } else {
m_isFinished = true; m_isFinished = true;
emit this->workResult(false); emit this->workResult(false);
@ -227,6 +232,7 @@ void UDiskGhostImageProxy::doGhostImage()
m_bSuccess = false; m_bSuccess = false;
m_isFinished = false; m_isFinished = false;
m_mksquashfs->start(args); m_mksquashfs->start(args);
emit checkResult(int(BackupResult::GHOST_START_SUCCESS));
QTimer::singleShot(1*1000, this, &UDiskGhostImageProxy::checkDestDirExists); QTimer::singleShot(1*1000, this, &UDiskGhostImageProxy::checkDestDirExists);
} }

View File

@ -267,6 +267,8 @@ enum class BackupResult {
MKSQUASHFS_START_SUCCESS, MKSQUASHFS_START_SUCCESS,
// mksquashfs压缩img文件失败 // mksquashfs压缩img文件失败
MKSQUASHFS_DO_FAIL, MKSQUASHFS_DO_FAIL,
// mksquashfs压缩img文件成功开始转移img文件到u盘
MKSQUASHFS_DO_SUCCESS,
// 开始取消操作 // 开始取消操作
START_CANCEL, START_CANCEL,
// 取消操作成功 // 取消操作成功

View File

@ -1277,7 +1277,7 @@ void DataBackup::initFifthWidget()
progressBar->setPersent(0); progressBar->setPersent(0);
movie->start(); movie->start();
// 不要使用电脑,以防数据丢失 // 不要使用电脑,以防数据丢失
labelTip->setDeplayText(tr("Do not use computers in case of data loss")); labelTip->setDeplayText(tr("Do not use computer in case of data loss"));
cancel->setEnabled(true); cancel->setEnabled(true);
// 开始备份 // 开始备份

View File

@ -399,7 +399,7 @@ void DataRestore::initSecondWidget()
// 检测成功 // 检测成功
bigTitle->setDeplayText(tr("Succeeded to check the environment")); bigTitle->setDeplayText(tr("Succeeded to check the environment"));
// 不要使用电脑,以防数据丢失 // 不要使用电脑,以防数据丢失
labelCheck1->setDeplayText(tr("Do not use computers in case of data loss")); labelCheck1->setDeplayText(tr("Do not use computer in case of data loss"));
dot2->setBackgroundColor(COLOR_YELLOW); dot2->setBackgroundColor(COLOR_YELLOW);
labelCheck2->setFontColor(COLOR_YELLOW); labelCheck2->setFontColor(COLOR_YELLOW);
labelCheck2->setFontWordWrap(true); labelCheck2->setFontWordWrap(true);
@ -596,7 +596,7 @@ void DataRestore::initThirdWidget()
labelTip->setIsOriginal(true); labelTip->setIsOriginal(true);
labelTip->setFontWordWrap(true); labelTip->setFontWordWrap(true);
// 不要使用电脑,以防数据丢失 // 不要使用电脑,以防数据丢失
labelTip->setDeplayText(tr("Do not use computers in case of data loss")); labelTip->setDeplayText(tr("Do not use computer in case of data loss"));
hlayoutCenterFont2->addStretch(); hlayoutCenterFont2->addStretch();
hlayoutCenterFont2->addWidget(labelTip); hlayoutCenterFont2->addWidget(labelTip);
hlayoutCenterFont2->addStretch(); hlayoutCenterFont2->addStretch();

View File

@ -749,7 +749,7 @@ void GhostImage::initForthWidget()
progressBar->setPersent(0); progressBar->setPersent(0);
movie->start(); movie->start();
// 不要使用电脑,以防数据丢失 // 不要使用电脑,以防数据丢失
labelTip->setDeplayText(tr("Do not use computers in case of data loss")); labelTip->setDeplayText(tr("Do not use computer in case of data loss"));
labelTip_1->setVisible(false); labelTip_1->setVisible(false);
labelTip_1->setDeplayText(""); labelTip_1->setDeplayText("");
cancel->setEnabled(true); cancel->setEnabled(true);
@ -758,6 +758,11 @@ void GhostImage::initForthWidget()
this->on_ghost_start(); this->on_ghost_start();
}); });
connect(this, &GhostImage::backupWarnning, labelTip_1, [=](const QString& msg) {
labelTip_1->setVisible(true);
labelTip_1->setDeplayText(msg);
});
// 进度 // 进度
connect(this, &GhostImage::progress, this, [=](int state, int rate) { connect(this, &GhostImage::progress, this, [=](int state, int rate) {
Q_UNUSED(state) Q_UNUSED(state)
@ -875,6 +880,16 @@ void GhostImage::on_checkGhost_end(int result)
// 请检查刚刚是否有删除备份点操作 // 请检查刚刚是否有删除备份点操作
errTip = tr("Check whether the backup point has been deleted"); errTip = tr("Check whether the backup point has been deleted");
break; break;
case int(BackupResult::GHOST_START_SUCCESS):
// 正压缩数据到本地磁盘,请耐心等待...
errTip = tr("The data is being compressed to the local disk, please wait patiently...");
emit this->backupWarnning(errTip);
return;
case int(BackupResult::MKSQUASHFS_DO_SUCCESS):
// 正在传输image文件到移动设备即将完成...
errTip = tr("Transferring image file to mobile device, about to be completed...");
emit this->backupWarnning(errTip);
return;
case int(BackupResult::CANCEL_SUCCESS): case int(BackupResult::CANCEL_SUCCESS):
// 已经取消本次镜像制作 // 已经取消本次镜像制作
errMsg = tr("The image creation had been canceled"); errMsg = tr("The image creation had been canceled");

View File

@ -44,6 +44,7 @@ signals:
void startGhost(); void startGhost();
void progress(int state, int rate); void progress(int state, int rate);
void checkGhostResult(bool result, const QString &errMsg = "", const QString &errTip = ""); void checkGhostResult(bool result, const QString &errMsg = "", const QString &errTip = "");
void backupWarnning(const QString &warnning);
public slots: public slots:
void on_pre_clicked(bool checked = false); void on_pre_clicked(bool checked = false);

View File

@ -879,7 +879,7 @@ void SystemBackup::initFifthWidget()
progressBar->setPersent(0); progressBar->setPersent(0);
movie->start(); movie->start();
// 不要使用电脑,以防数据丢失 // 不要使用电脑,以防数据丢失
labelTip->setDeplayText(tr("Do not use computers in case of data loss")); labelTip->setDeplayText(tr("Do not use computer in case of data loss"));
labelTip_1->setVisible(false); labelTip_1->setVisible(false);
labelTip_1->setDeplayText(""); labelTip_1->setDeplayText("");
cancel->setEnabled(true); cancel->setEnabled(true);
@ -998,8 +998,8 @@ void SystemBackup::on_checkBackup_end(int result)
emit this->backupWarnning(errTip); emit this->backupWarnning(errTip);
return; return;
case int(BackupResult::BACKUP_START_SUCCESS): case int(BackupResult::BACKUP_START_SUCCESS):
// 正在传输备份文件到移动设备,即将完成... // 正在传输image文件到移动设备,即将完成...
errTip = tr("Transferring backup files to mobile device, about to be completed..."); errTip = tr("Transferring image file to mobile device, about to be completed...");
emit this->backupWarnning(errTip); emit this->backupWarnning(errTip);
return; return;
case int(BackupResult::CANCEL_SUCCESS): case int(BackupResult::CANCEL_SUCCESS):

View File

@ -622,7 +622,7 @@ void SystemRestore::initThirdWidget()
labelTip->setIsOriginal(true); labelTip->setIsOriginal(true);
labelTip->setFontWordWrap(true); labelTip->setFontWordWrap(true);
// 不要使用电脑,以防数据丢失 // 不要使用电脑,以防数据丢失
labelTip->setDeplayText(tr("Do not use computers in case of data loss")); labelTip->setDeplayText(tr("Do not use computer in case of data loss"));
hlayoutCenterFont2->addStretch(); hlayoutCenterFont2->addStretch();
hlayoutCenterFont2->addWidget(labelTip); hlayoutCenterFont2->addWidget(labelTip);
hlayoutCenterFont2->addStretch(); hlayoutCenterFont2->addStretch();