阶段提交

This commit is contained in:
zhaominyong 2021-12-01 15:12:38 +08:00
parent bde4ab5735
commit 7ec8ecdf4f
100 changed files with 571 additions and 67 deletions

0
README.md Normal file → Executable file
View File

0
backup-daemon/myprocess/mksquashfsprocess.cpp Normal file → Executable file
View File

0
backup-daemon/myprocess/mksquashfsprocess.h Normal file → Executable file
View File

0
backup-daemon/mythread.cpp Normal file → Executable file
View File

0
backup-daemon/mythread.h Normal file → Executable file
View File

16
backup-daemon/udisksystembackupproxy.cpp Normal file → Executable file
View File

@ -53,6 +53,22 @@ bool UDiskSystemBackupProxy::checkEnvEx()
return false;
}
QString backupPath(m_backupWrapper.m_prefixDestPath);
backupPath.replace("//", "/");
QStorageInfo udisk(backupPath);
QString udisk_type = udisk.fileSystemType();
if (udisk_type == "vfat") {
qCritical() << m_backupWrapper.m_prefixDestPath + " udisk's filesystemtype is vfat";
emit checkResult(int(BackupResult::UDISK_FILESYSTEM_TYPE_IS_VFAT));
return false;
}
if (udisk.isReadOnly()) {
// 只读挂载的U盘
qCritical() << QString("udisk(%s) is readonly filesystem").arg(m_backupWrapper.m_prefixDestPath);
emit checkResult(int(BackupResult::UDISK_FILESYSTEM_IS_READONLY));
return false;
}
QTimer::singleShot(1*1000, this, &UDiskSystemBackupProxy::checkDestDirExists);
// 2、计算备份大小
calcSizeForBackup();

0
backup-daemon/udisksystembackupproxy.h Normal file → Executable file
View File

2
kybackup/app.qrc Normal file → Executable file
View File

@ -30,5 +30,7 @@
<file alias="/symbos/ukui-bf-system-restore-symbolic.png">resource/symbos/ukui-bf-system-restore-symbolic.png</file>
<file alias="/symbos/ukui-bf-volume-symbolic.png">resource/symbos/ukui-bf-volume-symbolic.png</file>
<file alias="/symbos/ukui-dialog-success.png">resource/symbos/ukui-dialog-success.png</file>
<file alias="/images/empty.png">resource/images/empty.png</file>
<file alias="/images/empty_dark.png">resource/images/empty_dark.png</file>
</qresource>
</RCC>

0
kybackup/backup_manager_interface.cpp Normal file → Executable file
View File

0
kybackup/backup_manager_interface.h Normal file → Executable file
View File

View File

@ -0,0 +1,100 @@
#include "backuppointlistdialog.h"
#include "ui_backuppointlistdialog.h"
#include <QHeaderView>
#include "component/mylabel.h"
#include "component/mypushbutton.h"
BackupPointListDialog::BackupPointListDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::BackupPointListDialog)
{
ui->setupUi(this);
// 到各个子类中去设置
// this->setWindowTitle(tr("Backup Points"));
// 去掉最大化、最小化按钮,保留关闭按钮,但是设置后窗口不显示了,实验了几种方式均不可以
// this->setWindowFlags(Qt::WindowCloseButtonHint);
// this->setWindowFlags(this->windowFlags() & ~Qt::WindowMinMaxButtonsHint);
// 设置背景色
this->setAutoFillBackground(true);
QPalette palette = this->palette();
palette.setColor(QPalette::Background, palette.color(QPalette::Base));
this->setPalette(palette);
// 纵向布局
QVBoxLayout *vlayout = new QVBoxLayout;
vlayout->setContentsMargins(20, 0, 20, 10);
QStringList headerList;
headerList << tr("Backup Name") << tr("UUID") << tr("Backup Time") << tr("Backup Device") << QObject::tr("Backup State") << QObject::tr("PrefixPath");
m_tableWidget = new QTableWidget;
m_tableWidget->setColumnCount(headerList.size());
m_tableWidget->setHorizontalHeaderLabels(headerList);
m_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
m_tableWidget->setShowGrid(false);
m_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
// m_tableWidget->resizeColumnsToContents();
m_tableWidget->hideColumn(5);
vlayout->addWidget(m_tableWidget);
MyLabel *note = new MyLabel;
// 您可以删除不需要的备份,更多细节请参考“操作日志”
note->setDeplayText(tr("You can delete backup point"));
MyPushButton * buttonDelete = new MyPushButton;
buttonDelete->setText(tr("Delete"));
m_bottomLayout = new QHBoxLayout;
m_bottomLayout->addWidget(note);
m_bottomLayout->addStretch();
m_bottomLayout->addWidget(buttonDelete);
vlayout->addLayout(m_bottomLayout);
this->setLayout(vlayout);
}
BackupPointListDialog::~BackupPointListDialog()
{
delete ui;
delete m_tableWidget;
}
/**
* @brief
* @return
*/
QList<ParseBackupList::backupPoint> BackupPointListDialog::getBackupPointList(const QStringList& pathList)
{
QList<parseBackupList::backupPoint> list;
for (QString backupPath : pathList) {
backupPath += BACKUP_XML_PATH;
QFile xmlFile(backupPath);
if (!xmlFile.exists() || 0 == xmlFile.size()) {
continue;
}
parseBackupList parse(backupPath);
list.append(parse.getBackupPointList());
}
return list;
}
void BackupPointListDialog::updateTargetList()
{
m_hasUsefulBackup = false; //是否存在有效备份
m_hasOneBackup = false; //是否存在一个备份(包括有效和失败的备份)
m_tableWidget->clear();
QStringList allPaths;
allPaths << ""; //"" is /
// if (!m_onlyshowlocal) {
// QStringList udiskPaths = m_proxy->getAllUdiskPaths();
// for (auto& path : udiskPaths) {
// allPaths << path;
// }
// }
// // readEveryPathBackupStorage(allPaths);
// insertLines(getBackupPointList(allPaths));
}

