From 52dbd4c861b002f4d976f8f10f14f439963a90e1 Mon Sep 17 00:00:00 2001 From: zhaominyong Date: Wed, 23 Mar 2022 17:36:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=B8=83=E5=B1=80=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backup-daemon/myprocess/calcbackupsize.cpp | 1 - kybackup/component/linelabel.cpp | 5 +- kybackup/component/linelabel.h | 2 +- kybackup/module/databackup.cpp | 417 +++++++++++++-------- kybackup/module/datarestore.cpp | 124 +++--- kybackup/module/ghostimage.cpp | 137 ++++--- kybackup/module/systembackup.cpp | 361 ++++++++++++------ kybackup/module/systemrestore.cpp | 120 +++--- 8 files changed, 703 insertions(+), 464 deletions(-) diff --git a/backup-daemon/myprocess/calcbackupsize.cpp b/backup-daemon/myprocess/calcbackupsize.cpp index 1fd5ea3..33557f6 100755 --- a/backup-daemon/myprocess/calcbackupsize.cpp +++ b/backup-daemon/myprocess/calcbackupsize.cpp @@ -91,7 +91,6 @@ void CalcBackupSize::parseResult() QString out(m_process->readAll()); QStringList lines = out.split("\n"); qDebug() << out; - m_size = 0; for (QString& line : lines) { // 获取文件夹数目 if (line.startsWith("Number of files:")) { diff --git a/kybackup/component/linelabel.cpp b/kybackup/component/linelabel.cpp index 3ed644b..8500514 100755 --- a/kybackup/component/linelabel.cpp +++ b/kybackup/component/linelabel.cpp @@ -2,11 +2,12 @@ #include #include -LineLabel::LineLabel(QWidget* parent /*= nullptr*/, QColor color /*= QColor(0xCC, 0xCC, 0xCC)*/, QSize size /*= QSize(150, 24)*/) : +LineLabel::LineLabel(QWidget* parent /*= nullptr*/, QColor color /*= QColor(0xCC, 0xCC, 0xCC)*/) : QLabel(parent), m_color(color) { - setFixedSize(size); + setMaximumHeight(30); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); } LineLabel::~LineLabel() diff --git a/kybackup/component/linelabel.h b/kybackup/component/linelabel.h index 4f2d756..e8f78a5 100755 --- a/kybackup/component/linelabel.h +++ b/kybackup/component/linelabel.h @@ -12,7 +12,7 @@ class LineLabel : public QLabel { Q_OBJECT public: - LineLabel(QWidget* parent = nullptr, QColor color = QColor(0xCC, 0xCC, 0xCC), QSize size = QSize(150, 24)); + LineLabel(QWidget* parent = nullptr, QColor color = QColor(0xCC, 0xCC, 0xCC)); virtual ~LineLabel(); protected: diff --git a/kybackup/module/databackup.cpp b/kybackup/module/databackup.cpp index f369b2e..de2b12b 100755 --- a/kybackup/module/databackup.cpp +++ b/kybackup/module/databackup.cpp @@ -261,14 +261,13 @@ void DataBackup::initSecondWidget() // 备份路径选择提示(新建数据备份时显示) MyLabel* labelPathSelect = new MyLabel(second); labelPathSelect->setDeplayText(tr("Please select backup position")); - labelPathSelect->setFixedWidth(600); - labelPathSelect->setFixedHeight(27); + labelPathSelect->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QFont font; font.setBold(true); font.setPixelSize(18); labelPathSelect->setFont(font); hlayoutLine1->addWidget(labelPathSelect); - hlayoutLine1->addStretch(); + hlayoutLine1->setAlignment(Qt::AlignLeft); vlayout->addLayout(hlayoutLine1); // 第二行 @@ -278,7 +277,7 @@ void DataBackup::initSecondWidget() // 备份路径选择框 QComboBox* comboSelect = new QComboBox(second); QPalette palette = comboSelect->palette(); - comboSelect->setFixedSize(680, 36); + comboSelect->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); // 添加本地默认路径、移动设备目录 connect(m_udector, &UdiskDetector::udiskListChanged, this, [=](QList diskList) { comboSelect->clear(); @@ -301,7 +300,7 @@ void DataBackup::initSecondWidget() }); m_udector->getStorageInfo(); hlayoutLine2->addWidget(comboSelect); - hlayoutLine2->addStretch(); + hlayoutLine2->addSpacing(35); vlayout->addLayout(hlayoutLine2); vlayout->addSpacing(30); @@ -311,11 +310,12 @@ void DataBackup::initSecondWidget() // label:选择备份数据 MyLabel* labelDataBackup = new MyLabel; labelDataBackup->setDeplayText(tr("Select backup data")); - labelDataBackup->setFixedWidth(600); - labelDataBackup->setFixedHeight(27); +// labelDataBackup->setFixedWidth(600); +// labelDataBackup->setFixedHeight(27); + labelDataBackup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); labelDataBackup->setFont(font); hlayoutLine3->addWidget(labelDataBackup); - hlayoutLine3->addStretch(); + hlayoutLine3->addSpacing(35); vlayout->addLayout(hlayoutLine3); // 第四行 @@ -324,7 +324,7 @@ void DataBackup::initSecondWidget() hlayoutLine4->addSpacing(30); // 所选备份路径编辑框 QLineEdit *editSelect = new QLineEdit; - editSelect->setMinimumWidth(460); + // editSelect->setMinimumWidth(460); editSelect->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); editSelect->setMaxLength(255); editSelect->setTextMargins(0, 0, 62, 0); @@ -380,11 +380,10 @@ void DataBackup::initSecondWidget() // 备份列表 BackupListWidget *listWidget = new BackupListWidget; - listWidget->setMinimumSize(680, 240); listWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); listWidget->setPathLimit(pathLimits); hlayoutLine5->addWidget(listWidget); - hlayoutLine5->addStretch(); + hlayoutLine5->addSpacing(35); vlayout->addLayout(hlayoutLine5); // 最后一行 @@ -420,9 +419,10 @@ void DataBackup::initSecondWidget() hlayoutLastLine->addSpacing(20); hlayoutLastLine->addWidget(nextStep); hlayoutLastLine->addStretch(); + hlayoutLastLine->setAlignment(Qt::AlignCenter); vlayout->addLayout(hlayoutLastLine); - vlayout->addStretch(); + vlayout->addSpacing(20); second->setLayout(vlayout); connect(buttonAdd, &QPushButton::clicked, this, [=]() { @@ -515,14 +515,13 @@ void DataBackup::initSecondWidget_inc() // 默认备份位置 MyLabel* labelPathSelect = new MyLabel(second); labelPathSelect->setDeplayText(tr("Default backup location")); - labelPathSelect->setFixedWidth(600); - labelPathSelect->setFixedHeight(27); + labelPathSelect->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QFont font; font.setBold(true); font.setPixelSize(18); labelPathSelect->setFont(font); hlayoutLine1->addWidget(labelPathSelect); - hlayoutLine1->addStretch(); + hlayoutLine1->setAlignment(Qt::AlignLeft); vlayout->addLayout(hlayoutLine1); // 第二行 @@ -531,7 +530,7 @@ void DataBackup::initSecondWidget_inc() hlayoutLine2->addSpacing(30); // 默认备份位置展示 MyLabel* labelBackupPosition = new MyLabel(second); - labelBackupPosition->setFixedWidth(700); + labelBackupPosition->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); if (m_isLocal) { QString qsLocalDefaultPath = Utils::getSysRootPath() + BACKUP_SNAPSHOTS_PATH; qsLocalDefaultPath.replace("//", "/"); @@ -543,7 +542,7 @@ void DataBackup::initSecondWidget_inc() } labelBackupPosition->setEnabled(false); hlayoutLine2->addWidget(labelBackupPosition); - hlayoutLine2->addStretch(); + hlayoutLine2->addSpacing(35); vlayout->addLayout(hlayoutLine2); vlayout->addSpacing(30); @@ -553,11 +552,10 @@ void DataBackup::initSecondWidget_inc() // label:选择备份数据 MyLabel* labelDataBackup = new MyLabel; labelDataBackup->setDeplayText(tr("Select backup data")); - labelDataBackup->setFixedWidth(600); - labelDataBackup->setFixedHeight(27); + labelDataBackup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); labelDataBackup->setFont(font); hlayoutLine3->addWidget(labelDataBackup); - hlayoutLine3->addStretch(); + hlayoutLine3->addSpacing(35); vlayout->addLayout(hlayoutLine3); // 第四行 @@ -566,8 +564,7 @@ void DataBackup::initSecondWidget_inc() hlayoutLine4->addSpacing(30); // 所选备份路径编辑框 QLineEdit *editSelect = new QLineEdit; - editSelect->setMinimumWidth(460); - editSelect->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + editSelect->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); editSelect->setMaxLength(255); editSelect->setTextMargins(0, 0, 62, 0); QHBoxLayout *searchLayout = new QHBoxLayout(editSelect); @@ -606,7 +603,6 @@ void DataBackup::initSecondWidget_inc() buttonSelect->setText(tr("Select")); hlayoutLine4->addWidget(editSelect); hlayoutLine4->addWidget(buttonSelect); - // hlayoutLine4->addStretch(); hlayoutLine4->addSpacing(35); vlayout->addLayout(hlayoutLine4); @@ -620,11 +616,10 @@ void DataBackup::initSecondWidget_inc() getPathsLimit(pathLimits, siderUrls); // 备份列表 BackupListWidget *listWidget = new BackupListWidget; - listWidget->setMinimumSize(680, 240); listWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); listWidget->setPathLimit(pathLimits); hlayoutLine5->addWidget(listWidget); - hlayoutLine5->addStretch(); + hlayoutLine5->addSpacing(35); vlayout->addLayout(hlayoutLine5); // 最后一行 @@ -649,9 +644,10 @@ void DataBackup::initSecondWidget_inc() hlayoutLastLine->addSpacing(20); hlayoutLastLine->addWidget(nextStep); hlayoutLastLine->addStretch(); + hlayoutLastLine->setAlignment(Qt::AlignCenter); vlayout->addLayout(hlayoutLastLine); - vlayout->addStretch(); + vlayout->addSpacing(20); second->setLayout(vlayout); connect(buttonAdd, &QPushButton::clicked, this, [=]() { @@ -741,42 +737,64 @@ void DataBackup::addOldBackupPaths(BackupListWidget *listWidget) void DataBackup::initThirdWidget() { QWidget *third = new QWidget; + QVBoxLayout *vlayout = new QVBoxLayout; + vlayout->addSpacing(40); // 流程进度提示栏 CircleLable *one = new CircleLable("1", third, 24, QColor(COLOR_BLUE)); - one->move(QPoint(81, 41)); LineLabel *line1 = new LineLabel(third, QColor(COLOR_BLUE)); - line1->move(QPoint(108, 41)); CircleLable *two = new CircleLable("2", third); - two->move(QPoint(261, 41)); LineLabel *line2 = new LineLabel(third); - line2->move(QPoint(288, 41)); CircleLable *three = new CircleLable("3", third); - three->move(QPoint(441, 41)); LineLabel *line3 = new LineLabel(third); - line3->move(QPoint(468, 41)); CircleLable *four = new CircleLable("4", third); - four->move(QPoint(621, 41)); + + QHBoxLayout *hlayoutTopLine1 = new QHBoxLayout; + hlayoutTopLine1->addSpacing(80); + hlayoutTopLine1->addWidget(one); + hlayoutTopLine1->addWidget(line1); + hlayoutTopLine1->addWidget(two); + hlayoutTopLine1->addWidget(line2); + hlayoutTopLine1->addWidget(three); + hlayoutTopLine1->addWidget(line3); + hlayoutTopLine1->addWidget(four); + hlayoutTopLine1->addSpacing(80); + vlayout->addLayout(hlayoutTopLine1); + MyLabel *label1 = new MyLabel(tr("checking"), third); label1->setFontColor(QColor(COLOR_BLUE)); - label1->setGeometry(11, 72, 164, 30); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("preparing"), third); - label2->setGeometry(191, 72, 164, 30); label2->setEnabled(false); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("backuping"), third); - label3->setGeometry(371, 72, 164, 30); label3->setEnabled(false); + label3->setFixedWidth(164); MyLabel *label4 = new MyLabel(tr("finished"), third); - label4->setGeometry(551, 72, 164, 30); label4->setEnabled(false); + label4->setFixedWidth(164); + + QHBoxLayout *hlayoutTopLine2 = new QHBoxLayout; + hlayoutTopLine2->addSpacing(11); + hlayoutTopLine2->addWidget(label1); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label2); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label3); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label4); + hlayoutTopLine2->addSpacing(11); + vlayout->addLayout(hlayoutTopLine2); + + vlayout->addSpacing(100); // ------------ 中部布局begin------------- - QVBoxLayout *vlayout = new QVBoxLayout(third); - vlayout->addSpacing(180); + QHBoxLayout *hlayout = new QHBoxLayout; hlayout->addStretch(); - + hlayout->addSpacing(80); QWidget *centerFont = new QWidget(third); + centerFont->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; // 第一行 @@ -795,10 +813,10 @@ void DataBackup::initThirdWidget() // 检测中大标题 MyLabel *bigTitle = new MyLabel(centerFont); bigTitle->setFontSize(24); - bigTitle->setMaximumWidth(550); bigTitle->setIsOriginal(true); + bigTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont1->addWidget(bigTitle); - hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont1); // 第二行 @@ -809,13 +827,12 @@ void DataBackup::initThirdWidget() hlayoutCenterFont2->addWidget(dot1); hlayoutCenterFont2->addSpacing(5); MyLabel *labelCheck1 = new MyLabel(centerFont); - labelCheck1->setMinimumWidth(300); - labelCheck1->setMaximumWidth(500); labelCheck1->setIsOriginal(true); labelCheck1->setWordWrap(true); labelCheck1->adjustSize(); + labelCheck1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont2->addWidget(labelCheck1); - hlayoutCenterFont2->addStretch(); + hlayoutCenterFont2->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont2); // 第三行 @@ -826,13 +843,12 @@ void DataBackup::initThirdWidget() hlayoutCenterFont3->addWidget(dot2); hlayoutCenterFont3->addSpacing(5); MyLabel *labelCheck2 = new MyLabel(centerFont); - labelCheck2->setMinimumWidth(300); - labelCheck2->setMaximumWidth(500); labelCheck2->setIsOriginal(true); labelCheck2->setWordWrap(true); labelCheck2->adjustSize(); + labelCheck2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont3->addWidget(labelCheck2); - hlayoutCenterFont3->addStretch(); + hlayoutCenterFont3->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont3); // 第四行 @@ -840,8 +856,7 @@ void DataBackup::initThirdWidget() // 第五行 QHBoxLayout *hlayoutCenterFont5 = new QHBoxLayout; - // hlayoutCenterFont5->addStretch(); - hlayoutCenterFont5->addSpacing(30); + hlayoutCenterFont5->addStretch(); // 上一步按钮 MyPushButton *preStep = new MyPushButton(centerFont); preStep->setText(tr("Back")); @@ -876,13 +891,16 @@ void DataBackup::initThirdWidget() }); hlayoutCenterFont5->addWidget(recheck); hlayoutCenterFont5->addStretch(); + hlayoutCenterFont5->setAlignment(Qt::AlignCenter); vlayoutCenterFont->addLayout(hlayoutCenterFont5); - centerFont->setLayout(vlayoutCenterFont); hlayout->addWidget(centerFont); + hlayout->addSpacing(80); hlayout->addStretch(); + hlayout->setAlignment(Qt::AlignCenter); vlayout->addLayout(hlayout); + vlayout->addStretch(); third->setLayout(vlayout); // ------------ 中部布局end------------- @@ -1071,42 +1089,69 @@ void DataBackup::on_checkEnv_end(int result) void DataBackup::initForthWidget() { QWidget *forth = new QWidget; + QVBoxLayout *vlayout = new QVBoxLayout; + vlayout->addSpacing(40); // 流程进度提示栏 CircleLable *one = new CircleLable("1", forth, 24, QColor(COLOR_BLUE)); - one->move(QPoint(81, 41)); LineLabel *line1 = new LineLabel(forth, QColor(COLOR_BLUE)); - line1->move(QPoint(108, 41)); CircleLable *two = new CircleLable("2", forth, 24, QColor(COLOR_BLUE)); - two->move(QPoint(261, 41)); LineLabel *line2 = new LineLabel(forth, QColor(COLOR_BLUE)); - line2->move(QPoint(288, 41)); CircleLable *three = new CircleLable("3", forth); - three->move(QPoint(441, 41)); LineLabel *line3 = new LineLabel(forth); - line3->move(QPoint(468, 41)); CircleLable *four = new CircleLable("4", forth); - four->move(QPoint(621, 41)); + + QHBoxLayout *hlayoutTopLine1 = new QHBoxLayout; + hlayoutTopLine1->addSpacing(80); + hlayoutTopLine1->addWidget(one); + hlayoutTopLine1->addWidget(line1); + hlayoutTopLine1->addWidget(two); + hlayoutTopLine1->addWidget(line2); + hlayoutTopLine1->addWidget(three); + hlayoutTopLine1->addWidget(line3); + hlayoutTopLine1->addWidget(four); + hlayoutTopLine1->addSpacing(80); + vlayout->addLayout(hlayoutTopLine1); + MyLabel *label1 = new MyLabel(tr("checking"), forth); label1->setFontColor(QColor(COLOR_BLUE)); - label1->setGeometry(11, 72, 164, 30); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("preparing"), forth); label2->setFontColor(QColor(COLOR_BLUE)); - label2->setGeometry(191, 72, 164, 30); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("backuping"), forth); - label3->setGeometry(371, 72, 164, 30); + label3->setFixedWidth(164); label3->setEnabled(false); MyLabel *label4 = new MyLabel(tr("finished"), forth); - label4->setGeometry(551, 72, 164, 30); + label4->setFixedWidth(164); label4->setEnabled(false); + QHBoxLayout *hlayoutTopLine2 = new QHBoxLayout; + hlayoutTopLine2->addSpacing(11); + hlayoutTopLine2->addWidget(label1); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label2); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label3); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label4); + hlayoutTopLine2->addSpacing(11); + vlayout->addLayout(hlayoutTopLine2); + + vlayout->addSpacing(80); + + // ------------ 中部布局begin------------- + + // 中部第一行 + QHBoxLayout *hlayoutCenterLine1 = new QHBoxLayout; // 备份名称 MyLabel *labelBackupName = new MyLabel(forth); - labelBackupName->setGeometry(81, 178, 150, 30); - labelBackupName->setAlignment(Qt::AlignRight); + labelBackupName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + labelBackupName->setAlignment(Qt::AlignRight | Qt::AlignHCenter); labelBackupName->setDeplayText(tr("Backup Name")); MyLineEdit *editBackupName = new MyLineEdit(forth); - editBackupName->setGeometry(238, 172, 350, 40); + editBackupName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + editBackupName->setMinimumWidth(350); editBackupName->setMaxLength(64); if (m_backupName.isEmpty()) editBackupName->setPlaceholderText(QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss")); @@ -1118,16 +1163,40 @@ void DataBackup::initForthWidget() QRegExp regx("^[\u4e00-\u9fa5a-zA-Z0-9-@& +():'()——《》‘’:“”]*$"); QValidator *validator = new QRegExpValidator(regx); editBackupName->setValidator(validator); + labelBackupName->setFixedHeight(editBackupName->height()); + + hlayoutCenterLine1->addStretch(); + hlayoutCenterLine1->addWidget(labelBackupName); + hlayoutCenterLine1->addWidget(editBackupName); + hlayoutCenterLine1->addSpacing(40); + hlayoutCenterLine1->addStretch(); + hlayoutCenterLine1->setAlignment(Qt::AlignCenter); + vlayout->addLayout(hlayoutCenterLine1); + + // 中部第二行 +// QHBoxLayout *hlayoutCenterLine2 = new QHBoxLayout; // 备份名称错误提示 MyLabel *labelError = new MyLabel(forth); - labelError->setGeometry(238, 215, 500, 30); + labelError->setFixedSize(editBackupName->size()); labelError->setFontSize(14); labelError->setFontColor(Qt::red); labelError->setVisible(false); + labelError->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + +// hlayoutCenterLine2->addStretch(); +// hlayoutCenterLine2->addSpacing(labelBackupName->width() + 10); // 和上一行对齐 +// hlayoutCenterLine2->addWidget(labelError); +// hlayoutCenterLine2->addSpacing(40); +// hlayoutCenterLine2->addStretch(); +// hlayoutCenterLine2->setAlignment(Qt::AlignCenter); +// vlayout->addLayout(hlayoutCenterLine2); + connect(editBackupName, &MyLineEdit::textChanged, this, [=](const QString &text) { if (!text.isEmpty() && text != this->m_backupName && this->isExistsBackupName(text)) { labelError->setDeplayText(tr("Name already exists")); labelError->setVisible(true); + + labelError->move(editBackupName->geometry().left(), editBackupName->geometry().bottom() + 10); } else { labelError->setDeplayText(""); labelError->setVisible(false); @@ -1144,17 +1213,21 @@ void DataBackup::initForthWidget() labelError->setVisible(false); }); + vlayout->addSpacing(50); + // 中部第三行 + QHBoxLayout *hlayoutCenterLine3 = new QHBoxLayout; + hlayoutCenterLine3->addStretch(); // 上一步按钮 MyPushButton *preStep = new MyPushButton(forth); - preStep->setGeometry(271, 268, 97, 36); preStep->setText(tr("Back")); preStep->setEnabled(true); preStep->setAutoRepeat(true); connect(preStep, &MyPushButton::clicked, this, &DataBackup::on_pre_clicked); + hlayoutCenterLine3->addWidget(preStep); + hlayoutCenterLine3->addSpacing(20); // 下一步按钮 MyPushButton *nextStep = new MyPushButton(forth); - nextStep->setGeometry(389, 268, 97, 36); nextStep->setText(tr("Next")); nextStep->setEnabled(true); nextStep->setAutoRepeat(true); @@ -1179,6 +1252,13 @@ void DataBackup::initForthWidget() } } }); + hlayoutCenterLine3->addWidget(nextStep); + hlayoutCenterLine3->addStretch(); + hlayoutCenterLine3->setAlignment(Qt::AlignCenter); + vlayout->addLayout(hlayoutCenterLine3); + + vlayout->addStretch(); + forth->setLayout(vlayout); addWidget(forth); } @@ -1225,28 +1305,30 @@ bool DataBackup::isExistsBackupName(const QString & backupName) if (!uuidFound.isEmpty()) return true; + return false; + // 然后,校验xml和log中的备份记录(这一步只是为了保险而兼容老版本的备份,以前的唯一性文件中只有U盘的备份) - QList backupPointList = getBackupPointList(); - QList list = Utils::getBackupLogList(); - QSet setName; - for (BackupWrapper& wraper : list) { - if (wraper.m_backupName == wraper.m_uuid) { - // 如果在xml中不存在,则说明是此备份点是之前存在的备份点,现在已经删除 - for (const ParseBackupList::BackupPoint & backupPonit : backupPointList) { - if (backupPonit.m_uuid == wraper.m_uuid) { - wraper.m_backupName = backupPonit.m_backupName; - } - } - } +// QList backupPointList = getBackupPointList(); +// QList list = Utils::getBackupLogList(); +// QSet setName; +// for (BackupWrapper& wraper : list) { +// if (wraper.m_backupName == wraper.m_uuid) { +// // 如果在xml中不存在,则说明是此备份点是之前存在的备份点,现在已经删除 +// for (const ParseBackupList::BackupPoint & backupPonit : backupPointList) { +// if (backupPonit.m_uuid == wraper.m_uuid) { +// wraper.m_backupName = backupPonit.m_backupName; +// } +// } +// } - // type==8为删除备份点操作 - if (BackupType::DELETE_BACKUP == wraper.m_type) - setName.remove(wraper.m_backupName); - else - setName.insert(wraper.m_backupName); - } +// // type==8为删除备份点操作 +// if (BackupType::DELETE_BACKUP == wraper.m_type) +// setName.remove(wraper.m_backupName); +// else +// setName.insert(wraper.m_backupName); +// } - return setName.contains(backupName); +// return setName.contains(backupName); } /** @@ -1255,100 +1337,110 @@ bool DataBackup::isExistsBackupName(const QString & backupName) void DataBackup::initFifthWidget() { QWidget *fifth = new QWidget; + QVBoxLayout *vlayout = new QVBoxLayout; + vlayout->setSpacing(10); + vlayout->addSpacing(40); // 流程进度提示栏 CircleLable *one = new CircleLable("1", fifth, 24, QColor(COLOR_BLUE)); - one->move(QPoint(81, 41)); LineLabel *line1 = new LineLabel(fifth, QColor(COLOR_BLUE)); - line1->move(QPoint(108, 41)); CircleLable *two = new CircleLable("2", fifth, 24, QColor(COLOR_BLUE)); - two->move(QPoint(261, 41)); LineLabel *line2 = new LineLabel(fifth, QColor(COLOR_BLUE)); - line2->move(QPoint(288, 41)); CircleLable *three = new CircleLable("3", fifth, 24, QColor(COLOR_BLUE)); - three->move(QPoint(441, 41)); LineLabel *line3 = new LineLabel(fifth, QColor(COLOR_BLUE)); - line3->move(QPoint(468, 41)); CircleLable *four = new CircleLable("4", fifth); - four->move(QPoint(621, 41)); + + QHBoxLayout *hlayoutTopLine1 = new QHBoxLayout; + hlayoutTopLine1->addSpacing(80); + hlayoutTopLine1->addWidget(one); + hlayoutTopLine1->addWidget(line1); + hlayoutTopLine1->addWidget(two); + hlayoutTopLine1->addWidget(line2); + hlayoutTopLine1->addWidget(three); + hlayoutTopLine1->addWidget(line3); + hlayoutTopLine1->addWidget(four); + hlayoutTopLine1->addSpacing(80); + vlayout->addLayout(hlayoutTopLine1); + MyLabel *label1 = new MyLabel(tr("checking"), fifth); label1->setFontColor(QColor(COLOR_BLUE)); - label1->setGeometry(11, 72, 164, 30); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("preparing"), fifth); label2->setFontColor(QColor(COLOR_BLUE)); - label2->setGeometry(191, 72, 164, 30); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("backuping"), fifth); label3->setFontColor(QColor(COLOR_BLUE)); - label3->setGeometry(371, 72, 164, 30); + label3->setFixedWidth(164); MyLabel *label4 = new MyLabel(tr("finished"), fifth); - label4->setGeometry(551, 72, 164, 30); + label4->setFixedWidth(164); label4->setEnabled(false); - // ------------ 中部布局begin------------- - QVBoxLayout *vlayout = new QVBoxLayout; - vlayout->addSpacing(180); - QHBoxLayout *hlayout = new QHBoxLayout; - hlayout->addStretch(); + QHBoxLayout *hlayoutTopLine2 = new QHBoxLayout; + hlayoutTopLine2->addSpacing(11); + hlayoutTopLine2->addWidget(label1); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label2); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label3); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label4); + hlayoutTopLine2->addSpacing(11); + vlayout->addLayout(hlayoutTopLine2); - QWidget *centerFont = new QWidget(fifth); - QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; + vlayout->addSpacing(80); + + // ------------ 中部布局begin------------- // 中部第一行 QHBoxLayout *hlayoutCenterFont1 = new QHBoxLayout; // 检测等待图标 - QLabel *loadingGif = new QLabel(centerFont); + QLabel *loadingGif = new QLabel(fifth); // 环境检测等待动画 - QMovie *movie = new QMovie(":/images/loading.gif", QByteArray(), centerFont); + QMovie *movie = new QMovie(":/images/loading.gif", QByteArray(), fifth); loadingGif->setMovie(movie); loadingGif->setFixedSize(20,20); loadingGif->setVisible(false); // 进度条 - RingsProgressbar *progressBar = new RingsProgressbar(centerFont); + RingsProgressbar *progressBar = new RingsProgressbar(fifth); progressBar->setFixedSize(100, 100); hlayoutCenterFont1->addStretch(); hlayoutCenterFont1->addWidget(loadingGif); hlayoutCenterFont1->addWidget(progressBar); - hlayoutCenterFont1->addSpacing(20); hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignCenter); + vlayout->addLayout(hlayoutCenterFont1); // 第二行 QHBoxLayout *hlayoutCenterFont2 = new QHBoxLayout; // 提醒 - MyLabel *labelTip = new MyLabel(centerFont); + MyLabel *labelTip = new MyLabel(fifth); labelTip->setAlignment(Qt::AlignCenter); labelTip->setIsOriginal(true); - labelTip->setFontWordWrap(true); - labelTip->setMinimumWidth(700); + labelTip->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont2->addStretch(); hlayoutCenterFont2->addWidget(labelTip); hlayoutCenterFont2->addStretch(); + hlayoutCenterFont2->setAlignment(Qt::AlignCenter); + vlayout->addLayout(hlayoutCenterFont2); + vlayout->addSpacing(30); // 第三行 QHBoxLayout *hlayoutCenterFont3 = new QHBoxLayout; // 取消按钮 - MyPushButton *cancel = new MyPushButton(centerFont); + MyPushButton *cancel = new MyPushButton(fifth); cancel->setText(tr("Cancel")); cancel->setAutoRepeat(true); hlayoutCenterFont3->addStretch(); hlayoutCenterFont3->addWidget(cancel); hlayoutCenterFont3->addStretch(); - - vlayoutCenterFont->addLayout(hlayoutCenterFont1); - vlayoutCenterFont->addLayout(hlayoutCenterFont2); - vlayoutCenterFont->addSpacing(40); - vlayoutCenterFont->addLayout(hlayoutCenterFont3); - vlayoutCenterFont->addStretch(); - centerFont->setLayout(vlayoutCenterFont); - - centerFont->setLayout(vlayoutCenterFont); - hlayout->addWidget(centerFont); - hlayout->addStretch(); - vlayout->addLayout(hlayout); - vlayout->addStretch(); - fifth->setLayout(vlayout); + hlayoutCenterFont3->setAlignment(Qt::AlignCenter); + vlayout->addLayout(hlayoutCenterFont3); // ------------ 中部布局end------------- + vlayout->addStretch(); + fifth->setLayout(vlayout); + connect(this, &DataBackup::backupWarnning, labelTip, [=](const QString& msg) { labelTip->setDeplayText(msg); }); @@ -1524,42 +1616,63 @@ void DataBackup::on_backup_end(bool result) void DataBackup::initLastWidget() { QWidget *last = new QWidget; + QVBoxLayout *vlayout = new QVBoxLayout; + vlayout->addSpacing(40); // 流程进度提示栏 CircleLable *one = new CircleLable("1", last, 24, QColor(COLOR_BLUE)); - one->move(QPoint(81, 41)); LineLabel *line1 = new LineLabel(last, QColor(COLOR_BLUE)); - line1->move(QPoint(108, 41)); CircleLable *two = new CircleLable("2", last, 24, QColor(COLOR_BLUE)); - two->move(QPoint(261, 41)); LineLabel *line2 = new LineLabel(last, QColor(COLOR_BLUE)); - line2->move(QPoint(288, 41)); CircleLable *three = new CircleLable("3", last, 24, QColor(COLOR_BLUE)); - three->move(QPoint(441, 41)); LineLabel *line3 = new LineLabel(last, QColor(COLOR_BLUE)); - line3->move(QPoint(468, 41)); CircleLable *four = new CircleLable("4", last, 24, QColor(COLOR_BLUE)); - four->move(QPoint(621, 41)); + + QHBoxLayout *hlayoutTopLine1 = new QHBoxLayout; + hlayoutTopLine1->addSpacing(80); + hlayoutTopLine1->addWidget(one); + hlayoutTopLine1->addWidget(line1); + hlayoutTopLine1->addWidget(two); + hlayoutTopLine1->addWidget(line2); + hlayoutTopLine1->addWidget(three); + hlayoutTopLine1->addWidget(line3); + hlayoutTopLine1->addWidget(four); + hlayoutTopLine1->addSpacing(80); + vlayout->addLayout(hlayoutTopLine1); + MyLabel *label1 = new MyLabel(tr("checking"), last); label1->setFontColor(QColor(COLOR_BLUE)); - label1->setGeometry(11, 72, 164, 30); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("preparing"), last); label2->setFontColor(QColor(COLOR_BLUE)); - label2->setGeometry(191, 72, 164, 30); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("backuping"), last); label3->setFontColor(QColor(COLOR_BLUE)); - label3->setGeometry(371, 72, 164, 30); + label3->setFixedWidth(164); MyLabel *label4 = new MyLabel(tr("finished"), last); label4->setFontColor(QColor(COLOR_BLUE)); - label4->setGeometry(551, 72, 164, 30); + label4->setFixedWidth(164); + + QHBoxLayout *hlayoutTopLine2 = new QHBoxLayout; + hlayoutTopLine2->addSpacing(11); + hlayoutTopLine2->addWidget(label1); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label2); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label3); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label4); + hlayoutTopLine2->addSpacing(11); + vlayout->addLayout(hlayoutTopLine2); + + vlayout->addSpacing(100); //------------ 中部布局begin------------- - QVBoxLayout *vlayout = new QVBoxLayout(last); - vlayout->addSpacing(180); QHBoxLayout *hlayout = new QHBoxLayout; hlayout->addStretch(); - + hlayout->addSpacing(80); QWidget *centerFont = new QWidget(last); + centerFont->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; // 第一行 @@ -1571,10 +1684,10 @@ void DataBackup::initLastWidget() // 检测中大标题 MyLabel *bigTitle = new MyLabel(centerFont); bigTitle->setFontSize(24); - bigTitle->setMaximumWidth(550); bigTitle->setIsOriginal(true); + bigTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont1->addWidget(bigTitle); - hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont1); // 第二行 @@ -1585,13 +1698,12 @@ void DataBackup::initLastWidget() hlayoutCenterFont2->addWidget(dot1); hlayoutCenterFont2->addSpacing(5); MyLabel *labelError1 = new MyLabel(centerFont); - labelError1->setMinimumWidth(300); - labelError1->setMaximumWidth(500); labelError1->setIsOriginal(true); labelError1->setWordWrap(true); labelError1->adjustSize(); + labelError1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont2->addWidget(labelError1); - hlayoutCenterFont2->addStretch(); + hlayoutCenterFont2->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont2); // 第三行 @@ -1602,13 +1714,12 @@ void DataBackup::initLastWidget() hlayoutCenterFont3->addWidget(dot2); hlayoutCenterFont3->addSpacing(5); MyLabel *labelError2 = new MyLabel(centerFont); - labelError2->setMinimumWidth(300); - labelError2->setMaximumWidth(500); labelError2->setIsOriginal(true); labelError2->setWordWrap(true); labelError2->adjustSize(); + labelError2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont3->addWidget(labelError2); - hlayoutCenterFont3->addStretch(); + hlayoutCenterFont3->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont3); // 第四行 @@ -1616,8 +1727,7 @@ void DataBackup::initLastWidget() // 第五行 QHBoxLayout *hlayoutCenterFont5 = new QHBoxLayout; - // hlayoutCenterFont5->addStretch(); - hlayoutCenterFont5->addSpacing(30); + hlayoutCenterFont5->addStretch(); // 返回首页 MyPushButton *homePage = new MyPushButton(centerFont); homePage->setText(tr("Home Page")); @@ -1631,14 +1741,17 @@ void DataBackup::initLastWidget() retry->setEnabled(true); retry->setAutoRepeat(true); hlayoutCenterFont5->addWidget(retry); - hlayoutCenterFont5->addSpacing(20); hlayoutCenterFont5->addStretch(); + hlayoutCenterFont5->setAlignment(Qt::AlignCenter); vlayoutCenterFont->addLayout(hlayoutCenterFont5); centerFont->setLayout(vlayoutCenterFont); hlayout->addWidget(centerFont); + hlayout->addSpacing(80); hlayout->addStretch(); + hlayout->setAlignment(Qt::AlignCenter); vlayout->addLayout(hlayout); + vlayout->addStretch(); last->setLayout(vlayout); //------------ 中部布局end------------- diff --git a/kybackup/module/datarestore.cpp b/kybackup/module/datarestore.cpp index c98d80b..8b5fbe5 100755 --- a/kybackup/module/datarestore.cpp +++ b/kybackup/module/datarestore.cpp @@ -223,39 +223,43 @@ void DataRestore::initSecondWidget() // 流程进度提示栏 CircleLable *one = new CircleLable("1", second, 24, QColor(COLOR_BLUE)); - LineLabel *line1 = new LineLabel(second, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line1 = new LineLabel(second, QColor(COLOR_BLUE)); CircleLable *two = new CircleLable("2", second); - LineLabel *line2 = new LineLabel(second, QColor(COLOR_GRAY), QSize(200, 24)); + LineLabel *line2 = new LineLabel(second, QColor(COLOR_GRAY)); CircleLable *three = new CircleLable("3", second); QHBoxLayout *layoutLine1 = new QHBoxLayout; - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); layoutLine1->addWidget(one); layoutLine1->addWidget(line1); layoutLine1->addWidget(two); layoutLine1->addWidget(line2); layoutLine1->addWidget(three); - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); MyLabel *label1 = new MyLabel(tr("checking"), second); label1->setIsOriginal(true); label1->setFontColor(QColor(COLOR_BLUE)); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("restoring"), second); label2->setIsOriginal(true); label2->setEnabled(false); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("finished"), second); label3->setIsOriginal(true); label3->setEnabled(false); + label3->setFixedWidth(164); QHBoxLayout *layoutLine2 = new QHBoxLayout; - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); layoutLine2->addWidget(label1); layoutLine2->addStretch(); layoutLine2->addWidget(label2); layoutLine2->addStretch(); layoutLine2->addWidget(label3); - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); // ------------ 中部布局begin------------- QWidget *centerFont = new QWidget(second); + centerFont->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; // 第一行 @@ -274,10 +278,10 @@ void DataRestore::initSecondWidget() // 检测中大标题 MyLabel *bigTitle = new MyLabel(centerFont); bigTitle->setFontSize(24); - bigTitle->setMaximumWidth(550); bigTitle->setIsOriginal(true); + bigTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont1->addWidget(bigTitle); - hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont1); // 第二行 @@ -288,13 +292,12 @@ void DataRestore::initSecondWidget() hlayoutCenterFont2->addWidget(dot1); hlayoutCenterFont2->addSpacing(5); MyLabel *labelCheck1 = new MyLabel(centerFont); - labelCheck1->setMinimumWidth(300); - labelCheck1->setMaximumWidth(500); labelCheck1->setIsOriginal(true); labelCheck1->setWordWrap(true); labelCheck1->adjustSize(); + labelCheck1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont2->addWidget(labelCheck1); - hlayoutCenterFont2->addStretch(); + hlayoutCenterFont2->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont2); // 第三行 @@ -305,13 +308,12 @@ void DataRestore::initSecondWidget() hlayoutCenterFont3->addWidget(dot2); hlayoutCenterFont3->addSpacing(5); MyLabel *labelCheck2 = new MyLabel(centerFont); - labelCheck2->setMinimumWidth(300); - labelCheck2->setMaximumWidth(500); labelCheck2->setIsOriginal(true); labelCheck2->setWordWrap(true); labelCheck2->adjustSize(); + labelCheck2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont3->addWidget(labelCheck2); - hlayoutCenterFont3->addStretch(); + hlayoutCenterFont3->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont3); // 第四行 @@ -319,8 +321,7 @@ void DataRestore::initSecondWidget() // 第五行 QHBoxLayout *hlayoutCenterFont5 = new QHBoxLayout; - // hlayoutCenterFont5->addStretch(); - hlayoutCenterFont5->addSpacing(30); + hlayoutCenterFont5->addStretch(); // 上一步按钮 MyPushButton *preStep = new MyPushButton(centerFont); preStep->setText(tr("Back")); @@ -346,16 +347,19 @@ void DataRestore::initSecondWidget() recheck->setAutoRepeat(true); hlayoutCenterFont5->addWidget(recheck); hlayoutCenterFont5->addStretch(); + hlayoutCenterFont5->setAlignment(Qt::AlignCenter); vlayoutCenterFont->addLayout(hlayoutCenterFont5); centerFont->setLayout(vlayoutCenterFont); - - // ------------ 中部布局end------------- - QHBoxLayout *layoutLine3 = new QHBoxLayout; layoutLine3->addStretch(); + layoutLine3->addSpacing(80); layoutLine3->addWidget(centerFont); + layoutLine3->addSpacing(80); layoutLine3->addStretch(); + layoutLine3->setAlignment(Qt::AlignCenter); + + // ------------ 中部布局end------------- // 布局 QVBoxLayout *vlayout = new QVBoxLayout; @@ -542,82 +546,74 @@ void DataRestore::initThirdWidget() // 流程进度提示栏 CircleLable *one = new CircleLable("1", third, 24, QColor(COLOR_BLUE)); - LineLabel *line1 = new LineLabel(third, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line1 = new LineLabel(third, QColor(COLOR_BLUE)); CircleLable *two = new CircleLable("2", third, 24, QColor(COLOR_BLUE)); - LineLabel *line2 = new LineLabel(third, QColor(COLOR_GRAY), QSize(200, 24)); + LineLabel *line2 = new LineLabel(third, QColor(COLOR_GRAY)); CircleLable *three = new CircleLable("3", third); QHBoxLayout *layoutLine1 = new QHBoxLayout; - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); layoutLine1->addWidget(one); layoutLine1->addWidget(line1); layoutLine1->addWidget(two); layoutLine1->addWidget(line2); layoutLine1->addWidget(three); - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); MyLabel *label1 = new MyLabel(tr("checking"), third); label1->setIsOriginal(true); label1->setFontColor(QColor(COLOR_BLUE)); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("restoring"), third); label2->setIsOriginal(true); label2->setFontColor(QColor(COLOR_BLUE)); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("finished"), third); label3->setIsOriginal(true); label3->setEnabled(false); + label3->setFixedWidth(164); QHBoxLayout *layoutLine2 = new QHBoxLayout; - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); layoutLine2->addWidget(label1); layoutLine2->addStretch(); layoutLine2->addWidget(label2); layoutLine2->addStretch(); layoutLine2->addWidget(label3); - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); // ------------ 中部布局begin------------- - QWidget *centerFont = new QWidget(third); - QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; - // 中部第一行 QHBoxLayout *hlayoutCenterFont1 = new QHBoxLayout; // 检测等待图标 - QLabel *loadingGif = new QLabel(centerFont); + QLabel *loadingGif = new QLabel(third); // 环境检测等待动画 - QMovie *movie = new QMovie(":/images/loading.gif", QByteArray(), centerFont); + QMovie *movie = new QMovie(":/images/loading.gif", QByteArray(), third); loadingGif->setMovie(movie); loadingGif->setVisible(false); // 进度条 - RingsProgressbar *progressBar = new RingsProgressbar(centerFont); + RingsProgressbar *progressBar = new RingsProgressbar(third); progressBar->setFixedSize(100, 100); hlayoutCenterFont1->addStretch(); hlayoutCenterFont1->addWidget(loadingGif); hlayoutCenterFont1->addWidget(progressBar); - hlayoutCenterFont1->addSpacing(20); hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignCenter); // 第二行 QHBoxLayout *hlayoutCenterFont2 = new QHBoxLayout; // 提醒 - MyLabel *labelTip = new MyLabel(centerFont); + MyLabel *labelTip = new MyLabel(third); labelTip->setAlignment(Qt::AlignCenter); labelTip->setIsOriginal(true); labelTip->setFontWordWrap(true); + labelTip->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); // 不要使用电脑,以防数据丢失 labelTip->setDeplayText(tr("Do not use computer in case of data loss")); hlayoutCenterFont2->addStretch(); hlayoutCenterFont2->addWidget(labelTip); hlayoutCenterFont2->addStretch(); - - vlayoutCenterFont->addLayout(hlayoutCenterFont1); - vlayoutCenterFont->addLayout(hlayoutCenterFont2); - vlayoutCenterFont->addStretch(); - centerFont->setLayout(vlayoutCenterFont); + hlayoutCenterFont2->setAlignment(Qt::AlignCenter); // ------------ 中部布局end------------- - QHBoxLayout *layoutLine3 = new QHBoxLayout; - layoutLine3->addStretch(); - layoutLine3->addSpacing(80); - layoutLine3->addWidget(centerFont); - layoutLine3->addStretch(); // 布局 QVBoxLayout *vlayout = new QVBoxLayout; @@ -625,7 +621,8 @@ void DataRestore::initThirdWidget() vlayout->addLayout(layoutLine1); vlayout->addLayout(layoutLine2); vlayout->addSpacing(50); - vlayout->addLayout(layoutLine3); + vlayout->addLayout(hlayoutCenterFont1); + vlayout->addLayout(hlayoutCenterFont2); vlayout->addStretch(); third->setLayout(vlayout); @@ -784,39 +781,43 @@ void DataRestore::initLastWidget() // 流程进度提示栏 CircleLable *one = new CircleLable("1", last, 24, QColor(COLOR_BLUE)); - LineLabel *line1 = new LineLabel(last, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line1 = new LineLabel(last, QColor(COLOR_BLUE)); CircleLable *two = new CircleLable("2", last, 24, QColor(COLOR_BLUE)); - LineLabel *line2 = new LineLabel(last, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line2 = new LineLabel(last, QColor(COLOR_BLUE)); CircleLable *three = new CircleLable("3", last, 24, QColor(COLOR_BLUE)); QHBoxLayout *layoutLine1 = new QHBoxLayout; - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); layoutLine1->addWidget(one); layoutLine1->addWidget(line1); layoutLine1->addWidget(two); layoutLine1->addWidget(line2); layoutLine1->addWidget(three); - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); MyLabel *label1 = new MyLabel(tr("checking"), last); label1->setIsOriginal(true); label1->setFontColor(QColor(COLOR_BLUE)); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("restoring"), last); label2->setIsOriginal(true); label2->setFontColor(QColor(COLOR_BLUE)); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("finished"), last); label3->setIsOriginal(true); label3->setFontColor(QColor(COLOR_BLUE)); + label3->setFixedWidth(164); QHBoxLayout *layoutLine2 = new QHBoxLayout; - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); layoutLine2->addWidget(label1); layoutLine2->addStretch(); layoutLine2->addWidget(label2); layoutLine2->addStretch(); layoutLine2->addWidget(label3); - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); // ------------ 中部布局begin------------- QWidget *centerFont = new QWidget(last); + centerFont->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; // 中部第一行 @@ -828,10 +829,10 @@ void DataRestore::initLastWidget() // 检测中大标题 MyLabel *bigTitle = new MyLabel(centerFont); bigTitle->setFontSize(24); - bigTitle->setMaximumWidth(550); bigTitle->setIsOriginal(true); + bigTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont1->addWidget(bigTitle); - hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont1); // 第二行 @@ -842,13 +843,12 @@ void DataRestore::initLastWidget() hlayoutCenterFont2->addWidget(dot1); hlayoutCenterFont2->addSpacing(5); MyLabel *labelError1 = new MyLabel(centerFont); - labelError1->setMinimumWidth(300); - labelError1->setMaximumWidth(500); labelError1->setIsOriginal(true); labelError1->setWordWrap(true); labelError1->adjustSize(); + labelError1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont2->addWidget(labelError1); - hlayoutCenterFont2->addStretch(); + hlayoutCenterFont2->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont2); // 第三行 @@ -859,13 +859,12 @@ void DataRestore::initLastWidget() hlayoutCenterFont3->addWidget(dot2); hlayoutCenterFont3->addSpacing(5); MyLabel *labelError2 = new MyLabel(centerFont); - labelError2->setMinimumWidth(300); - labelError2->setMaximumWidth(500); labelError2->setIsOriginal(true); labelError2->setWordWrap(true); labelError2->adjustSize(); + labelError2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont3->addWidget(labelError2); - hlayoutCenterFont3->addStretch(); + hlayoutCenterFont3->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont3); // 第四行 @@ -873,7 +872,7 @@ void DataRestore::initLastWidget() // 第五行 QHBoxLayout *hlayoutCenterFont5 = new QHBoxLayout; - hlayoutCenterFont5->addSpacing(30); + hlayoutCenterFont5->addStretch(); // 返回首页 MyPushButton *homePage = new MyPushButton(centerFont); homePage->setText(tr("Home Page")); @@ -894,16 +893,17 @@ void DataRestore::initLastWidget() reboot->setAutoRepeat(true); hlayoutCenterFont5->addWidget(reboot); hlayoutCenterFont5->addStretch(); + hlayoutCenterFont5->setAlignment(Qt::AlignCenter); vlayoutCenterFont->addLayout(hlayoutCenterFont5); - vlayoutCenterFont->addStretch(); centerFont->setLayout(vlayoutCenterFont); - // ------------ 中部布局end------------- - QHBoxLayout *layoutLine3 = new QHBoxLayout; layoutLine3->addStretch(); + layoutLine3->addSpacing(80); layoutLine3->addWidget(centerFont); + layoutLine3->addSpacing(80); layoutLine3->addStretch(); + // ------------ 中部布局end------------- // 布局 QVBoxLayout *vlayout = new QVBoxLayout; diff --git a/kybackup/module/ghostimage.cpp b/kybackup/module/ghostimage.cpp index cee9c2a..eb1b1c1 100755 --- a/kybackup/module/ghostimage.cpp +++ b/kybackup/module/ghostimage.cpp @@ -261,39 +261,43 @@ void GhostImage::initThirdWidget() // 流程进度提示栏 CircleLable *one = new CircleLable("1", third, 24, QColor(COLOR_BLUE)); - LineLabel *line1 = new LineLabel(third, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line1 = new LineLabel(third, QColor(COLOR_BLUE)); CircleLable *two = new CircleLable("2", third); - LineLabel *line2 = new LineLabel(third, QColor(COLOR_GRAY), QSize(200, 24)); + LineLabel *line2 = new LineLabel(third, QColor(COLOR_GRAY)); CircleLable *three = new CircleLable("3", third); QHBoxLayout *layoutLine1 = new QHBoxLayout; - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); layoutLine1->addWidget(one); layoutLine1->addWidget(line1); layoutLine1->addWidget(two); layoutLine1->addWidget(line2); layoutLine1->addWidget(three); - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); MyLabel *label1 = new MyLabel(tr("checking"), third); label1->setIsOriginal(true); label1->setFontColor(QColor(COLOR_BLUE)); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("ghosting"), third); label2->setIsOriginal(true); label2->setEnabled(false); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("finished"), third); label3->setIsOriginal(true); label3->setEnabled(false); + label3->setFixedWidth(164); QHBoxLayout *layoutLine2 = new QHBoxLayout; - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); layoutLine2->addWidget(label1); layoutLine2->addStretch(); layoutLine2->addWidget(label2); layoutLine2->addStretch(); layoutLine2->addWidget(label3); - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); // ------------ 中部布局begin------------- QWidget *centerFont = new QWidget(third); + centerFont->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; // 第一行 @@ -312,10 +316,10 @@ void GhostImage::initThirdWidget() // 检测中大标题 MyLabel *bigTitle = new MyLabel(centerFont); bigTitle->setFontSize(24); - bigTitle->setMaximumWidth(550); bigTitle->setIsOriginal(true); + bigTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont1->addWidget(bigTitle); - hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont1); // 第二行 @@ -326,13 +330,12 @@ void GhostImage::initThirdWidget() hlayoutCenterFont2->addWidget(dot1); hlayoutCenterFont2->addSpacing(5); MyLabel *labelCheck1 = new MyLabel(centerFont); - labelCheck1->setMinimumWidth(300); - labelCheck1->setMaximumWidth(500); labelCheck1->setIsOriginal(true); labelCheck1->setWordWrap(true); labelCheck1->adjustSize(); + labelCheck1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont2->addWidget(labelCheck1); - hlayoutCenterFont2->addStretch(); + hlayoutCenterFont2->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont2); // 第三行 @@ -343,13 +346,12 @@ void GhostImage::initThirdWidget() hlayoutCenterFont3->addWidget(dot2); hlayoutCenterFont3->addSpacing(5); MyLabel *labelCheck2 = new MyLabel(centerFont); - labelCheck2->setMinimumWidth(300); - labelCheck2->setMaximumWidth(500); labelCheck2->setIsOriginal(true); labelCheck2->setWordWrap(true); labelCheck2->adjustSize(); + labelCheck1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont3->addWidget(labelCheck2); - hlayoutCenterFont3->addStretch(); + hlayoutCenterFont3->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont3); // 第四行 @@ -357,8 +359,7 @@ void GhostImage::initThirdWidget() // 第五行 QHBoxLayout *hlayoutCenterFont5 = new QHBoxLayout; - // hlayoutCenterFont5->addStretch(); - hlayoutCenterFont5->addSpacing(30); + hlayoutCenterFont5->addStretch(); // 上一步按钮 MyPushButton *preStep = new MyPushButton(centerFont); preStep->setText(tr("Back")); @@ -384,16 +385,19 @@ void GhostImage::initThirdWidget() recheck->setAutoRepeat(true); hlayoutCenterFont5->addWidget(recheck); hlayoutCenterFont5->addStretch(); + hlayoutCenterFont5->setAlignment(Qt::AlignCenter); vlayoutCenterFont->addLayout(hlayoutCenterFont5); centerFont->setLayout(vlayoutCenterFont); - - // ------------ 中部布局end------------- - QHBoxLayout *layoutLine3 = new QHBoxLayout; layoutLine3->addStretch(); + layoutLine3->addSpacing(80); layoutLine3->addWidget(centerFont); + layoutLine3->addSpacing(80); layoutLine3->addStretch(); + layoutLine3->setAlignment(Qt::AlignCenter); + + // ------------ 中部布局end------------- // 布局 QVBoxLayout *vlayout = new QVBoxLayout; @@ -635,116 +639,109 @@ void GhostImage::initForthWidget() // 流程进度提示栏 CircleLable *one = new CircleLable("1", forth, 24, QColor(COLOR_BLUE)); - LineLabel *line1 = new LineLabel(forth, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line1 = new LineLabel(forth, QColor(COLOR_BLUE)); CircleLable *two = new CircleLable("2", forth, 24, QColor(COLOR_BLUE)); - LineLabel *line2 = new LineLabel(forth, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line2 = new LineLabel(forth, QColor(COLOR_BLUE)); CircleLable *three = new CircleLable("3", forth); QHBoxLayout *layoutLine1 = new QHBoxLayout; - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); layoutLine1->addWidget(one); layoutLine1->addWidget(line1); layoutLine1->addWidget(two); layoutLine1->addWidget(line2); layoutLine1->addWidget(three); - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); MyLabel *label1 = new MyLabel(tr("checking"), forth); label1->setIsOriginal(true); label1->setFontColor(QColor(COLOR_BLUE)); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("ghosting"), forth); label2->setIsOriginal(true); label2->setFontColor(QColor(COLOR_BLUE)); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("finished"), forth); label3->setIsOriginal(true); label3->setEnabled(false); + label3->setFixedWidth(164); QHBoxLayout *layoutLine2 = new QHBoxLayout; - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); layoutLine2->addWidget(label1); layoutLine2->addStretch(); layoutLine2->addWidget(label2); layoutLine2->addStretch(); layoutLine2->addWidget(label3); - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); // ------------ 中部布局begin------------- - QWidget *centerFont = new QWidget(forth); - QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; - // 中部第一行 QHBoxLayout *hlayoutCenterFont1 = new QHBoxLayout; // 检测等待图标 - QLabel *loadingGif = new QLabel(centerFont); + QLabel *loadingGif = new QLabel(forth); // 环境检测等待动画 - QMovie *movie = new QMovie(":/images/loading.gif", QByteArray(), centerFont); + QMovie *movie = new QMovie(":/images/loading.gif", QByteArray(), forth); loadingGif->setMovie(movie); loadingGif->setFixedSize(20,20); loadingGif->setVisible(false); // 进度条 - RingsProgressbar *progressBar = new RingsProgressbar(centerFont); + RingsProgressbar *progressBar = new RingsProgressbar(forth); progressBar->setFixedSize(100, 100); hlayoutCenterFont1->addStretch(); hlayoutCenterFont1->addWidget(loadingGif); hlayoutCenterFont1->addWidget(progressBar); - hlayoutCenterFont1->addSpacing(20); hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignCenter); // 第二行 QHBoxLayout *hlayoutCenterFont2 = new QHBoxLayout; // 提醒 - MyLabel *labelTip = new MyLabel(centerFont); + MyLabel *labelTip = new MyLabel(forth); labelTip->setAlignment(Qt::AlignCenter); labelTip->setIsOriginal(true); - labelTip->setFontWordWrap(true); - labelTip->setMinimumWidth(700); + labelTip->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont2->addStretch(); hlayoutCenterFont2->addWidget(labelTip); hlayoutCenterFont2->addStretch(); + hlayoutCenterFont2->setAlignment(Qt::AlignCenter); // 第二行 QHBoxLayout *hlayoutCenterFont2_1 = new QHBoxLayout; // 备份过程提醒信息 - MyLabel *labelTip_1 = new MyLabel(centerFont); + MyLabel *labelTip_1 = new MyLabel(forth); labelTip_1->setAlignment(Qt::AlignCenter); labelTip_1->setIsOriginal(true); labelTip_1->setFontWordWrap(true); - labelTip_1->setMinimumWidth(700); + labelTip_1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); labelTip_1->setDeplayText(""); hlayoutCenterFont2_1->addStretch(); hlayoutCenterFont2_1->addWidget(labelTip_1); hlayoutCenterFont2_1->addStretch(); + hlayoutCenterFont2_1->setAlignment(Qt::AlignCenter); // 第三行 QHBoxLayout *hlayoutCenterFont3 = new QHBoxLayout; // 取消按钮 - MyPushButton *cancel = new MyPushButton(centerFont); + MyPushButton *cancel = new MyPushButton(forth); cancel->setText(tr("Cancel")); cancel->setEnabled(true); cancel->setAutoRepeat(true); hlayoutCenterFont3->addStretch(); hlayoutCenterFont3->addWidget(cancel); hlayoutCenterFont3->addStretch(); - - vlayoutCenterFont->addLayout(hlayoutCenterFont1); - vlayoutCenterFont->addLayout(hlayoutCenterFont2); - vlayoutCenterFont->addLayout(hlayoutCenterFont2_1); - vlayoutCenterFont->addSpacing(40); - vlayoutCenterFont->addLayout(hlayoutCenterFont3); - vlayoutCenterFont->addStretch(); - centerFont->setLayout(vlayoutCenterFont); + hlayoutCenterFont3->setAlignment(Qt::AlignCenter); // ------------ 中部布局end------------- - QHBoxLayout *layoutLine3 = new QHBoxLayout; - layoutLine3->addStretch(); - layoutLine3->addWidget(centerFont); - layoutLine3->addStretch(); - // 布局 QVBoxLayout *vlayout = new QVBoxLayout; vlayout->addSpacing(40); vlayout->addLayout(layoutLine1); vlayout->addLayout(layoutLine2); vlayout->addSpacing(50); - vlayout->addLayout(layoutLine3); + vlayout->addLayout(hlayoutCenterFont1); + vlayout->addLayout(hlayoutCenterFont2); + vlayout->addLayout(hlayoutCenterFont2_1); + vlayout->addSpacing(30); + vlayout->addLayout(hlayoutCenterFont3); vlayout->addStretch(); forth->setLayout(vlayout); @@ -954,18 +951,18 @@ void GhostImage::initLastWidget() // 流程进度提示栏 CircleLable *one = new CircleLable("1", last, 24, QColor(COLOR_BLUE)); - LineLabel *line1 = new LineLabel(last, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line1 = new LineLabel(last, QColor(COLOR_BLUE)); CircleLable *two = new CircleLable("2", last, 24, QColor(COLOR_BLUE)); - LineLabel *line2 = new LineLabel(last, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line2 = new LineLabel(last, QColor(COLOR_BLUE)); CircleLable *three = new CircleLable("3", last, 24, QColor(COLOR_BLUE)); QHBoxLayout *layoutLine1 = new QHBoxLayout; - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); layoutLine1->addWidget(one); layoutLine1->addWidget(line1); layoutLine1->addWidget(two); layoutLine1->addWidget(line2); layoutLine1->addWidget(three); - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); MyLabel *label1 = new MyLabel(tr("checking"), last); label1->setIsOriginal(true); @@ -977,16 +974,17 @@ void GhostImage::initLastWidget() label3->setIsOriginal(true); label3->setFontColor(QColor(COLOR_BLUE)); QHBoxLayout *layoutLine2 = new QHBoxLayout; - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); layoutLine2->addWidget(label1); layoutLine2->addStretch(); layoutLine2->addWidget(label2); layoutLine2->addStretch(); layoutLine2->addWidget(label3); - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); //------------ 中部布局begin------------- QWidget *centerFont = new QWidget(last); + centerFont->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; // 第一行 @@ -998,10 +996,10 @@ void GhostImage::initLastWidget() // 检测中大标题 MyLabel *bigTitle = new MyLabel(centerFont); bigTitle->setFontSize(24); - bigTitle->setMaximumWidth(550); bigTitle->setIsOriginal(true); + bigTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont1->addWidget(bigTitle); - hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont1); // 第二行 @@ -1012,13 +1010,12 @@ void GhostImage::initLastWidget() hlayoutCenterFont2->addWidget(dot1); hlayoutCenterFont2->addSpacing(5); MyLabel *labelError1 = new MyLabel(centerFont); - labelError1->setMinimumWidth(300); - labelError1->setMaximumWidth(500); labelError1->setIsOriginal(true); labelError1->setWordWrap(true); labelError1->adjustSize(); + labelError1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont2->addWidget(labelError1); - hlayoutCenterFont2->addStretch(); + hlayoutCenterFont2->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont2); // 第三行 @@ -1029,13 +1026,12 @@ void GhostImage::initLastWidget() hlayoutCenterFont3->addWidget(dot2); hlayoutCenterFont3->addSpacing(5); MyLabel *labelError2 = new MyLabel(centerFont); - labelError2->setMinimumWidth(300); - labelError2->setMaximumWidth(500); labelError2->setIsOriginal(true); labelError2->setWordWrap(true); labelError2->adjustSize(); + labelError2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont3->addWidget(labelError2); - hlayoutCenterFont3->addStretch(); + hlayoutCenterFont3->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont3); // 第四行 @@ -1043,8 +1039,7 @@ void GhostImage::initLastWidget() // 第五行 QHBoxLayout *hlayoutCenterFont5 = new QHBoxLayout; - // hlayoutCenterFont5->addStretch(); - hlayoutCenterFont5->addSpacing(30); + hlayoutCenterFont5->addStretch(); // 返回首页 MyPushButton *homePage = new MyPushButton(centerFont); homePage->setText(tr("Home Page")); @@ -1059,15 +1054,17 @@ void GhostImage::initLastWidget() retry->setAutoRepeat(true); hlayoutCenterFont5->addWidget(retry); hlayoutCenterFont5->addStretch(); + hlayoutCenterFont5->setAlignment(Qt::AlignCenter); vlayoutCenterFont->addLayout(hlayoutCenterFont5); centerFont->setLayout(vlayoutCenterFont); - //------------ 中部布局end------------- - QHBoxLayout *layoutLine3 = new QHBoxLayout; layoutLine3->addStretch(); + layoutLine3->addSpacing(80); layoutLine3->addWidget(centerFont); + layoutLine3->addSpacing(80); layoutLine3->addStretch(); + //------------ 中部布局end------------- // 布局 QVBoxLayout *vlayout = new QVBoxLayout; diff --git a/kybackup/module/systembackup.cpp b/kybackup/module/systembackup.cpp index 8039ab0..4b8ba68 100755 --- a/kybackup/module/systembackup.cpp +++ b/kybackup/module/systembackup.cpp @@ -200,23 +200,32 @@ void SystemBackup::on_next_clicked(bool checked) void SystemBackup::initSecondWidget() { QWidget *second = new QWidget; + // 纵向布局 + QVBoxLayout *vlayout = new QVBoxLayout; + vlayout->addSpacing(40); + // 第一行 + QHBoxLayout * hlayoutLine1 = new QHBoxLayout; + hlayoutLine1->addSpacing(40); // 备份路径选择提示 MyLabel* labelSelect = new MyLabel(second); labelSelect->setDeplayText(tr("Please select backup position")); - labelSelect->setFixedWidth(600); - labelSelect->setFixedHeight(27); - labelSelect->move(41, 41); + labelSelect->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QFont font; font.setBold(true); font.setPixelSize(18); labelSelect->setFont(font); - labelSelect->setScaledContents(true); - labelSelect->adjustSize(); + hlayoutLine1->addWidget(labelSelect); + hlayoutLine1->setAlignment(Qt::AlignLeft); + vlayout->addLayout(hlayoutLine1); + // 第二行 + vlayout->addSpacing(5); + QHBoxLayout * hlayoutLine2 = new QHBoxLayout; + hlayoutLine2->addSpacing(40); // 备份路径选择框 QComboBox* comboSelect = new QComboBox(second); - comboSelect->setGeometry(41, 84, 680, 36); + comboSelect->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); // 添加本地默认路径、移动设备目录 connect(m_udector, &UdiskDetector::udiskListChanged, this, [=](QList diskList) { comboSelect->clear(); @@ -238,18 +247,25 @@ void SystemBackup::initSecondWidget() } }); m_udector->getStorageInfo(); + hlayoutLine2->addWidget(comboSelect); + hlayoutLine2->addSpacing(40); + vlayout->addLayout(hlayoutLine2); + vlayout->addSpacing(30); + // 第三行 + QHBoxLayout * hlayoutLine3 = new QHBoxLayout; + hlayoutLine3->addStretch(); // 上一步按钮 MyPushButton *preStep = new MyPushButton(second); - preStep->setGeometry(271, 176, 97, 36); preStep->setText(tr("Back")); preStep->setEnabled(true); preStep->setAutoRepeat(true); connect(preStep, &MyPushButton::clicked, this, &SystemBackup::on_pre_clicked); + hlayoutLine3->addWidget(preStep); + hlayoutLine3->addSpacing(20); // 下一步按钮 MyPushButton *nextStep = new MyPushButton(second); - nextStep->setGeometry(389, 176, 97, 36); nextStep->setText(tr("Next")); nextStep->setEnabled(true); nextStep->setAutoRepeat(true); @@ -262,6 +278,13 @@ void SystemBackup::initSecondWidget() this->on_next_clicked(checked); emit this->startCheckEnv(); }); + hlayoutLine3->addWidget(nextStep); + hlayoutLine3->addStretch(); + hlayoutLine3->setAlignment(Qt::AlignCenter); + vlayout->addLayout(hlayoutLine3); + + vlayout->addStretch(); + second->setLayout(vlayout); addWidget(second); } @@ -272,42 +295,63 @@ void SystemBackup::initSecondWidget() void SystemBackup::initThirdWidget() { QWidget *third = new QWidget; + QVBoxLayout *vlayout = new QVBoxLayout; + vlayout->addSpacing(40); // 流程进度提示栏 CircleLable *one = new CircleLable("1", third, 24, QColor(COLOR_BLUE)); - one->move(QPoint(81, 41)); LineLabel *line1 = new LineLabel(third, QColor(COLOR_BLUE)); - line1->move(QPoint(108, 41)); CircleLable *two = new CircleLable("2", third); - two->move(QPoint(261, 41)); LineLabel *line2 = new LineLabel(third); - line2->move(QPoint(288, 41)); CircleLable *three = new CircleLable("3", third); - three->move(QPoint(441, 41)); LineLabel *line3 = new LineLabel(third); - line3->move(QPoint(468, 41)); CircleLable *four = new CircleLable("4", third); - four->move(QPoint(621, 41)); + + QHBoxLayout *hlayoutTopLine1 = new QHBoxLayout; + hlayoutTopLine1->addSpacing(80); + hlayoutTopLine1->addWidget(one); + hlayoutTopLine1->addWidget(line1); + hlayoutTopLine1->addWidget(two); + hlayoutTopLine1->addWidget(line2); + hlayoutTopLine1->addWidget(three); + hlayoutTopLine1->addWidget(line3); + hlayoutTopLine1->addWidget(four); + hlayoutTopLine1->addSpacing(80); + vlayout->addLayout(hlayoutTopLine1); + MyLabel *label1 = new MyLabel(tr("checking"), third); label1->setFontColor(QColor(COLOR_BLUE)); - label1->setGeometry(11, 72, 164, 30); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("preparing"), third); - label2->setGeometry(191, 72, 164, 30); + label2->setFixedWidth(164); label2->setEnabled(false); MyLabel *label3 = new MyLabel(tr("backuping"), third); - label3->setGeometry(371, 72, 164, 30); + label3->setFixedWidth(164); label3->setEnabled(false); MyLabel *label4 = new MyLabel(tr("finished"), third); - label4->setGeometry(551, 72, 164, 30); + label4->setFixedWidth(164); label4->setEnabled(false); + QHBoxLayout *hlayoutTopLine2 = new QHBoxLayout; + hlayoutTopLine2->addSpacing(11); + hlayoutTopLine2->addWidget(label1); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label2); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label3); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label4); + hlayoutTopLine2->addSpacing(11); + vlayout->addLayout(hlayoutTopLine2); + + vlayout->addSpacing(100); + // ------------ 中部布局begin------------- - QVBoxLayout *vlayout = new QVBoxLayout(third); - vlayout->addSpacing(180); QHBoxLayout *hlayout = new QHBoxLayout; hlayout->addStretch(); - + hlayout->addSpacing(80); QWidget *centerFont = new QWidget(third); + centerFont->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; // 第一行 @@ -326,10 +370,10 @@ void SystemBackup::initThirdWidget() // 检测中大标题 MyLabel *bigTitle = new MyLabel(centerFont); bigTitle->setFontSize(24); - bigTitle->setMaximumWidth(550); bigTitle->setIsOriginal(true); + bigTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont1->addWidget(bigTitle); - hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont1); // 第二行 @@ -340,13 +384,12 @@ void SystemBackup::initThirdWidget() hlayoutCenterFont2->addWidget(dot1); hlayoutCenterFont2->addSpacing(5); MyLabel *labelCheck1 = new MyLabel(centerFont); - labelCheck1->setMinimumWidth(300); - labelCheck1->setMaximumWidth(500); labelCheck1->setIsOriginal(true); labelCheck1->setWordWrap(true); labelCheck1->adjustSize(); + labelCheck1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont2->addWidget(labelCheck1); - hlayoutCenterFont2->addStretch(); + hlayoutCenterFont2->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont2); // 第三行 @@ -357,13 +400,12 @@ void SystemBackup::initThirdWidget() hlayoutCenterFont3->addWidget(dot2); hlayoutCenterFont3->addSpacing(5); MyLabel *labelCheck2 = new MyLabel(centerFont); - labelCheck2->setMinimumWidth(300); - labelCheck2->setMaximumWidth(500); labelCheck2->setIsOriginal(true); labelCheck2->setWordWrap(true); labelCheck2->adjustSize(); + labelCheck2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont3->addWidget(labelCheck2); - hlayoutCenterFont3->addStretch(); + hlayoutCenterFont3->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont3); // 第四行 @@ -371,8 +413,7 @@ void SystemBackup::initThirdWidget() // 第五行 QHBoxLayout *hlayoutCenterFont5 = new QHBoxLayout; - // hlayoutCenterFont5->addStretch(); - hlayoutCenterFont5->addSpacing(30); + hlayoutCenterFont5->addStretch(); // 上一步按钮 MyPushButton *preStep = new MyPushButton(centerFont); preStep->setText(tr("Back")); @@ -402,13 +443,16 @@ void SystemBackup::initThirdWidget() }); hlayoutCenterFont5->addWidget(recheck); hlayoutCenterFont5->addStretch(); + hlayoutCenterFont5->setAlignment(Qt::AlignCenter); vlayoutCenterFont->addLayout(hlayoutCenterFont5); - centerFont->setLayout(vlayoutCenterFont); hlayout->addWidget(centerFont); + hlayout->addSpacing(80); hlayout->addStretch(); + hlayout->setAlignment(Qt::AlignCenter); vlayout->addLayout(hlayout); + vlayout->addStretch(); third->setLayout(vlayout); // ------------ 中部布局end------------- @@ -601,42 +645,69 @@ void SystemBackup::on_checkEnv_end(int result) void SystemBackup::initForthWidget() { QWidget *forth = new QWidget; + QVBoxLayout *vlayout = new QVBoxLayout; + vlayout->addSpacing(40); // 流程进度提示栏 CircleLable *one = new CircleLable("1", forth, 24, QColor(COLOR_BLUE)); - one->move(QPoint(81, 41)); LineLabel *line1 = new LineLabel(forth, QColor(COLOR_BLUE)); - line1->move(QPoint(108, 41)); CircleLable *two = new CircleLable("2", forth, 24, QColor(COLOR_BLUE)); - two->move(QPoint(261, 41)); LineLabel *line2 = new LineLabel(forth, QColor(COLOR_BLUE)); - line2->move(QPoint(288, 41)); CircleLable *three = new CircleLable("3", forth); - three->move(QPoint(441, 41)); LineLabel *line3 = new LineLabel(forth); - line3->move(QPoint(468, 41)); CircleLable *four = new CircleLable("4", forth); - four->move(QPoint(621, 41)); + + QHBoxLayout *hlayoutTopLine1 = new QHBoxLayout; + hlayoutTopLine1->addSpacing(80); + hlayoutTopLine1->addWidget(one); + hlayoutTopLine1->addWidget(line1); + hlayoutTopLine1->addWidget(two); + hlayoutTopLine1->addWidget(line2); + hlayoutTopLine1->addWidget(three); + hlayoutTopLine1->addWidget(line3); + hlayoutTopLine1->addWidget(four); + hlayoutTopLine1->addSpacing(80); + vlayout->addLayout(hlayoutTopLine1); + MyLabel *label1 = new MyLabel(tr("checking"), forth); label1->setFontColor(QColor(COLOR_BLUE)); - label1->setGeometry(11, 72, 164, 30); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("preparing"), forth); label2->setFontColor(QColor(COLOR_BLUE)); - label2->setGeometry(191, 72, 164, 30); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("backuping"), forth); - label3->setGeometry(371, 72, 164, 30); + label3->setFixedWidth(164); label3->setEnabled(false); MyLabel *label4 = new MyLabel(tr("finished"), forth); - label4->setGeometry(551, 72, 164, 30); + label4->setFixedWidth(164); label4->setEnabled(false); + QHBoxLayout *hlayoutTopLine2 = new QHBoxLayout; + hlayoutTopLine2->addSpacing(11); + hlayoutTopLine2->addWidget(label1); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label2); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label3); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label4); + hlayoutTopLine2->addSpacing(11); + vlayout->addLayout(hlayoutTopLine2); + + vlayout->addSpacing(80); + + // ------------ 中部布局begin------------- + + // 中部第一行 + QHBoxLayout *hlayoutCenterLine1 = new QHBoxLayout; // 备份名称 MyLabel *labelBackupName = new MyLabel(forth); - labelBackupName->setGeometry(81, 178, 150, 30); - labelBackupName->setAlignment(Qt::AlignRight); + labelBackupName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + labelBackupName->setAlignment(Qt::AlignRight | Qt::AlignHCenter); labelBackupName->setDeplayText(tr("Backup Name")); MyLineEdit *editBackupName = new MyLineEdit(forth); - editBackupName->setGeometry(238, 172, 350, 40); + editBackupName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + editBackupName->setMinimumWidth(350); editBackupName->setMaxLength(64); editBackupName->setPlaceholderText(QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss")); // 支持输入中英文数字和部分字符 @@ -644,16 +715,29 @@ void SystemBackup::initForthWidget() QRegExp regx("^[\u4e00-\u9fa5a-zA-Z0-9-@& +():'()——《》‘’:“”]*$"); QValidator *validator = new QRegExpValidator(regx); editBackupName->setValidator(validator); + labelBackupName->setFixedHeight(editBackupName->height()); + + hlayoutCenterLine1->addStretch(); + hlayoutCenterLine1->addWidget(labelBackupName); + hlayoutCenterLine1->addWidget(editBackupName); + hlayoutCenterLine1->addSpacing(40); + hlayoutCenterLine1->addStretch(); + hlayoutCenterLine1->setAlignment(Qt::AlignCenter); + vlayout->addLayout(hlayoutCenterLine1); + // 备份名称错误提示 MyLabel *labelError = new MyLabel(forth); - labelError->setGeometry(238, 215, 500, 30); + labelError->setFixedSize(editBackupName->size()); labelError->setFontSize(14); labelError->setFontColor(Qt::red); labelError->setVisible(false); + labelError->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); connect(editBackupName, &MyLineEdit::textChanged, this, [=](const QString &text) { if (!text.isEmpty() && this->isExistsBackupName(text)) { labelError->setDeplayText(tr("Name already exists")); labelError->setVisible(true); + + labelError->move(editBackupName->geometry().left(), editBackupName->geometry().bottom() + 10); } else { labelError->setDeplayText(""); labelError->setVisible(false); @@ -668,17 +752,21 @@ void SystemBackup::initForthWidget() labelError->setVisible(false); }); + vlayout->addSpacing(50); + // 中部第三行 + QHBoxLayout *hlayoutCenterLine3 = new QHBoxLayout; + hlayoutCenterLine3->addStretch(); // 上一步按钮 MyPushButton *preStep = new MyPushButton(forth); - preStep->setGeometry(271, 268, 97, 36); preStep->setText(tr("Back")); preStep->setEnabled(true); preStep->setAutoRepeat(true); connect(preStep, &MyPushButton::clicked, this, &SystemBackup::on_pre_clicked); + hlayoutCenterLine3->addWidget(preStep); + hlayoutCenterLine3->addSpacing(20); // 下一步按钮 MyPushButton *nextStep = new MyPushButton(forth); - nextStep->setGeometry(389, 268, 97, 36); nextStep->setText(tr("Next")); nextStep->setEnabled(true); nextStep->setAutoRepeat(true); @@ -704,6 +792,14 @@ void SystemBackup::initForthWidget() } }); + hlayoutCenterLine3->addWidget(nextStep); + hlayoutCenterLine3->addStretch(); + hlayoutCenterLine3->setAlignment(Qt::AlignCenter); + vlayout->addLayout(hlayoutCenterLine3); + + vlayout->addStretch(); + forth->setLayout(vlayout); + addWidget(forth); } @@ -785,108 +881,119 @@ bool SystemBackup::isExistsBackupName(const QString & backupName) void SystemBackup::initFifthWidget() { QWidget *fifth = new QWidget; + QVBoxLayout *vlayout = new QVBoxLayout; + vlayout->setSpacing(10); + vlayout->addSpacing(40); // 流程进度提示栏 CircleLable *one = new CircleLable("1", fifth, 24, QColor(COLOR_BLUE)); - one->move(QPoint(81, 41)); LineLabel *line1 = new LineLabel(fifth, QColor(COLOR_BLUE)); - line1->move(QPoint(108, 41)); CircleLable *two = new CircleLable("2", fifth, 24, QColor(COLOR_BLUE)); - two->move(QPoint(261, 41)); LineLabel *line2 = new LineLabel(fifth, QColor(COLOR_BLUE)); - line2->move(QPoint(288, 41)); CircleLable *three = new CircleLable("3", fifth, 24, QColor(COLOR_BLUE)); - three->move(QPoint(441, 41)); LineLabel *line3 = new LineLabel(fifth, QColor(COLOR_BLUE)); - line3->move(QPoint(468, 41)); CircleLable *four = new CircleLable("4", fifth); - four->move(QPoint(621, 41)); + + QHBoxLayout *hlayoutTopLine1 = new QHBoxLayout; + hlayoutTopLine1->addSpacing(80); + hlayoutTopLine1->addWidget(one); + hlayoutTopLine1->addWidget(line1); + hlayoutTopLine1->addWidget(two); + hlayoutTopLine1->addWidget(line2); + hlayoutTopLine1->addWidget(three); + hlayoutTopLine1->addWidget(line3); + hlayoutTopLine1->addWidget(four); + hlayoutTopLine1->addSpacing(80); + vlayout->addLayout(hlayoutTopLine1); + MyLabel *label1 = new MyLabel(tr("checking"), fifth); label1->setFontColor(QColor(COLOR_BLUE)); - label1->setGeometry(11, 72, 164, 30); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("preparing"), fifth); label2->setFontColor(QColor(COLOR_BLUE)); - label2->setGeometry(191, 72, 164, 30); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("backuping"), fifth); label3->setFontColor(QColor(COLOR_BLUE)); - label3->setGeometry(371, 72, 164, 30); + label3->setFixedWidth(164); MyLabel *label4 = new MyLabel(tr("finished"), fifth); - label4->setGeometry(551, 72, 164, 30); + label4->setFixedWidth(164); label4->setEnabled(false); + QHBoxLayout *hlayoutTopLine2 = new QHBoxLayout; + hlayoutTopLine2->addSpacing(11); + hlayoutTopLine2->addWidget(label1); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label2); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label3); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label4); + hlayoutTopLine2->addSpacing(11); + vlayout->addLayout(hlayoutTopLine2); + + vlayout->addSpacing(80); + // ------------ 中部布局begin------------- - QVBoxLayout *vlayout = new QVBoxLayout; - vlayout->addSpacing(180); - QHBoxLayout *hlayout = new QHBoxLayout; - hlayout->addStretch(); - - QWidget *centerFont = new QWidget(fifth); - QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; - // 中部第一行 QHBoxLayout *hlayoutCenterFont1 = new QHBoxLayout; // 检测等待图标 - QLabel *loadingGif = new QLabel(centerFont); + QLabel *loadingGif = new QLabel(fifth); // 环境检测等待动画 - QMovie *movie = new QMovie(":/images/loading.gif", QByteArray(), centerFont); + QMovie *movie = new QMovie(":/images/loading.gif", QByteArray(), fifth); loadingGif->setMovie(movie); loadingGif->setFixedSize(20,20); loadingGif->setVisible(false); // 进度条 - RingsProgressbar *progressBar = new RingsProgressbar(centerFont); + RingsProgressbar *progressBar = new RingsProgressbar(fifth); progressBar->setFixedSize(100, 100); hlayoutCenterFont1->addStretch(); hlayoutCenterFont1->addWidget(loadingGif); hlayoutCenterFont1->addWidget(progressBar); - hlayoutCenterFont1->addSpacing(20); hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignCenter); + vlayout->addLayout(hlayoutCenterFont1); // 第二行 QHBoxLayout *hlayoutCenterFont2 = new QHBoxLayout; // 提醒 - MyLabel *labelTip = new MyLabel(centerFont); + MyLabel *labelTip = new MyLabel(fifth); labelTip->setAlignment(Qt::AlignCenter); labelTip->setIsOriginal(true); - labelTip->setFontWordWrap(true); - labelTip->setMinimumWidth(700); + labelTip->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont2->addStretch(); hlayoutCenterFont2->addWidget(labelTip); hlayoutCenterFont2->addStretch(); - // 第二行 + hlayoutCenterFont2->setAlignment(Qt::AlignCenter); + vlayout->addLayout(hlayoutCenterFont2); + + // 第二行(隐) QHBoxLayout *hlayoutCenterFont2_1 = new QHBoxLayout; // 备份过程提醒信息 - MyLabel *labelTip_1 = new MyLabel(centerFont); + MyLabel *labelTip_1 = new MyLabel(fifth); labelTip_1->setAlignment(Qt::AlignCenter); labelTip_1->setIsOriginal(true); labelTip_1->setFontWordWrap(true); - labelTip_1->setMinimumWidth(700); + labelTip_1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); labelTip_1->setDeplayText(""); hlayoutCenterFont2_1->addStretch(); hlayoutCenterFont2_1->addWidget(labelTip_1); hlayoutCenterFont2_1->addStretch(); + hlayoutCenterFont2_1->setAlignment(Qt::AlignCenter); + vlayout->addLayout(hlayoutCenterFont2); + vlayout->addSpacing(30); // 第三行 QHBoxLayout *hlayoutCenterFont3 = new QHBoxLayout; // 取消按钮 - MyPushButton *cancel = new MyPushButton(centerFont); + MyPushButton *cancel = new MyPushButton(fifth); cancel->setText(tr("Cancel")); cancel->setAutoRepeat(true); hlayoutCenterFont3->addStretch(); hlayoutCenterFont3->addWidget(cancel); hlayoutCenterFont3->addStretch(); + hlayoutCenterFont3->setAlignment(Qt::AlignCenter); + vlayout->addLayout(hlayoutCenterFont3); - vlayoutCenterFont->addLayout(hlayoutCenterFont1); - vlayoutCenterFont->addLayout(hlayoutCenterFont2); - vlayoutCenterFont->addLayout(hlayoutCenterFont2_1); - vlayoutCenterFont->addSpacing(40); - vlayoutCenterFont->addLayout(hlayoutCenterFont3); - vlayoutCenterFont->addStretch(); - centerFont->setLayout(vlayoutCenterFont); - - centerFont->setLayout(vlayoutCenterFont); - hlayout->addWidget(centerFont); - hlayout->addStretch(); - vlayout->addLayout(hlayout); vlayout->addStretch(); fifth->setLayout(vlayout); @@ -1103,42 +1210,63 @@ void SystemBackup::on_backup_end(bool result) void SystemBackup::initLastWidget() { QWidget *last = new QWidget; + QVBoxLayout *vlayout = new QVBoxLayout; + vlayout->addSpacing(40); // 流程进度提示栏 CircleLable *one = new CircleLable("1", last, 24, QColor(COLOR_BLUE)); - one->move(QPoint(81, 41)); LineLabel *line1 = new LineLabel(last, QColor(COLOR_BLUE)); - line1->move(QPoint(108, 41)); CircleLable *two = new CircleLable("2", last, 24, QColor(COLOR_BLUE)); - two->move(QPoint(261, 41)); LineLabel *line2 = new LineLabel(last, QColor(COLOR_BLUE)); - line2->move(QPoint(288, 41)); CircleLable *three = new CircleLable("3", last, 24, QColor(COLOR_BLUE)); - three->move(QPoint(441, 41)); LineLabel *line3 = new LineLabel(last, QColor(COLOR_BLUE)); - line3->move(QPoint(468, 41)); CircleLable *four = new CircleLable("4", last, 24, QColor(COLOR_BLUE)); - four->move(QPoint(621, 41)); + + QHBoxLayout *hlayoutTopLine1 = new QHBoxLayout; + hlayoutTopLine1->addSpacing(80); + hlayoutTopLine1->addWidget(one); + hlayoutTopLine1->addWidget(line1); + hlayoutTopLine1->addWidget(two); + hlayoutTopLine1->addWidget(line2); + hlayoutTopLine1->addWidget(three); + hlayoutTopLine1->addWidget(line3); + hlayoutTopLine1->addWidget(four); + hlayoutTopLine1->addSpacing(80); + vlayout->addLayout(hlayoutTopLine1); + MyLabel *label1 = new MyLabel(tr("checking"), last); label1->setFontColor(QColor(COLOR_BLUE)); - label1->setGeometry(11, 72, 164, 30); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("preparing"), last); label2->setFontColor(QColor(COLOR_BLUE)); - label2->setGeometry(191, 72, 164, 30); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("backuping"), last); label3->setFontColor(QColor(COLOR_BLUE)); - label3->setGeometry(371, 72, 164, 30); + label3->setFixedWidth(164); MyLabel *label4 = new MyLabel(tr("finished"), last); label4->setFontColor(QColor(COLOR_BLUE)); - label4->setGeometry(551, 72, 164, 30); + label4->setFixedWidth(164); + + QHBoxLayout *hlayoutTopLine2 = new QHBoxLayout; + hlayoutTopLine2->addSpacing(11); + hlayoutTopLine2->addWidget(label1); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label2); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label3); + hlayoutTopLine2->addStretch(); + hlayoutTopLine2->addWidget(label4); + hlayoutTopLine2->addSpacing(11); + vlayout->addLayout(hlayoutTopLine2); + + vlayout->addSpacing(100); //------------ 中部布局begin------------- - QVBoxLayout *vlayout = new QVBoxLayout(last); - vlayout->addSpacing(180); QHBoxLayout *hlayout = new QHBoxLayout; hlayout->addStretch(); - + hlayout->addSpacing(80); QWidget *centerFont = new QWidget(last); + centerFont->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; // 第一行 @@ -1150,10 +1278,10 @@ void SystemBackup::initLastWidget() // 检测中大标题 MyLabel *bigTitle = new MyLabel(centerFont); bigTitle->setFontSize(24); - bigTitle->setMaximumWidth(550); bigTitle->setIsOriginal(true); + bigTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont1->addWidget(bigTitle); - hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont1); // 第二行 @@ -1164,13 +1292,12 @@ void SystemBackup::initLastWidget() hlayoutCenterFont2->addWidget(dot1); hlayoutCenterFont2->addSpacing(5); MyLabel *labelError1 = new MyLabel(centerFont); - labelError1->setMinimumWidth(300); - labelError1->setMaximumWidth(500); labelError1->setIsOriginal(true); labelError1->setWordWrap(true); labelError1->adjustSize(); + labelError1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont2->addWidget(labelError1); - hlayoutCenterFont2->addStretch(); + hlayoutCenterFont2->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont2); // 第三行 @@ -1181,13 +1308,12 @@ void SystemBackup::initLastWidget() hlayoutCenterFont3->addWidget(dot2); hlayoutCenterFont3->addSpacing(5); MyLabel *labelError2 = new MyLabel(centerFont); - labelError2->setMinimumWidth(300); - labelError2->setMaximumWidth(500); labelError2->setIsOriginal(true); labelError2->setWordWrap(true); labelError2->adjustSize(); + labelError2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont3->addWidget(labelError2); - hlayoutCenterFont3->addStretch(); + hlayoutCenterFont3->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont3); // 第四行 @@ -1195,8 +1321,7 @@ void SystemBackup::initLastWidget() // 第五行 QHBoxLayout *hlayoutCenterFont5 = new QHBoxLayout; - // hlayoutCenterFont5->addStretch(); - hlayoutCenterFont5->addSpacing(30); + hlayoutCenterFont5->addStretch(); // 返回首页 MyPushButton *homePage = new MyPushButton(centerFont); homePage->setText(tr("Home Page")); @@ -1211,12 +1336,16 @@ void SystemBackup::initLastWidget() retry->setAutoRepeat(true); hlayoutCenterFont5->addWidget(retry); hlayoutCenterFont5->addStretch(); + hlayoutCenterFont5->setAlignment(Qt::AlignCenter); vlayoutCenterFont->addLayout(hlayoutCenterFont5); centerFont->setLayout(vlayoutCenterFont); hlayout->addWidget(centerFont); + hlayout->addSpacing(80); hlayout->addStretch(); + hlayout->setAlignment(Qt::AlignCenter); vlayout->addLayout(hlayout); + vlayout->addStretch(); last->setLayout(vlayout); //------------ 中部布局end------------- diff --git a/kybackup/module/systemrestore.cpp b/kybackup/module/systemrestore.cpp index 514e073..4624681 100755 --- a/kybackup/module/systemrestore.cpp +++ b/kybackup/module/systemrestore.cpp @@ -241,39 +241,43 @@ void SystemRestore::initSecondWidget() // 流程进度提示栏 CircleLable *one = new CircleLable("1", second, 24, QColor(COLOR_BLUE)); - LineLabel *line1 = new LineLabel(second, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line1 = new LineLabel(second, QColor(COLOR_BLUE)); CircleLable *two = new CircleLable("2", second); - LineLabel *line2 = new LineLabel(second, QColor(COLOR_GRAY), QSize(200, 24)); + LineLabel *line2 = new LineLabel(second, QColor(COLOR_GRAY)); CircleLable *three = new CircleLable("3", second); QHBoxLayout *layoutLine1 = new QHBoxLayout; - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); layoutLine1->addWidget(one); layoutLine1->addWidget(line1); layoutLine1->addWidget(two); layoutLine1->addWidget(line2); layoutLine1->addWidget(three); - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); MyLabel *label1 = new MyLabel(tr("checking"), second); label1->setIsOriginal(true); label1->setFontColor(QColor(COLOR_BLUE)); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("restoring"), second); label2->setIsOriginal(true); label2->setEnabled(false); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("finished"), second); label3->setIsOriginal(true); label3->setEnabled(false); + label3->setFixedWidth(164); QHBoxLayout *layoutLine2 = new QHBoxLayout; - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); layoutLine2->addWidget(label1); layoutLine2->addStretch(); layoutLine2->addWidget(label2); layoutLine2->addStretch(); layoutLine2->addWidget(label3); - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); // ------------ 中部布局begin------------- QWidget *centerFont = new QWidget(second); + centerFont->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; // 第一行 @@ -292,10 +296,10 @@ void SystemRestore::initSecondWidget() // 检测中大标题 MyLabel *bigTitle = new MyLabel(centerFont); bigTitle->setFontSize(24); - bigTitle->setMaximumWidth(550); bigTitle->setIsOriginal(true); + bigTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont1->addWidget(bigTitle); - hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont1); // 第二行 @@ -306,13 +310,12 @@ void SystemRestore::initSecondWidget() hlayoutCenterFont2->addWidget(dot1); hlayoutCenterFont2->addSpacing(5); MyLabel *labelCheck1 = new MyLabel(centerFont); - labelCheck1->setMinimumWidth(300); - labelCheck1->setMaximumWidth(500); labelCheck1->setIsOriginal(true); labelCheck1->setWordWrap(true); labelCheck1->adjustSize(); + labelCheck1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont2->addWidget(labelCheck1); - hlayoutCenterFont2->addStretch(); + hlayoutCenterFont2->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont2); // 第三行 @@ -323,13 +326,12 @@ void SystemRestore::initSecondWidget() hlayoutCenterFont3->addWidget(dot2); hlayoutCenterFont3->addSpacing(5); MyLabel *labelCheck2 = new MyLabel(centerFont); - labelCheck2->setMinimumWidth(300); - labelCheck2->setMaximumWidth(500); labelCheck2->setIsOriginal(true); labelCheck2->setWordWrap(true); labelCheck2->adjustSize(); + labelCheck2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont3->addWidget(labelCheck2); - hlayoutCenterFont3->addStretch(); + hlayoutCenterFont3->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont3); // 第四行 @@ -363,17 +365,19 @@ void SystemRestore::initSecondWidget() recheck->setEnabled(true); recheck->setAutoRepeat(true); hlayoutCenterFont5->addWidget(recheck); - hlayoutCenterFont5->addStretch(); + hlayoutCenterFont5->setAlignment(Qt::AlignCenter); vlayoutCenterFont->addLayout(hlayoutCenterFont5); centerFont->setLayout(vlayoutCenterFont); - - // ------------ 中部布局end------------- - QHBoxLayout *layoutLine3 = new QHBoxLayout; layoutLine3->addStretch(); + layoutLine3->addSpacing(80); layoutLine3->addWidget(centerFont); + layoutLine3->addSpacing(80); layoutLine3->addStretch(); + layoutLine3->setAlignment(Qt::AlignCenter); + + // ------------ 中部布局end------------- // 布局 QVBoxLayout *vlayout = new QVBoxLayout; @@ -568,82 +572,74 @@ void SystemRestore::initThirdWidget() // 流程进度提示栏 CircleLable *one = new CircleLable("1", third, 24, QColor(COLOR_BLUE)); - LineLabel *line1 = new LineLabel(third, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line1 = new LineLabel(third, QColor(COLOR_BLUE)); CircleLable *two = new CircleLable("2", third, 24, QColor(COLOR_BLUE)); - LineLabel *line2 = new LineLabel(third, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line2 = new LineLabel(third, QColor(COLOR_BLUE)); CircleLable *three = new CircleLable("3", third); QHBoxLayout *layoutLine1 = new QHBoxLayout; - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); layoutLine1->addWidget(one); layoutLine1->addWidget(line1); layoutLine1->addWidget(two); layoutLine1->addWidget(line2); layoutLine1->addWidget(three); - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); MyLabel *label1 = new MyLabel(tr("checking"), third); label1->setIsOriginal(true); label1->setFontColor(QColor(COLOR_BLUE)); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("restoring"), third); label2->setIsOriginal(true); label2->setFontColor(QColor(COLOR_BLUE)); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("finished"), third); label3->setIsOriginal(true); label3->setEnabled(false); + label3->setFixedWidth(164); QHBoxLayout *layoutLine2 = new QHBoxLayout; - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); layoutLine2->addWidget(label1); layoutLine2->addStretch(); layoutLine2->addWidget(label2); layoutLine2->addStretch(); layoutLine2->addWidget(label3); - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); // ------------ 中部布局begin------------- - QWidget *centerFont = new QWidget(third); - QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; - // 中部第一行 QHBoxLayout *hlayoutCenterFont1 = new QHBoxLayout; // 检测等待图标 - QLabel *loadingGif = new QLabel(centerFont); + QLabel *loadingGif = new QLabel(third); // 环境检测等待动画 - QMovie *movie = new QMovie(":/images/loading.gif", QByteArray(), centerFont); + QMovie *movie = new QMovie(":/images/loading.gif", QByteArray(), third); loadingGif->setMovie(movie); loadingGif->setVisible(false); // 进度条 - RingsProgressbar *progressBar = new RingsProgressbar(centerFont); + RingsProgressbar *progressBar = new RingsProgressbar(third); progressBar->setFixedSize(100, 100); hlayoutCenterFont1->addStretch(); hlayoutCenterFont1->addWidget(loadingGif); hlayoutCenterFont1->addWidget(progressBar); - hlayoutCenterFont1->addSpacing(20); hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignCenter); // 第二行 QHBoxLayout *hlayoutCenterFont2 = new QHBoxLayout; // 提醒 - MyLabel *labelTip = new MyLabel(centerFont); + MyLabel *labelTip = new MyLabel(third); labelTip->setAlignment(Qt::AlignCenter); labelTip->setIsOriginal(true); labelTip->setFontWordWrap(true); + labelTip->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); // 不要使用电脑,以防数据丢失 labelTip->setDeplayText(tr("Do not use computer in case of data loss")); hlayoutCenterFont2->addStretch(); hlayoutCenterFont2->addWidget(labelTip); hlayoutCenterFont2->addStretch(); - - vlayoutCenterFont->addLayout(hlayoutCenterFont1); - vlayoutCenterFont->addLayout(hlayoutCenterFont2); - vlayoutCenterFont->addStretch(); - centerFont->setLayout(vlayoutCenterFont); + hlayoutCenterFont2->setAlignment(Qt::AlignCenter); // ------------ 中部布局end------------- - QHBoxLayout *layoutLine3 = new QHBoxLayout; - layoutLine3->addStretch(); - layoutLine3->addSpacing(80); - layoutLine3->addWidget(centerFont); - layoutLine3->addStretch(); // 布局 QVBoxLayout *vlayout = new QVBoxLayout; @@ -651,7 +647,8 @@ void SystemRestore::initThirdWidget() vlayout->addLayout(layoutLine1); vlayout->addLayout(layoutLine2); vlayout->addSpacing(50); - vlayout->addLayout(layoutLine3); + vlayout->addLayout(hlayoutCenterFont1); + vlayout->addLayout(hlayoutCenterFont2); vlayout->addStretch(); third->setLayout(vlayout); @@ -811,39 +808,43 @@ void SystemRestore::initLastWidget() // 流程进度提示栏 CircleLable *one = new CircleLable("1", last, 24, QColor(COLOR_BLUE)); - LineLabel *line1 = new LineLabel(last, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line1 = new LineLabel(last, QColor(COLOR_BLUE)); CircleLable *two = new CircleLable("2", last, 24, QColor(COLOR_BLUE)); - LineLabel *line2 = new LineLabel(last, QColor(COLOR_BLUE), QSize(200, 24)); + LineLabel *line2 = new LineLabel(last, QColor(COLOR_BLUE)); CircleLable *three = new CircleLable("3", last, 24, QColor(COLOR_BLUE)); QHBoxLayout *layoutLine1 = new QHBoxLayout; - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); layoutLine1->addWidget(one); layoutLine1->addWidget(line1); layoutLine1->addWidget(two); layoutLine1->addWidget(line2); layoutLine1->addWidget(three); - layoutLine1->addStretch(); + layoutLine1->addSpacing(105); MyLabel *label1 = new MyLabel(tr("checking"), last); label1->setIsOriginal(true); label1->setFontColor(QColor(COLOR_BLUE)); + label1->setFixedWidth(164); MyLabel *label2 = new MyLabel(tr("restoring"), last); label2->setIsOriginal(true); label2->setFontColor(QColor(COLOR_BLUE)); + label2->setFixedWidth(164); MyLabel *label3 = new MyLabel(tr("finished"), last); label3->setIsOriginal(true); label3->setFontColor(QColor(COLOR_BLUE)); + label3->setFixedWidth(164); QHBoxLayout *layoutLine2 = new QHBoxLayout; - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); layoutLine2->addWidget(label1); layoutLine2->addStretch(); layoutLine2->addWidget(label2); layoutLine2->addStretch(); layoutLine2->addWidget(label3); - layoutLine2->addSpacing(100); + layoutLine2->addSpacing(41); // ------------ 中部布局begin------------- QWidget *centerFont = new QWidget(last); + centerFont->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QVBoxLayout *vlayoutCenterFont = new QVBoxLayout; // 中部第一行 @@ -855,10 +856,10 @@ void SystemRestore::initLastWidget() // 检测中大标题 MyLabel *bigTitle = new MyLabel(centerFont); bigTitle->setFontSize(24); - bigTitle->setMaximumWidth(550); bigTitle->setIsOriginal(true); + bigTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont1->addWidget(bigTitle); - hlayoutCenterFont1->addStretch(); + hlayoutCenterFont1->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont1); // 第二行 @@ -869,13 +870,12 @@ void SystemRestore::initLastWidget() hlayoutCenterFont2->addWidget(dot1); hlayoutCenterFont2->addSpacing(5); MyLabel *labelError1 = new MyLabel(centerFont); - labelError1->setMinimumWidth(300); - labelError1->setMaximumWidth(500); labelError1->setIsOriginal(true); labelError1->setWordWrap(true); labelError1->adjustSize(); + labelError1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont2->addWidget(labelError1); - hlayoutCenterFont2->addStretch(); + hlayoutCenterFont2->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont2); // 第三行 @@ -886,13 +886,12 @@ void SystemRestore::initLastWidget() hlayoutCenterFont3->addWidget(dot2); hlayoutCenterFont3->addSpacing(5); MyLabel *labelError2 = new MyLabel(centerFont); - labelError2->setMinimumWidth(300); - labelError2->setMaximumWidth(500); labelError2->setIsOriginal(true); labelError2->setWordWrap(true); labelError2->adjustSize(); + labelError2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); hlayoutCenterFont3->addWidget(labelError2); - hlayoutCenterFont3->addStretch(); + hlayoutCenterFont3->setAlignment(Qt::AlignLeft); vlayoutCenterFont->addLayout(hlayoutCenterFont3); // 第四行 @@ -915,16 +914,17 @@ void SystemRestore::initLastWidget() retry->setAutoRepeat(true); hlayoutCenterFont5->addWidget(retry); hlayoutCenterFont5->addStretch(); + hlayoutCenterFont5->setAlignment(Qt::AlignCenter); vlayoutCenterFont->addLayout(hlayoutCenterFont5); - vlayoutCenterFont->addStretch(); centerFont->setLayout(vlayoutCenterFont); - // ------------ 中部布局end------------- - QHBoxLayout *layoutLine3 = new QHBoxLayout; layoutLine3->addStretch(); + layoutLine3->addSpacing(80); layoutLine3->addWidget(centerFont); + layoutLine3->addSpacing(80); layoutLine3->addStretch(); + // ------------ 中部布局end------------- // 布局 QVBoxLayout *vlayout = new QVBoxLayout;