!48 修复2.4第二测试以及自测中出现的缺陷

From: @liubuguiii 
Reviewed-by: @tangjie02 
Signed-off-by: @tangjie02
This commit is contained in:
openeuler-ci-bot 2022-12-02 06:57:43 +00:00 committed by Gitee
commit 502109fbb5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 19 additions and 1417 deletions

View File

@ -1,429 +0,0 @@
From 19ed0f093a304c99f7b54dc66ef0c05ceb3162bd Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Mon, 7 Nov 2022 15:44:34 +0800
Subject: [PATCH 1/5] feat(license): briefly displays the license
information,provide access to the activation interface
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 简要展示激活信息,提供激活信息入口
---
plugins/system/CMakeLists.txt | 6 +
.../data/com.kylinsec.Kiran.LicenseObject.xml | 45 +++++++
.../system-information/system-information.cpp | 124 +++++++++++++++---
.../system-information/system-information.h | 8 +-
.../system-information/system-information.ui | 85 ++++++++++++
5 files changed, 249 insertions(+), 19 deletions(-)
create mode 100644 plugins/system/data/com.kylinsec.Kiran.LicenseObject.xml
diff --git a/plugins/system/CMakeLists.txt b/plugins/system/CMakeLists.txt
index fb49f4b..619f469 100644
--- a/plugins/system/CMakeLists.txt
+++ b/plugins/system/CMakeLists.txt
@@ -18,9 +18,15 @@ file(GLOB_RECURSE SYSTEM_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
qt5_create_translation(SYSTEM_QM ${CMAKE_CURRENT_SOURCE_DIR} .//translations/kiran-cpanel-system.zh_CN.ts)
+kiran_qt5_add_dbus_interface_ex(LICENSE_DBUS_SRC
+ data/com.kylinsec.Kiran.LicenseObject.xml
+ dbus_license_dbus
+ DBusLicenseObject)
+
add_library(${TARGET_NAME} SHARED
${SYSTEM_SRC}
${SYSTEM_QM}
+ ${LICENSE_DBUS_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/data/res.qrc)
target_include_directories(${TARGET_NAME} PRIVATE
diff --git a/plugins/system/data/com.kylinsec.Kiran.LicenseObject.xml b/plugins/system/data/com.kylinsec.Kiran.LicenseObject.xml
new file mode 100644
index 0000000..cf3760f
--- /dev/null
+++ b/plugins/system/data/com.kylinsec.Kiran.LicenseObject.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
+ <interface name="com.kylinsec.Kiran.LicenseObject">
+
+ <method name="GetLicense">
+ <arg name="license_json" direction="out" type="s">
+ <summary>The license info contain activation status, service status, activation code, machine code and activation type etc..</summary>
+ </arg>
+ <description>Get the license info.</description>
+ </method>
+
+ <method name="ActivateByActivationCode">
+ <arg name="activation_code" direction="in" type="s">
+ <summary>The activation code.</summary>
+ </arg>
+ <description>Activate by activation code.</description>
+ </method>
+
+ <method name="ActivateByUsbKey">
+ <arg name="ukey_json" direction="out" type="s">
+ <summary>The usb key info contain authorized points and remaining points.</summary>
+ </arg>
+ <description>Activate by usb key.</description>
+ </method>
+
+ <method name="ActivateOnLine">
+ <arg name="host" direction="in" type="s">
+ <summary>The host used to request activation code.</summary>
+ </arg>
+ <arg name="service_uid" direction="in" type="s">
+ <summary>The service uid to request activation code.</summary>
+ </arg>
+ <description>Activate on-line.</description>
+ </method>
+
+ <signal name="LicenseChanged">
+ <arg name="placeholder" type="b">
+ <summary>The placeholder.</summary>
+ </arg>
+ <description>The license info is changed, you need call function GetLicense to get the newest license info.</description>
+ </signal>
+
+ </interface>
+</node>
diff --git a/plugins/system/src/pages/system-information/system-information.cpp b/plugins/system/src/pages/system-information/system-information.cpp
index 4409040..bf36086 100644
--- a/plugins/system/src/pages/system-information/system-information.cpp
+++ b/plugins/system/src/pages/system-information/system-information.cpp
@@ -14,11 +14,14 @@
#include "system-information.h"
#include "dbus-wrapper/system-info-dbus.h"
+#include "dbus_license_dbus.h"
#include "license-agreement.h"
#include "ui_system-information.h"
-
#include <kiran-log/qt5-log-i.h>
+#include <style-property.h>
+#include <QDBusConnection>
+#include <QDBusConnectionInterface>
#include <QDateTime>
#include <QDesktopWidget>
#include <QFont>
@@ -26,7 +29,10 @@
#include <QJsonObject>
#include <QJsonValue>
#include <QPainter>
-#include <style-property.h>
+#include <QDateTime>
+#include <QProcess>
+#include <kiran-message-box.h>
+
#define HOST_NAME "host_name"
#define ARCH "arch"
#define KERNEL_VERSION "kernel_version"
@@ -34,7 +40,7 @@
#define KERNEL_RELEASE "kernel_release"
#define PRODUCT_RELEASE "product_release"
-SystemInformation::SystemInformation(QWidget *parent)
+SystemInformation::SystemInformation(QWidget* parent)
: QWidget(parent), ui(new Ui::SystemInformation), hostNameWidget(nullptr), licenseAgreement(nullptr)
{
ui->setupUi(this);
@@ -78,9 +84,10 @@ void SystemInformation::init()
});
// clang-format on
connect(ui->btn_change_name, &QPushButton::clicked, this, &SystemInformation::handleChangeHostName);
- Kiran::StylePropertyHelper::setButtonType(ui->btn_change_name,Kiran::BUTTON_Default);
- Kiran::StylePropertyHelper::setButtonType(ui->btn_EULA,Kiran::BUTTON_Default);
- Kiran::StylePropertyHelper::setButtonType(ui->btn_version_license,Kiran::BUTTON_Default);
+ Kiran::StylePropertyHelper::setButtonType(ui->btn_change_name, Kiran::BUTTON_Default);
+ Kiran::StylePropertyHelper::setButtonType(ui->btn_EULA, Kiran::BUTTON_Default);
+ Kiran::StylePropertyHelper::setButtonType(ui->btn_version_license, Kiran::BUTTON_Default);
+ Kiran::StylePropertyHelper::setButtonType(ui->btn_license_show, Kiran::BUTTON_Default);
}
bool SystemInformation::initUI()
@@ -97,7 +104,7 @@ bool SystemInformation::initUI()
}
else
{
- QString hostname,arch,systemVersion,kernelVersion;
+ QString hostname, arch, systemVersion, kernelVersion;
parseSoftwareInfoJson(systemInfoJson,
hostname,
arch,
@@ -108,16 +115,26 @@ bool SystemInformation::initUI()
ui->lab_system_arch_info->setText(arch);
ui->lab_system_version_info->setText(systemVersion);
ui->lab_core_version_info->setText(kernelVersion);
+ }
+ QString licenseDesc;
+ if (!checkLicensEnable() || !getLicenseDesc(licenseDesc))
+ {
+ ui->widget_license->setVisible(false);
+ }
+ else
+ {
+ ui->lab_license_status->setText(licenseDesc);
+ connect(ui->btn_license_show, &QPushButton::clicked, this, &SystemInformation::handleShowLicenseDialog);
}
- QList<QLabel *> labels = {ui->lab_name_info,ui->lab_core_version_info, ui->lab_system_arch_info,ui->lab_system_version_info};
- for (auto label : labels)
+ QList<QLabel*> labels = {ui->lab_name_info, ui->lab_core_version_info, ui->lab_system_arch_info, ui->lab_system_version_info, ui->lab_license_status};
+ for (QLabel* label : labels)
{
label->setStyleSheet("color:#919191;font-family: \"Noto Sans CJK SC regular\";");
}
- auto kiranFrames = findChildren<KiranFrame *>();
+ auto kiranFrames = findChildren<KiranFrame*>();
for (auto frame : kiranFrames)
{
frame->setRadius(6);
@@ -151,25 +168,90 @@ void SystemInformation::parseSoftwareInfoJson(QString jsonString,
return;
}
QJsonObject rootObject = jsonDocument.object();
- if( rootObject.contains("host_name") && rootObject["host_name"].isString() )
+ if (rootObject.contains("host_name") && rootObject["host_name"].isString())
{
hostName = rootObject["host_name"].toString();
}
- if( rootObject.contains("arch") && rootObject["arch"].isString() )
+ if (rootObject.contains("arch") && rootObject["arch"].isString())
{
arch = rootObject["arch"].toString();
}
- if( rootObject.contains("product_release") && rootObject["product_release"].isString() )
+ if (rootObject.contains("product_release") && rootObject["product_release"].isString())
{
systemVersion = rootObject["product_release"].toString();
}
- if( rootObject.contains("kernal_name") && rootObject["kernal_name"].isString() &&
- rootObject.contains("kernel_release") && rootObject["kernel_release"].isString() )
+ if (rootObject.contains("kernal_name") && rootObject["kernal_name"].isString() &&
+ rootObject.contains("kernel_release") && rootObject["kernel_release"].isString())
{
kernelVersion = rootObject["kernal_name"].toString() + " " + rootObject["kernel_release"].toString();
}
}
+bool SystemInformation::checkLicensEnable()
+{
+ QDBusConnection dbusConn = QDBusConnection::systemBus();
+ return dbusConn.interface()->isServiceRegistered("com.kylinsec.Kiran.LicenseManager");
+}
+
+bool SystemInformation::getLicenseDesc(QString& licenseStatus)
+{
+ DBusLicenseObject dBusLicenseObject("com.kylinsec.Kiran.LicenseManager",
+ "/com/kylinsec/Kiran/LicenseObject/KylinSecOS",
+ QDBusConnection::systemBus());
+ auto reply = dBusLicenseObject.GetLicense();
+ reply.waitForFinished();
+ if (reply.isError())
+ {
+ KLOG_ERROR() << "KylinSecOS GetLicense failed:" << reply.error();
+ return false;
+ }
+
+ QString licenseJson = reply.value();
+ QJsonDocument jsonDocument = QJsonDocument::fromJson(licenseJson.toUtf8());
+ QJsonObject rootObj = jsonDocument.object();
+ QStringList keys = rootObj.keys();
+
+ QSet<QString> keySet = {"expired_time","activation_status"};
+ for( auto key:keySet )
+ {
+ if( !keys.contains(key) )
+ {
+ KLOG_ERROR() << "KylinSecOS GetLicense missing key:" << key;
+ return false;
+ }
+ }
+
+ QVariant expiredTimeVar = rootObj["expired_time"].toVariant();
+ qlonglong expiredTimeSinceEpoch = expiredTimeVar.toULongLong();
+
+ QVariant activationStatusVar = rootObj["activation_status"].toVariant();
+ qulonglong activationStatus = activationStatusVar.toULongLong();
+
+ QDateTime expiredTime = QDateTime::fromSecsSinceEpoch(expiredTimeSinceEpoch);
+ if (activationStatus == 0) //未激活
+ {
+ licenseStatus = tr("UnActivated");
+ }
+ else
+ {
+ QDateTime currentDateTime = QDateTime::currentDateTime();
+
+ if( currentDateTime > expiredTime ) //激活码已过期
+ {
+ licenseStatus = tr("Activation code has expired");
+ }
+ else if( expiredTime.date().year() >= 2100 ) //永久激活
+ {
+ licenseStatus = tr("Permanently activated");
+ }
+ else //已激活
+ {
+ licenseStatus = tr("Activated");
+ }
+ }
+ return true;
+}
+
/**
* @brief SystemInformation::onBtnchangeHostName: 当点击更改用户名后的槽函数
*/
@@ -200,13 +282,21 @@ void SystemInformation::updateHostName(bool isChanged, QString name)
}
}
+void SystemInformation::handleShowLicenseDialog()
+{
+ if( !QProcess::startDetached("/usr/bin/ksl-os-gui") )
+ {
+ KiranMessageBox::message(this, tr("Error"), tr("Failed to open the license activator"),KiranMessageBox::Ok);
+ }
+}
+
/**
* @brief 事件监听,当收到激活向导窗口或者授权信息窗口的关闭事件时,释放窗口内存
* @param obj 事件对象
* @param obj 事件
* @return 是否过滤
*/
-bool SystemInformation::eventFilter(QObject *obj, QEvent *event)
+bool SystemInformation::eventFilter(QObject* obj, QEvent* event)
{
if (obj == hostNameWidget && event->type() == QEvent::Close)
{
@@ -218,5 +308,5 @@ bool SystemInformation::eventFilter(QObject *obj, QEvent *event)
QSize SystemInformation::sizeHint() const
{
- return {500,657};
+ return {500, 657};
}
diff --git a/plugins/system/src/pages/system-information/system-information.h b/plugins/system/src/pages/system-information/system-information.h
index c15561c..d46ad74 100644
--- a/plugins/system/src/pages/system-information/system-information.h
+++ b/plugins/system/src/pages/system-information/system-information.h
@@ -43,9 +43,13 @@ private:
QString &systemVersion,
QString &kernelVersion);
-private slots :
- void handleChangeHostName(void);
+ bool checkLicensEnable();
+ bool getLicenseDesc(QString& licenseStatus);
+
+private slots:
+ void handleChangeHostName(void);
void updateHostName(bool isChanged, QString name);
+ void handleShowLicenseDialog();
protected:
bool eventFilter(QObject *obj, QEvent *event);
diff --git a/plugins/system/src/pages/system-information/system-information.ui b/plugins/system/src/pages/system-information/system-information.ui
index b036ab6..7dd5cdd 100644
--- a/plugins/system/src/pages/system-information/system-information.ui
+++ b/plugins/system/src/pages/system-information/system-information.ui
@@ -423,6 +423,91 @@
</layout>
</widget>
</item>
+ <item>
+ <widget class="KiranFrame" name="widget_license" native="true">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>40</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>40</height>
+ </size>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>10</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>10</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Activation status:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="lab_license_status">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btn_license_show">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>56</width>
+ <height>28</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>56</width>
+ <height>28</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Show</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
<item>
<widget class="KiranFrame" name="widget_EULA" native="true">
<property name="minimumSize">
--
2.33.0

View File

@ -1,143 +0,0 @@
From 532833286b96f101310ad58692083f9e8ef37155 Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Fri, 4 Nov 2022 14:41:27 +0800
Subject: [PATCH] fix(network-tray):Fix the problem that the tray has an
unavailable widget when the device is available
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复托盘在设备可用时,出现设备不可用界面的问题
---
plugins/network/src/tray/network-tray.cpp | 64 ++++++++++++++---------
1 file changed, 39 insertions(+), 25 deletions(-)
diff --git a/plugins/network/src/tray/network-tray.cpp b/plugins/network/src/tray/network-tray.cpp
index ccf6495..f16943b 100644
--- a/plugins/network/src/tray/network-tray.cpp
+++ b/plugins/network/src/tray/network-tray.cpp
@@ -180,6 +180,7 @@ void NetworkTray::initMenu()
// 初始化条件:设备存在且被管理
void NetworkTray::initTrayPage()
{
+ KLOG_DEBUG() << "init Tray Page";
m_wiredDeviceList = NetworkUtils::getAvailableDeviceList(Device::Ethernet);
m_wirelessDeviceList = NetworkUtils::getAvailableDeviceList(Device::Wifi);
@@ -432,25 +433,18 @@ void NetworkTray::handleDeviceStateChanged(NetworkManager::Device::State newstat
NetworkManager::Device::State oldstate,
NetworkManager::Device::StateChangeReason reason)
{
-
- // KLOG_DEBUG() << "newstate:" << newstate;
- // KLOG_DEBUG() << "oldstate:" << oldstate;
- // KLOG_DEBUG() << "reason:" << reason;
Device *device = qobject_cast<Device *>(sender());
auto deviceType = device->type();
+ KLOG_DEBUG() << "Device interfaceName:" << device->interfaceName();
+ KLOG_DEBUG() << "Device newstate:" << newstate;
+ KLOG_DEBUG() << "Device oldstate:" << oldstate;
+ KLOG_DEBUG() << "Device reason:" << reason;
//设备变为可用
- if ((oldstate == Device::Unavailable || oldstate == Device::Unmanaged)
+ if ((oldstate == Device::Unavailable || oldstate == Device::Unmanaged || oldstate == Device::UnknownState)
&&
(newstate != Device::Unmanaged && newstate != Device::Unavailable && newstate != Device::UnknownState))
{
- if(m_unavailableWidget != nullptr)
- {
- m_verticalLayout->removeWidget(m_unavailableWidget);
- m_unavailableWidget->deleteLater();
- m_unavailableWidget = nullptr;
- }
-
if (deviceType == Device::Ethernet)
{
reloadWiredTrayPage();
@@ -459,12 +453,24 @@ void NetworkTray::handleDeviceStateChanged(NetworkManager::Device::State newstat
{
reloadWirelessTrayPage();
}
+
+ if((m_wiredTrayPage != nullptr) || (m_wirelessTrayPage != nullptr))
+ {
+ if(m_unavailableWidget != nullptr)
+ {
+ m_verticalLayout->removeWidget(m_unavailableWidget);
+ m_unavailableWidget->deleteLater();
+ m_unavailableWidget = nullptr;
+ KLOG_DEBUG() << "remove unavailable widget";
+ }
+ }
}
//设备变为不可用时,如果无线和有线均不可用则显示网络不可用的提示
if(newstate == Device::Unavailable || newstate == Device::Unmanaged
|| newstate == Device::UnknownState)
{
+ KLOG_DEBUG() << "device is unavailable";
if (deviceType == Device::Ethernet)
{
reloadWiredTrayPage();
@@ -476,10 +482,13 @@ void NetworkTray::handleDeviceStateChanged(NetworkManager::Device::State newstat
if(m_wiredTrayPage == nullptr && m_wirelessTrayPage == nullptr)
{
- initUnavailableWidget();
- m_verticalLayout->addWidget(m_unavailableWidget);
+ if(m_unavailableWidget == nullptr)
+ {
+ initUnavailableWidget();
+ m_verticalLayout->addWidget(m_unavailableWidget);
+ KLOG_DEBUG() << "add unavailable widget";
+ }
}
-
}
}
@@ -550,12 +559,14 @@ void NetworkTray::handlePrimaryConnectionChanged(const QString &uni)
void NetworkTray::reloadWiredTrayPage()
{
KLOG_DEBUG() << "reloadWiredTrayPage";
- m_verticalLayout->removeWidget(m_wiredTrayPage);
- m_wiredTrayPage->disconnect();
- delete m_wiredTrayPage;
- m_wiredTrayPage = nullptr;
+ if(m_wiredTrayPage != nullptr)
+ {
+ m_verticalLayout->removeWidget(m_wiredTrayPage);
+ delete m_wiredTrayPage;
+ m_wiredTrayPage = nullptr;
+ }
+
m_wiredDeviceList.clear();
-
m_wiredDeviceList = NetworkUtils::getAvailableDeviceList(Device::Ethernet);
if (m_wiredDeviceList.count() != 0)
{
@@ -569,12 +580,15 @@ void NetworkTray::reloadWiredTrayPage()
void NetworkTray::reloadWirelessTrayPage()
{
- m_verticalLayout->removeWidget(m_wirelessTrayPage);
- m_wiredTrayPage->disconnect();
- delete m_wirelessTrayPage;
- m_wirelessTrayPage = nullptr;
- m_wirelessDeviceList.clear();
+ KLOG_DEBUG() << "reloadWirelessTrayPage";
+ if(m_wirelessTrayPage != nullptr)
+ {
+ m_verticalLayout->removeWidget(m_wirelessTrayPage);
+ delete m_wirelessTrayPage;
+ m_wirelessTrayPage = nullptr;
+ }
+ m_wirelessDeviceList.clear();
m_wirelessDeviceList = NetworkUtils::getAvailableDeviceList(Device::Wifi);
if (m_wirelessDeviceList.count() != 0)
{
--
2.33.0

View File

@ -1,100 +0,0 @@
From 896bb4517b2a8a413265ffb6795ce2b5acb885d4 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Wed, 9 Nov 2022 15:02:41 +0800
Subject: [PATCH 2/5] fix(memcheck): Fix problems in valgrind memcheck
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复valgrind memcheck中出现的问题
---
lib/common-widgets/kiran-frame/kiran-frame.h | 1 +
plugins/appearance/src/pages/theme/theme-widget.h | 14 +++++++-------
.../appearance/src/pages/wallpaper/wallpaper.cpp | 1 +
plugins/system/src/kylinsec-logo.cpp | 1 +
.../system-information/system-information.cpp | 5 +++--
5 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/lib/common-widgets/kiran-frame/kiran-frame.h b/lib/common-widgets/kiran-frame/kiran-frame.h
index 1b1f290..4a3dc9f 100644
--- a/lib/common-widgets/kiran-frame/kiran-frame.h
+++ b/lib/common-widgets/kiran-frame/kiran-frame.h
@@ -22,6 +22,7 @@
//给控制中心组件提供色块的控件,用于突出显示
class KiranFrame : public QWidget
{
+ Q_OBJECT
public:
explicit KiranFrame(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
diff --git a/plugins/appearance/src/pages/theme/theme-widget.h b/plugins/appearance/src/pages/theme/theme-widget.h
index df419ad..672876f 100644
--- a/plugins/appearance/src/pages/theme/theme-widget.h
+++ b/plugins/appearance/src/pages/theme/theme-widget.h
@@ -44,15 +44,15 @@ protected:
virtual bool eventFilter(QObject* watched, QEvent* event);
private:
- QLabel* m_iconSelectLabel;
- KiranFrame* m_iconImgWidget;
- QWidget* m_currIconTheme;
+ QLabel* m_iconSelectLabel = nullptr;
+ KiranFrame* m_iconImgWidget = nullptr;
+ QWidget* m_currIconTheme = nullptr;
- QLabel* m_selectLabel;
- KiranFrame* m_themeImgWidget;
+ QLabel* m_selectLabel = nullptr;
+ KiranFrame* m_themeImgWidget = nullptr;
- QLabel* m_cursorSelectLabel;
- KiranFrame* m_cursorWidget;
+ QLabel* m_cursorSelectLabel = nullptr;
+ KiranFrame* m_cursorWidget = nullptr;
QString m_theme;
};
diff --git a/plugins/appearance/src/pages/wallpaper/wallpaper.cpp b/plugins/appearance/src/pages/wallpaper/wallpaper.cpp
index 139ab0f..9abd0b8 100644
--- a/plugins/appearance/src/pages/wallpaper/wallpaper.cpp
+++ b/plugins/appearance/src/pages/wallpaper/wallpaper.cpp
@@ -69,6 +69,7 @@ Wallpaper::~Wallpaper()
delete ui;
m_thread->quit();
m_thread->wait();
+ delete m_thread;
}
void Wallpaper::initUI()
diff --git a/plugins/system/src/kylinsec-logo.cpp b/plugins/system/src/kylinsec-logo.cpp
index 31df8c4..5c1e24b 100644
--- a/plugins/system/src/kylinsec-logo.cpp
+++ b/plugins/system/src/kylinsec-logo.cpp
@@ -19,6 +19,7 @@
#define SYSTEM_LOGO "KylinSec OS"
KylinsecLogo::KylinsecLogo(QWidget *parent)
+ :QWidget(parent)
{
setAccessibleName("KylinsecLogo");
}
diff --git a/plugins/system/src/pages/system-information/system-information.cpp b/plugins/system/src/pages/system-information/system-information.cpp
index bf36086..0fb839f 100644
--- a/plugins/system/src/pages/system-information/system-information.cpp
+++ b/plugins/system/src/pages/system-information/system-information.cpp
@@ -134,9 +134,10 @@ bool SystemInformation::initUI()
label->setStyleSheet("color:#919191;font-family: \"Noto Sans CJK SC regular\";");
}
- auto kiranFrames = findChildren<KiranFrame*>();
- for (auto frame : kiranFrames)
+ QList<KiranFrame*> kiranFrames = findChildren<KiranFrame*>();
+ for (int i = 0; i < kiranFrames.count();i++)
{
+ KiranFrame* frame = kiranFrames.at(i);
frame->setRadius(6);
frame->setDrawBroder(false);
}
--
2.33.0

View File

@ -1,34 +0,0 @@
From 4813ea776b59abbe2beacea74b310249402e48e7 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Mon, 14 Nov 2022 16:20:50 +0800
Subject: [PATCH 3/5] fix(shortcut): Filter the Exec Key when reading the exec
from the desktop entry
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
新增快捷键时从desktop entry读取exec时过滤掉Exec Key
---
plugins/keybinding/src/shortcut.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/plugins/keybinding/src/shortcut.cpp b/plugins/keybinding/src/shortcut.cpp
index f15d794..b3d4e1a 100644
--- a/plugins/keybinding/src/shortcut.cpp
+++ b/plugins/keybinding/src/shortcut.cpp
@@ -364,6 +364,12 @@ bool Shortcut::getExecFromDesktop(QString fileName, QString &exec)
if (str.isNull())
return false;
+ //移除掉无用的%f,%u,%F,%U
+ //https://specifications.freedesktop.org/desktop-entry-spec/1.1/ar01s06.html
+
+ str = str.replace("%f","",Qt::CaseInsensitive);
+ str = str.replace("%u","",Qt::CaseInsensitive);
+
exec = str;
return true;
}
--
2.33.0

View File

@ -1,62 +0,0 @@
From 458eeaf6b93ace479e96dd464b9c13a1309aa67d Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Mon, 14 Nov 2022 17:28:45 +0800
Subject: [PATCH 4/5] fix(messagebox): Adjust the pop-up button of account
management
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 调整帐户管理下弹框的按钮
---
.../account/src/pages/create-user-page/create-user-page.cpp | 2 +-
plugins/account/src/pages/user-info-page/user-info-page.cpp | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/plugins/account/src/pages/create-user-page/create-user-page.cpp b/plugins/account/src/pages/create-user-page/create-user-page.cpp
index 65a4b74..cb8695f 100644
--- a/plugins/account/src/pages/create-user-page/create-user-page.cpp
+++ b/plugins/account/src/pages/create-user-page/create-user-page.cpp
@@ -232,7 +232,7 @@ void CreateUserPage::handlerCreateNewUserIsDone(QString userPath,
if (!errMsg.isEmpty())
{
KiranMessageBox::message(nullptr, tr("Error"),
- errMsg, KiranMessageBox::Yes | KiranMessageBox::No);
+ errMsg, KiranMessageBox::Ok);
}
if (!userPath.isEmpty())
{
diff --git a/plugins/account/src/pages/user-info-page/user-info-page.cpp b/plugins/account/src/pages/user-info-page/user-info-page.cpp
index 68b2e17..4e76c51 100644
--- a/plugins/account/src/pages/user-info-page/user-info-page.cpp
+++ b/plugins/account/src/pages/user-info-page/user-info-page.cpp
@@ -311,7 +311,7 @@ void UserInfoPage::handlerUpdateUserPropertyDone(QString errMsg)
{
KiranMessageBox::message(nullptr,
tr("Error"), errMsg,
- KiranMessageBox::Yes | KiranMessageBox::No);
+ KiranMessageBox::Ok);
}
else
{
@@ -330,7 +330,7 @@ void UserInfoPage::handlerUpdatePasswdDone(QString errMsg)
{
KiranMessageBox::message(nullptr,
tr("Error"), errMsg,
- KiranMessageBox::Yes | KiranMessageBox::No);
+ KiranMessageBox::Ok);
}
else
{
@@ -363,7 +363,7 @@ void UserInfoPage::handlerDeleteUserDone(QString errMsg)
emit sigIsBusyChanged(false);
if (!errMsg.isEmpty())
{
- KiranMessageBox::message(this, tr("Error"), errMsg, KiranMessageBox::Yes | KiranMessageBox::No);
+ KiranMessageBox::message(this, tr("Error"), errMsg, KiranMessageBox::Ok);
}
}
--
2.33.0

View File

@ -1,630 +0,0 @@
From d1f1a182b540ae4b9c1c6fb35aa4ac0b5caebc9e Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Mon, 14 Nov 2022 17:55:08 +0800
Subject: [PATCH 5/5] refactor(*): Reconstruct the code structure
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 重构代码结构,简化解析IconTheme json字符串的代码
---
include/panel-interface.h | 2 +
include/plugin-interface-v2.h | 4 +-
include/plugin-subitem-interface.h | 2 +-
launcher/src/main.cpp | 1 -
lib/common-widgets/hover-tips/hover-tips.cpp | 7 +-
.../kiran-module-widget.cpp | 23 ++--
.../src/kiran-cpanel-appearance.cpp | 67 ---------
.../appearance/src/kiran-cpanel-appearance.h | 60 --------
.../appearance/src/kiran-cpanel-appearance.ui | 130 ------------------
.../pages/theme/icon-themes/icon-themes.cpp | 79 ++++++-----
.../src/pages/theme/icon-themes/icon-themes.h | 2 +-
11 files changed, 69 insertions(+), 308 deletions(-)
delete mode 100644 plugins/appearance/src/kiran-cpanel-appearance.cpp
delete mode 100644 plugins/appearance/src/kiran-cpanel-appearance.h
delete mode 100644 plugins/appearance/src/kiran-cpanel-appearance.ui
diff --git a/include/panel-interface.h b/include/panel-interface.h
index 6276649..d352ed4 100644
--- a/include/panel-interface.h
+++ b/include/panel-interface.h
@@ -22,7 +22,9 @@ namespace KiranControlPanel
class PanelInterface
{
public:
+ //通知控制中心主面板功能项信息变化
virtual void handlePluginSubItemInfoChanged(const QString& subItemID) = 0;
+ //通知控制中心主面板 功能项 发生改变,调用该接口,控制中心将重新加载该插件下的功能项信息
virtual void handlePluginSubItemChanged() = 0;
};
} // namespace KiranControlPanel
diff --git a/include/plugin-interface-v2.h b/include/plugin-interface-v2.h
index 19b0824..2643ffc 100644
--- a/include/plugin-interface-v2.h
+++ b/include/plugin-interface-v2.h
@@ -38,8 +38,8 @@ public:
//主面板调用该接口取消掉该插件初始化做的操作并卸载该插件
virtual void uninit() = 0;
- // 功能项数组,生存周期由插件维护
- // 功能项发生变更时应调用init时传入KcpInterface接口通知主面板相关信息变更,及时加载新的功能项信息
+ // 功能项数组
+ // 功能项发生变更时应调用init时传入KcpInterface接口通知主面板功能项发生变更,及时同步功能项
virtual QVector<KiranControlPanel::SubItemPtr> getSubItems() = 0;
};
} // namespace KiranControlPanel
diff --git a/include/plugin-subitem-interface.h b/include/plugin-subitem-interface.h
index b28be7e..01fc608 100644
--- a/include/plugin-subitem-interface.h
+++ b/include/plugin-subitem-interface.h
@@ -46,7 +46,7 @@ public:
// QVector< 显示文本(已翻译)搜索跳转标识ID >
virtual QVector<QPair<QString, QString>> getSearchKeys() = 0;
- //创建显示控件
+ //创建该功能项显示控件,释放由控制中心主面板决定
virtual QWidget* createWidget() = 0;
//跳转至自定义搜索项
diff --git a/launcher/src/main.cpp b/launcher/src/main.cpp
index 7bb78f2..eaeee99 100644
--- a/launcher/src/main.cpp
+++ b/launcher/src/main.cpp
@@ -119,7 +119,6 @@ int main(int argc, char *argv[])
w.setIcon(titleIcon);
w.setSubItems(plugin.getSubItems());
w.resize(w.sizeHint());
- KLOG_DEBUG() << "sizeHint:" << w.sizeHint();
QScreen* screen = QApplication::screenAt(QCursor::pos());
QRect screenGeometry = screen->geometry();
diff --git a/lib/common-widgets/hover-tips/hover-tips.cpp b/lib/common-widgets/hover-tips/hover-tips.cpp
index 61821dc..569290a 100644
--- a/lib/common-widgets/hover-tips/hover-tips.cpp
+++ b/lib/common-widgets/hover-tips/hover-tips.cpp
@@ -39,7 +39,7 @@ void HoverTips::show(HoverTipsTypeEnum typeEnum, const QString &msg)
auto iter = m_tipsTypeIconMap.find(typeEnum);
if (iter == m_tipsTypeIconMap.end())
{
- KLOG_WARNING() << "invalid type enum";
+ KLOG_WARNING() << "HoverTips: invalid type enum" << typeEnum;
return;
}
@@ -66,9 +66,10 @@ void HoverTips::updatePostion()
{
if (parentWidget() == nullptr)
{
- KLOG_WARNING() << "hover tips parnetwidget is null";
+ KLOG_WARNING() << "HoverTips: parnetwidget is null,don't update position";
return;
}
+
this->move((parentWidget()->width() - width()) / 2,
(parentWidget()->height() - height()) / 2);
}
@@ -97,7 +98,7 @@ void HoverTips::setIcon(HoverTips::HoverTipsTypeEnum typeEnum, const QString &ic
QPixmap pixmap;
if (!pixmap.load(icon) || pixmap.isNull())
{
- KLOG_WARNING() << "load icon failed.";
+ KLOG_WARNING() << "HoverTips: load icon" << icon << "failed.";
return;
}
m_tipsTypeIconMap[typeEnum] = icon;
diff --git a/lib/common-widgets/kiran-module-widget/kiran-module-widget.cpp b/lib/common-widgets/kiran-module-widget/kiran-module-widget.cpp
index 629bf83..6ddb2bd 100644
--- a/lib/common-widgets/kiran-module-widget/kiran-module-widget.cpp
+++ b/lib/common-widgets/kiran-module-widget/kiran-module-widget.cpp
@@ -42,9 +42,12 @@ KiranModuleWidget::~KiranModuleWidget()
void KiranModuleWidget::clear()
{
- disconnect(m_category, &Category::subItemAdded, this, &KiranModuleWidget::handleCategorySubItemAdded);
- disconnect(m_category, &Category::subItemDeleted, this, &KiranModuleWidget::handleCategorySubItemDeleted);
- disconnect(m_category, &Category::subItemInfoChanged, this, &KiranModuleWidget::handleCategorySubItemInfoChanged);
+ if (m_category != nullptr)
+ {
+ disconnect(m_category, &Category::subItemAdded, this, &KiranModuleWidget::handleCategorySubItemAdded);
+ disconnect(m_category, &Category::subItemDeleted, this, &KiranModuleWidget::handleCategorySubItemDeleted);
+ disconnect(m_category, &Category::subItemInfoChanged, this, &KiranModuleWidget::handleCategorySubItemInfoChanged);
+ }
ui->list_subItems->clear();
ui->widget_siderbar->hide();
@@ -96,7 +99,7 @@ void KiranModuleWidget::appendListWidgetItem(KiranControlPanel::SubItemPtr subit
item->setWeight(subitem->getWeight());
if (icon.isNull())
{
- KLOG_WARNING() << "can't find subitem icon:" << name << icon;
+ KLOG_WARNING() << "KiranModuleWidget: can't find subitem icon:" << name << icon;
}
else
{
@@ -154,7 +157,7 @@ void KiranModuleWidget::handleCurrentItemChanged()
auto selectedItems = ui->list_subItems->selectedItems();
if (selectedItems.size() != 1)
{
- KLOG_ERROR() << "sider bar size != 1";
+ KLOG_ERROR() << "KiranModuleWidget: sider bar size != 1";
return;
}
@@ -162,21 +165,21 @@ void KiranModuleWidget::handleCurrentItemChanged()
if (m_currentSubItem.first == selectedItem)
{
- KLOG_DEBUG() << "subitem not changed,ignore 'itemSelectionChanged' signal!";
+ KLOG_DEBUG() << "KiranModuleWidget: subitem not changed,ignore 'itemSelectionChanged' signal!";
return;
}
auto mapIter = m_subItemsMap.find(selectedItem);
if (mapIter == m_subItemsMap.end())
{
- KLOG_WARNING() << "can't find KiranControlPanel::SubItemPtr by QListWidgetItem," << selectedItem->text();
+ KLOG_WARNING() << "KiranModuleWidget: can't find KiranControlPanel::SubItemPtr by QListWidgetItem," << selectedItem->text();
return;
}
KiranControlPanel::SubItemPtr pluginSubitem = *mapIter;
if (checkHasUnSaved())
{
- KLOG_DEBUG() << "switch subitem to:" << pluginSubitem->getName() << "reject";
+ KLOG_DEBUG() << "KiranModuleWidget: switch subitem to:" << pluginSubitem->getName() << "reject";
m_currentSubItem.first->setSelected(true);
return;
}
@@ -194,12 +197,12 @@ void KiranModuleWidget::handleCurrentItemChanged()
QWidget *widget = pluginSubitem->createWidget();
if (widget)
{
- KLOG_DEBUG() << "sub item widget sizeHint:" << widget->sizeHint();
+ KLOG_DEBUG() << "KiranModuleWidget: sub item widget sizeHint:" << widget->sizeHint();
ui->centerLayout->addWidget(widget);
}
else
{
- KLOG_ERROR() << "can't get subitem widget:" << pluginSubitem->getName() << pluginSubitem->getID();
+ KLOG_ERROR() << "KiranModuleWidget: can't get subitem widget:" << pluginSubitem->getName() << pluginSubitem->getID();
}
m_subItemWidget = widget;
diff --git a/plugins/appearance/src/kiran-cpanel-appearance.cpp b/plugins/appearance/src/kiran-cpanel-appearance.cpp
deleted file mode 100644
index 3dee3c6..0000000
--- a/plugins/appearance/src/kiran-cpanel-appearance.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
- * kiran-control-panel is licensed under Mulan PSL v2.
- * You can use this software according to the terms and conditions of the Mulan PSL v2.
- * You may obtain a copy of Mulan PSL v2 at:
- * http://license.coscl.org.cn/MulanPSL2
- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
- * See the Mulan PSL v2 for more details.
- *
- * Author: yuanxing <yuanxing@kylinsec.com.cn>
- */
-
-#include "kiran-cpanel-appearance.h"
-#include <QListWidgetItem>
-#include "ui_kiran-cpanel-appearance.h"
-
-KiranCpanelAppearance::KiranCpanelAppearance(QWidget *parent) : KiranTitlebarWindow(parent),
- ui(new Ui::KiranCpanelAppearance)
-{
- ui->setupUi(getWindowContentWidget());
- initUI();
-
- connect(ui->listWidget, &KiranSidebarWidget::itemClicked,
- [=](QListWidgetItem *item) {
- int row = ui->listWidget->row(item);
- ui->stackedWidget->setCurrentIndex(row);
- //TODO:后续根据需求确定是否切换列表项时需要指定第一页
- if (row == ITEM_BACKGROUND)
- ;
- else if (row == ITEM_THEME)
- {
- ui->page_theme->setPage(0);
- }
- else
- {
- };
- });
-}
-
-KiranCpanelAppearance::~KiranCpanelAppearance()
-{
- delete ui;
-}
-
-bool KiranCpanelAppearance::initUI()
-{
- //TODO:connect dbus if faile return false;
- setIcon(QIcon::fromTheme("kcp-appearance"));
-
- ui->listWidget->setIconSize(QSize(16, 16));
- addSidebarItem(tr("Wallpaper Setting"), ":/images/wallpaper.svg");
- addSidebarItem(tr("Theme Setting"), ":/images/themes.svg");
- addSidebarItem(tr("Font Setting"), ":/images/themes.svg");
-
- ui->listWidget->setCurrentRow(0);
- return true;
-}
-
-void KiranCpanelAppearance::addSidebarItem(QString text, QString icon)
-{
- QListWidgetItem *item = new QListWidgetItem(ui->listWidget);
- item->setIcon(QIcon(icon));
- item->setText(text);
- ui->listWidget->addItem(item);
-}
diff --git a/plugins/appearance/src/kiran-cpanel-appearance.h b/plugins/appearance/src/kiran-cpanel-appearance.h
deleted file mode 100644
index a5edb7c..0000000
--- a/plugins/appearance/src/kiran-cpanel-appearance.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
- * kiran-control-panel is licensed under Mulan PSL v2.
- * You can use this software according to the terms and conditions of the Mulan PSL v2.
- * You may obtain a copy of Mulan PSL v2 at:
- * http://license.coscl.org.cn/MulanPSL2
- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
- * See the Mulan PSL v2 for more details.
- *
- * Author: yuanxing <yuanxing@kylinsec.com.cn>
- */
-
-#ifndef KIRANCPANELAPPEARANCE_H
-#define KIRANCPANELAPPEARANCE_H
-#include <kiran-titlebar-window.h>
-
-#include <QWidget>
-
-namespace Ui
-{
-class KiranCpanelAppearance;
-}
-
-enum pages
-{
- PAGE_BACKGROUND = 0,
- PAGE_THEME,
- PAGE_FONT,
- PAGE_BACKGROND_SELECT,
- PAGE_ICON_THEME,
- PAGE_CURSOR_THEME
-};
-
-enum items
-{
- ITEM_BACKGROUND = 0,
- ITEM_THEME,
- ITEM_FONT
-};
-
-class QListWidgetItem;
-class KiranCpanelAppearance : public KiranTitlebarWindow
-{
- Q_OBJECT
-
-public:
- explicit KiranCpanelAppearance(QWidget *parent = 0);
- ~KiranCpanelAppearance();
-
-private:
- bool initUI();
- void addSidebarItem(QString, QString);
-
-private:
- Ui::KiranCpanelAppearance *ui;
-};
-
-#endif // KIRANCPANELAPPEARANCE_H
diff --git a/plugins/appearance/src/kiran-cpanel-appearance.ui b/plugins/appearance/src/kiran-cpanel-appearance.ui
deleted file mode 100644
index d2cdea5..0000000
--- a/plugins/appearance/src/kiran-cpanel-appearance.ui
+++ /dev/null
@@ -1,130 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>KiranCpanelAppearance</class>
- <widget class="QWidget" name="KiranCpanelAppearance">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>712</width>
- <height>591</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>KiranCpanelAppearance</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <property name="spacing">
- <number>0</number>
- </property>
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QWidget" name="widget_sidebar" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="KiranSidebarWidget" name="listWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>282</width>
- <height>16777215</height>
- </size>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QWidget" name="widget_page" native="true">
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <property name="spacing">
- <number>0</number>
- </property>
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QStackedWidget" name="stackedWidget">
- <widget class="Wallpaper" name="page_wallpaper"/>
- <widget class="Themes" name="page_theme"/>
- <widget class="Fonts" name="page_font"/>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <customwidgets>
- <customwidget>
- <class>KiranSidebarWidget</class>
- <extends>QListWidget</extends>
- <header location="global">/usr/include/kiranwidgets-qt5/kiran-sidebar-widget.h</header>
- </customwidget>
- <customwidget>
- <class>Fonts</class>
- <extends>QWidget</extends>
- <header>pages/font/fonts.h</header>
- <container>1</container>
- </customwidget>
- <customwidget>
- <class>Themes</class>
- <extends>QWidget</extends>
- <header>pages/theme/themes.h</header>
- <container>1</container>
- </customwidget>
- <customwidget>
- <class>Wallpaper</class>
- <extends>QWidget</extends>
- <header>pages/wallpaper/wallpaper.h</header>
- <container>1</container>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
diff --git a/plugins/appearance/src/pages/theme/icon-themes/icon-themes.cpp b/plugins/appearance/src/pages/theme/icon-themes/icon-themes.cpp
index 184ae66..6e6f614 100644
--- a/plugins/appearance/src/pages/theme/icon-themes/icon-themes.cpp
+++ b/plugins/appearance/src/pages/theme/icon-themes/icon-themes.cpp
@@ -13,9 +13,11 @@
*/
#include "icon-themes.h"
+
#include <kiran-log/qt5-log-i.h>
#include <kiran-session-daemon/appearance-i.h>
#include <kiranwidgets-qt5/kiran-message-box.h>
+
#include <QDir>
#include <QIcon>
#include <QJsonArray>
@@ -23,6 +25,7 @@
#include <QJsonObject>
#include <QJsonParseError>
#include <QVBoxLayout>
+
#include "../theme-widget-group.h"
#include "../theme-widget.h"
#include "dbus-interface/appearance-global-info.h"
@@ -49,7 +52,7 @@ IconThemes::~IconThemes()
bool IconThemes::initUI()
{
- if (!getIconThemes(APPEARANCE_THEME_TYPE_ICON))
+ if (!getIconThemes())
{
return false;
}
@@ -84,10 +87,10 @@ void IconThemes::updateIconTheme(QString newIconTheme)
* @return true 成功
* false 失败
*/
-bool IconThemes::getIconThemes(int themeType)
+bool IconThemes::getIconThemes()
{
QString iconThemesJson = nullptr;
- if (!AppearanceGlobalInfo::instance()->getAllThemes(themeType, iconThemesJson))
+ if (!AppearanceGlobalInfo::instance()->getAllThemes(APPEARANCE_THEME_TYPE_ICON, iconThemesJson))
{
return false;
}
@@ -103,44 +106,51 @@ int IconThemes::getJsonValueFromString(QString jsonString)
{
QJsonParseError jsonError;
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonString.toLocal8Bit().data(), &jsonError);
+
if (jsonDocument.isNull() || jsonError.error != QJsonParseError::NoError)
{
- KLOG_ERROR() << " please check the string " << jsonString.toLocal8Bit().data();
+ KLOG_ERROR() << "parse icon theme json failed," << jsonString << jsonError.errorString() << jsonError.error;
+ return -1;
+ }
+
+ if( !jsonDocument.isArray() )
+ {
+ return 0;
+ }
+
+ QJsonArray array = jsonDocument.array();
+ if( array.size() < 1 )
+ {
return -1;
}
- if (jsonDocument.isArray())
+
+ for (int i = 0; i < array.size();i++)
{
- QJsonArray array = jsonDocument.array();
- int iconThemesNum = array.size();
- if (iconThemesNum < 1)
- return -1;
- for (int i = 0; i < iconThemesNum; i++)
+ QJsonValue value = array.at(i);
+ if( value.type() != QJsonValue::Object )
{
- QJsonValue value = array.at(i);
- if (value.type() == QJsonValue::Object)
- {
- QJsonObject themeInfoObj = value.toObject();
- if (themeInfoObj.contains("name"))
- {
- QJsonValue themeValue = themeInfoObj.value("name");
- if (themeValue.isString())
- {
- QString name = themeValue.toVariant().toString();
- m_iconThemes.insert(i, name);
- }
- }
- if (themeInfoObj.contains("path"))
- {
- QJsonValue themeValue = themeInfoObj.value("path");
- if (themeValue.isString())
- {
- QString path = themeValue.toVariant().toString();
- m_iconThemesPath.insert(i, path);
- }
- }
- }
+ continue;
}
+
+ QJsonObject themeInfoObj = value.toObject();
+ if( !themeInfoObj.contains("name") || !themeInfoObj.contains("path") )
+ {
+ KLOG_WARNING() << "parse getAllThemes json failed,Missing specific key(name/path)";
+ continue;
+ }
+ if( !themeInfoObj["name"].isString() || !themeInfoObj["path"].isString() )
+ {
+ KLOG_WARNING() << "parse getAllThemes json failed,Wrong key format(name/path)";
+ continue;
+ }
+
+ QString name = themeInfoObj["name"].toString();
+ m_iconThemes.append(name);
+
+ QString path = themeInfoObj["path"].toString();
+ m_iconThemesPath.append(path);
}
+
return m_iconThemes.size();
}
@@ -153,8 +163,10 @@ void IconThemes::createIconWidgets()
QVBoxLayout *vLayout = new QVBoxLayout(ui->widget_icon);
vLayout->setMargin(0);
vLayout->setSpacing(4);
+
for (int i = 0; i < m_iconThemes.size(); i++)
{
+
if (m_iconThemes.at(i).startsWith("Kiran", Qt::CaseInsensitive))
{
QString path = m_iconThemesPath.at(i) + "/apps/scalable/";
@@ -238,6 +250,7 @@ void IconThemes::createIconWidgets()
continue;
}
}
+
connect(m_iconThemeWidgetGroup, &ThemeWidgetGroup::themeWidgetChange,
[=](ThemeWidget *preWidget, ThemeWidget *currWidget) {
if (currWidget->getTheme() == m_currentIconTheme)
diff --git a/plugins/appearance/src/pages/theme/icon-themes/icon-themes.h b/plugins/appearance/src/pages/theme/icon-themes/icon-themes.h
index 1e57ee0..3a86516 100644
--- a/plugins/appearance/src/pages/theme/icon-themes/icon-themes.h
+++ b/plugins/appearance/src/pages/theme/icon-themes/icon-themes.h
@@ -34,7 +34,7 @@ public:
void updateIconTheme(QString newIconTheme);
private:
- bool getIconThemes(int themeType);
+ bool getIconThemes();
int getJsonValueFromString(QString jsonString);
void createIconWidgets();
--
2.33.0

View File

@ -1,20 +1,12 @@
Name: kiran-control-panel
Version: 2.4.0
Release: 3
Version: 2.4.1
Release: 1
Summary: Kiran Control Panel
Summary(zh_CN): Kiran桌面控制面板
License: MulanPSL-2.0
Source0: %{name}-%{version}.tar.gz
Patch0001: 0001-fix-network-tray-Fix-the-problem-that-the-tray-has-a.patch
Patch0002: 0001-feat-license-briefly-displays-the-license-informatio.patch
Patch0003: 0002-fix-memcheck-Fix-problems-in-valgrind-memcheck.patch
Patch0004: 0003-fix-shortcut-Filter-the-Exec-Key-when-reading-the-ex.patch
Patch0005: 0004-fix-messagebox-Adjust-the-pop-up-button-of-account-m.patch
Patch0006: 0005-refactor-Reconstruct-the-code-structure.patch
BuildRequires: gcc-c++
BuildRequires: cmake >= 3.2
BuildRequires: glib2-devel
@ -60,15 +52,15 @@ Requires: cryptopp
Requires: NetworkManager-l2tp
#Requires: NetworkManager-pptp
Obsoletes: kiran-cpanel-account
Obsoletes: kiran-cpanel-appearance
Obsoletes: kiran-cpanel-display
Obsoletes: kiran-cpanel-keybinding
Obsoletes: kiran-cpanel-keyboard
Obsoletes: kiran-cpanel-mouse
Obsoletes: kiran-cpanel-power
Obsoletes: kiran-cpanel-system
Obsoletes: kiran-cpanel-timedate
Obsoletes: kiran-cpanel-account < 2.3
Obsoletes: kiran-cpanel-appearance < 2.3
Obsoletes: kiran-cpanel-display < 2.3
Obsoletes: kiran-cpanel-keybinding < 2.3
Obsoletes: kiran-cpanel-keyboard < 2.3
Obsoletes: kiran-cpanel-mouse < 2.3
Obsoletes: kiran-cpanel-power < 2.3
Obsoletes: kiran-cpanel-system < 2.3
Obsoletes: kiran-cpanel-timedate < 2.3
%description
@ -149,6 +141,14 @@ make %{?_smp_mflags}
rm -rf %{buildroot}
%changelog
* Thu Dec 01 2022 liuxinhao <liuxinhao@kylinsec.com.cn> - 2.4.1-1
- KYOS-F: Omit the right end of long names in network settings
- KYOS-F: Fix the problem of expanding the label when the user name is too long
- KYOS-F: In the extended mode, when there is only one display left, the "Switch" and "Set as main display" buttons will change from disabled to popup prompt
- KYOS-F: Modify the system information page. The hardware information label is KiranLabel, which supports dynamic omission
- KYOS-F: Handle the situation that the displayed popup window cannot disappear when the tray fails to grab the keyboard and mouse when it pops up
- kYOS-F: Memory in hardware information shows total memory and available memory
* Mon Nov 14 2022 liuxinhao <liuxinhao@kylinsec.com.cn> - 2.4.0-3
- KYOS-F: Reconstruct the code structure
- KYOS-F: Adjust the pop-up button of account management