View File

@ -0,0 +1,33 @@
#ifndef BackupPointListDialog_H
#define BackupPointListDialog_H
#include <QDialog>
#include <QTableWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
namespace Ui {
class BackupPointListDialog;
}
class BackupPointListDialog : public QDialog
{
Q_OBJECT
public:
explicit BackupPointListDialog(QWidget *parent = nullptr);
~BackupPointListDialog();
void updateTargetList();
protected:
QHBoxLayout *m_bottomLayout = nullptr;
private:
Ui::BackupPointListDialog *ui;
QTableWidget * m_tableWidget;
bool m_hasUsefulBackup = false; //是否存在有效备份
bool m_hasOneBackup = false; //是否存在一个备份(包括有效和失败的备份)
};
#endif // BackupPointListDialog_H

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BackupPointListDialog</class>
<widget class="QDialog" name="BackupPointListDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>686</width>
<height>371</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
</widget>
<resources/>
<connections/>
</ui>

0
kybackup/component/circlelabel.cpp Normal file → Executable file
View File

0
kybackup/component/circlelabel.h Normal file → Executable file
View File

0
kybackup/component/clicklabel.cpp Normal file → Executable file
View File

0
kybackup/component/clicklabel.h Normal file → Executable file
View File

0
kybackup/component/hoverwidget.cpp Normal file → Executable file
View File

0
kybackup/component/hoverwidget.h Normal file → Executable file
View File

0
kybackup/component/imageutil.cpp Normal file → Executable file
View File

0
kybackup/component/imageutil.h Normal file → Executable file
View File

0
kybackup/component/linelabel.cpp Normal file → Executable file
View File

0
kybackup/component/linelabel.h Normal file → Executable file
View File

View File

@ -0,0 +1,18 @@
#include "mycheckbox.h"
MyCheckBox::MyCheckBox(const QString &text, QWidget *parent) :
QCheckBox(text, parent)
{}
MyCheckBox::~MyCheckBox()
{}
void MyCheckBox::setFontSize(int size)
{
QFont font = this->font();
font.setPixelSize(size);
// 默认为大字体粗体显示
if (size > 20)
font.setBold(true);
this->setFont(font);
}

16
kybackup/component/mycheckbox.h Executable file
View File

@ -0,0 +1,16 @@
#ifndef MYCHECKBOX_H
#define MYCHECKBOX_H
#include <QCheckBox>
class MyCheckBox : public QCheckBox
{
Q_OBJECT
public:
explicit MyCheckBox(const QString &text, QWidget *parent = nullptr);
virtual ~MyCheckBox();
void setFontSize(int size);
};
#endif // MYCHECKBOX_H

0
kybackup/component/myiconbutton.cpp Normal file → Executable file
View File

0
kybackup/component/myiconbutton.h Normal file → Executable file
View File

0
kybackup/component/myiconlabel.cpp Normal file → Executable file
View File

0
kybackup/component/myiconlabel.h Normal file → Executable file
View File

6
kybackup/component/mylabel.cpp Normal file → Executable file
View File

@ -21,7 +21,6 @@ MyLabel::MyLabel(QWidget* parent) :
{
}
MyLabel::~MyLabel()
{}
@ -55,6 +54,11 @@ void MyLabel::setFontWordWrap(bool on)
void MyLabel::paintEvent(QPaintEvent *event)
{
if (m_isOriginal) {
QLabel::paintEvent(event);
return ;
}
QFontMetrics fontMetrics(this->font());
int fontSize = fontMetrics.width(m_text);
if (m_bWordWrap && m_width > 0) {

2
kybackup/component/mylabel.h Normal file → Executable file
View File

@ -16,6 +16,7 @@ public:
void setFontColor(QColor color);
void setFontSize(int size);
void setFontWordWrap(bool on);
void setIsOriginal(bool isOriginal) { m_isOriginal = isOriginal; }
protected:
void paintEvent(QPaintEvent *event);
@ -25,6 +26,7 @@ private:
bool m_bWordWrap = false;
int m_width = 0;
int m_height = 0;
bool m_isOriginal = false;
QRect m_rect;
};

0
kybackup/component/mylineedit.cpp Normal file → Executable file
View File

0
kybackup/component/mylineedit.h Normal file → Executable file
View File

11
kybackup/component/mypushbutton.cpp Normal file → Executable file
View File

@ -6,3 +6,14 @@ MyPushButton::MyPushButton(QWidget *parent) :
MyPushButton::~MyPushButton()
{}
void MyPushButton::setFontSize(int size)
{
QFont font = this->font();
font.setPixelSize(size);
// 默认为大字体粗体显示
if (size > 20)
font.setBold(true);
this->setFont(font);
}

2
kybackup/component/mypushbutton.h Normal file → Executable file
View File

@ -9,6 +9,8 @@ class MyPushButton : public QPushButton
public:
MyPushButton(QWidget* parent = nullptr);
virtual ~MyPushButton();
void setFontSize(int size);
};
#endif // MYPUSHBUTTON_H

