跟随主题问题修复

This commit is contained in:
zhaominyong 2022-02-22 15:25:28 +08:00
parent f4366ecb7d
commit 34042d31cf
18 changed files with 596 additions and 523 deletions

View File

@ -342,6 +342,8 @@ bool DataBackupProxy::recordBackupPoint()
m_backupPoint.m_size = Utils::StringBySize(m_size); m_backupPoint.m_size = Utils::StringBySize(m_size);
m_backupPoint.m_time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss"); m_backupPoint.m_time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
m_backupPoint.m_state = BACKUP_PARSE_STATE_FAIL_STRTING; m_backupPoint.m_state = BACKUP_PARSE_STATE_FAIL_STRTING;
if (0 < m_backupWrapper.m_frontUid)
m_backupPoint.m_userId = QString::number(m_backupWrapper.m_frontUid);
m_backupPoint.m_os = SystemInfo::m_os; m_backupPoint.m_os = SystemInfo::m_os;
m_backupPoint.m_arch = SystemInfo::m_arch; m_backupPoint.m_arch = SystemInfo::m_arch;
m_backupPoint.m_archdetect = SystemInfo::m_archDetect; m_backupPoint.m_archdetect = SystemInfo::m_archDetect;

View File

@ -41,6 +41,14 @@ bool DeleteBackupProxy::deleteXmlBackupPoint()
xmlPath.replace("//", "/"); xmlPath.replace("//", "/");
ParseBackupList parse(xmlPath); ParseBackupList parse(xmlPath);
// 查询节点
ParseBackupList::BackupPoint backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid);
if ( int(BackupType::BACKUP_DATA) != backupPoint.m_type
&& int(BackupType::INC_BACKUP_DATA) != backupPoint.m_type) {
m_backupWrapper.m_type = backupPoint.m_type;
}
// 删除节点
if (parse.deleteItem(m_backupWrapper.m_uuid) != ParseBackupList::SUCCESS) { if (parse.deleteItem(m_backupWrapper.m_uuid) != ParseBackupList::SUCCESS) {
qCritical() << QString("failed to delete %1 from backuplist.xml!").arg(m_backupWrapper.m_uuid); qCritical() << QString("failed to delete %1 from backuplist.xml!").arg(m_backupWrapper.m_uuid);
emit workResult(false); emit workResult(false);
@ -69,6 +77,11 @@ void DeleteBackupProxy::deleteBackupPointDir()
QProcess::execute("rm", args); QProcess::execute("rm", args);
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss"); QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupWrapper.m_backupName); if ( int(BackupType::BACKUP_DATA) == m_backupWrapper.m_type
|| int(BackupType::INC_BACKUP_DATA) == m_backupWrapper.m_type) {
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupWrapper.m_backupName);
} else {
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupWrapper.m_backupName);
}
} }

View File

@ -278,6 +278,8 @@ bool UDiskDataBackupProxy::recordBackupPointToUdisk()
m_backupPoint.m_size = Utils::StringBySize(m_size); m_backupPoint.m_size = Utils::StringBySize(m_size);
m_backupPoint.m_time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss"); m_backupPoint.m_time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
m_backupPoint.m_state = BACKUP_PARSE_STATE_FAIL_STRTING; m_backupPoint.m_state = BACKUP_PARSE_STATE_FAIL_STRTING;
if (0 < m_backupWrapper.m_frontUid)
m_backupPoint.m_userId = QString::number(m_backupWrapper.m_frontUid);
m_backupPoint.m_os = SystemInfo::m_os; m_backupPoint.m_os = SystemInfo::m_os;
m_backupPoint.m_arch = SystemInfo::m_arch; m_backupPoint.m_arch = SystemInfo::m_arch;
m_backupPoint.m_archdetect = SystemInfo::m_archDetect; m_backupPoint.m_archdetect = SystemInfo::m_archDetect;

View File

@ -27,12 +27,7 @@ AboutDialog::AboutDialog(QWidget *parent) :
hints.decorations = MWM_DECOR_BORDER; hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(winId(), hints); XAtomHelper::getInstance()->setWindowMotifHint(winId(), hints);
// 设置背景色
this->setAutoFillBackground(true); this->setAutoFillBackground(true);
QPalette palette = this->palette();
palette.setColor(QPalette::Window, palette.color(QPalette::Base));
this->setPalette(palette);
this->setFixedWidth(420); this->setFixedWidth(420);
this->setMinimumHeight(420); this->setMinimumHeight(420);
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
@ -146,3 +141,15 @@ AboutDialog::~AboutDialog()
{ {
delete ui; delete ui;
} }
void AboutDialog::paintEvent(QPaintEvent *event)
{
// 设置背景色
QPalette palette = this->palette();
palette.setColor(QPalette::Window, palette.color(QPalette::Base));
this->setPalette(palette);
QDialog::paintEvent(event);
}

