diff --git a/common/mydefine.h b/common/mydefine.h index c23fae0..8ff6fe6 100755 --- a/common/mydefine.h +++ b/common/mydefine.h @@ -53,6 +53,8 @@ #define COLOR_YELLOW "#F8A34C" #define COLOR_LIGHT_BLUE "#DDEBFF" +#define QT_USE_NAMESPACE_TEST using namespace Qt; + /** * @brief 备份还原操作类型 */ diff --git a/common/utils.cpp b/common/utils.cpp index 06b8c44..a0318ec 100755 --- a/common/utils.cpp +++ b/common/utils.cpp @@ -26,6 +26,8 @@ #include "mylittleparse.h" #include "mydefine.h" +QT_USE_NAMESPACE_TEST + QString SystemInfo::m_os; QString SystemInfo::m_arch; QString SystemInfo::m_archDetect; diff --git a/debian/changelog b/debian/changelog index 9b48c79..c40154a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,11 @@ -yhkylin-backup-tools (4.0.14-kylin01) v101; urgency=medium +yhkylin-backup-tools (4.0.14-kylin06) v101; urgency=medium - * BUG 号:无 + * BUG 号: + 108063 【备份还原4.0.14】Gost镜像完成页面与设计稿不符 + 107778 中等 一般 【备份还原4.0.14】系统备份中点击取消,取消系统备份后,之前的系统备份都被删除 + 107706 【备份还原4.0.14】备份/还原过程可以关闭备份还原 * 需求号:无 - * 其它:UKUI3.1版本 - * git commit:2828ff5789620d0963b5481a88a240493987fd0d + * 其它:无 + * git commit: 310c94c8d3f997a8df031a1db902636b15ae19df - -- zhaominyong Thu, 04 Nov 2021 20:00:21 +0800 + -- zhaominyong Thu, 24 Feb 2022 15:41:48 +0800 diff --git a/kybackup/component/backuplistwidget.cpp b/kybackup/component/backuplistwidget.cpp index f56ecd7..a389318 100755 --- a/kybackup/component/backuplistwidget.cpp +++ b/kybackup/component/backuplistwidget.cpp @@ -131,8 +131,9 @@ bool BackupListWidget::appendItem(const QString &text) this->takeItem(this->row(item)); delete item; if (this->count() == 0) { - m_plusLogo->setVisible(true); - m_plusText->setVisible(true); + this->m_plusLogo->setVisible(true); + this->m_plusText->setVisible(true); + emit this->deleteEmpty(); } }); diff --git a/kybackup/component/backuplistwidget.h b/kybackup/component/backuplistwidget.h index 243020d..fa6aede 100755 --- a/kybackup/component/backuplistwidget.h +++ b/kybackup/component/backuplistwidget.h @@ -39,12 +39,16 @@ public: // 清空 void clearData() { this->clear(); - m_List.clear(); + this->m_List.clear(); + emit this->deleteEmpty(); } protected: void dropEvent(QDropEvent *e); +signals: + void deleteEmpty(); + private: bool checkPathLimit(const QString &path); diff --git a/kybackup/component/myiconbutton.cpp b/kybackup/component/myiconbutton.cpp index 06e2e3f..a37ddf6 100755 --- a/kybackup/component/myiconbutton.cpp +++ b/kybackup/component/myiconbutton.cpp @@ -23,7 +23,7 @@ MyIconButton::MyIconButton(QWidget *parent) : textLabelPolicy.setHorizontalPolicy(QSizePolicy::Fixed); textLabelPolicy.setVerticalPolicy(QSizePolicy::Fixed); m_textLabel->setSizePolicy(textLabelPolicy); - m_textLabel->setScaledContents(true); + // m_textLabel->setScaledContents(true); QHBoxLayout *hLayout = new QHBoxLayout(); hLayout->setContentsMargins(8, 0, 0, 0); @@ -58,27 +58,20 @@ void MyIconButton::changePalette(bool checked) m_iconButton->setChecked(checked); QPalette pal = m_textLabel->palette(); // png格式的图标会自动跟随主题,不需再手动设置像素颜色 -// QIcon icon = QIcon::fromTheme(m_themeIconName, QIcon(m_defaultIconName)); -// QPixmap pix; if (g_GSettingWrapper.isDarkTheme()) { if (checked) { pal.setColor(QPalette::ButtonText, this->palette().highlightedText().color()); -// pix = ImageUtil::loadPixmap(icon, QString("black")); } else { pal.setColor(QPalette::ButtonText, this->palette().windowText().color()); -// pix = ImageUtil::loadPixmap(icon, QString("white")); } } else { if (checked) { pal.setColor(QPalette::ButtonText, this->palette().highlightedText().color()); -// pix = ImageUtil::loadPixmap(icon, QString("white")); } else { pal.setColor(QPalette::ButtonText, this->palette().windowText().color()); -// pix = ImageUtil::loadPixmap(icon, QString("black")); } } m_textLabel->setPalette(pal); - //m_iconButton->setIcon(pix); } void MyIconButton::paintEvent(QPaintEvent *event) diff --git a/kybackup/component/mylabel.cpp b/kybackup/component/mylabel.cpp index 2a44491..9a7fdd1 100755 --- a/kybackup/component/mylabel.cpp +++ b/kybackup/component/mylabel.cpp @@ -24,13 +24,28 @@ MyLabel::MyLabel(QWidget* parent) : } } }); + + connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::fontChanged, this, [=]() { + // 字体家族、大小变化需重绘,并且字体大小变化也可能会造成显示不全问题 + if (this->wordWrap()) { + this->setText(m_text); + } else { + QFontMetrics fontMetrics(this->font()); + int fontSize = fontMetrics.width(m_text); + if (fontSize > this->width()) { + this->setText(fontMetrics.elidedText(m_text, Qt::ElideRight, this->width())); + } else { + this->setText(m_text); + } + } + }); } /** * @brief 构造固定大小、颜色、内容居中等的label,一般用于label控件不会变化重绘的场景 * @param text * @param parent - * @param color + * @param align */ MyLabel::MyLabel(const QString& text, QWidget* parent /*= nullptr*/, Qt::Alignment align /*= Qt::AlignCenter*/) : QLabel(parent), @@ -38,7 +53,6 @@ MyLabel::MyLabel(const QString& text, QWidget* parent /*= nullptr*/, Qt::Alignme m_bAutoTheme(true) { this->setAlignment(align); - this->setScaledContents(true); this->setText(text); connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) { @@ -51,6 +65,21 @@ MyLabel::MyLabel(const QString& text, QWidget* parent /*= nullptr*/, Qt::Alignme } } }); + + connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::fontChanged, this, [=]() { + // 字体家族、大小变化需重绘,并且字体大小变化也可能会造成显示不全问题 + if (this->wordWrap()) { + this->setText(m_text); + } else { + QFontMetrics fontMetrics(this->font()); + int fontSize = fontMetrics.width(m_text); + if (fontSize > this->width()) { + this->setText(fontMetrics.elidedText(m_text, Qt::ElideRight, this->width())); + } else { + this->setText(m_text); + } + } + }); } MyLabel::~MyLabel() @@ -106,43 +135,43 @@ void MyLabel::setFontWordWrap(bool on) m_rect = geometry(); } -void MyLabel::paintEvent(QPaintEvent *event) -{ - // 1、场景一:布局动态变化场景,使用原始的QLabel绘制 - if (m_isOriginal) { - this->setText(m_text); - QLabel::paintEvent(event); +//void MyLabel::paintEvent(QPaintEvent *event) +//{ +// // 1、场景一:布局动态变化场景,使用原始的QLabel绘制 +// if (m_isOriginal) { +// this->setText(m_text); +// QLabel::paintEvent(event); - return ; - } +// return ; +// } - // 2、场景二:setGeometry固定label位置和大小的场景 - QFontMetrics fontMetrics(this->font()); - int fontSize = fontMetrics.width(m_text); - if (m_bWordWrap && m_width > 0) { - // resize(m_width, m_height); - // setGeometry(m_rect); - // 恢复控件宽度,如果不固定宽度则换行位置不好控制 - this->setFixedWidth(m_width); - } +// // 2、场景二:setGeometry固定label位置和大小的场景 +// QFontMetrics fontMetrics(this->font()); +// int fontSize = fontMetrics.width(m_text); +// if (m_bWordWrap && m_width > 0) { +// // resize(m_width, m_height); +// // setGeometry(m_rect); +// // 恢复控件宽度,如果不固定宽度则换行位置不好控制 +// this->setFixedWidth(m_width); +// } - if (fontSize > this->width()) { - if (m_bWordWrap) { - // 调整控件大小 - adjustSize(); - setAlignment(Qt::AlignTop | Qt::AlignLeft); - this->setText(m_text); - } else { - this->setText(fontMetrics.elidedText(m_text, Qt::ElideRight, this->width())); - } - } else { - if (m_bWordWrap) { - // 恢复控件大小及位置 - setGeometry(m_rect); - setAlignment(Qt::AlignVCenter | Qt::AlignLeft); - } - this->setText(m_text); - } +// if (fontSize > this->width()) { +// if (m_bWordWrap) { +// // 调整控件大小 +// adjustSize(); +// setAlignment(Qt::AlignTop | Qt::AlignLeft); +// this->setText(m_text); +// } else { +// this->setText(fontMetrics.elidedText(m_text, Qt::ElideRight, this->width())); +// } +// } else { +// if (m_bWordWrap) { +// // 恢复控件大小及位置 +// setGeometry(m_rect); +// setAlignment(Qt::AlignVCenter | Qt::AlignLeft); +// } +// this->setText(m_text); +// } - QLabel::paintEvent(event); -} +// QLabel::paintEvent(event); +//} diff --git a/kybackup/component/mylabel.h b/kybackup/component/mylabel.h index 599d8a4..f211960 100755 --- a/kybackup/component/mylabel.h +++ b/kybackup/component/mylabel.h @@ -19,7 +19,8 @@ public: void setIsOriginal(bool isOriginal) { m_isOriginal = isOriginal; } protected: - void paintEvent(QPaintEvent *event); + // 主要因为字体变化而重绘,故暂不重写paintEvent,改为在构造方法中监控主题的字体(家族和大小)变化 +// void paintEvent(QPaintEvent *event); private: QString m_text; diff --git a/kybackup/globalsignals.h b/kybackup/globalsignals.h index 0361a77..7b265e6 100755 --- a/kybackup/globalsignals.h +++ b/kybackup/globalsignals.h @@ -14,14 +14,17 @@ signals: // 系统忙碌信号 void busy(bool isBusy); - // 主题背景变化信号 - void styleNameChanged(bool isDark); - // 主题图标变更 void themeIconChanged(); + // 主题背景变化信号 + void styleNameChanged(bool isDark); + // 窗口或控件的背景色发生了变化。主要用于通知主题监控模块,用于修正控件颜色,以简化用户自定义背景色跟随主题变化的代码 void backgroundColorChanged(); + + // 字体(家族或大小)变化 + void fontChanged(); }; #endif // GLOBALSIGNALS_H diff --git a/kybackup/gsettingswrapper.cpp b/kybackup/gsettingswrapper.cpp index 12ddfff..d3f818a 100755 --- a/kybackup/gsettingswrapper.cpp +++ b/kybackup/gsettingswrapper.cpp @@ -39,6 +39,9 @@ GSettingsWrapper::GSettingsWrapper(token) } else if (key == ICON_THEME_NAME) { // 图标变更 emit GlobelBackupInfo::inst().getGlobalSignals()->themeIconChanged(); + } else if ("systemFont" == key || "systemFontSize" == key) { + // 字体大小或字体类型发生变化 + emit GlobelBackupInfo::inst().getGlobalSignals()->fontChanged(); } }); } diff --git a/kybackup/leftsiderbarwidget.cpp b/kybackup/leftsiderbarwidget.cpp index 9bb1b1a..8170ba5 100755 --- a/kybackup/leftsiderbarwidget.cpp +++ b/kybackup/leftsiderbarwidget.cpp @@ -75,10 +75,6 @@ LeftsiderbarWidget::LeftsiderbarWidget(QWidget *parent, StartMode mode) // 設置無邊框,跟隨背景色 funcButton->setFlat(true); - // 設置了setStyleSheet,不能再跟隨主題,舍弃此种方式 -// funcButton->setStyleSheet("QPushButton:hover{background-color: rgba(55,144,250,0.30);border-radius: 4px;}" -// "QPushButton:checked{background-color: palette(highlight);border-radius: 4px;}" -// "QPushButton:!checked{border: none;}"); m_funcGroup->addButton(funcButton, type); m_leftSideBarVLayout->addWidget(funcButton); } diff --git a/kybackup/main.cpp b/kybackup/main.cpp index b5e4ec0..09d7cd7 100755 --- a/kybackup/main.cpp +++ b/kybackup/main.cpp @@ -77,12 +77,12 @@ int main(int argc, char *argv[]) */ void initApp(QApplication& a) { - //前端向后端传递QString参数,若参数中含有中文则保证不会乱码 + // 前端向后端传递QString参数,若参数中含有中文则保证不会乱码 QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); - //区分中英文 + // 区分中英文 QString locale = QLocale::system().name(); - //QT自身标准的翻译 + // QT自身标准的翻译 #ifndef QT_NO_TRANSLATION QString translatorFileName = QLatin1String("qt_"); translatorFileName += locale; @@ -93,7 +93,7 @@ void initApp(QApplication& a) qDebug() << "load qt translator file failed!"; #endif - //应用内的翻译 + // 应用内的翻译 QTranslator *translator = new QTranslator(); if (locale == "zh_CN") { //中文需要翻译 diff --git a/kybackup/module/databackup.cpp b/kybackup/module/databackup.cpp index b5b3368..39ea840 100755 --- a/kybackup/module/databackup.cpp +++ b/kybackup/module/databackup.cpp @@ -357,32 +357,6 @@ void DataBackup::initSecondWidget() hlayoutLine5->addWidget(listWidget); hlayoutLine5->addStretch(); vlayout->addLayout(hlayoutLine5); - connect(buttonAdd, &QPushButton::clicked, this, [=]() { - if (editSelect->text().isEmpty()) - MessageBoxUtils::QMESSAGE_BOX_WARNING(this, QObject::tr("Warning"), - QObject::tr("Please select a backup file or directory"), - QObject::tr("Ok")); - else { - if (listWidget->appendItem(editSelect->text())) { - editSelect->setText(""); - } - } - }); - connect(buttonSelect, &MyPushButton::clicked, this, [=](){ - MyFileSelect *fileDialog = new MyFileSelect(this); - fileDialog->setWindowTitle(tr("Please select file to backup")); - fileDialog->setSidebarUrls(siderUrls); - - if (fileDialog->exec() == QDialog::Accepted) { - QStringList selectFiles = fileDialog->selectedFiles(); - if (!selectFiles.isEmpty()) { - QString fileName = selectFiles.at(0); - editSelect->setText(fileName); - } - } - - delete fileDialog; - }); // 最后一行 vlayout->addSpacing(25); @@ -400,7 +374,7 @@ void DataBackup::initSecondWidget() // 下一步按钮 MyPushButton *nextStep = new MyPushButton(second); nextStep->setText(tr("Next")); - nextStep->setEnabled(true); + nextStep->setEnabled(false); nextStep->setAutoRepeat(true); connect(nextStep, &MyPushButton::clicked, this, [=]() { // 备份路径选择索引 @@ -422,6 +396,37 @@ void DataBackup::initSecondWidget() vlayout->addStretch(); second->setLayout(vlayout); + connect(buttonAdd, &QPushButton::clicked, this, [=]() { + if (editSelect->text().isEmpty()) + MessageBoxUtils::QMESSAGE_BOX_WARNING(this, QObject::tr("Warning"), + QObject::tr("Please select a backup file or directory"), + QObject::tr("Ok")); + else { + if (listWidget->appendItem(editSelect->text())) { + editSelect->setText(""); + nextStep->setEnabled(true); + } + } + }); + connect(buttonSelect, &MyPushButton::clicked, this, [=](){ + MyFileSelect *fileDialog = new MyFileSelect(this); + fileDialog->setWindowTitle(tr("Please select file to backup")); + fileDialog->setSidebarUrls(siderUrls); + + if (fileDialog->exec() == QDialog::Accepted) { + QStringList selectFiles = fileDialog->selectedFiles(); + if (!selectFiles.isEmpty()) { + QString fileName = selectFiles.at(0); + editSelect->setText(fileName); + } + } + + delete fileDialog; + }); + connect(listWidget, &BackupListWidget::deleteEmpty, this, [=](){ + nextStep->setEnabled(false); + }); + connect(this, &DataBackup::reset, this, [=]() { editSelect->setText(""); this->m_backupPaths.clear(); @@ -572,38 +577,6 @@ void DataBackup::initSecondWidget_inc() hlayoutLine5->addWidget(listWidget); hlayoutLine5->addStretch(); vlayout->addLayout(hlayoutLine5); - connect(buttonAdd, &QPushButton::clicked, this, [=]() { - if (editSelect->text().isEmpty()) - MessageBoxUtils::QMESSAGE_BOX_WARNING(this, QObject::tr("Warning"), - QObject::tr("Please select a backup file or directory"), - QObject::tr("Ok")); - else { - if (listWidget->appendItem(editSelect->text())) - editSelect->setText(""); - } - }); - connect(buttonSelect, &MyPushButton::clicked, this, [=](){ - QFileDialog *fileDialog = new QFileDialog(this); - fileDialog->setViewMode(QFileDialog::List); - fileDialog->setWindowTitle(tr("Please select file to backup")); - fileDialog->setSidebarUrls(siderUrls); - fileDialog->setFilter(QDir::System | QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); - - if (fileDialog->exec() == QDialog::Accepted) { - QStringList selectFiles = fileDialog->selectedFiles(); - if (!selectFiles.isEmpty()) { - QString fileName = selectFiles.at(0); - editSelect->setText(fileName); - } - } - - delete fileDialog; - }); - // 增量备份初始化备份路径列表 - connect(this, &DataBackup::initIncListWidget, this, [=]() { - emit this->reset(); - this->addOldBackupPaths(listWidget); - }); // 最后一行 vlayout->addSpacing(25); @@ -621,14 +594,8 @@ void DataBackup::initSecondWidget_inc() // 下一步按钮 MyPushButton *nextStep = new MyPushButton(second); nextStep->setText(tr("Next")); - nextStep->setEnabled(true); nextStep->setAutoRepeat(true); - connect(nextStep, &MyPushButton::clicked, this, [=]() { - this->m_backupPaths.clear(); - this->m_backupPaths.append(listWidget->getBackupPaths()); - this->setCurrentIndex(CHECK_ENV_PAGE); - emit this->startCheckEnv(); - }); + hlayoutLastLine->addWidget(preStep); hlayoutLastLine->addSpacing(20); hlayoutLastLine->addWidget(nextStep); @@ -638,6 +605,55 @@ void DataBackup::initSecondWidget_inc() vlayout->addStretch(); second->setLayout(vlayout); + connect(buttonAdd, &QPushButton::clicked, this, [=]() { + if (editSelect->text().isEmpty()) + MessageBoxUtils::QMESSAGE_BOX_WARNING(this, QObject::tr("Warning"), + QObject::tr("Please select a backup file or directory"), + QObject::tr("Ok")); + else { + if (listWidget->appendItem(editSelect->text())) { + editSelect->setText(""); + nextStep->setEnabled(true); + } + } + }); + + connect(buttonSelect, &MyPushButton::clicked, this, [=](){ + QFileDialog *fileDialog = new QFileDialog(this); + fileDialog->setViewMode(QFileDialog::List); + fileDialog->setWindowTitle(tr("Please select file to backup")); + fileDialog->setSidebarUrls(siderUrls); + fileDialog->setFilter(QDir::System | QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); + + if (fileDialog->exec() == QDialog::Accepted) { + QStringList selectFiles = fileDialog->selectedFiles(); + if (!selectFiles.isEmpty()) { + QString fileName = selectFiles.at(0); + editSelect->setText(fileName); + } + } + + delete fileDialog; + }); + + connect(listWidget, &BackupListWidget::deleteEmpty, this, [=](){ + nextStep->setEnabled(false); + }); + + connect(nextStep, &MyPushButton::clicked, this, [=]() { + this->m_backupPaths.clear(); + this->m_backupPaths.append(listWidget->getBackupPaths()); + this->setCurrentIndex(CHECK_ENV_PAGE); + emit this->startCheckEnv(); + }); + + // 增量备份初始化备份路径列表 + connect(this, &DataBackup::initIncListWidget, this, [=]() { + emit this->reset(); + this->addOldBackupPaths(listWidget); + nextStep->setEnabled(true); + }); + connect(this, &DataBackup::reset, this, [=]() { editSelect->setText(""); this->m_backupPaths.clear();