0
kybackup/component/ringsprogressbar.cpp Normal file → Executable file
View File

0
kybackup/component/ringsprogressbar.h Normal file → Executable file
View File

0
kybackup/functypeconverter.cpp Normal file → Executable file
View File

0
kybackup/functypeconverter.h Normal file → Executable file
View File

0
kybackup/globalbackupinfo.h Normal file → Executable file
View File

0
kybackup/globalsignals.h Normal file → Executable file
View File

0
kybackup/gsettingswrapper.cpp Normal file → Executable file
View File

0
kybackup/gsettingswrapper.h Normal file → Executable file
View File

7
kybackup/kybackup.pro Normal file → Executable file
View File

@ -36,11 +36,13 @@ HEADERS += \
../common/spinlock_mutex.h \
../common/utils.h \
backup_manager_interface.h \
backuppointlistdialog.h \
component/circlelabel.h \
component/clicklabel.h \
component/hoverwidget.h \
component/imageutil.h \
component/linelabel.h \
component/mycheckbox.h \
component/myiconbutton.h \
component/myiconlabel.h \
component/mylabel.h \
@ -53,6 +55,7 @@ HEADERS += \
gsettingswrapper.h \
leftsiderbarwidget.h \
maindialog.h \
messageboxutils.h \
module/systembackup.h \
module/systemrestore.h \
module/udiskdetector.h \
@ -67,11 +70,13 @@ SOURCES += \
../common/mylittleparse.cpp \
../common/utils.cpp \
backup_manager_interface.cpp \
backuppointlistdialog.cpp \
component/circlelabel.cpp \
component/clicklabel.cpp \
component/hoverwidget.cpp \
component/imageutil.cpp \
component/linelabel.cpp \
component/mycheckbox.cpp \
component/myiconbutton.cpp \
component/myiconlabel.cpp \
component/mylabel.cpp \
@ -83,6 +88,7 @@ SOURCES += \
leftsiderbarwidget.cpp \
main.cpp \
maindialog.cpp \
messageboxutils.cpp \
module/systembackup.cpp \
module/systemrestore.cpp \
module/udiskdetector.cpp \
@ -93,6 +99,7 @@ SOURCES += \
xatom-helper.cpp
FORMS += \
backuppointlistdialog.ui \
maindialog.ui
TRANSLATIONS += qt_zh_CN.ts

0
kybackup/leftsiderbarwidget.cpp Normal file → Executable file
View File

0
kybackup/leftsiderbarwidget.h Normal file → Executable file
View File

0
kybackup/main.cpp Normal file → Executable file
View File

6
kybackup/maindialog.cpp Normal file → Executable file
View File

@ -91,11 +91,11 @@ void MainDialog::initTileBar()
QMenu* selectTheme = new QMenu(this);
selectTheme->setObjectName("selectTheme");
backupTheme->setMenu(selectTheme);
QAction* defaultTheme = new QAction(tr("DefaultTheme"),this);
QAction* defaultTheme = new QAction(tr("Auto"),this);
selectTheme->addAction(defaultTheme);
QAction* darkTheme = new QAction(tr("DarkTheme"),this);
QAction* darkTheme = new QAction(tr("Dark"),this);
selectTheme->addAction(darkTheme);
QAction* lightTheme = new QAction(tr("LightTheme"),this);
QAction* lightTheme = new QAction(tr("Light"),this);
selectTheme->addAction(lightTheme);
m_backupHelp = new QAction(tr("Help"),this);

0
kybackup/maindialog.h Normal file → Executable file
View File

0
kybackup/maindialog.ui Normal file → Executable file
View File

57
kybackup/messageboxutils.cpp Executable file
View File

@ -0,0 +1,57 @@
#include "messageboxutils.h"
#include "gsettingswrapper.h"
#include <QMessageBox>
#include <QIcon>
void MessageBoxUtils::QMESSAGE_BOX_WARNING(QWidget* q_parent, const QString& typelabel, const QString& message, const QString& label)
{
QMessageBox box(q_parent);
box.setIcon(QMessageBox::Warning);
box.setWindowTitle(typelabel);
box.setText(message);
box.setStandardButtons(QMessageBox::Ok);
box.setButtonText(QMessageBox::Ok, label);
//add title icon
QIcon titleIcon = QIcon::fromTheme("yhkylin-backup-tools");
box.setWindowIcon(titleIcon);
GSettingsWrapper::connectUkuiStyleSchema(&box);
box.exec();
}
bool MessageBoxUtils::QMESSAGE_BOX_WARNING_CANCEL(QWidget *q_parent, const QString &typelabel, const QString &message, const QString &label_yes, const QString &label_no)
{
QMessageBox box(q_parent);
box.setIcon(QMessageBox::Warning);
box.setWindowTitle(typelabel);
box.setText(message);
box.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
box.setButtonText(QMessageBox::Ok, label_yes);
box.setButtonText(QMessageBox::Cancel, label_no);
//add title icon
QIcon titleIcon = QIcon::fromTheme("yhkylin-backup-tools");
box.setWindowIcon(titleIcon);
GSettingsWrapper::connectUkuiStyleSchema(&box);
if (box.exec() != QMessageBox::Ok)
return false;
return true;
}
void MessageBoxUtils::QMESSAGE_BOX_CRITICAL(QWidget* q_parent, const QString& typelabel, const QString& message, const QString& label)
{
QMessageBox box(q_parent);
box.setIcon(QMessageBox::Critical);
box.setWindowTitle(typelabel);
box.setText(message);
box.setStandardButtons(QMessageBox::Ok);
box.setButtonText(QMessageBox::Ok, label);
//add title icon
QIcon titleIcon = QIcon::fromTheme("yhkylin-backup-tools");
box.setWindowIcon(titleIcon);
GSettingsWrapper::connectUkuiStyleSchema(&box);
box.exec();
}

