openkylin适配

This commit is contained in:
赵民勇 2022-11-01 15:57:17 +08:00
parent 11df8abd20
commit d731b2aa11
24 changed files with 96 additions and 158 deletions

View File

@ -7,8 +7,7 @@ CONFIG -= app_bundle
CONFIG += link_pkgconfig
LIBS += -lblkid \
-lkysec
LIBS += -lblkid
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings

View File

@ -2,7 +2,6 @@
#include <QStorageInfo>
#include <QDateTime>
#include <QDebug>
#include <kysec/status.h>
#include "../common/utils.h"
#include "../common/mydusizetool.h"
#include "mymountproxy.h"
@ -463,22 +462,8 @@ bool CustomizeDataBackupProxy::backupData()
});
m_p->start(args, false);
do_kylin_security(m_destPath);
qDebug() << "CustomizeDataBackupProxy::backupData invoke end";
return true;
}
void CustomizeDataBackupProxy::do_kylin_security(const QString& dstDir)
{
int ret = 0;
ret = kysec_getstatus();
if (ret > 0) {
QString seFilePath(dstDir + "/.exectl");
QFile file(seFilePath);
file.open(QIODevice::WriteOnly);
file.close();
}
}

View File

@ -67,8 +67,6 @@ protected:
*/
QStringList getRsyncArgs(CustomizeDataBackupScene scene);
void do_kylin_security(const QString& dstDir);
// 失败则删除相应数据
virtual void deleteFailedData();

View File

@ -4,7 +4,6 @@
#include <QDateTime>
#include <QTimer>
#include <QDebug>
#include <kysec/status.h>
#include <unistd.h>
#include "../common/utils.h"
#include "../common/mydusizetool.h"

View File

@ -4,7 +4,6 @@
#include <QDateTime>
#include <QDebug>
#include <QTimer>
#include <kysec/status.h>
#include "../common/utils.h"
#include "../common/mydusizetool.h"
#include "mymountproxy.h"
@ -302,7 +301,6 @@ void CustomizeSystemBackupProxy::doMksqushfs()
args.append(getRsyncArgs(CustomizeSystemBackupScene::MKSQUASHFS));
if (m_mksquashfs->start(args)) {
do_kylin_security(m_destPath);
} else {
emit checkResult(int(BackupResult::MKSQUASHFS_DO_FAIL));
}
@ -386,15 +384,3 @@ bool CustomizeSystemBackupProxy::recordBackupPoint()
return true;
}
void CustomizeSystemBackupProxy::do_kylin_security(const QString& dstDir)
{
int ret = 0;
ret = kysec_getstatus();
if (ret > 0) {
QString seFilePath(dstDir + "/.exectl");
QFile file(seFilePath);
file.open(QIODevice::WriteOnly);
file.close();
}
}

View File

@ -62,8 +62,6 @@ private:
bool backup(const QStringList &args);
void do_kylin_security(const QString& dstDir);
// 失败则删除相应数据
void deleteFailedData();

View File

@ -2,7 +2,6 @@
#include <QStorageInfo>
#include <QDateTime>
#include <QDebug>
#include <kysec/status.h>
#include "../common/utils.h"
#include "../common/mydusizetool.h"
#include "mymountproxy.h"
@ -425,21 +424,6 @@ bool DataBackupProxy::backupData()
});
m_p->start(args, false);
do_kylin_security(m_destPath);
qDebug() << "DataBackupProxy::backupData invoke end";
return true;
}
void DataBackupProxy::do_kylin_security(const QString& dstDir)
{
int ret = 0;
ret = kysec_getstatus();
if (ret > 0) {
QString seFilePath(dstDir + "/.exectl");
QFile file(seFilePath);
file.open(QIODevice::WriteOnly);
file.close();
}
}

View File

@ -67,8 +67,6 @@ protected:
*/
QStringList getRsyncArgs(DataBackupScene scene);
void do_kylin_security(const QString& dstDir);
// 失败则删除相应数据
virtual void deleteFailedData();

View File

