跟随主题问题修复

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_time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
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_arch = SystemInfo::m_arch;
m_backupPoint.m_archdetect = SystemInfo::m_archDetect;

View File

@ -41,6 +41,14 @@ bool DeleteBackupProxy::deleteXmlBackupPoint()
xmlPath.replace("//", "/");
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) {
qCritical() << QString("failed to delete %1 from backuplist.xml!").arg(m_backupWrapper.m_uuid);
emit workResult(false);
@ -69,6 +77,11 @@ void DeleteBackupProxy::deleteBackupPointDir()
QProcess::execute("rm", args);
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
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_time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
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_arch = SystemInfo::m_arch;
m_backupPoint.m_archdetect = SystemInfo::m_archDetect;

View File

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

View File

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

View File

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

View File

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

View File

@ -20,6 +20,7 @@ DeleteBackupDialog::DeleteBackupDialog(ParseBackupList::BackupPoint backupPonit,
ui->setupUi(this);
setMinimumSize(450, 138);
setMaximumSize(450, 200);
this->setAutoFillBackground(true);
// 添加窗管协议
MotifWmHints hints;
@ -29,12 +30,6 @@ DeleteBackupDialog::DeleteBackupDialog(ParseBackupList::BackupPoint backupPonit,
XAtomHelper::getInstance()->setWindowMotifHint(winId(), hints);
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();
@ -224,3 +219,13 @@ void DeleteBackupDialog::on_deleteBackup_end(bool result)
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);
~DeleteBackupDialog();
void paintEvent(QPaintEvent *event);
signals:
void deleteFinished(bool result);

View File

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

View File

@ -132,7 +132,7 @@ TRANSLATIONS += qt_zh_CN.ts
system(rm -f qt_zh_CN.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 += \
app.qrc

View File

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

View File

@ -87,6 +87,7 @@ void ManageBackupPointList::insertLines(const QList<ParseBackupList::BackupPoint
QString preDevPath(Utils::getSysRootPath());
preDevPath += "/media";
preDevPath.replace("//", "/");
for (const ParseBackupList::BackupPoint& backupPoint : backupPoints) {
// 系统备份排除非系统备份且非增量系统备份
if (BackupPointType::SYSTEM == m_backupType &&
@ -98,6 +99,17 @@ void ManageBackupPointList::insertLines(const QList<ParseBackupList::BackupPoint
int(BackupType::INC_BACKUP_DATA) != backupPoint.m_type)
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
if (backupPoint.m_uuid == FACTORY_BACKUP_UUID)
continue;

View File

@ -33,18 +33,18 @@ void OperationLog::initFirstWidget()
QHBoxLayout *hlayoutLine1 = new QHBoxLayout;
QLabel *labelEmptyLogo = new QLabel(this);
if (g_GSettingWrapper.isDarkTheme()) {
QPixmap pixmap(":/images/empty_dark.svg");
QPixmap pixmap(":/images/empty_dark.png");
labelEmptyLogo->setPixmap(pixmap);
} else {
QPixmap pixmap(":/images/empty.svg");
QPixmap pixmap(":/images/empty.png");
labelEmptyLogo->setPixmap(pixmap);
}
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) {
if (isDark) {
QPixmap pixmap(":/images/empty_dark.svg");
QPixmap pixmap(":/images/empty_dark.png");
labelEmptyLogo->setPixmap(pixmap);
} else {
QPixmap pixmap(":/images/empty.svg");
QPixmap pixmap(":/images/empty.png");
labelEmptyLogo->setPixmap(pixmap);
}
});
@ -121,6 +121,14 @@ void OperationLog::initOperationLogs(const QList<BackupWrapper>& list)
int indexOfRow = 0;
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);
setItem(indexOfRow, 0, backupPoint.m_backupName);
setItem(indexOfRow, 1, backupPoint.m_uuid);

View File

@ -4,6 +4,7 @@
#include "component/mypushbutton.h"
#include "../../common/utils.h"
#include "messageboxutils.h"
#include "../globalbackupinfo.h"
SelectRestorePoint::SelectRestorePoint(QWidget *parent, BackupPointType backupType, bool isOnlyShowLocal) :
BackupPointListDialog(parent, isOnlyShowLocal),
@ -93,6 +94,17 @@ void SelectRestorePoint::insertLines(const QList<ParseBackupList::BackupPoint> &
int(BackupType::INC_BACKUP_DATA) != backupPoint.m_type)
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)
continue;

File diff suppressed because it is too large Load Diff

Binary file not shown.