16
kybackup/messageboxutils.h Executable file
View File

@ -0,0 +1,16 @@
#ifndef MESSAGEBOXUTILS_H
#define MESSAGEBOXUTILS_H
#include <QWidget>
#include <QString>
class MessageBoxUtils
{
public:
static void QMESSAGE_BOX_WARNING(QWidget* q_parent, const QString& typelabel, const QString& message, const QString& label);
static void QMESSAGE_BOX_CRITICAL(QWidget* q_parent, const QString& typelabel, const QString& message, const QString& label);
static bool QMESSAGE_BOX_WARNING_CANCEL(QWidget* q_parent, const QString& typelabel, const QString& message,
const QString& label_yes, const QString& label_no);
};
#endif // MESSAGEBOXUTILS_H

245
kybackup/module/systembackup.cpp Normal file → Executable file
View File

@ -3,6 +3,8 @@
#include <QPushButton>
#include <QComboBox>
#include <QMovie>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <unistd.h>
#include "../component/clicklabel.h"
@ -20,7 +22,8 @@ SystemBackup::SystemBackup(QWidget *parent /*= nullptr*/) :
QStackedWidget(parent),
m_udector(new UdiskDetector()),
m_isLocal(true),
m_systemBackupState(SystemBackupState::IDEL)
m_systemBackupState(SystemBackupState::IDEL),
m_pInterface(nullptr)
{
// 界面手写代码创建,作为练手
initFirstWidget();
@ -34,6 +37,10 @@ SystemBackup::SystemBackup(QWidget *parent /*= nullptr*/) :
SystemBackup::~SystemBackup()
{
delete m_udector;
m_udector = nullptr;
delete m_pInterface;
m_pInterface = nullptr;
}
/**
@ -117,13 +124,23 @@ void SystemBackup::initFirstWidget()
beginBackup->setFont(font);
connect(beginBackup, &MyPushButton::clicked, this, &SystemBackup::on_next_clicked);
// 底部控件布局
QVBoxLayout *bottomVBoxLayout = new QVBoxLayout(first);
bottomVBoxLayout->addStretch();
QHBoxLayout *bottomHBoxLayout = new QHBoxLayout(first);
bottomVBoxLayout->addLayout(bottomHBoxLayout);
bottomVBoxLayout->addSpacing(20);
bottomHBoxLayout->addStretch();
// 备份管理
ClickLabel * backupPointManage = new ClickLabel(tr("Backup Management >>"), first);
backupPointManage->setGeometry(551, 551, 200, 30);
QPalette pal(backupPointManage->palette());
pal.setColor(QPalette::WindowText, QColor(Qt::blue));
backupPointManage->setPalette(pal);
backupPointManage->setToolTip(tr("Backup Management >>"));
bottomHBoxLayout->addWidget(backupPointManage);
bottomHBoxLayout->addSpacing(20);
connect(backupPointManage, &ClickLabel::clicked, this, &SystemBackup::on_systemBackupManage_clicked);
addWidget(first);
@ -267,54 +284,98 @@ void SystemBackup::initThirdWidget()
MyLabel *label4 = new MyLabel(tr("finished"), third);
label4->setGeometry(551, 72, 164, 30);
//------------ 中部布局begin-------------
QVBoxLayout *vlayout = new QVBoxLayout(third);
vlayout->addSpacing(180);
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addStretch();
QWidget *centerFont = new QWidget(third);
QVBoxLayout *vlayoutCenterFont = new QVBoxLayout;
// 第一行
QHBoxLayout *hlayoutCenterFont1 = new QHBoxLayout;
// 检测等待图标
QLabel *loadingGif = new QLabel(third);
QLabel *loadingGif = new QLabel(centerFont);
loadingGif->setFixedSize(20,20);
// 环境检测等待动画
QMovie *movie = new QMovie(":/images/loading.gif", QByteArray(), third);
QMovie *movie = new QMovie(":/images/loading.gif", QByteArray(), centerFont);
loadingGif->setMovie(movie);
loadingGif->setGeometry(180, 180, 20, 20);
hlayoutCenterFont1->addWidget(loadingGif);
// 检测结果对错图标
QLabel *resultLogo = new QLabel(third);
resultLogo->setGeometry(180, 180, 20, 20);
QLabel *resultLogo = new QLabel(centerFont);
resultLogo->setFixedSize(20,20);
hlayoutCenterFont1->addWidget(resultLogo);
// 检测中大标题
MyLabel *bigTitle = new MyLabel(third);
MyLabel *bigTitle = new MyLabel(centerFont);
bigTitle->setFontSize(24);
bigTitle->setGeometry(210, 170, 500, 36);
bigTitle->setMaximumWidth(700);
hlayoutCenterFont1->addWidget(bigTitle);
hlayoutCenterFont1->addStretch();
vlayoutCenterFont->addLayout(hlayoutCenterFont1);
// 检测中的记录:黑点和文字
CircleLable *dot1 = new CircleLable(QString(""), third, 6, Qt::black);
dot1->setGeometry(190, 235, 6, 6);
MyLabel *labelCheck1 = new MyLabel(third);
labelCheck1->setGeometry(210, 220, 500, 30);
// 第二行
QHBoxLayout *hlayoutCenterFont2 = new QHBoxLayout;
hlayoutCenterFont2->addSpacing(10);
// 检测中的记录黑点1和文字1
CircleLable *dot1 = new CircleLable(QString(""), centerFont, 6, Qt::black);
hlayoutCenterFont2->addWidget(dot1);
hlayoutCenterFont2->addSpacing(5);
MyLabel *labelCheck1 = new MyLabel(centerFont);
labelCheck1->setMinimumWidth(400);
labelCheck1->setMaximumWidth(600);
labelCheck1->setIsOriginal(true);
labelCheck1->setWordWrap(true);
labelCheck1->adjustSize();
hlayoutCenterFont2->addWidget(labelCheck1);
hlayoutCenterFont2->addStretch();
vlayoutCenterFont->addLayout(hlayoutCenterFont2);
CircleLable *dot2 = new CircleLable(QString(""), third, 6, Qt::black);
dot2->setGeometry(190, 265, 6, 6);
MyLabel *labelCheck2 = new MyLabel(third);
labelCheck2->setGeometry(210, 250, 450, 30);
// 第三行
QHBoxLayout *hlayoutCenterFont3 = new QHBoxLayout;
hlayoutCenterFont3->addSpacing(10);
// 检测中的记录黑点2和文字2
CircleLable *dot2 = new CircleLable(QString(""), centerFont, 6, Qt::black);
hlayoutCenterFont3->addWidget(dot2);
hlayoutCenterFont3->addSpacing(5);
MyLabel *labelCheck2 = new MyLabel(centerFont);
labelCheck2->setMinimumWidth(400);
labelCheck2->setMaximumWidth(600);
labelCheck2->setIsOriginal(true);
labelCheck2->setWordWrap(true);
labelCheck2->adjustSize();
hlayoutCenterFont3->addWidget(labelCheck2);
hlayoutCenterFont3->addStretch();
vlayoutCenterFont->addLayout(hlayoutCenterFont3);
// 第四行
vlayoutCenterFont->addSpacing(30);
// 第五行
QHBoxLayout *hlayoutCenterFont5 = new QHBoxLayout;
hlayoutCenterFont5->addStretch();
// 上一步按钮
MyPushButton *preStep = new MyPushButton(third);
preStep->setGeometry(221, 330, 97, 36);
MyPushButton *preStep = new MyPushButton(centerFont);
preStep->setFixedSize(97, 36);
preStep->setText(tr("back"));
preStep->setEnabled(true);
preStep->setAutoRepeat(true);
connect(preStep, &MyPushButton::clicked, this, &SystemBackup::on_pre_clicked);
hlayoutCenterFont5->addWidget(preStep);
hlayoutCenterFont5->addSpacing(20);
// 下一步按钮
MyPushButton *nextStep = new MyPushButton(third);
nextStep->setGeometry(339, 330, 97, 36);
MyPushButton *nextStep = new MyPushButton(centerFont);
nextStep->setFixedSize(97, 36);
nextStep->setText(tr("next"));
nextStep->setEnabled(true);
nextStep->setAutoRepeat(true);
connect(nextStep, &MyPushButton::clicked, this, [=](bool checked) {
this->on_next_clicked(checked);
});
hlayoutCenterFont5->addWidget(nextStep);
// 重新检测按钮
MyPushButton *recheck = new MyPushButton(third);
recheck->setGeometry(339, 330, 97, 36);
MyPushButton *recheck = new MyPushButton(centerFont);
recheck->setFixedSize(97, 36);
recheck->setText(tr("recheck"));
recheck->setEnabled(true);
recheck->setAutoRepeat(true);
@ -322,6 +383,18 @@ void SystemBackup::initThirdWidget()
Q_UNUSED(checked)
emit this->startCheckEnv();
});
hlayoutCenterFont5->addWidget(recheck);
hlayoutCenterFont5->addStretch();
vlayoutCenterFont->addLayout(hlayoutCenterFont5);
centerFont->setLayout(vlayoutCenterFont);
hlayout->addWidget(centerFont);
hlayout->addStretch();
vlayout->addLayout(hlayout);
vlayout->addStretch();
third->setLayout(vlayout);
//------------ 中部布局end-------------
// 开始检测
connect(this, &SystemBackup::startCheckEnv, this, [=]() {
@ -333,9 +406,8 @@ void SystemBackup::initThirdWidget()
bigTitle->setDeplayText(tr("Being checked, wait a moment ..."));
dot1->setBackgroundColor(Qt::black);
dot2->setBackgroundColor(Qt::black);
// 环境检测中
labelCheck1->setDeplayText(tr("The environment is being checked ..."));
labelCheck2->setFontWordWrap(true);
// 备份过程中不要做其它操作,以防数据丢失
labelCheck1->setDeplayText(tr("Do not perform other operations during backup to avoid data loss"));
if (this->m_isLocal) {
// 检测备份分区空间是否充足···
labelCheck2->setDeplayText(tr("Check whether the remaining capacity of the backup partition is sufficient"));
@ -466,9 +538,21 @@ void SystemBackup::on_checkEnv_end(int result)
// 检查是否有备份分区
errTip = tr("Check whether there is a backup partition");
break;
case int(BackupResult::UDISK_FILESYSTEM_TYPE_IS_VFAT):
// 移动设备的文件系统是vfat格式
errMsg = tr("The filesystem of device is vfat format");
// 请换成ext4、ntfs等格式
errTip = tr("Please change filesystem format to ext3、ext4 or ntfs");
break;
case int(BackupResult::UDISK_FILESYSTEM_IS_READONLY):
// 移动设备是只读的
errMsg = tr("The device is read only");
// 请修改为可读写权限的
errTip = tr("Please chmod to rw");
break;
case int(BackupResult::BACKUP_CAPACITY_IS_NOT_ENOUGH):
// 备份空间不足
errMsg = tr("The storage for backup is not enough.");
errMsg = tr("The storage for backup is not enough");
// 建议释放空间后重试
errTip = tr("Retry after release space");
break;
@ -686,6 +770,7 @@ void SystemBackup::initFifthWidget()
MyLabel *labelTip = new MyLabel(fifth);
labelTip->setGeometry(101, 261, 520, 30);
labelTip->setAlignment(Qt::AlignCenter);
labelTip->setFontWordWrap(true);
labelTip->setDeplayText(tr("Do not use computers in case of data loss"));
connect(this, &SystemBackup::backupWarnning, labelTip, [=](const QString& msg) {
labelTip->setDeplayText(msg);
@ -806,7 +891,7 @@ void SystemBackup::on_checkBackup_end(int result)
break;
case int(BackupResult::MKSQUASHFS_START_SUCCESS):
// 正压缩系统到本地磁盘,请耐心等待。。。
errTip = tr("The system is being compressed to the local disk, Please wait patiently...");
errTip = tr("The system is being compressed to the local disk, please wait patiently...");
emit this->backupWarnning(errTip);
return;
case int(BackupResult::BACKUP_START_SUCCESS):
@ -894,41 +979,95 @@ void SystemBackup::initLastWidget()
label4->setFontColor(QColor(COLOR_BLUE));
label4->setGeometry(551, 72, 164, 30);
// --------------失败界面--------------
//------------ 中部布局begin-------------
QVBoxLayout *vlayout = new QVBoxLayout(last);
vlayout->addSpacing(180);
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addStretch();
QWidget *centerFont = new QWidget(last);
QVBoxLayout *vlayoutCenterFont = new QVBoxLayout;
// 第一行
QHBoxLayout *hlayoutCenterFont1 = new QHBoxLayout;
// 备份结果对错图标
QLabel *resultLogo = new QLabel(last);
resultLogo->setGeometry(220, 180, 20, 20);
// 备份结果大标题
MyLabel *bigTitle = new MyLabel(last);
QLabel *resultLogo = new QLabel(centerFont);
resultLogo->setFixedSize(20,20);
hlayoutCenterFont1->addWidget(resultLogo);
// 检测中大标题
MyLabel *bigTitle = new MyLabel(centerFont);
bigTitle->setFontSize(24);
bigTitle->setGeometry(251, 170, 500, 36);
bigTitle->setMaximumWidth(700);
hlayoutCenterFont1->addWidget(bigTitle);
hlayoutCenterFont1->addStretch();
vlayoutCenterFont->addLayout(hlayoutCenterFont1);
// 第二行
QHBoxLayout *hlayoutCenterFont2 = new QHBoxLayout;
hlayoutCenterFont2->addSpacing(10);
// 备份结果错误提示:黑点和文字
CircleLable *dot1 = new CircleLable(QString(""), last, 6, Qt::black);
dot1->setGeometry(231, 235, 6, 6);
MyLabel *labelError1 = new MyLabel(last);
labelError1->setGeometry(251, 220, 300, 30);
CircleLable *dot1 = new CircleLable(QString(""), centerFont, 6, Qt::black);
hlayoutCenterFont2->addWidget(dot1);
hlayoutCenterFont2->addSpacing(5);
MyLabel *labelError1 = new MyLabel(centerFont);
labelError1->setMinimumWidth(400);
labelError1->setMaximumWidth(600);
labelError1->setIsOriginal(true);
labelError1->setWordWrap(true);
labelError1->adjustSize();
hlayoutCenterFont2->addWidget(labelError1);
hlayoutCenterFont2->addStretch();
vlayoutCenterFont->addLayout(hlayoutCenterFont2);
CircleLable *dot2 = new CircleLable(QString(""), last, 6, Qt::black);
dot2->setGeometry(231, 265, 6, 6);
MyLabel *labelError2 = new MyLabel(last);
labelError2->setGeometry(251, 250, 300, 30);
// 第三行
QHBoxLayout *hlayoutCenterFont3 = new QHBoxLayout;
hlayoutCenterFont3->addSpacing(10);
// 检测中的记录黑点2和文字2
CircleLable *dot2 = new CircleLable(QString(""), centerFont, 6, Qt::black);
hlayoutCenterFont3->addWidget(dot2);
hlayoutCenterFont3->addSpacing(5);
MyLabel *labelError2 = new MyLabel(centerFont);
labelError2->setMinimumWidth(400);
labelError2->setMaximumWidth(600);
labelError2->setIsOriginal(true);
labelError2->setWordWrap(true);
labelError2->adjustSize();
hlayoutCenterFont3->addWidget(labelError2);
hlayoutCenterFont3->addStretch();
vlayoutCenterFont->addLayout(hlayoutCenterFont3);
// 第四行
vlayoutCenterFont->addSpacing(30);
// 第五行
QHBoxLayout *hlayoutCenterFont5 = new QHBoxLayout;
hlayoutCenterFont5->addStretch();
// 再试一次
MyPushButton *retry = new MyPushButton(last);
retry->setGeometry(310, 330, 97, 36);
MyPushButton *retry = new MyPushButton(centerFont);
retry->setFixedSize(97, 36);
retry->setText(tr("retry"));
retry->setEnabled(true);
retry->setAutoRepeat(true);
// --------------成功界面--------------
hlayoutCenterFont5->addWidget(retry);
hlayoutCenterFont5->addSpacing(20);
// 返回首页
MyPushButton *homePage = new MyPushButton(last);
homePage->setGeometry(310, 240, 97, 36);
homePage->setFixedSize(97, 36);
homePage->setText(tr("home page"));
homePage->setEnabled(true);
homePage->setAutoRepeat(true);
hlayoutCenterFont5->addWidget(homePage);
hlayoutCenterFont5->addStretch();
vlayoutCenterFont->addLayout(hlayoutCenterFont5);
centerFont->setLayout(vlayoutCenterFont);
hlayout->addWidget(centerFont);
hlayout->addStretch();
vlayout->addLayout(hlayout);
vlayout->addStretch();
last->setLayout(vlayout);
//------------ 中部布局end-------------
// 备份检测结果
connect(this, &SystemBackup::checkBackupResult, this, [=](bool result, const QString &errMsg, const QString &errTip) {

0
kybackup/module/systembackup.h Normal file → Executable file
View File

71
kybackup/module/systemrestore.cpp Normal file → Executable file
View File

@ -4,10 +4,13 @@
#include <QComboBox>
#include <QCheckBox>
#include <QMovie>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <unistd.h>
#include "../component/clicklabel.h"
#include "../component/circlelabel.h"
#include "../component/mycheckbox.h"
#include "../component/myiconlabel.h"
#include "../component/mylabel.h"
#include "../component/mylineedit.h"
@ -16,17 +19,24 @@
#include "../component/ringsprogressbar.h"
#include "../../common/utils.h"
#include "../globalbackupinfo.h"
#include "messageboxutils.h"
#include "backuppointlistdialog.h"
SystemRestore::SystemRestore(QWidget *parent) :
QStackedWidget(parent)
{
m_isRetainUserData = false;
m_isFactoryRestore = false;
m_pInterface = nullptr;
// 界面手写代码创建,作为练手
initFirstWidget();
}
SystemRestore::~SystemRestore()
{}
{
delete m_pInterface;
m_pInterface = nullptr;
}
/**
* @brief
@ -108,12 +118,38 @@ void SystemRestore::initFirstWidget()
beginRestore->setAutoRepeat(true);
font.setPixelSize(24);
beginRestore->setFont(font);
connect(beginRestore, &MyPushButton::clicked, this, &SystemRestore::on_next_clicked);
connect(beginRestore, &MyPushButton::clicked, this, &SystemRestore::on_button_beginRestore_clicked);
// 底部控件布局
QVBoxLayout *bottomVBoxLayout = new QVBoxLayout(first);
bottomVBoxLayout->addStretch();
QHBoxLayout *bottomHBoxLayout = new QHBoxLayout(first);
bottomVBoxLayout->addLayout(bottomHBoxLayout);
bottomVBoxLayout->addSpacing(20);
bottomHBoxLayout->addStretch();
// 恢复出厂复选框
MyCheckBox * checkFactoryRestore = new MyCheckBox(tr("Factory Restore"), first);
// if (!Utils::isHuawei990())
// checkFactoryRestore->setVisible(false);
// 保留用户数据复选框
QCheckBox * retainUserData = new QCheckBox(tr("Retaining User Data"), first);
retainUserData->setGeometry(551, 551, 200, 30);
connect(retainUserData, &QCheckBox::stateChanged, this, &SystemRestore::on_retainUserData_checked);
MyCheckBox * retainUserData = new MyCheckBox(tr("Retaining User Data"), first);
bottomHBoxLayout->addWidget(checkFactoryRestore);
bottomHBoxLayout->addSpacing(10);
bottomHBoxLayout->addWidget(retainUserData);
bottomHBoxLayout->addSpacing(20);
connect(checkFactoryRestore, &MyCheckBox::stateChanged, this, [=](int state) {
this->m_isFactoryRestore = Qt::Unchecked == state ? false : true;
if (this->m_isFactoryRestore) {
retainUserData->setChecked(false);
}
});
connect(retainUserData, &MyCheckBox::stateChanged, this, [=](int state) {
this->m_isRetainUserData = Qt::Unchecked == state ? false : true;
if (this->m_isRetainUserData) {
checkFactoryRestore->setChecked(false);
}
});
addWidget(first);
}
@ -132,7 +168,7 @@ void SystemRestore::on_pre_clicked(bool checked)
}
/**
* @brief
* @brief
* @param checked
*/
void SystemRestore::on_next_clicked(bool checked)
@ -145,10 +181,27 @@ void SystemRestore::on_next_clicked(bool checked)
}
/**
* @brief
* @brief
* @param checked
*/
void SystemRestore::on_retainUserData_checked(bool checked)
void SystemRestore::on_button_beginRestore_clicked(bool checked)
{
m_isRetainUserData = checked;
Q_UNUSED(checked)
// 出厂还原,不用去选择备份点
if (m_isFactoryRestore) {
if (!MessageBoxUtils::QMESSAGE_BOX_WARNING_CANCEL(this, QObject::tr("Warning"),
QObject::tr("Restore factory settings, your system user data will not be retained"),
QObject::tr("Continue"), QObject::tr("Cancel"))) {
return;
}
//出厂还原
m_uuid = FACTORY_BACKUP_UUID;
} else {
// 系统备份点列表中选择备份点
BackupPointListDialog *backupPointListDialog = new BackupPointListDialog(this);
backupPointListDialog->exec();
}
}