@ -3,7 +3,6 @@
#include <QFileInfo>
#include <QDateTime>
#include <QDebug>
#include <kysec/status.h>
#include <unistd.h>
#include "../common/utils.h"
#include "../common/mydusizetool.h"

View File

@ -12,7 +12,6 @@
#include <QDBusConnection>
#include <mutex>
#include <sys/reboot.h>
#include <kysec/status.h>
#include "mybackupmanager.h"
#include "../common/utils.h"
#include "mymountproxy.h"
@ -559,32 +558,6 @@ bool MyBackupManager::unlock()
*/
void MyBackupManager::setKysecStatus(bool status)
{
if (status) {
if (m_bOpenKysec)
Utils::setKysecStatus(true);
m_bOpenKysec = false;
if (m_bStartKysecDeamon)
Utils::setKysecDaemon(true);
m_bStartKysecDeamon = false;
} else {
if (KYSEC_STATUS_ENABLED == kysec_getstatus()) {
// 安全保护已开启
m_bOpenKysec = true;
Utils::setKysecStatus(false);
// 开启安全防护
// QProcess::execute("systemctl start kysec-init.service");
} else {
m_bOpenKysec = false;
}
if(Utils::isRunning("kysec-sync-daemon")){
m_bStartKysecDeamon = true;
Utils::setKysecDaemon(false);
// 停止安全防护
// QProcess::execute("systemctl stop kysec-init.service");
} else {
m_bStartKysecDeamon = false;
}
}
// openkylin平台中不开源安全模块删掉安全模块的调用
Q_UNUSED(status)
}

View File

@ -2,7 +2,6 @@
#include <QStorageInfo>
#include <QDateTime>
#include <QDebug>
#include <kysec/status.h>
#include "../common/utils.h"
#include "../common/mydusizetool.h"
#include "mymountproxy.h"
@ -509,21 +508,7 @@ bool SystemBackupProxy::backupSystem()
});
m_p->start(args, false);
do_kylin_security(m_destPath);
qDebug() << "SystemBackupProxy::backupSystem invoke end";
return true;
}
void SystemBackupProxy::do_kylin_security(const QString& dstDir)
{
int ret = 0;
ret = kysec_getstatus();
if (ret > 0) {
QString seFilePath(dstDir + "/.exectl");
QFile file(seFilePath);
file.open(QIODevice::WriteOnly);
file.close();
}
}

View File

@ -70,8 +70,6 @@ private:
// 备份系统
bool backupSystem();
void do_kylin_security(const QString& dstDir);
// 失败则删除相应数据
void deleteFailedData();

View File

@ -3,7 +3,6 @@
#include <QDateTime>
#include <QDebug>
#include <QTimer>
#include <kysec/status.h>
#include "../common/utils.h"
#include "../common/mydusizetool.h"
#include "mymountproxy.h"
@ -411,8 +410,6 @@ bool UDiskDataBackupProxy::backupDataToUdisk()
});
m_p->start(args, false);
do_kylin_security(m_destPath);
qDebug() << "UDiskDataBackupProxy::backupDataToUdisk invoke end";
return true;
}

View File

@ -4,7 +4,6 @@
#include <QDateTime>
#include <QTimer>
#include <QDebug>
#include <kysec/status.h>
#include <unistd.h>
#include "../common/utils.h"
#include "../common/mydusizetool.h"

View File

