This commit is contained in:
zhaominyong 2022-03-08 09:56:06 +08:00
parent a32dd09a23
commit f6121c996c
13 changed files with 185 additions and 132 deletions

View File

@ -53,6 +53,8 @@
#define COLOR_YELLOW "#F8A34C"
#define COLOR_LIGHT_BLUE "#DDEBFF"
#define QT_USE_NAMESPACE_TEST using namespace Qt;
/**
* @brief
*/

View File

@ -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;

13
debian/changelog vendored
View File

@ -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 <zhaominyong@kylinos.cn> Thu, 04 Nov 2021 20:00:21 +0800
-- zhaominyong <zhaominyong@kylinos.cn> Thu, 24 Feb 2022 15:41:48 +0800

View File

@ -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();
}
});

View File

@ -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);

View File

@ -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)

View File

@ -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 labellabel控件不会变化重绘的场景
* @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);
//}

View File

@ -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;

View File

@ -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

View File

@ -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();
}
});
}

View File

@ -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);
}

View File

@ -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") {
//中文需要翻译

View File

@ -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();