11
kybackup/module/systemrestore.h Normal file → Executable file
View File

@ -2,6 +2,8 @@
#define SYSTEMRESTORE_H
#include <QStackedWidget>
#include "../backup_manager_interface.h"
#include "../backup-daemon/parsebackuplist.h"
class SystemRestore : public QStackedWidget
{
@ -34,11 +36,18 @@ private:
public slots:
void on_pre_clicked(bool checked = false);
void on_next_clicked(bool checked = false);
void on_retainUserData_checked(bool checked = false);
void on_button_beginRestore_clicked(bool checked = false);
private:
// 是否保留用户数据
bool m_isRetainUserData;
// 是否出厂还原
bool m_isFactoryRestore;
// dbus接口
ComKylinBackupManagerInterface *m_pInterface;
QString m_uuid; // 还原点的UUID
};
#endif // SYSTEMRESTORE_H

0
kybackup/module/udiskdetector.cpp Normal file → Executable file
View File

0
kybackup/module/udiskdetector.h Normal file → Executable file
View File

0
kybackup/qtsingleapplication/qtlocalpeer.cpp Normal file → Executable file
View File

0
kybackup/qtsingleapplication/qtlocalpeer.h Normal file → Executable file
View File

0
kybackup/qtsingleapplication/qtlockedfile.cpp Normal file → Executable file
View File

