阶段提交
|
@ -53,6 +53,22 @@ bool UDiskSystemBackupProxy::checkEnvEx()
|
||||||
return false;
|
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);
|
QTimer::singleShot(1*1000, this, &UDiskSystemBackupProxy::checkDestDirExists);
|
||||||
// 2、计算备份大小
|
// 2、计算备份大小
|
||||||
calcSizeForBackup();
|
calcSizeForBackup();
|
||||||
|
|
|
@ -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-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-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="/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>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -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));
|
||||||
|
}
|
|
@ -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
|
|
@ -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,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);
|
||||||
|
}
|
|
@ -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
|
|
@ -21,7 +21,6 @@ MyLabel::MyLabel(QWidget* parent) :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MyLabel::~MyLabel()
|
MyLabel::~MyLabel()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -55,6 +54,11 @@ void MyLabel::setFontWordWrap(bool on)
|
||||||
|
|
||||||
void MyLabel::paintEvent(QPaintEvent *event)
|
void MyLabel::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
|
if (m_isOriginal) {
|
||||||
|
QLabel::paintEvent(event);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
QFontMetrics fontMetrics(this->font());
|
QFontMetrics fontMetrics(this->font());
|
||||||
int fontSize = fontMetrics.width(m_text);
|
int fontSize = fontMetrics.width(m_text);
|
||||||
if (m_bWordWrap && m_width > 0) {
|
if (m_bWordWrap && m_width > 0) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ public:
|
||||||
void setFontColor(QColor color);
|
void setFontColor(QColor color);
|
||||||
void setFontSize(int size);
|
void setFontSize(int size);
|
||||||
void setFontWordWrap(bool on);
|
void setFontWordWrap(bool on);
|
||||||
|
void setIsOriginal(bool isOriginal) { m_isOriginal = isOriginal; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
@ -25,6 +26,7 @@ private:
|
||||||
bool m_bWordWrap = false;
|
bool m_bWordWrap = false;
|
||||||
int m_width = 0;
|
int m_width = 0;
|
||||||
int m_height = 0;
|
int m_height = 0;
|
||||||
|
bool m_isOriginal = false;
|
||||||
QRect m_rect;
|
QRect m_rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,3 +6,14 @@ MyPushButton::MyPushButton(QWidget *parent) :
|
||||||
|
|
||||||
MyPushButton::~MyPushButton()
|
MyPushButton::~MyPushButton()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void MyPushButton::setFontSize(int size)
|
||||||
|
{
|
||||||
|
QFont font = this->font();
|
||||||
|
font.setPixelSize(size);
|
||||||
|
// 默认为大字体粗体显示
|
||||||
|
if (size > 20)
|
||||||
|
font.setBold(true);
|
||||||
|
this->setFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ class MyPushButton : public QPushButton
|
||||||
public:
|
public:
|
||||||
MyPushButton(QWidget* parent = nullptr);
|
MyPushButton(QWidget* parent = nullptr);
|
||||||
virtual ~MyPushButton();
|
virtual ~MyPushButton();
|
||||||
|
|
||||||
|
void setFontSize(int size);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MYPUSHBUTTON_H
|
#endif // MYPUSHBUTTON_H
|
||||||
|
|
|
@ -36,11 +36,13 @@ HEADERS += \
|
||||||
../common/spinlock_mutex.h \
|
../common/spinlock_mutex.h \
|
||||||
../common/utils.h \
|
../common/utils.h \
|
||||||
backup_manager_interface.h \
|
backup_manager_interface.h \
|
||||||
|
backuppointlistdialog.h \
|
||||||
component/circlelabel.h \
|
component/circlelabel.h \
|
||||||
component/clicklabel.h \
|
component/clicklabel.h \
|
||||||
component/hoverwidget.h \
|
component/hoverwidget.h \
|
||||||
component/imageutil.h \
|
component/imageutil.h \
|
||||||
component/linelabel.h \
|
component/linelabel.h \
|
||||||
|
component/mycheckbox.h \
|
||||||
component/myiconbutton.h \
|
component/myiconbutton.h \
|
||||||
component/myiconlabel.h \
|
component/myiconlabel.h \
|
||||||
component/mylabel.h \
|
component/mylabel.h \
|
||||||
|
@ -53,6 +55,7 @@ HEADERS += \
|
||||||
gsettingswrapper.h \
|
gsettingswrapper.h \
|
||||||
leftsiderbarwidget.h \
|
leftsiderbarwidget.h \
|
||||||
maindialog.h \
|
maindialog.h \
|
||||||
|
messageboxutils.h \
|
||||||
module/systembackup.h \
|
module/systembackup.h \
|
||||||
module/systemrestore.h \
|
module/systemrestore.h \
|
||||||
module/udiskdetector.h \
|
module/udiskdetector.h \
|
||||||
|
@ -67,11 +70,13 @@ SOURCES += \
|
||||||
../common/mylittleparse.cpp \
|
../common/mylittleparse.cpp \
|
||||||
../common/utils.cpp \
|
../common/utils.cpp \
|
||||||
backup_manager_interface.cpp \
|
backup_manager_interface.cpp \
|
||||||
|
backuppointlistdialog.cpp \
|
||||||
component/circlelabel.cpp \
|
component/circlelabel.cpp \
|
||||||
component/clicklabel.cpp \
|
component/clicklabel.cpp \
|
||||||
component/hoverwidget.cpp \
|
component/hoverwidget.cpp \
|
||||||
component/imageutil.cpp \
|
component/imageutil.cpp \
|
||||||
component/linelabel.cpp \
|
component/linelabel.cpp \
|
||||||
|
component/mycheckbox.cpp \
|
||||||
component/myiconbutton.cpp \
|
component/myiconbutton.cpp \
|
||||||
component/myiconlabel.cpp \
|
component/myiconlabel.cpp \
|
||||||
component/mylabel.cpp \
|
component/mylabel.cpp \
|
||||||
|
@ -83,6 +88,7 @@ SOURCES += \
|
||||||
leftsiderbarwidget.cpp \
|
leftsiderbarwidget.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
maindialog.cpp \
|
maindialog.cpp \
|
||||||
|
messageboxutils.cpp \
|
||||||
module/systembackup.cpp \
|
module/systembackup.cpp \
|
||||||
module/systemrestore.cpp \
|
module/systemrestore.cpp \
|
||||||
module/udiskdetector.cpp \
|
module/udiskdetector.cpp \
|
||||||
|
@ -93,6 +99,7 @@ SOURCES += \
|
||||||
xatom-helper.cpp
|
xatom-helper.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
|
backuppointlistdialog.ui \
|
||||||
maindialog.ui
|
maindialog.ui
|
||||||
|
|
||||||
TRANSLATIONS += qt_zh_CN.ts
|
TRANSLATIONS += qt_zh_CN.ts
|
||||||
|
|
|
@ -91,11 +91,11 @@ void MainDialog::initTileBar()
|
||||||
QMenu* selectTheme = new QMenu(this);
|
QMenu* selectTheme = new QMenu(this);
|
||||||
selectTheme->setObjectName("selectTheme");
|
selectTheme->setObjectName("selectTheme");
|
||||||
backupTheme->setMenu(selectTheme);
|
backupTheme->setMenu(selectTheme);
|
||||||
QAction* defaultTheme = new QAction(tr("DefaultTheme"),this);
|
QAction* defaultTheme = new QAction(tr("Auto"),this);
|
||||||
selectTheme->addAction(defaultTheme);
|
selectTheme->addAction(defaultTheme);
|
||||||
QAction* darkTheme = new QAction(tr("DarkTheme"),this);
|
QAction* darkTheme = new QAction(tr("Dark"),this);
|
||||||
selectTheme->addAction(darkTheme);
|
selectTheme->addAction(darkTheme);
|
||||||
QAction* lightTheme = new QAction(tr("LightTheme"),this);
|
QAction* lightTheme = new QAction(tr("Light"),this);
|
||||||
selectTheme->addAction(lightTheme);
|
selectTheme->addAction(lightTheme);
|
||||||
|
|
||||||
m_backupHelp = new QAction(tr("Help"),this);
|
m_backupHelp = new QAction(tr("Help"),this);
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
|
@ -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
|
|
@ -3,6 +3,8 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QMovie>
|
#include <QMovie>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QVBoxLayout>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "../component/clicklabel.h"
|
#include "../component/clicklabel.h"
|
||||||
|
@ -20,7 +22,8 @@ SystemBackup::SystemBackup(QWidget *parent /*= nullptr*/) :
|
||||||
QStackedWidget(parent),
|
QStackedWidget(parent),
|
||||||
m_udector(new UdiskDetector()),
|
m_udector(new UdiskDetector()),
|
||||||
m_isLocal(true),
|
m_isLocal(true),
|
||||||
m_systemBackupState(SystemBackupState::IDEL)
|
m_systemBackupState(SystemBackupState::IDEL),
|
||||||
|
m_pInterface(nullptr)
|
||||||
{
|
{
|
||||||
// 界面手写代码创建,作为练手
|
// 界面手写代码创建,作为练手
|
||||||
initFirstWidget();
|
initFirstWidget();
|
||||||
|
@ -34,6 +37,10 @@ SystemBackup::SystemBackup(QWidget *parent /*= nullptr*/) :
|
||||||
SystemBackup::~SystemBackup()
|
SystemBackup::~SystemBackup()
|
||||||
{
|
{
|
||||||
delete m_udector;
|
delete m_udector;
|
||||||
|
m_udector = nullptr;
|
||||||
|
|
||||||
|
delete m_pInterface;
|
||||||
|
m_pInterface = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,13 +124,23 @@ void SystemBackup::initFirstWidget()
|
||||||
beginBackup->setFont(font);
|
beginBackup->setFont(font);
|
||||||
connect(beginBackup, &MyPushButton::clicked, this, &SystemBackup::on_next_clicked);
|
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);
|
ClickLabel * backupPointManage = new ClickLabel(tr("Backup Management >>"), first);
|
||||||
backupPointManage->setGeometry(551, 551, 200, 30);
|
|
||||||
QPalette pal(backupPointManage->palette());
|
QPalette pal(backupPointManage->palette());
|
||||||
pal.setColor(QPalette::WindowText, QColor(Qt::blue));
|
pal.setColor(QPalette::WindowText, QColor(Qt::blue));
|
||||||
backupPointManage->setPalette(pal);
|
backupPointManage->setPalette(pal);
|
||||||
backupPointManage->setToolTip(tr("Backup Management >>"));
|
backupPointManage->setToolTip(tr("Backup Management >>"));
|
||||||
|
|
||||||
|
bottomHBoxLayout->addWidget(backupPointManage);
|
||||||
|
bottomHBoxLayout->addSpacing(20);
|
||||||
|
|
||||||
connect(backupPointManage, &ClickLabel::clicked, this, &SystemBackup::on_systemBackupManage_clicked);
|
connect(backupPointManage, &ClickLabel::clicked, this, &SystemBackup::on_systemBackupManage_clicked);
|
||||||
|
|
||||||
addWidget(first);
|
addWidget(first);
|
||||||
|
@ -267,54 +284,98 @@ void SystemBackup::initThirdWidget()
|
||||||
MyLabel *label4 = new MyLabel(tr("finished"), third);
|
MyLabel *label4 = new MyLabel(tr("finished"), third);
|
||||||
label4->setGeometry(551, 72, 164, 30);
|
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->setMovie(movie);
|
||||||
loadingGif->setGeometry(180, 180, 20, 20);
|
hlayoutCenterFont1->addWidget(loadingGif);
|
||||||
|
|
||||||
// 检测结果对错图标
|
// 检测结果对错图标
|
||||||
QLabel *resultLogo = new QLabel(third);
|
QLabel *resultLogo = new QLabel(centerFont);
|
||||||
resultLogo->setGeometry(180, 180, 20, 20);
|
resultLogo->setFixedSize(20,20);
|
||||||
|
hlayoutCenterFont1->addWidget(resultLogo);
|
||||||
// 检测中大标题
|
// 检测中大标题
|
||||||
MyLabel *bigTitle = new MyLabel(third);
|
MyLabel *bigTitle = new MyLabel(centerFont);
|
||||||
bigTitle->setFontSize(24);
|
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);
|
QHBoxLayout *hlayoutCenterFont2 = new QHBoxLayout;
|
||||||
dot1->setGeometry(190, 235, 6, 6);
|
hlayoutCenterFont2->addSpacing(10);
|
||||||
MyLabel *labelCheck1 = new MyLabel(third);
|
// 检测中的记录:黑点1和文字1
|
||||||
labelCheck1->setGeometry(210, 220, 500, 30);
|
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);
|
QHBoxLayout *hlayoutCenterFont3 = new QHBoxLayout;
|
||||||
MyLabel *labelCheck2 = new MyLabel(third);
|
hlayoutCenterFont3->addSpacing(10);
|
||||||
labelCheck2->setGeometry(210, 250, 450, 30);
|
// 检测中的记录:黑点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);
|
MyPushButton *preStep = new MyPushButton(centerFont);
|
||||||
preStep->setGeometry(221, 330, 97, 36);
|
preStep->setFixedSize(97, 36);
|
||||||
preStep->setText(tr("back"));
|
preStep->setText(tr("back"));
|
||||||
preStep->setEnabled(true);
|
preStep->setEnabled(true);
|
||||||
preStep->setAutoRepeat(true);
|
preStep->setAutoRepeat(true);
|
||||||
connect(preStep, &MyPushButton::clicked, this, &SystemBackup::on_pre_clicked);
|
connect(preStep, &MyPushButton::clicked, this, &SystemBackup::on_pre_clicked);
|
||||||
|
hlayoutCenterFont5->addWidget(preStep);
|
||||||
|
hlayoutCenterFont5->addSpacing(20);
|
||||||
// 下一步按钮
|
// 下一步按钮
|
||||||
MyPushButton *nextStep = new MyPushButton(third);
|
MyPushButton *nextStep = new MyPushButton(centerFont);
|
||||||
nextStep->setGeometry(339, 330, 97, 36);
|
nextStep->setFixedSize(97, 36);
|
||||||
nextStep->setText(tr("next"));
|
nextStep->setText(tr("next"));
|
||||||
nextStep->setEnabled(true);
|
nextStep->setEnabled(true);
|
||||||
nextStep->setAutoRepeat(true);
|
nextStep->setAutoRepeat(true);
|
||||||
connect(nextStep, &MyPushButton::clicked, this, [=](bool checked) {
|
connect(nextStep, &MyPushButton::clicked, this, [=](bool checked) {
|
||||||
this->on_next_clicked(checked);
|
this->on_next_clicked(checked);
|
||||||
});
|
});
|
||||||
|
hlayoutCenterFont5->addWidget(nextStep);
|
||||||
// 重新检测按钮
|
// 重新检测按钮
|
||||||
MyPushButton *recheck = new MyPushButton(third);
|
MyPushButton *recheck = new MyPushButton(centerFont);
|
||||||
recheck->setGeometry(339, 330, 97, 36);
|
recheck->setFixedSize(97, 36);
|
||||||
recheck->setText(tr("recheck"));
|
recheck->setText(tr("recheck"));
|
||||||
recheck->setEnabled(true);
|
recheck->setEnabled(true);
|
||||||
recheck->setAutoRepeat(true);
|
recheck->setAutoRepeat(true);
|
||||||
|
@ -322,6 +383,18 @@ void SystemBackup::initThirdWidget()
|
||||||
Q_UNUSED(checked)
|
Q_UNUSED(checked)
|
||||||
emit this->startCheckEnv();
|
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, [=]() {
|
connect(this, &SystemBackup::startCheckEnv, this, [=]() {
|
||||||
|
@ -333,9 +406,8 @@ void SystemBackup::initThirdWidget()
|
||||||
bigTitle->setDeplayText(tr("Being checked, wait a moment ..."));
|
bigTitle->setDeplayText(tr("Being checked, wait a moment ..."));
|
||||||
dot1->setBackgroundColor(Qt::black);
|
dot1->setBackgroundColor(Qt::black);
|
||||||
dot2->setBackgroundColor(Qt::black);
|
dot2->setBackgroundColor(Qt::black);
|
||||||
// 环境检测中
|
// 备份过程中不要做其它操作,以防数据丢失
|
||||||
labelCheck1->setDeplayText(tr("The environment is being checked ..."));
|
labelCheck1->setDeplayText(tr("Do not perform other operations during backup to avoid data loss"));
|
||||||
labelCheck2->setFontWordWrap(true);
|
|
||||||
if (this->m_isLocal) {
|
if (this->m_isLocal) {
|
||||||
// 检测备份分区空间是否充足···
|
// 检测备份分区空间是否充足···
|
||||||
labelCheck2->setDeplayText(tr("Check whether the remaining capacity of the backup partition is sufficient"));
|
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");
|
errTip = tr("Check whether there is a backup partition");
|
||||||
break;
|
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):
|
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");
|
errTip = tr("Retry after release space");
|
||||||
break;
|
break;
|
||||||
|
@ -686,6 +770,7 @@ void SystemBackup::initFifthWidget()
|
||||||
MyLabel *labelTip = new MyLabel(fifth);
|
MyLabel *labelTip = new MyLabel(fifth);
|
||||||
labelTip->setGeometry(101, 261, 520, 30);
|
labelTip->setGeometry(101, 261, 520, 30);
|
||||||
labelTip->setAlignment(Qt::AlignCenter);
|
labelTip->setAlignment(Qt::AlignCenter);
|
||||||
|
labelTip->setFontWordWrap(true);
|
||||||
labelTip->setDeplayText(tr("Do not use computers in case of data loss"));
|
labelTip->setDeplayText(tr("Do not use computers in case of data loss"));
|
||||||
connect(this, &SystemBackup::backupWarnning, labelTip, [=](const QString& msg) {
|
connect(this, &SystemBackup::backupWarnning, labelTip, [=](const QString& msg) {
|
||||||
labelTip->setDeplayText(msg);
|
labelTip->setDeplayText(msg);
|
||||||
|
@ -806,7 +891,7 @@ void SystemBackup::on_checkBackup_end(int result)
|
||||||
break;
|
break;
|
||||||
case int(BackupResult::MKSQUASHFS_START_SUCCESS):
|
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);
|
emit this->backupWarnning(errTip);
|
||||||
return;
|
return;
|
||||||
case int(BackupResult::BACKUP_START_SUCCESS):
|
case int(BackupResult::BACKUP_START_SUCCESS):
|
||||||
|
@ -894,41 +979,95 @@ void SystemBackup::initLastWidget()
|
||||||
label4->setFontColor(QColor(COLOR_BLUE));
|
label4->setFontColor(QColor(COLOR_BLUE));
|
||||||
label4->setGeometry(551, 72, 164, 30);
|
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);
|
QLabel *resultLogo = new QLabel(centerFont);
|
||||||
resultLogo->setGeometry(220, 180, 20, 20);
|
resultLogo->setFixedSize(20,20);
|
||||||
|
hlayoutCenterFont1->addWidget(resultLogo);
|
||||||
// 备份结果大标题
|
// 检测中大标题
|
||||||
MyLabel *bigTitle = new MyLabel(last);
|
MyLabel *bigTitle = new MyLabel(centerFont);
|
||||||
bigTitle->setFontSize(24);
|
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);
|
CircleLable *dot1 = new CircleLable(QString(""), centerFont, 6, Qt::black);
|
||||||
dot1->setGeometry(231, 235, 6, 6);
|
hlayoutCenterFont2->addWidget(dot1);
|
||||||
MyLabel *labelError1 = new MyLabel(last);
|
hlayoutCenterFont2->addSpacing(5);
|
||||||
labelError1->setGeometry(251, 220, 300, 30);
|
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);
|
QHBoxLayout *hlayoutCenterFont3 = new QHBoxLayout;
|
||||||
MyLabel *labelError2 = new MyLabel(last);
|
hlayoutCenterFont3->addSpacing(10);
|
||||||
labelError2->setGeometry(251, 250, 300, 30);
|
// 检测中的记录:黑点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);
|
MyPushButton *retry = new MyPushButton(centerFont);
|
||||||
retry->setGeometry(310, 330, 97, 36);
|
retry->setFixedSize(97, 36);
|
||||||
retry->setText(tr("retry"));
|
retry->setText(tr("retry"));
|
||||||
retry->setEnabled(true);
|
retry->setEnabled(true);
|
||||||
retry->setAutoRepeat(true);
|
retry->setAutoRepeat(true);
|
||||||
|
hlayoutCenterFont5->addWidget(retry);
|
||||||
// --------------成功界面--------------
|
hlayoutCenterFont5->addSpacing(20);
|
||||||
// 返回首页
|
// 返回首页
|
||||||
MyPushButton *homePage = new MyPushButton(last);
|
MyPushButton *homePage = new MyPushButton(last);
|
||||||
homePage->setGeometry(310, 240, 97, 36);
|
homePage->setFixedSize(97, 36);
|
||||||
homePage->setText(tr("home page"));
|
homePage->setText(tr("home page"));
|
||||||
homePage->setEnabled(true);
|
homePage->setEnabled(true);
|
||||||
homePage->setAutoRepeat(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) {
|
connect(this, &SystemBackup::checkBackupResult, this, [=](bool result, const QString &errMsg, const QString &errTip) {
|
||||||
|
|
|
@ -4,10 +4,13 @@
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QMovie>
|
#include <QMovie>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QVBoxLayout>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "../component/clicklabel.h"
|
#include "../component/clicklabel.h"
|
||||||
#include "../component/circlelabel.h"
|
#include "../component/circlelabel.h"
|
||||||
|
#include "../component/mycheckbox.h"
|
||||||
#include "../component/myiconlabel.h"
|
#include "../component/myiconlabel.h"
|
||||||
#include "../component/mylabel.h"
|
#include "../component/mylabel.h"
|
||||||
#include "../component/mylineedit.h"
|
#include "../component/mylineedit.h"
|
||||||
|
@ -16,17 +19,24 @@
|
||||||
#include "../component/ringsprogressbar.h"
|
#include "../component/ringsprogressbar.h"
|
||||||
#include "../../common/utils.h"
|
#include "../../common/utils.h"
|
||||||
#include "../globalbackupinfo.h"
|
#include "../globalbackupinfo.h"
|
||||||
|
#include "messageboxutils.h"
|
||||||
|
#include "backuppointlistdialog.h"
|
||||||
|
|
||||||
SystemRestore::SystemRestore(QWidget *parent) :
|
SystemRestore::SystemRestore(QWidget *parent) :
|
||||||
QStackedWidget(parent)
|
QStackedWidget(parent)
|
||||||
{
|
{
|
||||||
m_isRetainUserData = false;
|
m_isRetainUserData = false;
|
||||||
|
m_isFactoryRestore = false;
|
||||||
|
m_pInterface = nullptr;
|
||||||
// 界面手写代码创建,作为练手
|
// 界面手写代码创建,作为练手
|
||||||
initFirstWidget();
|
initFirstWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemRestore::~SystemRestore()
|
SystemRestore::~SystemRestore()
|
||||||
{}
|
{
|
||||||
|
delete m_pInterface;
|
||||||
|
m_pInterface = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 初始化第一个页面
|
* @brief 初始化第一个页面
|
||||||
|
@ -108,12 +118,38 @@ void SystemRestore::initFirstWidget()
|
||||||
beginRestore->setAutoRepeat(true);
|
beginRestore->setAutoRepeat(true);
|
||||||
font.setPixelSize(24);
|
font.setPixelSize(24);
|
||||||
beginRestore->setFont(font);
|
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);
|
MyCheckBox * retainUserData = new MyCheckBox(tr("Retaining User Data"), first);
|
||||||
retainUserData->setGeometry(551, 551, 200, 30);
|
bottomHBoxLayout->addWidget(checkFactoryRestore);
|
||||||
connect(retainUserData, &QCheckBox::stateChanged, this, &SystemRestore::on_retainUserData_checked);
|
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);
|
addWidget(first);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +168,7 @@ void SystemRestore::on_pre_clicked(bool checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief “开始备份”“下一步”按钮响应槽
|
* @brief “下一步”按钮响应槽
|
||||||
* @param checked
|
* @param checked
|
||||||
*/
|
*/
|
||||||
void SystemRestore::on_next_clicked(bool 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#define SYSTEMRESTORE_H
|
#define SYSTEMRESTORE_H
|
||||||
|
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
|
#include "../backup_manager_interface.h"
|
||||||
|
#include "../backup-daemon/parsebackuplist.h"
|
||||||
|
|
||||||
class SystemRestore : public QStackedWidget
|
class SystemRestore : public QStackedWidget
|
||||||
{
|
{
|
||||||
|
@ -34,11 +36,18 @@ private:
|
||||||
public slots:
|
public slots:
|
||||||
void on_pre_clicked(bool checked = false);
|
void on_pre_clicked(bool checked = false);
|
||||||
void on_next_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:
|
private:
|
||||||
// 是否保留用户数据
|
// 是否保留用户数据
|
||||||
bool m_isRetainUserData;
|
bool m_isRetainUserData;
|
||||||
|
// 是否出厂还原
|
||||||
|
bool m_isFactoryRestore;
|
||||||
|
|
||||||
|
// dbus接口
|
||||||
|
ComKylinBackupManagerInterface *m_pInterface;
|
||||||
|
|
||||||
|
QString m_uuid; // 还原点的UUID
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SYSTEMRESTORE_H
|
#endif // SYSTEMRESTORE_H
|
||||||
|
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 315 B After Width: | Height: | Size: 315 B |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 550 B After Width: | Height: | Size: 550 B |
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 379 B |
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 138 B |
Before Width: | Height: | Size: 286 B After Width: | Height: | Size: 286 B |
Before Width: | Height: | Size: 328 B After Width: | Height: | Size: 328 B |
Before Width: | Height: | Size: 327 B After Width: | Height: | Size: 327 B |
Before Width: | Height: | Size: 353 B After Width: | Height: | Size: 353 B |
Before Width: | Height: | Size: 354 B After Width: | Height: | Size: 354 B |
Before Width: | Height: | Size: 384 B After Width: | Height: | Size: 384 B |
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 231 B |
Before Width: | Height: | Size: 328 B After Width: | Height: | Size: 328 B |
Before Width: | Height: | Size: 277 B After Width: | Height: | Size: 277 B |
Before Width: | Height: | Size: 348 B After Width: | Height: | Size: 348 B |
Before Width: | Height: | Size: 364 B After Width: | Height: | Size: 364 B |
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 294 B |
Before Width: | Height: | Size: 320 B After Width: | Height: | Size: 320 B |
Before Width: | Height: | Size: 320 B After Width: | Height: | Size: 320 B |
Before Width: | Height: | Size: 500 B After Width: | Height: | Size: 500 B |