2021-10-26 09:24:05 +08:00
|
|
|
#ifndef GLABELBACKUPINFO_H
|
|
|
|
#define GLABELBACKUPINFO_H
|
|
|
|
|
|
|
|
#include "../common/singleton.h"
|
|
|
|
#include "../common/spinlock_mutex.h"
|
2021-11-17 13:23:38 +08:00
|
|
|
#include "functypeconverter.h"
|
|
|
|
#include "globalsignals.h"
|
2021-10-26 09:24:05 +08:00
|
|
|
|
|
|
|
class GlobelBackupInfo : public Singleton<GlobelBackupInfo> {
|
|
|
|
public:
|
2022-02-15 16:51:03 +08:00
|
|
|
enum BlackgroundMode {
|
|
|
|
Auto,
|
|
|
|
Light,
|
|
|
|
Dark
|
|
|
|
};
|
|
|
|
|
2021-10-26 09:24:05 +08:00
|
|
|
GlobelBackupInfo(token) {}
|
|
|
|
~GlobelBackupInfo() {}
|
|
|
|
|
2021-12-26 18:15:21 +08:00
|
|
|
// 设置是否管理员用户登录
|
2022-02-15 16:51:03 +08:00
|
|
|
void setIsManager(bool isManager) {
|
|
|
|
m_isManager = isManager;
|
|
|
|
}
|
2021-12-26 18:15:21 +08:00
|
|
|
// 是否管理员用户登录
|
2022-02-15 16:51:03 +08:00
|
|
|
bool isManager() {
|
|
|
|
return m_isManager;
|
|
|
|
}
|
2021-12-26 18:15:21 +08:00
|
|
|
|
2022-02-22 15:25:28 +08:00
|
|
|
// 设置当前登录用户id
|
|
|
|
void setCurUserId(QString curUserId) {
|
|
|
|
m_curUserId = curUserId;
|
|
|
|
}
|
|
|
|
// 当前登录用户id
|
|
|
|
QString curUserId() {
|
|
|
|
return m_curUserId;
|
|
|
|
}
|
|
|
|
|
2021-12-26 18:15:21 +08:00
|
|
|
// 设置是否以--restore参数启动的备份还原工具
|
2022-02-15 16:51:03 +08:00
|
|
|
void setHasArgRestore(bool hasArg_restore) {
|
|
|
|
m_hasArg_restore = hasArg_restore;
|
|
|
|
}
|
2021-12-26 18:15:21 +08:00
|
|
|
// 是否以--restore参数启动的备份还原工具
|
2022-02-15 16:51:03 +08:00
|
|
|
bool hasArgRestore() {
|
|
|
|
return m_hasArg_restore;
|
|
|
|
}
|
2021-12-26 18:15:21 +08:00
|
|
|
|
2021-10-26 09:24:05 +08:00
|
|
|
// 设置是否正在进行备份、还原等操作
|
|
|
|
void setIsBusy(bool isBusy) {
|
|
|
|
std::lock_guard<spinlock_mutex> lock(m_interMutex);
|
|
|
|
m_isBusy = isBusy;
|
2021-11-17 13:23:38 +08:00
|
|
|
emit m_globalSignals.busy(isBusy);
|
2021-10-26 09:24:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 是否正在进行备份、还原等操作
|
|
|
|
bool isBusy() {
|
|
|
|
std::lock_guard<spinlock_mutex> lock(m_interMutex);
|
|
|
|
return m_isBusy;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 是否有备份分区
|
|
|
|
void setHasBackupPartition(bool has) {
|
|
|
|
m_hasBackupPartition = has;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 是否有备份分区
|
|
|
|
bool hasBackupPartition() {
|
|
|
|
return m_hasBackupPartition;
|
|
|
|
}
|
|
|
|
|
2021-11-17 13:23:38 +08:00
|
|
|
// 设置当前功能类型
|
|
|
|
void setFuncType(FuncTypeConverter::FunType type) {
|
|
|
|
m_funcType = type;
|
|
|
|
}
|
|
|
|
|
2022-10-12 17:37:42 +08:00
|
|
|
// 设置是否平板模式
|
|
|
|
void setIsTabletMode(bool is) {
|
|
|
|
m_isTabletMode = is;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 是否平板模式
|
|
|
|
bool isTabletMode() {
|
|
|
|
return m_isTabletMode;
|
|
|
|
}
|
|
|
|
|
2022-10-19 17:02:42 +08:00
|
|
|
// 设置是否wayland平台
|
|
|
|
void setIsWayland(bool is) {
|
|
|
|
m_isWayland = is;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 是否wayland平台
|
|
|
|
bool isWayland() {
|
|
|
|
return m_isWayland;
|
|
|
|
}
|
|
|
|
|
2023-03-17 17:59:26 +08:00
|
|
|
// 设置是否试安装小系统中运行
|
|
|
|
void setIsCasper(bool isCasper) {
|
|
|
|
m_isCasper = isCasper;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 是否试安装小系统中运行模式
|
|
|
|
bool isCasper() {
|
|
|
|
return m_isCasper;
|
|
|
|
}
|
|
|
|
|
2021-11-17 13:23:38 +08:00
|
|
|
// 获取当前功能类型
|
|
|
|
FuncTypeConverter::FunType getFuncType() {
|
|
|
|
return m_funcType;
|
|
|
|
}
|
|
|
|
|
2022-04-18 17:26:52 +08:00
|
|
|
void setMainWidget(QWidget * mainWidget) {
|
|
|
|
m_mainWidget = mainWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget * getMainWidget() {
|
|
|
|
return m_mainWidget;
|
|
|
|
}
|
|
|
|
|
2022-02-15 16:51:03 +08:00
|
|
|
// 设置主题背景模式
|
|
|
|
void setBlackgroundMode(BlackgroundMode blackgroundMode) {
|
|
|
|
m_BlackgroundMode = blackgroundMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 主题背景模式
|
|
|
|
BlackgroundMode getBlackgroundMode() {
|
|
|
|
return m_BlackgroundMode;
|
|
|
|
}
|
|
|
|
|
2021-11-17 13:23:38 +08:00
|
|
|
GlobalSignals * getGlobalSignals() {
|
|
|
|
return &m_globalSignals;
|
|
|
|
}
|
|
|
|
|
2021-10-26 09:24:05 +08:00
|
|
|
void lock() {
|
|
|
|
m_outerMutex.lock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void unlock() {
|
|
|
|
m_outerMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool try_lock() {
|
|
|
|
return m_outerMutex.try_lock();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2023-03-17 17:59:26 +08:00
|
|
|
// 是否试安装小系统中运行
|
|
|
|
bool m_isCasper = false;
|
2021-12-26 18:15:21 +08:00
|
|
|
// 是否管理员
|
|
|
|
bool m_isManager = true;
|
2022-02-22 15:25:28 +08:00
|
|
|
// 当前登录用户id
|
|
|
|
QString m_curUserId;
|
2021-10-26 09:24:05 +08:00
|
|
|
// 是否正在进行备份、还原等操作
|
|
|
|
bool m_isBusy = false;
|
|
|
|
// 是否有备份分区
|
|
|
|
bool m_hasBackupPartition = true;
|
2021-11-17 13:23:38 +08:00
|
|
|
// 当前功能类型
|
|
|
|
FuncTypeConverter::FunType m_funcType = FuncTypeConverter::FunType::TOTALMODULES;
|
2021-12-26 18:15:21 +08:00
|
|
|
// 是否以--restore参数启动的备份还原工具
|
|
|
|
bool m_hasArg_restore = false;
|
2022-02-15 16:51:03 +08:00
|
|
|
// 是否跟随主题
|
|
|
|
BlackgroundMode m_BlackgroundMode = BlackgroundMode::Auto;
|
2022-10-12 17:37:42 +08:00
|
|
|
// 是否平板模式
|
|
|
|
bool m_isTabletMode = false;
|
2022-10-19 17:02:42 +08:00
|
|
|
// 是否wayland平台
|
|
|
|
bool m_isWayland = false;
|
2021-11-17 13:23:38 +08:00
|
|
|
|
2022-04-18 17:26:52 +08:00
|
|
|
QWidget * m_mainWidget = nullptr;
|
|
|
|
|
2021-11-17 13:23:38 +08:00
|
|
|
// 全局信号对象
|
|
|
|
GlobalSignals m_globalSignals;
|
2021-10-26 09:24:05 +08:00
|
|
|
|
|
|
|
spinlock_mutex m_interMutex;
|
|
|
|
spinlock_mutex m_outerMutex;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GLABELBACKUPINFO_H
|