@ -4,7 +4,6 @@
#include <QDateTime>
#include <QDebug>
#include <QTimer>
#include <kysec/status.h>
#include "../common/utils.h"
#include "../common/mydusizetool.h"
#include "mymountproxy.h"
@ -560,24 +559,10 @@ bool UDiskSystemBackupProxy::backup(const QStringList &args)
m_p->start(args, false);
emit checkResult(int(BackupResult::BACKUP_START_SUCCESS));
do_kylin_security(m_destPath);
qDebug() << "UDiskSystemBackupProxy::backup invoke end";
return true;
}
void UDiskSystemBackupProxy::do_kylin_security(const QString& dstDir)
{
int ret = 0;
ret = kysec_getstatus();
if (ret > 0) {
QString seFilePath(dstDir + "/.exectl");
QFile file(seFilePath);
file.open(QIODevice::WriteOnly);
file.close();
}
}
/**
* @brief
* @return: bool,truefalse

View File

@ -87,8 +87,6 @@ private:
bool backup(const QStringList &args);
void do_kylin_security(const QString& dstDir);
// 失败则删除相应数据
void deleteFailedData();

5
debian/control vendored
View File

@ -13,18 +13,19 @@ Build-Depends: debhelper (>= 9),
qtbase5-dev-tools,
qtbase5-private-dev,
libblkid-dev,
libkysec-dev,
libkf5windowsystem-dev,
libx11-dev,
libqt5x11extras5-dev,
libgsettings-qt-dev,
libkysdk-qtwidgets-dev,
libkysdk-waylandhelper-dev,
libkysdk-appcommon,
Standards-Version: 3.9.5
Homepage: http://kylinos.cn
Package: yhkylin-backup-tools
Architecture: any
Depends: ${misc:Depends},${shlibs:Depends},libqt5widgets5,libqt5gui5,libqt5dbus5,libqt5xml5,libqt5core5a,libblkid1,rsync,squashfs-tools, libkysec
Depends: ${misc:Depends},${shlibs:Depends},libqt5widgets5,libqt5gui5,libqt5dbus5,libqt5xml5,libqt5core5a,libblkid1,rsync,squashfs-tools
Description: YHkylin backup tools
YHkylin backup tools

View File

@ -9,6 +9,8 @@
#include "../common/mydefine.h"
#include "../common/utils.h"
#include "messageboxutils.h"
#include <ukuistylehelper/ukuistylehelper.h>
#include <windowmanager/windowmanager.h>
DeleteBackupDialog::DeleteBackupDialog(ParseBackupList::BackupPoint backupPonit, QWidget *parent) :
QDialog(parent),
@ -22,11 +24,16 @@ DeleteBackupDialog::DeleteBackupDialog(ParseBackupList::BackupPoint backupPonit,
this->setAutoFillBackground(true);
// 添加窗管协议
MotifWmHints hints;
hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
hints.functions = MWM_FUNC_ALL;
hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(winId(), hints);
if (GlobelBackupInfo::inst().isWayland()){
// 去除窗管标题栏传入参数为QWidget *
kdk::UkuiStyleHelper::self()->removeHeader(this);
} else {
MotifWmHints hints;
hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
hints.functions = MWM_FUNC_ALL;
hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(winId(), hints);
}
setWindowModality(Qt::WindowModal);
// 设置标题栏

View File

@ -82,6 +82,16 @@ public:
return m_isTabletMode;
}
// 设置是否wayland平台
void setIsWayland(bool is) {
m_isWayland = is;
}
// 是否wayland平台
bool isWayland() {
return m_isWayland;
}
// 获取当前功能类型
FuncTypeConverter::FunType getFuncType() {
return m_funcType;
@ -138,6 +148,8 @@ private:
BlackgroundMode m_BlackgroundMode = BlackgroundMode::Auto;
// 是否平板模式
bool m_isTabletMode = false;
// 是否wayland平台
bool m_isWayland = false;
QWidget * m_mainWidget = nullptr;

View File

@ -16,7 +16,7 @@ LIBS +=-lX11
# 配置gsettings
CONFIG += link_pkgconfig
PKGCONFIG += gsettings-qt
PKGCONFIG += kysdk-qtwidgets
PKGCONFIG += kysdk-qtwidgets kysdk-waylandhelper
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings

View File

@ -15,6 +15,8 @@
#include "xatom-helper.h"
#include "globalbackupinfo.h"
#include "messageboxutils.h"
#include <ukuistylehelper/ukuistylehelper.h>
#include <windowmanager/windowmanager.h>
// 声明
void initApp(QApplication& a);
@ -48,9 +50,11 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS;
}
QString platform = QGuiApplication::platformName();
if(platform.startsWith(QLatin1String("wayland"),Qt::CaseInsensitive) || QString(qgetenv("XDG_SESSION_TYPE")) == "wayland") {
GlobelBackupInfo::inst().setIsWayland(true);
}
MainDialog w;
// 居中窗口
centerToScreen(&w);
a.setWindowIcon(QIcon::fromTheme(THEME_YHKYLIN_BACKUP_TOOLS, QIcon(":/images/yhkylin-backup-tools.png")));
a.setActivationWindow(&w, true);
@ -58,6 +62,9 @@ int main(int argc, char *argv[])
QObject::connect(&a,SIGNAL(messageReceived(const QString&)),&w,SLOT(sltMessageReceived(const QString&)));
w.show();
// 居中窗口
centerToScreen(&w);
return a.exec();
}
@ -179,17 +186,27 @@ bool isManager()
* @brief
* @param widget
*/
#include <QScreen>
void centerToScreen(QWidget* widget)
{
if (!widget)
return;
QDesktopWidget* m = QApplication::desktop();
// QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
QRect desk_rect = m->screenGeometry(widget);
int desk_x = desk_rect.width();
int desk_y = desk_rect.height();
int x = widget->width();
int y = widget->height();
widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
if (GlobelBackupInfo::inst().isWayland()){
// center window
int sw=QGuiApplication::primaryScreen()->availableGeometry().width();
int sh=QGuiApplication::primaryScreen()->availableGeometry().height();
kdk::WindowManager::setGeometry(widget->windowHandle(), QRect((sw - x)/2, (sh - y)/2, x, y));
} else {
QDesktopWidget* m = QApplication::desktop();
// QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
QRect desk_rect = m->screenGeometry(widget);
int desk_x = desk_rect.width();
int desk_y = desk_rect.height();
widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
}
}