0
kybackup/qtsingleapplication/qtlockedfile.h Normal file → Executable file
View File

0
kybackup/qtsingleapplication/qtlockedfile_unix.cpp Normal file → Executable file
View File

0
kybackup/qtsingleapplication/qtsingleapplication.cpp Normal file → Executable file
View File

0
kybackup/qtsingleapplication/qtsingleapplication.h Normal file → Executable file
View File

0
kybackup/resource/images/data_backup.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

0
kybackup/resource/images/data_backup_dark.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

0
kybackup/resource/images/data_restore.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

0
kybackup/resource/images/data_restore_dark.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

0
kybackup/resource/images/folder.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 315 B

After

Width:  |  Height:  |  Size: 315 B

0
kybackup/resource/images/ghost_image.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

0
kybackup/resource/images/ghost_image_dark.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

0
kybackup/resource/images/loading.gif Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

0
kybackup/resource/images/sysem_restore.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

0
kybackup/resource/images/sysem_restore_dark.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

0
kybackup/resource/images/system_backup.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 69 KiB

0
kybackup/resource/images/system_backup_dark.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

0
kybackup/resource/symbos/dialog-error.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 550 B

After

Width:  |  Height:  |  Size: 550 B

View File

Before

Width:  |  Height:  |  Size: 379 B

