2021-08-06 10:20:03 +08:00
|
|
|
|
#include "maindialog.h"
|
|
|
|
|
#include "ui_maindialog.h"
|
|
|
|
|
|
2021-09-16 16:05:46 +08:00
|
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QProcess>
|
2021-10-26 09:24:05 +08:00
|
|
|
|
#include <QMessageBox>
|
2021-09-16 16:05:46 +08:00
|
|
|
|
#include <KWindowSystem>
|
2022-02-15 16:51:03 +08:00
|
|
|
|
#include <KWindowEffects>
|
2021-09-16 16:05:46 +08:00
|
|
|
|
#include <unistd.h>
|
2022-02-15 16:51:03 +08:00
|
|
|
|
#include "xatom-helper.h"
|
2021-09-16 16:05:46 +08:00
|
|
|
|
#include "../common/mydefine.h"
|
|
|
|
|
#include "module/systembackup.h"
|
2021-11-17 13:23:38 +08:00
|
|
|
|
#include "module/systemrestore.h"
|
2021-12-26 18:15:21 +08:00
|
|
|
|
#include "module/databackup.h"
|
2021-12-28 16:51:35 +08:00
|
|
|
|
#include "module/datarestore.h"
|
2021-12-30 10:27:03 +08:00
|
|
|
|
#include "module/operationlog.h"
|
2022-01-13 14:06:40 +08:00
|
|
|
|
#include "module/ghostimage.h"
|
2021-10-26 09:24:05 +08:00
|
|
|
|
#include "backup_manager_interface.h"
|
|
|
|
|
#include "globalbackupinfo.h"
|
2021-12-28 16:51:35 +08:00
|
|
|
|
#include "messageboxutils.h"
|
2022-01-28 12:06:03 +08:00
|
|
|
|
#include "aboutdialog.h"
|
2022-02-15 16:51:03 +08:00
|
|
|
|
#include "gsettingswrapper.h"
|
|
|
|
|
#include "component/mywidget.h"
|
2021-09-16 16:05:46 +08:00
|
|
|
|
|
2021-08-06 10:20:03 +08:00
|
|
|
|
MainDialog::MainDialog(QWidget *parent)
|
|
|
|
|
: QMainWindow(parent)
|
|
|
|
|
, ui(new Ui::MainDialog)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
2022-02-15 16:51:03 +08:00
|
|
|
|
// 主窗口
|
|
|
|
|
this->setWindowTitle(tr("Backup & Restore"));
|
|
|
|
|
// 窗口背景透明化;setWindowOpacity可使得窗口及其上控件都透明或半透明-w.setWindowOpacity(0.7);
|
|
|
|
|
this->setAttribute(Qt::WA_TranslucentBackground);
|
|
|
|
|
// 使得窗口无边框
|
|
|
|
|
// w.setWindowFlag(Qt::FramelessWindowHint);
|
|
|
|
|
// 指示窗口管理器模糊给定窗口后面指定区域的背景(毛玻璃化背景)
|
|
|
|
|
KWindowEffects::enableBlurBehind(this->winId(), true);
|
|
|
|
|
// 或使用设置毛玻璃属性的方式实现毛玻璃背景(两者都行,可使用其一)
|
|
|
|
|
// this->setProperty("useSystemStyleBlur", true);
|
2022-02-16 17:47:06 +08:00
|
|
|
|
this->setAutoFillBackground(true);
|
2022-02-15 16:51:03 +08:00
|
|
|
|
|
|
|
|
|
// 添加窗管协议
|
|
|
|
|
MotifWmHints hints;
|
|
|
|
|
hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
|
|
|
|
hints.functions = MWM_FUNC_ALL;
|
|
|
|
|
hints.decorations = MWM_DECOR_BORDER;
|
|
|
|
|
XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints);
|
|
|
|
|
|
2022-04-18 17:26:52 +08:00
|
|
|
|
GlobelBackupInfo::inst().setMainWidget(this);
|
|
|
|
|
|
2021-09-16 16:05:46 +08:00
|
|
|
|
initUI();
|
|
|
|
|
initConnect();
|
2021-10-26 09:24:05 +08:00
|
|
|
|
|
|
|
|
|
// 注册BackupWrapper类型,之后qdbus接口才能使用
|
|
|
|
|
BackupWrapper::registerMetaType();
|
|
|
|
|
mountBackupPartition();
|
2021-08-06 10:20:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainDialog::~MainDialog()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 16:05:46 +08:00
|
|
|
|
void MainDialog::initUI()
|
|
|
|
|
{
|
2022-01-21 16:09:08 +08:00
|
|
|
|
// 总体布局为横向布局,分为左侧和右侧
|
|
|
|
|
m_totalHLayout = new QHBoxLayout;
|
2021-09-16 16:05:46 +08:00
|
|
|
|
m_totalHLayout->setSpacing(0);
|
|
|
|
|
m_totalHLayout->setObjectName(QString::fromUtf8("m_totalHLayout"));
|
|
|
|
|
m_totalHLayout->setContentsMargins(0, 0, 0, 0);
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_totalHLayout->setSpacing(0);
|
2021-09-23 11:21:58 +08:00
|
|
|
|
ui->centralwidget->setLayout(m_totalHLayout);
|
2021-09-16 16:05:46 +08:00
|
|
|
|
|
2021-12-26 18:15:21 +08:00
|
|
|
|
if (GlobelBackupInfo::inst().isManager())
|
|
|
|
|
m_leftSiderBarWidget = new LeftsiderbarWidget(ui->centralwidget);
|
|
|
|
|
else
|
|
|
|
|
m_leftSiderBarWidget = new LeftsiderbarWidget(ui->centralwidget, LeftsiderbarWidget::StartMode::std_user);
|
2021-09-16 16:05:46 +08:00
|
|
|
|
m_leftSiderBarWidget->setObjectName(QString::fromUtf8("m_leftSiderBarWidget"));
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_leftSiderBarWidget->setFixedSize(200, 640);
|
2022-04-12 11:27:37 +08:00
|
|
|
|
m_leftSiderBarWidget->initUi();
|
2021-09-16 16:05:46 +08:00
|
|
|
|
|
|
|
|
|
m_totalHLayout->addWidget(m_leftSiderBarWidget);
|
|
|
|
|
|
2022-02-15 16:51:03 +08:00
|
|
|
|
m_rightWidget = new MyWidget;
|
2022-01-21 16:09:08 +08:00
|
|
|
|
|
|
|
|
|
m_rightVLayout = new QVBoxLayout;
|
2021-09-16 16:05:46 +08:00
|
|
|
|
m_rightVLayout->setObjectName(QString::fromUtf8("m_rightVLayout"));
|
|
|
|
|
m_rightVLayout->setContentsMargins(0, 0, 0, 0);
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_rightVLayout->setSpacing(0);
|
2021-09-16 16:05:46 +08:00
|
|
|
|
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_titleWidget = new QWidget;
|
2021-09-16 16:05:46 +08:00
|
|
|
|
m_titleWidget->setObjectName(QString::fromUtf8("m_titleWidget"));
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_titleWidget->setFixedSize(760, 40);
|
2021-09-16 16:05:46 +08:00
|
|
|
|
m_rightVLayout->addWidget(m_titleWidget);
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_rightVLayout->addStretch();
|
2021-09-16 16:05:46 +08:00
|
|
|
|
|
2022-02-22 15:49:57 +08:00
|
|
|
|
if (GlobelBackupInfo::inst().isManager() && GlobelBackupInfo::inst().hasArgRestore())
|
2021-12-26 18:15:21 +08:00
|
|
|
|
selected(FuncTypeConverter::FunType::RESTORE_SYSTEM);
|
2022-02-22 15:49:57 +08:00
|
|
|
|
else if (!GlobelBackupInfo::inst().isManager() && GlobelBackupInfo::inst().hasArgRestore())
|
|
|
|
|
selected(FuncTypeConverter::FunType::RESTORE_DATA);
|
|
|
|
|
else if (!GlobelBackupInfo::inst().isManager())
|
|
|
|
|
selected(FuncTypeConverter::FunType::BACKUP_DATA);
|
2021-12-26 18:15:21 +08:00
|
|
|
|
else
|
|
|
|
|
selected(FuncTypeConverter::FunType::BACKUP_SYSTEM);
|
2021-09-16 16:05:46 +08:00
|
|
|
|
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_rightWidget->setLayout(m_rightVLayout);
|
|
|
|
|
m_totalHLayout->addWidget(m_rightWidget);
|
|
|
|
|
m_totalHLayout->addStretch();
|
2021-09-16 16:05:46 +08:00
|
|
|
|
|
|
|
|
|
initTileBar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainDialog::initTileBar()
|
|
|
|
|
{
|
|
|
|
|
m_titleLayout = new QHBoxLayout;
|
|
|
|
|
m_titleLayout->setContentsMargins(8, 4, 4, 0);
|
|
|
|
|
m_titleLayout->setSpacing(0);
|
|
|
|
|
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_menuOptionBtn = new QToolButton;
|
|
|
|
|
m_minBtn = new QPushButton;
|
|
|
|
|
m_closeBtn = new QPushButton;
|
2021-09-16 16:05:46 +08:00
|
|
|
|
|
|
|
|
|
m_menuOptionBtn->setToolTip(tr("Main menu"));
|
|
|
|
|
m_minBtn->setToolTip(tr("Minimize"));
|
|
|
|
|
m_closeBtn->setToolTip(tr("Close"));
|
|
|
|
|
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_menuOptionBtn->setProperty("isWindowButton", 0x1);
|
|
|
|
|
m_menuOptionBtn->setProperty("useIconHighlightEffect", 0x2);
|
|
|
|
|
m_menuOptionBtn->setIcon(QIcon::fromTheme("open-menu-symbolic"));
|
2021-09-16 16:05:46 +08:00
|
|
|
|
m_menuOptionBtn->setFixedSize(30, 30);
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_menuOptionBtn->setAutoRaise(true);
|
|
|
|
|
m_menuOptionBtn->setPopupMode(QToolButton::InstantPopup);
|
|
|
|
|
// m_menuOptionBtn->setProperty("setIconHighlightEffectDefaultColor", m_closeBtn->palette().color(QPalette::Active, QPalette::Base));
|
|
|
|
|
|
|
|
|
|
m_minBtn->setProperty("isWindowButton", 0x1);
|
|
|
|
|
m_minBtn->setProperty("useIconHighlightEffect", 0x2);
|
2021-09-16 16:05:46 +08:00
|
|
|
|
m_minBtn->setFixedSize(30, 30);
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_minBtn->setFlat(true);
|
|
|
|
|
m_minBtn->setIcon(QIcon::fromTheme("window-minimize-symbolic"));
|
|
|
|
|
// m_minBtn->setProperty("setIconHighlightEffectDefaultColor", m_closeBtn->palette().color(QPalette::Active, QPalette::Base));
|
|
|
|
|
|
|
|
|
|
m_closeBtn->setProperty("isWindowButton", 0x2);
|
|
|
|
|
m_closeBtn->setProperty("useIconHighlightEffect", 0x8);
|
2021-09-16 16:05:46 +08:00
|
|
|
|
m_closeBtn->setFixedSize(30, 30);
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_closeBtn->setFlat(true);
|
|
|
|
|
m_closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic"));
|
|
|
|
|
// m_closeBtn->setProperty("setIconHighlightEffectDefaultColor", m_closeBtn->palette().color(QPalette::Active, QPalette::Base));
|
2021-09-16 16:05:46 +08:00
|
|
|
|
|
2022-01-21 16:09:08 +08:00
|
|
|
|
QMenu* backupMain = new QMenu(m_titleWidget);
|
2021-09-16 16:05:46 +08:00
|
|
|
|
backupMain->setObjectName("mainMenu");
|
|
|
|
|
m_menuOptionBtn->setMenu(backupMain);
|
|
|
|
|
|
2022-02-21 11:04:44 +08:00
|
|
|
|
// 暂时只需跟随主题,浅色主题和深色主题后续可能会独立出来
|
|
|
|
|
// QAction* backupTheme = new QAction(tr("Theme"), m_titleWidget);
|
|
|
|
|
// backupMain->addAction(backupTheme);
|
|
|
|
|
// QMenu* selectTheme = new QMenu( m_titleWidget);
|
|
|
|
|
// selectTheme->setObjectName("selectTheme");
|
|
|
|
|
// backupTheme->setMenu(selectTheme);
|
|
|
|
|
// QAction* defaultTheme = new QAction(tr("Auto"), m_titleWidget);
|
|
|
|
|
// selectTheme->addAction(defaultTheme);
|
|
|
|
|
// QAction* lightTheme = new QAction(tr("Light"), m_titleWidget);
|
|
|
|
|
// selectTheme->addAction(lightTheme);
|
|
|
|
|
// QAction* darkTheme = new QAction(tr("Dark"), m_titleWidget);
|
|
|
|
|
// selectTheme->addAction(darkTheme);
|
2021-09-16 16:05:46 +08:00
|
|
|
|
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_backupHelp = new QAction(tr("Help"), m_titleWidget);
|
2022-03-09 15:36:34 +08:00
|
|
|
|
m_backupHelp->setShortcut(QKeySequence::HelpContents);
|
2021-09-16 16:05:46 +08:00
|
|
|
|
backupMain->addAction(m_backupHelp);
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_backupAbout = new QAction(tr("About"), m_titleWidget);
|
2021-09-16 16:05:46 +08:00
|
|
|
|
backupMain->addAction(m_backupAbout);
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_backupExit = new QAction(tr("Exit"), m_titleWidget);
|
2021-09-16 16:05:46 +08:00
|
|
|
|
backupMain->addAction(m_backupExit);
|
|
|
|
|
|
|
|
|
|
m_titleLayout->addStretch();
|
|
|
|
|
m_titleLayout->addWidget(m_menuOptionBtn);
|
|
|
|
|
m_titleLayout->addSpacing(4);
|
|
|
|
|
m_titleLayout->addWidget(m_minBtn);
|
|
|
|
|
m_titleLayout->addSpacing(4);
|
|
|
|
|
m_titleLayout->addWidget(m_closeBtn);
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_titleWidget->setLayout(m_titleLayout);
|
2021-09-16 16:05:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainDialog::initConnect()
|
|
|
|
|
{
|
2021-11-17 13:23:38 +08:00
|
|
|
|
// 左侧功能选择栏
|
|
|
|
|
connect(m_leftSiderBarWidget, &LeftsiderbarWidget::selected, this, &MainDialog::selected);
|
|
|
|
|
|
2021-09-16 16:05:46 +08:00
|
|
|
|
// 标题栏右侧按钮区域
|
|
|
|
|
// 退出
|
|
|
|
|
connect(m_backupExit, &QAction::triggered, this, &MainDialog::closeBtn);
|
|
|
|
|
|
|
|
|
|
// 关于
|
|
|
|
|
connect(m_backupAbout, &QAction::triggered, this, [=] {
|
2022-01-28 12:06:03 +08:00
|
|
|
|
AboutDialog *about = new AboutDialog(this);
|
|
|
|
|
about->exec();
|
|
|
|
|
about->deleteLater();
|
2021-09-16 16:05:46 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(m_backupHelp, &QAction::triggered, this, [=] {
|
|
|
|
|
QProcess process(this);
|
|
|
|
|
process.startDetached("kylin-user-guide -A kybackup");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//最小化按钮
|
|
|
|
|
connect(m_minBtn, &QPushButton::clicked, this, &MainDialog::showMinimized);
|
|
|
|
|
|
|
|
|
|
//关闭按钮
|
|
|
|
|
connect(m_closeBtn, &QPushButton::clicked, this, &MainDialog::closeBtn);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-17 13:23:38 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief 左侧功能选择栏响应槽
|
|
|
|
|
* @param func_type,功能类型
|
|
|
|
|
*/
|
|
|
|
|
void MainDialog::selected(int func_type)
|
|
|
|
|
{
|
|
|
|
|
if (GlobelBackupInfo::inst().getFuncType() == func_type)
|
|
|
|
|
return ;
|
|
|
|
|
|
|
|
|
|
if (m_stackedWidget) {
|
|
|
|
|
m_rightVLayout->removeWidget(m_stackedWidget);
|
|
|
|
|
delete m_stackedWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (func_type) {
|
|
|
|
|
case FuncTypeConverter::FunType::BACKUP_SYSTEM:
|
2022-04-18 17:26:52 +08:00
|
|
|
|
m_stackedWidget = new SystemBackup(m_rightWidget);
|
2021-11-17 13:23:38 +08:00
|
|
|
|
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::BACKUP_SYSTEM);
|
|
|
|
|
break;
|
|
|
|
|
case FuncTypeConverter::FunType::RESTORE_SYSTEM:
|
2022-04-18 17:26:52 +08:00
|
|
|
|
m_stackedWidget = new SystemRestore(m_rightWidget);
|
2021-11-17 13:23:38 +08:00
|
|
|
|
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::RESTORE_SYSTEM);
|
|
|
|
|
break;
|
2021-12-26 18:15:21 +08:00
|
|
|
|
case FuncTypeConverter::FunType::BACKUP_DATA:
|
2022-04-18 17:26:52 +08:00
|
|
|
|
m_stackedWidget = new DataBackup(m_rightWidget);
|
2021-12-26 18:15:21 +08:00
|
|
|
|
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::BACKUP_DATA);
|
|
|
|
|
break;
|
2021-12-28 16:51:35 +08:00
|
|
|
|
case FuncTypeConverter::FunType::RESTORE_DATA:
|
2022-04-18 17:26:52 +08:00
|
|
|
|
m_stackedWidget = new DataRestore(m_rightWidget);
|
2021-12-28 16:51:35 +08:00
|
|
|
|
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::RESTORE_DATA);
|
|
|
|
|
break;
|
2021-12-30 10:27:03 +08:00
|
|
|
|
case FuncTypeConverter::FunType::OPERATION_LOG:
|
2022-04-18 17:26:52 +08:00
|
|
|
|
m_stackedWidget = new OperationLog(m_rightWidget);
|
2021-12-30 10:27:03 +08:00
|
|
|
|
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::OPERATION_LOG);
|
|
|
|
|
break;
|
2022-01-13 14:06:40 +08:00
|
|
|
|
case FuncTypeConverter::FunType::GHOST_IMAGE:
|
2022-04-18 17:26:52 +08:00
|
|
|
|
m_stackedWidget = new GhostImage(m_rightWidget);
|
2022-01-13 14:06:40 +08:00
|
|
|
|
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::GHOST_IMAGE);
|
|
|
|
|
break;
|
2021-11-17 13:23:38 +08:00
|
|
|
|
default:
|
2022-04-18 17:26:52 +08:00
|
|
|
|
m_stackedWidget = new SystemBackup(m_rightWidget);
|
2021-11-17 13:23:38 +08:00
|
|
|
|
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::BACKUP_SYSTEM);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_stackedWidget->setObjectName(QString::fromUtf8("m_stackedWidget"));
|
2022-01-21 16:09:08 +08:00
|
|
|
|
m_stackedWidget->setFixedSize(760, 600);
|
2021-11-17 13:23:38 +08:00
|
|
|
|
m_rightVLayout->addWidget(m_stackedWidget);
|
2022-02-22 15:49:57 +08:00
|
|
|
|
|
|
|
|
|
m_leftSiderBarWidget->setCheckedFunc(func_type);
|
2021-11-17 13:23:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 16:05:46 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief 多例启动信息槽
|
|
|
|
|
* @param msg 信息,里面存放新启动实例的账户id
|
|
|
|
|
*/
|
|
|
|
|
void MainDialog::sltMessageReceived(const QString &msg)
|
|
|
|
|
{
|
|
|
|
|
QString user = QString::number(getuid());
|
|
|
|
|
if (msg == user) {
|
|
|
|
|
// this->setWindowFlag(Qt::WindowStaysOnTopHint,true);
|
|
|
|
|
// this->setWindowFlag(Qt::WindowStaysOnTopHint,false);
|
|
|
|
|
KWindowSystem::forceActiveWindow(this->winId());
|
|
|
|
|
this->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-26 09:24:05 +08:00
|
|
|
|
void MainDialog::mountBackupPartition()
|
|
|
|
|
{
|
|
|
|
|
// 挂载/backup分区
|
|
|
|
|
ComKylinBackupManagerInterface intf("com.kylin.backup", "/", QDBusConnection::systemBus());
|
|
|
|
|
QDBusPendingReply<int> reply = intf.Mount_backup_partition();
|
|
|
|
|
reply.waitForFinished();
|
|
|
|
|
if (reply.isError()) {
|
|
|
|
|
// 挂载分区时出现异常
|
2022-02-15 16:51:03 +08:00
|
|
|
|
MessageBoxUtils::QMESSAGE_BOX_CRITICAL(this, QObject::tr("Warning"),
|
2021-12-28 16:51:35 +08:00
|
|
|
|
QObject::tr("An exception occurred when mounting backup partition."),
|
|
|
|
|
QObject::tr("Ok"));
|
2021-10-26 09:24:05 +08:00
|
|
|
|
|
2022-02-23 16:00:42 +08:00
|
|
|
|
// 此时还未进入应用的事件循环中,故不能使用qApp->quit();
|
|
|
|
|
exit(1);
|
2021-10-26 09:24:05 +08:00
|
|
|
|
} else if (int(MountResult::CANNOT_GET_BACKUPUUID) == reply.value()) {
|
|
|
|
|
// 没有找到备份分区,只能备份到移动设备中
|
2022-04-19 16:13:38 +08:00
|
|
|
|
// MessageBoxUtils::QMESSAGE_BOX_WARNING(this, QObject::tr("Information"),
|
|
|
|
|
// QObject::tr("Please check if the backup partition exists which can be created when you install the Operating System."),
|
|
|
|
|
// QObject::tr("Ok"));
|
|
|
|
|
// // 此时还未进入应用的事件循环中,故不能使用qApp->quit();
|
|
|
|
|
// exit(1);
|
|
|
|
|
GlobelBackupInfo::inst().setHasBackupPartition(false);
|
2021-10-26 09:24:05 +08:00
|
|
|
|
} else if (int(MountResult::MOUNTED) != reply.value()) {
|
|
|
|
|
// 挂载备份分区失败
|
2022-02-15 16:51:03 +08:00
|
|
|
|
MessageBoxUtils::QMESSAGE_BOX_CRITICAL(this, QObject::tr("Warning"),
|
2021-12-28 16:51:35 +08:00
|
|
|
|
QObject::tr("Failed to mount backup partition."),
|
|
|
|
|
QObject::tr("Ok"));
|
2021-10-26 09:24:05 +08:00
|
|
|
|
|
2022-02-23 16:00:42 +08:00
|
|
|
|
// 此时还未进入应用的事件循环中,故不能使用qApp->quit();
|
|
|
|
|
exit(1);
|
2021-10-26 09:24:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainDialog::umountBackupPartition()
|
|
|
|
|
{
|
|
|
|
|
// 卸载/backup分区
|
|
|
|
|
ComKylinBackupManagerInterface intf("com.kylin.backup", "/", QDBusConnection::systemBus());
|
|
|
|
|
intf.umountBackupPartition();
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-24 12:19:06 +08:00
|
|
|
|
void MainDialog::closeEvent(QCloseEvent *e)
|
2021-09-16 16:05:46 +08:00
|
|
|
|
{
|
2021-10-26 09:24:05 +08:00
|
|
|
|
if (GlobelBackupInfo::inst().isBusy()) {
|
2021-12-28 16:51:35 +08:00
|
|
|
|
// 系统正忙,请稍等
|
|
|
|
|
MessageBoxUtils::QMESSAGE_BOX_WARNING(this, QObject::tr("Warning"),
|
|
|
|
|
QObject::tr("It's busy, please wait"),
|
|
|
|
|
QObject::tr("Ok"));
|
2021-10-26 09:24:05 +08:00
|
|
|
|
|
2022-02-24 12:19:06 +08:00
|
|
|
|
e->ignore();
|
2021-10-26 09:24:05 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GlobelBackupInfo::inst().hasBackupPartition())
|
|
|
|
|
umountBackupPartition();
|
|
|
|
|
|
2022-02-24 12:19:06 +08:00
|
|
|
|
e->accept();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainDialog::closeBtn()
|
|
|
|
|
{
|
|
|
|
|
if (this->close()) {
|
|
|
|
|
qApp->quit();
|
|
|
|
|
}
|
2021-09-16 16:05:46 +08:00
|
|
|
|
}
|
|
|
|
|
|