View File

@ -21,6 +21,8 @@
#include "aboutdialog.h"
#include "gsettingswrapper.h"
#include "component/mywidget.h"
#include <ukuistylehelper/ukuistylehelper.h>
#include <windowmanager/windowmanager.h>
MainDialog::MainDialog(QWidget *parent)
: QMainWindow(parent)
@ -40,11 +42,16 @@ MainDialog::MainDialog(QWidget *parent)
this->setAutoFillBackground(true);
// 添加窗管协议
MotifWmHints hints;
hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
hints.functions = MWM_FUNC_ALL;
hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints);
if (GlobelBackupInfo::inst().isWayland()){
// 去除窗管标题栏传入参数为QWidget *
kdk::UkuiStyleHelper::self()->removeHeader(this);
} else {
MotifWmHints hints;
hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
hints.functions = MWM_FUNC_ALL;
hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints);
}
GlobelBackupInfo::inst().setMainWidget(this);

View File

@ -345,8 +345,6 @@ void DataBackup::initSecondWidget()
searchLayout->setSpacing(0);
// 删除按钮
PixmapLabel *buttonDelete = new PixmapLabel;
buttonDelete->setFixedSize(24, 24);
buttonDelete->setUkuiIconSchema("window-close-symbolic", ":/symbos/window-close-symbolic");
buttonDelete->setToolTip(tr("Clear"));
buttonDelete->setChangeHover();
connect(buttonDelete, &PixmapLabel::clicked, this, [=]() {
@ -354,8 +352,6 @@ void DataBackup::initSecondWidget()
});
// 添加按钮
PixmapLabel *buttonAdd = new PixmapLabel;
buttonAdd->setFixedSize(24, 24);
buttonAdd->setUkuiIconSchema("object-select-symbolic", ":/symbos/object-select-symbolic");
buttonAdd->setToolTip(tr("Add"));
buttonAdd->setChangeHover();
searchLayout->addWidget(buttonDelete);
@ -376,9 +372,17 @@ void DataBackup::initSecondWidget()
if (GlobelBackupInfo::inst().isTabletMode()) {
editSelect->setTextMargins(0, 0, 70, 0);
buttonDelete->setFixedSize(28, 28);
buttonDelete->setUkuiIconSchema("window-close-symbolic", ":/symbos/window-close-symbolic", QSize(24, 24));
buttonDelete->setUkuiIconSchema("window-close-symbolic", ":/symbos/window-close-symbolic", QSize(20, 20));
buttonAdd->setFixedSize(28, 28);
buttonAdd->setUkuiIconSchema("object-select-symbolic", ":/symbos/object-select-symbolic", QSize(24, 24));
buttonAdd->setUkuiIconSchema("object-select-symbolic", ":/symbos/object-select-symbolic", QSize(20, 20));
searchLayout->setSpacing(5);
} else {
editSelect->setTextMargins(0, 0, 62, 0);
buttonDelete->setFixedSize(24, 24);
buttonDelete->setUkuiIconSchema("window-close-symbolic", ":/symbos/window-close-symbolic");
buttonAdd->setFixedSize(24, 24);
buttonAdd->setUkuiIconSchema("object-select-symbolic", ":/symbos/object-select-symbolic");
searchLayout->setSpacing(0);
}
// 选择按钮
@ -704,8 +708,6 @@ void DataBackup::initSecondWidget_inc()
searchLayout->setSpacing(0);
// 删除按钮
PixmapLabel *buttonDelete = new PixmapLabel;
buttonDelete->setFixedSize(24, 24);
buttonDelete->setUkuiIconSchema("window-close-symbolic", ":/symbos/window-close-symbolic");
buttonDelete->setToolTip(tr("Clear"));
buttonDelete->setChangeHover();
connect(buttonDelete, &PixmapLabel::clicked, this, [=]() {
@ -713,8 +715,6 @@ void DataBackup::initSecondWidget_inc()
});
// 添加按钮
PixmapLabel *buttonAdd = new PixmapLabel;
buttonAdd->setFixedSize(24, 24);
buttonAdd->setUkuiIconSchema("object-select-symbolic", ":/symbos/object-select-symbolic");
buttonAdd->setToolTip(tr("Add"));
buttonAdd->setChangeHover();
searchLayout->addWidget(buttonDelete);
@ -731,6 +731,22 @@ void DataBackup::initSecondWidget_inc()
buttonAdd->setVisible(false);
}
});
// 平板中放大点
if (GlobelBackupInfo::inst().isTabletMode()) {
editSelect->setTextMargins(0, 0, 70, 0);
buttonDelete->setFixedSize(28, 28);
buttonDelete->setUkuiIconSchema("window-close-symbolic", ":/symbos/window-close-symbolic", QSize(20, 20));
buttonAdd->setFixedSize(28, 28);
buttonAdd->setUkuiIconSchema("object-select-symbolic", ":/symbos/object-select-symbolic", QSize(20, 20));
searchLayout->setSpacing(5);
} else {
editSelect->setTextMargins(0, 0, 62, 0);
buttonDelete->setFixedSize(24, 24);
buttonDelete->setUkuiIconSchema("window-close-symbolic", ":/symbos/window-close-symbolic");
buttonAdd->setFixedSize(24, 24);
buttonAdd->setUkuiIconSchema("object-select-symbolic", ":/symbos/object-select-symbolic");
searchLayout->setSpacing(0);
}
// 选择按钮
MyPushButton *buttonSelect = new MyPushButton;
@ -1665,10 +1681,6 @@ void DataBackup::initFifthWidget()
// 不要使用电脑,以防数据丢失
labelTip->setDeplayText(tr("Do not use computer in case of data loss"));
cancel->setEnabled(true);
if (this->m_isIncrement)
cancel->setVisible(false);
else
cancel->setVisible(true);
// 开始备份
this->on_backup_start();

View File

@ -7,10 +7,11 @@ Comment[zh_CN]=提供系统备份还原和数据备份还原等功能
Comment[bo_CN]=རྒྱུད་ཁོངས་གྲབས་ཉར་དང་གཞི་གྲངས་གྲབས་ཉར་སོར་ལོག་མཁོ་འདོན་སོགས་ཀྱི་ནུས་པ་
Keywords=backup
TryExec=kybackup
Exec=kybackup %U
Exec=/usr/bin/kybackup %U
StartupNotify=true
Terminal=false
Type=Application
Icon=yhkylin-backup-tools
X-GNOME-DocPath=
Categories=GNOME;GTK;Tools;System
X-KDE-Wayland-Interfaces=org_kde_plasma_window_management,org_kde_kwin_keystate