View File

@ -18,6 +18,8 @@ public:
QString getBackupVersion(); QString getBackupVersion();
void paintEvent(QPaintEvent *event);
private: private:
Ui::AboutDialog *ui; Ui::AboutDialog *ui;
}; };

View File

@ -84,18 +84,18 @@ BackupPointListDialog::BackupPointListDialog(QWidget *parent, bool isOnlyShowLoc
// 列表为空时展示图片 // 列表为空时展示图片
m_labelEmpty = new QLabel(m_tableWidget); m_labelEmpty = new QLabel(m_tableWidget);
if (g_GSettingWrapper.isDarkTheme()) { if (g_GSettingWrapper.isDarkTheme()) {
QPixmap pixmap(":/images/empty_dark.svg"); QPixmap pixmap(":/images/empty_dark.png");
m_labelEmpty->setPixmap(pixmap); m_labelEmpty->setPixmap(pixmap);
} else { } else {
QPixmap pixmap(":/images/empty.svg"); QPixmap pixmap(":/images/empty.png");
m_labelEmpty->setPixmap(pixmap); m_labelEmpty->setPixmap(pixmap);
} }
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) { connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) {
if (isDark) { if (isDark) {
QPixmap pixmap(":/images/empty_dark.svg"); QPixmap pixmap(":/images/empty_dark.png");
m_labelEmpty->setPixmap(pixmap); m_labelEmpty->setPixmap(pixmap);
} else { } else {
QPixmap pixmap(":/images/empty.svg"); QPixmap pixmap(":/images/empty.png");
m_labelEmpty->setPixmap(pixmap); m_labelEmpty->setPixmap(pixmap);
} }
}); });

View File