After

Width:  |  Height:  |  Size: 379 B

0
kybackup/resource/symbos/list-add-symbolic.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 138 B

After

Width:  |  Height:  |  Size: 138 B

View File

Before

Width:  |  Height:  |  Size: 286 B

After

Width:  |  Height:  |  Size: 286 B

0
kybackup/resource/symbos/ukui-bf-damage-symbolic.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 328 B

View File

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 327 B

View File

Before

Width:  |  Height:  |  Size: 353 B

After

Width:  |  Height:  |  Size: 353 B

0
kybackup/resource/symbos/ukui-bf-dataloss-symbolic.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 354 B

After

Width:  |  Height:  |  Size: 354 B

0
kybackup/resource/symbos/ukui-bf-fast-symbolic.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 384 B

After

Width:  |  Height:  |  Size: 384 B

View File

Before

Width:  |  Height:  |  Size: 231 B

After

Width:  |  Height:  |  Size: 231 B

View File

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 328 B

View File

Before

Width:  |  Height:  |  Size: 277 B

After

Width:  |  Height:  |  Size: 277 B

0
kybackup/resource/symbos/ukui-bf-security-symbolic.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 348 B

After

Width:  |  Height:  |  Size: 348 B

0
kybackup/resource/symbos/ukui-bf-simple-symbolic.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 364 B

After

Width:  |  Height:  |  Size: 364 B

View File

Before

Width:  |  Height:  |  Size: 294 B

After

Width:  |  Height:  |  Size: 294 B

View File

Before

Width:  |  Height:  |  Size: 320 B

After

Width:  |  Height:  |  Size: 320 B

0
kybackup/resource/symbos/ukui-bf-volume-symbolic.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 320 B

After

Width:  |  Height:  |  Size: 320 B

0
kybackup/resource/symbos/ukui-dialog-success.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 500 B

After

Width:  |  Height:  |  Size: 500 B

0
kybackup/xatom-helper.cpp Normal file → Executable file
View File

0
kybackup/xatom-helper.h Normal file → Executable file
View File

0
yhkylin-backup-tool.pro Normal file → Executable file
View File