@ -9,10 +9,10 @@
MyIconButton::MyIconButton(QWidget *parent) : MyIconButton::MyIconButton(QWidget *parent) :
QPushButton(parent) QPushButton(parent)
{ {
this->setCheckable(true); this->setCheckable(false);
m_iconButton = new QPushButton(this); m_iconButton = new QPushButton(this);
m_iconButton->setCheckable(true); m_iconButton->setCheckable(false);
m_iconButton->setFixedSize(QSize(24, 24)); m_iconButton->setFixedSize(QSize(24, 24));
m_iconButton->setFocusPolicy(Qt::NoFocus); m_iconButton->setFocusPolicy(Qt::NoFocus);
m_iconButton->setFlat(true); m_iconButton->setFlat(true);
@ -61,7 +61,7 @@ void MyIconButton::setDesplayText(const QString &text)
void MyIconButton::changePalette(bool checked) void MyIconButton::changePalette(bool checked)
{ {
m_iconButton->setChecked(checked); // m_iconButton->setChecked(checked);
QPalette pal(m_textLabel->palette()); QPalette pal(m_textLabel->palette());
QIcon icon = QIcon::fromTheme(m_themeIconName, QIcon(m_defaultIconName)); QIcon icon = QIcon::fromTheme(m_themeIconName, QIcon(m_defaultIconName));
QPixmap pix; QPixmap pix;

View File

@ -28,9 +28,9 @@ void RingsProgressbar::paintEvent(QPaintEvent *)
QPen pen = p.pen(); QPen pen = p.pen();
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
if (g_GSettingWrapper.isDarkTheme()) if (g_GSettingWrapper.isDarkTheme())
p.setBrush(QBrush(QColor(COLOR_LIGHT_BLUE)));
else
p.setBrush(QBrush(palette().button().color())); p.setBrush(QBrush(palette().button().color()));
else
p.setBrush(QBrush(QColor(COLOR_LIGHT_BLUE)));
p.drawEllipse(outRect); p.drawEllipse(outRect);
p.setBrush(QBrush(QColor(COLOR_BLUE))); p.setBrush(QBrush(QColor(COLOR_BLUE)));

View File

@ -20,6 +20,7 @@ DeleteBackupDialog::DeleteBackupDialog(ParseBackupList::BackupPoint backupPonit,
ui->setupUi(this); ui->setupUi(this);
setMinimumSize(450, 138); setMinimumSize(450, 138);
setMaximumSize(450, 200); setMaximumSize(450, 200);
this->setAutoFillBackground(true);
// 添加窗管协议 // 添加窗管协议
MotifWmHints hints; MotifWmHints hints;
@ -29,12 +30,6 @@ DeleteBackupDialog::DeleteBackupDialog(ParseBackupList::BackupPoint backupPonit,
XAtomHelper::getInstance()->setWindowMotifHint(winId(), hints); XAtomHelper::getInstance()->setWindowMotifHint(winId(), hints);
setWindowModality(Qt::WindowModal); setWindowModality(Qt::WindowModal);
// 设置背景色
this->setAutoFillBackground(true);
QPalette palette = this->palette();
palette.setColor(QPalette::Window, palette.color(QPalette::Base));
this->setPalette(palette);
// 设置标题栏 // 设置标题栏
QHBoxLayout * titleLayout = new QHBoxLayout(); QHBoxLayout * titleLayout = new QHBoxLayout();
@ -224,3 +219,13 @@ void DeleteBackupDialog::on_deleteBackup_end(bool result)
m_pInterface = nullptr; m_pInterface = nullptr;
} }
void DeleteBackupDialog::paintEvent(QPaintEvent *event)
{
// 设置背景色
QPalette palette = this->palette();
palette.setColor(QPalette::Window, palette.color(QPalette::Base));
this->setPalette(palette);
QDialog::paintEvent(event);
}

View File

@ -21,6 +21,8 @@ public:
explicit DeleteBackupDialog(ParseBackupList::BackupPoint backupPonit, QWidget *parent = nullptr); explicit DeleteBackupDialog(ParseBackupList::BackupPoint backupPonit, QWidget *parent = nullptr);
~DeleteBackupDialog(); ~DeleteBackupDialog();
void paintEvent(QPaintEvent *event);
signals: signals:
void deleteFinished(bool result); void deleteFinished(bool result);

View File

@ -26,6 +26,15 @@ public:
return m_isManager; return m_isManager;
} }
// 设置当前登录用户id
void setCurUserId(QString curUserId) {
m_curUserId = curUserId;
}
// 当前登录用户id
QString curUserId() {
return m_curUserId;
}
// 设置是否以--restore参数启动的备份还原工具 // 设置是否以--restore参数启动的备份还原工具
void setHasArgRestore(bool hasArg_restore) { void setHasArgRestore(bool hasArg_restore) {
m_hasArg_restore = hasArg_restore; m_hasArg_restore = hasArg_restore;
@ -97,6 +106,8 @@ public:
private: private:
// 是否管理员 // 是否管理员
bool m_isManager = true; bool m_isManager = true;
// 当前登录用户id
QString m_curUserId;
// 是否正在进行备份、还原等操作 // 是否正在进行备份、还原等操作
bool m_isBusy = false; bool m_isBusy = false;
// 是否有备份分区 // 是否有备份分区

View File

@ -132,7 +132,7 @@ TRANSLATIONS += qt_zh_CN.ts
system(rm -f qt_zh_CN.qm) system(rm -f qt_zh_CN.qm)
!system(lrelease qt_zh_CN.ts): error("Failed to generate qm") !system(lrelease qt_zh_CN.ts): error("Failed to generate qm")
system(cp qt_zh_CN.qm resource/language) system(cp qt_zh_CN.qm resource/language/)
RESOURCES += \ RESOURCES += \
app.qrc app.qrc

View File

@ -133,11 +133,12 @@ bool isManager()
return true; return true;
uid_t uid = getuid(); uid_t uid = getuid();
QString sid = QString::number(uid);
GlobelBackupInfo::inst().setCurUserId(sid);
// root用户 // root用户
if (0 == uid) if (0 == uid)
return true; return true;
QString sid = QString::number(uid);
QString userObject = "/org/freedesktop/Accounts/User" + sid; QString userObject = "/org/freedesktop/Accounts/User" + sid;
// 创建QDBusInterface // 创建QDBusInterface

View File

@ -87,6 +87,7 @@ void ManageBackupPointList::insertLines(const QList<ParseBackupList::BackupPoint
QString preDevPath(Utils::getSysRootPath()); QString preDevPath(Utils::getSysRootPath());
preDevPath += "/media"; preDevPath += "/media";
preDevPath.replace("//", "/"); preDevPath.replace("//", "/");
for (const ParseBackupList::BackupPoint& backupPoint : backupPoints) { for (const ParseBackupList::BackupPoint& backupPoint : backupPoints) {
// 系统备份排除非系统备份且非增量系统备份 // 系统备份排除非系统备份且非增量系统备份
if (BackupPointType::SYSTEM == m_backupType && if (BackupPointType::SYSTEM == m_backupType &&
@ -98,6 +99,17 @@ void ManageBackupPointList::insertLines(const QList<ParseBackupList::BackupPoint
int(BackupType::INC_BACKUP_DATA) != backupPoint.m_type) int(BackupType::INC_BACKUP_DATA) != backupPoint.m_type)
continue; continue;
// 数据备份需要用户隔离
if (BackupPointType::DATA == m_backupType) {
// 管理员可看自己用户进行的数据备份和无用户信息的数据备份(旧备份数据)
if (GlobelBackupInfo::inst().isManager() && !backupPoint.m_userId.isEmpty() && backupPoint.m_userId != GlobelBackupInfo::inst().curUserId())
continue ;
// 标准用户只能看自己进行的操作
if (!GlobelBackupInfo::inst().isManager() && backupPoint.m_userId != GlobelBackupInfo::inst().curUserId())
continue ;
}
//hide factory backup //hide factory backup
if (backupPoint.m_uuid == FACTORY_BACKUP_UUID) if (backupPoint.m_uuid == FACTORY_BACKUP_UUID)
continue; continue;

View File

@ -33,18 +33,18 @@ void OperationLog::initFirstWidget()
QHBoxLayout *hlayoutLine1 = new QHBoxLayout; QHBoxLayout *hlayoutLine1 = new QHBoxLayout;
QLabel *labelEmptyLogo = new QLabel(this); QLabel *labelEmptyLogo = new QLabel(this);
if (g_GSettingWrapper.isDarkTheme()) { if (g_GSettingWrapper.isDarkTheme()) {
QPixmap pixmap(":/images/empty_dark.svg"); QPixmap pixmap(":/images/empty_dark.png");
labelEmptyLogo->setPixmap(pixmap); labelEmptyLogo->setPixmap(pixmap);
} else { } else {
QPixmap pixmap(":/images/empty.svg"); QPixmap pixmap(":/images/empty.png");
labelEmptyLogo->setPixmap(pixmap); labelEmptyLogo->setPixmap(pixmap);
} }
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) { connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) {
if (isDark) { if (isDark) {
QPixmap pixmap(":/images/empty_dark.svg"); QPixmap pixmap(":/images/empty_dark.png");
labelEmptyLogo->setPixmap(pixmap); labelEmptyLogo->setPixmap(pixmap);
} else { } else {
QPixmap pixmap(":/images/empty.svg"); QPixmap pixmap(":/images/empty.png");
labelEmptyLogo->setPixmap(pixmap); labelEmptyLogo->setPixmap(pixmap);
} }
}); });
@ -121,6 +121,14 @@ void OperationLog::initOperationLogs(const QList<BackupWrapper>& list)
int indexOfRow = 0; int indexOfRow = 0;
for (const BackupWrapper& backupPoint : list) { for (const BackupWrapper& backupPoint : list) {
// 管理员可看自己用户进行的操作和无用户信息的数据备份(旧备份数据)
if (GlobelBackupInfo::inst().isManager() && (backupPoint.m_frontUid != -1) && backupPoint.m_frontUid != GlobelBackupInfo::inst().curUserId().toInt())
continue ;
// 标准用户只能看自己进行的操作
if (!GlobelBackupInfo::inst().isManager() && backupPoint.m_frontUid != GlobelBackupInfo::inst().curUserId().toInt())
continue ;
m_tableWidget->insertRow(indexOfRow); m_tableWidget->insertRow(indexOfRow);
setItem(indexOfRow, 0, backupPoint.m_backupName); setItem(indexOfRow, 0, backupPoint.m_backupName);
setItem(indexOfRow, 1, backupPoint.m_uuid); setItem(indexOfRow, 1, backupPoint.m_uuid);

View File

@ -4,6 +4,7 @@
#include "component/mypushbutton.h" #include "component/mypushbutton.h"
#include "../../common/utils.h" #include "../../common/utils.h"
#include "messageboxutils.h" #include "messageboxutils.h"
#include "../globalbackupinfo.h"
SelectRestorePoint::SelectRestorePoint(QWidget *parent, BackupPointType backupType, bool isOnlyShowLocal) : SelectRestorePoint::SelectRestorePoint(QWidget *parent, BackupPointType backupType, bool isOnlyShowLocal) :
BackupPointListDialog(parent, isOnlyShowLocal), BackupPointListDialog(parent, isOnlyShowLocal),
@ -93,6 +94,17 @@ void SelectRestorePoint::insertLines(const QList<ParseBackupList::BackupPoint> &
int(BackupType::INC_BACKUP_DATA) != backupPoint.m_type) int(BackupType::INC_BACKUP_DATA) != backupPoint.m_type)
continue; continue;
// 数据备份需要用户隔离
if (BackupPointType::DATA == m_backupType) {
// 管理员可看自己用户进行的数据备份和无用户信息的数据备份(旧备份数据)
if (GlobelBackupInfo::inst().isManager() && !backupPoint.m_userId.isEmpty() && backupPoint.m_userId != GlobelBackupInfo::inst().curUserId())
continue ;
// 标准用户只能看自己进行的操作
if (!GlobelBackupInfo::inst().isManager() && backupPoint.m_userId != GlobelBackupInfo::inst().curUserId())
continue ;
}
// 不展示未完成的备份点 // 不展示未完成的备份点
if (BACKUP_PARSE_STATE_SUCCESS_STRTING != backupPoint.m_state) if (BACKUP_PARSE_STATE_SUCCESS_STRTING != backupPoint.m_state)
continue; continue;

File diff suppressed because it is too large Load Diff

Binary file not shown.