Update to 2.6.0-6

This commit is contained in:
luoqing 2024-01-18 12:00:32 +08:00
parent afeb3ece72
commit cdc571f6ab
37 changed files with 12332 additions and 2461 deletions

View File

@ -0,0 +1,32 @@
From 558754678f0a34d1e624dcc9c17b583bc05d4d80 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Tue, 12 Dec 2023 20:26:29 +0800
Subject: [PATCH] fix(pkgconfig): Fix the issue of incorrect content in the PC
file provided by pkgconfig
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复提供的pkgconfig配置内容缺失的问题
---
data/kiran-control-panel.pc.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/data/kiran-control-panel.pc.in b/data/kiran-control-panel.pc.in
index de3ae6b..1e50a0d 100644
--- a/data/kiran-control-panel.pc.in
+++ b/data/kiran-control-panel.pc.in
@@ -1,7 +1,7 @@
-includedir=@KCP_INSTALL_INCLUDE@
+includedir=@KCP_INCLUDEDIR@
-category_desktop_location=@CATEGORY_DESKTOP_INSTALL_DIR@
-category_icon_location=@CATEGORY_ICON_INSTALL_DIR@
+category_desktop_location=@CATEGORY_DESKTOP_DIR@
+category_icon_location=@CATEGORY_ICON_DIR@
plugin_location=@PLUGIN_LIBS_DIR@
plugin_desktop_location=@PLUGIN_DESKTOP_DIR@
--
2.27.0

File diff suppressed because it is too large Load Diff

View File

@ -1,121 +0,0 @@
From c3f02b61332c2cbac185e0306ff2583f639e5ca8 Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Tue, 22 Aug 2023 15:57:19 +0800
Subject: [PATCH 1/5] fix(network):After receiving the Connection::Update
signal from an active connection, the connection is no longer automatically
reactivated
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 收到已激活的连接的更新信号Connection::Update后不再自动重新激活连接
Related #13231
---
.../src/plugin/manager/wired-manager.cpp | 69 +++++++++----------
1 file changed, 32 insertions(+), 37 deletions(-)
diff --git a/plugins/network/src/plugin/manager/wired-manager.cpp b/plugins/network/src/plugin/manager/wired-manager.cpp
index ffe33b3..32ac227 100644
--- a/plugins/network/src/plugin/manager/wired-manager.cpp
+++ b/plugins/network/src/plugin/manager/wired-manager.cpp
@@ -91,27 +91,34 @@ void WiredManager::handleActivateSelectedConnection(const QString &connectionPat
auto devicestate = device->state();
KLOG_DEBUG() << "device state:" << devicestate ;
- if(devicestate != Device::Unavailable)
+ if(devicestate == Device::Unavailable)
{
- QDBusPendingReply<QDBusObjectPath> reply =
- NetworkManager::activateConnection(connectionPath, m_devicePath, connectionParameter);
+ StatusNotification::connectitonFailedNotifyByReason(tr("The current device is not available"));
+ return;
+ }
- reply.waitForFinished();
- if (reply.isError())
+ QDBusPendingReply<QDBusObjectPath> reply =
+ NetworkManager::activateConnection(connectionPath, m_devicePath, connectionParameter);
+
+ reply.waitForFinished();
+ if (reply.isError())
+ {
+ // 此处处理进入激活流程失败的原因,并不涉及流程中某个具体阶段失败的原因
+ KLOG_ERROR() << "activate connection failed:" << reply.error();
+ QString errorMessage = reply.error().message();
+ if (errorMessage.contains("device has no carrier"))
{
- // 此处处理进入激活流程失败的原因,并不涉及流程中某个具体阶段失败的原因
- KLOG_ERROR() << "activate connection failed:" << reply.error();
- QString errorMessage = reply.error().message();
- if (errorMessage.contains("device has no carrier"))
- StatusNotification::connectitonFailedNotifyByReason(tr("The carrier is pulled out"));
- else
- StatusNotification::connectitonFailedNotify(connectionPath);
+ StatusNotification::connectitonFailedNotifyByReason(tr("The carrier is pulled out"));
}
else
- KLOG_DEBUG() << "activateConnection reply:" << reply.reply();
+ {
+ StatusNotification::connectitonFailedNotify(connectionPath);
+ }
}
else
- StatusNotification::connectitonFailedNotifyByReason(tr("The current device is not available"));
+ {
+ KLOG_DEBUG() << "activateConnection reply:" << reply.reply();
+ }
}
// 获取到当前激活对象后,开启等待动画,判断完激活状态后停止等待动画
@@ -141,7 +148,7 @@ void WiredManager::handleActiveConnectionAdded(const QString &path)
break;
}
}
- connect(activatedConnection.data(), &ActiveConnection::stateChanged, this, &WiredManager::handleActiveConnectionStateChanged);
+ connect(activatedConnection.data(), &ActiveConnection::stateChanged, this, &WiredManager::handleActiveConnectionStateChanged, Qt::UniqueConnection);
}
}
@@ -214,28 +221,16 @@ void WiredManager::handleConnectionUpdated(const QString &path)
{
KLOG_DEBUG() << "Connection updated:" << path;
Connection::Ptr updateConnection = findConnection(path);
- if (updateConnection->settings()->connectionType() == ConnectionSettings::Wired)
+ if (updateConnection->settings()->connectionType() != ConnectionSettings::Wired)
{
- //移除后再加载进来以更新信息
- ui->connectionShowPage->removeConnectionFromList(path);
- ui->connectionShowPage->addConnection(updateConnection, "");
- if (ui->stackedWidget->currentIndex() != PAGE_SETTING)
- handleReturnPreviousPage();
-
- QString updateConnectionPath = updateConnection->path();
- ActiveConnection::List activeConnectionLists = activeConnections();
- //已连接的网络的配置被修改后,点击保存 ,应该重新连接网络,以使配置生效
- for (auto activeConn : activeConnectionLists)
- {
- if (activeConn->connection()->path() == updateConnectionPath)
- {
- auto deviceLists = activeConn->devices();
- if (deviceLists.contains(m_devicePath))
- {
- QDBusPendingReply<> reply = NetworkManager::deactivateConnection(activeConn->connection()->path());
- handleActivateSelectedConnection(updateConnectionPath, "");
- }
- }
- }
+ return;
+ }
+
+ //移除后再加载进来以更新信息
+ ui->connectionShowPage->removeConnectionFromList(path);
+ ui->connectionShowPage->addConnection(updateConnection, "");
+ if (ui->stackedWidget->currentIndex() != PAGE_SETTING)
+ {
+ handleReturnPreviousPage();
}
}
--
2.33.0

View File

@ -1,63 +0,0 @@
From 8468d6df5794ede71a39905e2d31f4cadda244b7 Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Wed, 23 Aug 2023 11:11:09 +0800
Subject: [PATCH 2/5] feature(display):When switching resolutions, refresh rate
preferentially selects the recommended refresh rate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 切换分辨率时,刷新率优先选择推荐的刷新率
Related #13283
---
plugins/display/src/display-page.cpp | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/plugins/display/src/display-page.cpp b/plugins/display/src/display-page.cpp
index a885b8b..23b5e8e 100644
--- a/plugins/display/src/display-page.cpp
+++ b/plugins/display/src/display-page.cpp
@@ -263,22 +263,35 @@ void DisplayPage::initExtraComboBoxRefreshRate(QComboBox *comboBox, const QList<
{
comboBox->clear();
- QString recommend;
QList<DisplayModesStu> list = m_displayConfig->listPreferredModes(m_curMonitorPath);
+ double recommendRefreshRate;
if (!list.isEmpty())
{
- double refreshRate = list.first().refreshRate;
- recommend = QString("%1HZ").arg(QString::asprintf("%.2f", refreshRate));
+ recommendRefreshRate = list.first().refreshRate;
}
+ QString strPostfix = tr(" (recommended)");
QList<double> t_refreshRateList = refreshRateList;
std::sort(t_refreshRateList.begin(), t_refreshRateList.end(), std::greater<double>());
foreach (double r, t_refreshRateList)
{
QString text = QString("%1HZ").arg(QString::asprintf("%.2f", r));
- if (text == recommend) text += tr(" (recommended)");
+ if (QString::asprintf("%.2f", r) == QString::asprintf("%.2f", recommendRefreshRate))
+ {
+ text.append(strPostfix);
+ }
comboBox->addItem(text, r);
}
+
+ for (size_t i = 0; i < comboBox->count(); i++)
+ {
+ double refreshRate = comboBox->itemData(i).toDouble();
+ if(QString::asprintf("%.2f", refreshRate) == QString::asprintf("%.2f", recommendRefreshRate))
+ {
+ comboBox->setCurrentIndex(i);
+ break;
+ }
+ }
}
void DisplayPage::selectResolutionComboboxItem(QComboBox *comboBox, const int &w, const int &h)
--
2.33.0

View File

@ -0,0 +1,93 @@
From 18e6891a56f471168cbe964c61c134f6d2aeb90d Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Fri, 15 Dec 2023 21:06:06 +0800
Subject: [PATCH] fix(plugins): Fix runtime plugin loading errors
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复运行时插件加载错误,补全相关依赖
---
CMakeLists.txt | 2 +-
common/plugin-subitem.h | 4 ++--
plugins/account/CMakeLists.txt | 12 +++++++++---
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4fe9765..07a668d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -102,4 +102,4 @@ add_subdirectory(lib)
add_subdirectory(libexec)
add_subdirectory(launcher)
add_subdirectory(plugins)
-add_subdirectory(data)
\ No newline at end of file
+add_subdirectory(data)
diff --git a/common/plugin-subitem.h b/common/plugin-subitem.h
index f6f6287..1315fda 100644
--- a/common/plugin-subitem.h
+++ b/common/plugin-subitem.h
@@ -32,7 +32,7 @@ public:
m_pCreateWidget(func)
{
}
- ~PluginSubItem();
+ ~PluginSubItem(){};
public:
// 功能项ID,用于区分功能项,应确保其唯一
@@ -72,4 +72,4 @@ private:
QString m_icon;
int m_weight;
CreateWidgetFunc m_pCreateWidget = nullptr;
-};
\ No newline at end of file
+};
diff --git a/plugins/account/CMakeLists.txt b/plugins/account/CMakeLists.txt
index 98c5383..586c6c8 100644
--- a/plugins/account/CMakeLists.txt
+++ b/plugins/account/CMakeLists.txt
@@ -5,6 +5,8 @@ if (PASSWD_EXPIRATION_POLICY_VISIBLE)
endif ()
pkg_search_module(CRYPTOPP REQUIRED cryptopp)
+pkg_search_module(PAM REQUIRED pam)
+pkg_search_module(LIBCRYPT REQUIRED libcrypt)
file(GLOB_RECURSE ACCOUNT_SRC
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
@@ -22,11 +24,13 @@ target_include_directories(${TARGET_NAME} PRIVATE
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/pages
${CMAKE_CURRENT_SOURCE_DIR}/utils
+ ${PAM_INCLUDE_DIRS}
${KIRAN_WIDGETS_INCLUDE_DIRS}
${KIRAN_CC_DAEMON_INCLUDE_DIRS}
${KLOG_INCLUDE_DIRS}
${KIRAN_STYLE_INCLUDE_DIRS}
- ${CRYPTOPP_INCLUDE_DIRS})
+ ${CRYPTOPP_INCLUDE_DIRS}
+ ${LIBCRYPT_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME}
common-widgets
@@ -34,10 +38,12 @@ target_link_libraries(${TARGET_NAME}
Qt5::Widgets
Qt5::DBus
Qt5::Svg
+ ${PAM_LIBRARIES}
${KIRAN_WIDGETS_LIBRARIES}
${KIRAN_CC_DAEMON_LIBRARIES}
${KLOG_LIBRARIES}
${KIRAN_STYLE_LIBRARIES}
- ${CRYPTOPP_LIBRARIES})
+ ${CRYPTOPP_LIBRARIES}
+ ${LIBCRYPT_LIBRARIES})
-install(TARGETS ${TARGET_NAME} DESTINATION ${PLUGIN_LIBS_DIR}/)
\ No newline at end of file
+install(TARGETS ${TARGET_NAME} DESTINATION ${PLUGIN_LIBS_DIR}/)
--
2.27.0

View File

@ -0,0 +1,47 @@
From 78e2ba6f38de67917befdabfe9d40a910b02a88c Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Fri, 15 Dec 2023 16:13:08 +0800
Subject: [PATCH 03/17] fix(LC_TIME): set LC_TIME to UTF-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
根据环境变量重新设置LC_TIME为UTF-8
Closes #21517,#24064
---
src/main.cpp | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/main.cpp b/src/main.cpp
index 05f7153..981fdbf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -165,6 +165,24 @@ int main(int argc, char *argv[])
exit(EXIT_SUCCESS);
}
+ /// NOTE: 由于strftime获取系统locale进行格式化Qt使用UTF8,若编码设置不为UTF8中文环境下会导致乱码
+ /// 所以LANG后面的编码若不为UTF-8,修改成UTF-8,使获取时间都为UTF-8格式
+ QString lang = qgetenv("LANG");
+ if (lang.contains("."))
+ {
+#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
+ QStringList splitRes = lang.split(".", QString::SkipEmptyParts);
+#else
+ QStringList splitRes = lang.split(".", Qt::SkipEmptyParts);
+#endif
+ if(splitRes.size() == 2 && splitRes.at(1)!="UTF-8" )
+ {
+ splitRes.replace(1, "UTF-8");
+ QString newLocale = splitRes.join(".");
+ setlocale(LC_TIME, newLocale.toStdString().c_str());
+ }
+ }
+
// 安装翻译
installTranslator();
--
2.33.0

View File

@ -1,29 +0,0 @@
From 22d4318174acee6af3008fe648f7b8fdf96404cb Mon Sep 17 00:00:00 2001
From: yuanxing <yuanxing@kylinsec.com.cn>
Date: Fri, 25 Aug 2023 10:49:36 +0800
Subject: [PATCH 3/5] fix(wallpaper):change system wallpaper xml path to kiran
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修改获取的系统壁纸xml文件路径为kiran
---
plugins/appearance/src/pages/wallpaper/wallpaper-def.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/appearance/src/pages/wallpaper/wallpaper-def.h b/plugins/appearance/src/pages/wallpaper/wallpaper-def.h
index d27c921..adefaf9 100644
--- a/plugins/appearance/src/pages/wallpaper/wallpaper-def.h
+++ b/plugins/appearance/src/pages/wallpaper/wallpaper-def.h
@@ -30,7 +30,7 @@ enum WallpaperType
#define SYSTEM_BACKGROUND_PATH "/usr/share/backgrounds/kiran/"
#define LOCAL_WALLPAPER_FILE ".config/kylinsec/kiran-cpanel-appearance/wallpaper.xml"
-#define SYSTEM_WALLPAPER_FILE "/usr/share/mate-background-properties/kiran_background.xml"
+#define SYSTEM_WALLPAPER_FILE "/usr/share/kiran-background-properties/kiran_background.xml"
#define CACHE_IMAGE_DIR ".config/kylinsec/kiran-cpanel-appearance/"
#define FILENAME "filename"
--
2.33.0

View File

@ -0,0 +1,50 @@
From f803d07ba85e579776fb185f4878b6fcd6c17ddf Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Thu, 21 Dec 2023 09:25:47 +0800
Subject: [PATCH 04/17] fix(network):fix compile issues,QString::SkipEmptyParts
is used under Qt 5.14
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复编译问题在Qt 5.14 以下使用QString::SkipEmptyParts
---
plugins/network/src/plugin/setting-widget/ipv4-widget.cpp | 4 ++++
plugins/network/src/plugin/setting-widget/ipv6-widget.cpp | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp b/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp
index da46dab..fa23708 100644
--- a/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp
+++ b/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp
@@ -131,7 +131,11 @@ void Ipv4Widget::saveSettings()
{
//多个DNS以分号分隔
QString dnsString = ui->ipv4DNS->text();
+#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
+ QStringList dnsList = dnsString.split(";",QString::SkipEmptyParts);
+#else
QStringList dnsList = dnsString.split(";",Qt::SkipEmptyParts);
+#endif
for(auto dns : dnsList)
{
ipv4DNS << QHostAddress(dns);
diff --git a/plugins/network/src/plugin/setting-widget/ipv6-widget.cpp b/plugins/network/src/plugin/setting-widget/ipv6-widget.cpp
index feefdcf..d19a5e0 100644
--- a/plugins/network/src/plugin/setting-widget/ipv6-widget.cpp
+++ b/plugins/network/src/plugin/setting-widget/ipv6-widget.cpp
@@ -124,7 +124,11 @@ void Ipv6Widget::saveSettings()
{
//多个DNS以分号分隔
QString dnsString = ui->ipv6DNS->text();
+#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
+ QStringList dnsList = dnsString.split(";",QString::SkipEmptyParts);
+#else
QStringList dnsList = dnsString.split(";",Qt::SkipEmptyParts);
+#endif
for(auto dns : dnsList)
{
ipv6DNS << QHostAddress(dns);
--
2.33.0

View File

@ -1,44 +0,0 @@
From ae26631a045b39aeb760ada4c1cfd98783599fda Mon Sep 17 00:00:00 2001
From: yuanxing <yuanxing@kylinsec.com.cn>
Date: Fri, 25 Aug 2023 13:47:13 +0800
Subject: [PATCH 4/5] fix(wallpaper):don't call xmlWriter if system background
xml not exists to solve segmentation fault
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 当系统系统壁纸xml文件不存在时不调用xmlWriter函数防止段错误
---
.../wallpaper/widget/xml-management/xml-management.cpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/plugins/appearance/src/pages/wallpaper/widget/xml-management/xml-management.cpp b/plugins/appearance/src/pages/wallpaper/widget/xml-management/xml-management.cpp
index 8d174ab..385eb9e 100644
--- a/plugins/appearance/src/pages/wallpaper/widget/xml-management/xml-management.cpp
+++ b/plugins/appearance/src/pages/wallpaper/widget/xml-management/xml-management.cpp
@@ -38,8 +38,8 @@ void XmlManagement::loadXmlFiles()
if (!file.exists())
{
KLOG_DEBUG() << "local xml file no exist";
- xmlReader(SYSTEM_WALLPAPER_FILE);
- xmlWriter();
+ if (xmlReader(SYSTEM_WALLPAPER_FILE))
+ xmlWriter();
}
xmlReader(localFile);
}
@@ -209,6 +209,11 @@ void XmlManagement::xmlUpdate(QList<QMap<QString, QString>> updateList)
{
QString localFile = QString("%1/%2").arg(QDir::homePath()).arg(LOCAL_WALLPAPER_FILE);
QFile file(localFile);
+ if (!file.exists())
+ {
+ KLOG_DEBUG() << localFile << " doesn't exists!";
+ return;
+ }
if (!file.open(QFile::WriteOnly | QFile::Text))
{
KLOG_DEBUG() << "open " << localFile << " failed!";
--
2.33.0

View File

@ -1,129 +0,0 @@
From 766a1ac3345852e3f95a005bd6ef2469ab9f1dd9 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Mon, 28 Aug 2023 19:17:41 +0800
Subject: [PATCH 5/5] fix(account): Fixed issues related to creating and
deleting users in account management
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复账户管理创建删除用户中出现的相关问题
Closes #13994, #13990
---
plugins/account/src/kiran-account-manager.cpp | 15 ++++++---------
.../account/src/widgets/animation-push-button.cpp | 11 +++++++++++
.../account/src/widgets/animation-push-button.h | 1 +
.../account/src/widgets/avatar-item-button.cpp | 2 +-
plugins/account/src/widgets/mask-widget.cpp | 2 +-
5 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/plugins/account/src/kiran-account-manager.cpp b/plugins/account/src/kiran-account-manager.cpp
index 01b4fbf..15653d9 100644
--- a/plugins/account/src/kiran-account-manager.cpp
+++ b/plugins/account/src/kiran-account-manager.cpp
@@ -109,14 +109,11 @@ void KiranAccountManager::appendSiderbarItem(const QString &userPath)
void KiranAccountManager::setDefaultSiderbarItem()
{
//设置默认侧边栏项
- if (m_tabList->count() > 1)
+ auto items = m_tabList->findItems(AccountsGlobalInfo::instance()->getCurrentUser(), Qt::MatchCaseSensitive);
+ if ( items.size() >= 1 )
{
- auto items = m_tabList->findItems(AccountsGlobalInfo::instance()->getCurrentUser(), Qt::MatchCaseSensitive);
- if (items.size() == 1)
- {
- auto item = items.at(0);
- m_tabList->setCurrentRow(m_tabList->row(item));
- }
+ auto item = items.at(0);
+ m_tabList->setCurrentRow(m_tabList->row(item));
}
else
{
@@ -128,7 +125,7 @@ void KiranAccountManager::initUI()
{
/* 遮罩,用于繁忙时屏蔽用户操作 */
m_maskWidget = new MaskWidget(this);
- m_maskWidget->setVisible(false);
+ m_maskWidget->setVisible(true);
/* 初始化界面主布局 */
auto contentLayout = new QHBoxLayout(this);
@@ -444,7 +441,7 @@ void KiranAccountManager::setMaskVisible(bool visible)
{
if (visible)
{
- this->stackUnder(m_maskWidget);
+ m_maskWidget->raise();
m_maskWidget->show();
}
else
diff --git a/plugins/account/src/widgets/animation-push-button.cpp b/plugins/account/src/widgets/animation-push-button.cpp
index 65791f0..d65b348 100644
--- a/plugins/account/src/widgets/animation-push-button.cpp
+++ b/plugins/account/src/widgets/animation-push-button.cpp
@@ -16,6 +16,7 @@
#include <QPropertyAnimation>
#include <QStyleOption>
#include <qt5-log-i.h>
+#include <QMouseEvent>
#include "animation-push-button.h"
@@ -85,6 +86,16 @@ void AnimationPushButton::paintEvent(QPaintEvent *event)
}
}
+void AnimationPushButton::mousePressEvent(QMouseEvent *e)
+{
+ if( m_isBusy )
+ {
+ e->ignore();
+ return;
+ }
+ QPushButton::mousePressEvent(e);
+}
+
void AnimationPushButton::initTimeLine()
{
m_timeLine.setCurrentTime(0);
diff --git a/plugins/account/src/widgets/animation-push-button.h b/plugins/account/src/widgets/animation-push-button.h
index 9a172e2..f39e9a4 100644
--- a/plugins/account/src/widgets/animation-push-button.h
+++ b/plugins/account/src/widgets/animation-push-button.h
@@ -38,6 +38,7 @@ private:
protected:
virtual void paintEvent(QPaintEvent *event) override;
+ virtual void mousePressEvent(QMouseEvent *e) override;
private:
bool m_isBusy = false;
diff --git a/plugins/account/src/widgets/avatar-item-button.cpp b/plugins/account/src/widgets/avatar-item-button.cpp
index a078974..a9e5a4b 100644
--- a/plugins/account/src/widgets/avatar-item-button.cpp
+++ b/plugins/account/src/widgets/avatar-item-button.cpp
@@ -106,7 +106,7 @@ void AvatarItemButton::paintEvent(QPaintEvent *event)
QPoint checkedIconLeftop((this->width() - checkedIconSize.width()) / 2,
(this->height() - checkedIconSize.height()) / 2);
QRect checkedIconRect(checkedIconLeftop, checkedIconSize);
- QSvgRenderer svgRenderer(QString(":/kcp-account/images/success-indicator.svg"));
+ QSvgRenderer svgRenderer(QString(":/kiran-control-panel/images/success-indicator.svg"));
svgRenderer.render(&painter, checkedIconRect);
}
}
diff --git a/plugins/account/src/widgets/mask-widget.cpp b/plugins/account/src/widgets/mask-widget.cpp
index 088fd48..476cbb3 100644
--- a/plugins/account/src/widgets/mask-widget.cpp
+++ b/plugins/account/src/widgets/mask-widget.cpp
@@ -41,5 +41,5 @@ bool MaskWidget::eventFilter(QObject *watched, QEvent *event)
break;
}
}
- return QObject::eventFilter(watched, event);
+ return QWidget::eventFilter(watched, event);
}
--
2.33.0

View File

@ -0,0 +1,202 @@
From b7eb0462cb754bccde3afc53b151a9b6b61e4143 Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Wed, 3 Jan 2024 13:49:14 +0800
Subject: [PATCH 05/17] fix(audio):listen to mute property change to fix
shortcut key mute, volume icon unchanged issue
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 监听mute静音属性变化,以修复快捷键静音,音量图标未变化的问题
Related #25508
---
.../src/system-tray/audio-system-tray.cpp | 12 ++++
.../src/system-tray/volume-setting-page.cpp | 69 ++++++++++++-------
.../src/system-tray/volume-setting-page.h | 5 +-
3 files changed, 60 insertions(+), 26 deletions(-)
diff --git a/plugins/audio/src/system-tray/audio-system-tray.cpp b/plugins/audio/src/system-tray/audio-system-tray.cpp
index eb554b2..ed4412f 100644
--- a/plugins/audio/src/system-tray/audio-system-tray.cpp
+++ b/plugins/audio/src/system-tray/audio-system-tray.cpp
@@ -124,6 +124,18 @@ void AudioSystemTray::initConnect()
setTrayIcon(currentVolume);
});
+ connect(m_volumeSettingPage,&VolumeSettingPage::sinkMuteChanged,[this](bool mute,double currentVolume)
+ {
+ if(mute)
+ {
+ setTrayIcon(0);
+ }
+ else
+ {
+ setTrayIcon(currentVolume);
+ }
+ });
+
connect(Kiran::StylePalette::instance(), &Kiran::StylePalette::themeChanged, [this](Kiran::PaletteType paletteType)
{
//获取当前音量值重新设置TrayIcon
diff --git a/plugins/audio/src/system-tray/volume-setting-page.cpp b/plugins/audio/src/system-tray/volume-setting-page.cpp
index 03116c7..dbb1cd8 100644
--- a/plugins/audio/src/system-tray/volume-setting-page.cpp
+++ b/plugins/audio/src/system-tray/volume-setting-page.cpp
@@ -15,8 +15,8 @@
#include "dbus/audio-device-interface.h"
#include "dbus/audio-interface.h"
#include "dbus/audio-stream-interface.h"
-#include "ui_volume-setting-page.h"
#include "logging-category.h"
+#include "ui_volume-setting-page.h"
#include <kiran-session-daemon/audio-i.h>
#include <qt5-log-i.h>
@@ -41,7 +41,9 @@ VolumeSettingPage::VolumeSettingPage(enum AudioNode audio, const QString objectP
m_sink = new AudioDeviceInterface(AUDIO_DBUS_NAME, defaultSinkPath, QDBusConnection::sessionBus(), this);
initAudioDevice();
- connect(m_sink, &AudioDeviceInterface::volumeChanged, this, &VolumeSettingPage::handleVolumeChanged);
+ connect(m_sink, &AudioDeviceInterface::volumeChanged, this, &VolumeSettingPage::handleVolumeChanged, Qt::UniqueConnection);
+ connect(m_sink, &AudioDeviceInterface::muteChanged, this, &VolumeSettingPage::changeSinkMute, Qt::UniqueConnection);
+
connect(ui->volumeSetting, &QSlider::valueChanged, [this](int value)
{
double volumeValue = value / 100.0;
@@ -101,6 +103,7 @@ void VolumeSettingPage::initAudioStream()
initSettings(m_sinkInput);
ui->volumeName->setText(m_sinkInput->GetProperty("application.name"));
connect(m_sinkInput, &AudioStreamInterface::volumeChanged, this, &VolumeSettingPage::handleVolumeChanged);
+ connect(m_sinkInput, &AudioStreamInterface::muteChanged, this, &VolumeSettingPage::changeSinkInputMute);
connect(ui->volumeSetting, &QSlider::valueChanged, [this](int value)
{
double volumeValue = value / 100.0;
@@ -123,10 +126,38 @@ void VolumeSettingPage::initSettings(Audio *audio)
ui->volume->setText(QString::number(currentVolume) + "%");
}
+void VolumeSettingPage::changeSinkMute(bool value)
+{
+ KLOG_DEBUG() << "change sink mute:" << value;
+ double currentVolume = m_sink->volume() * 100;
+ emit sinkMuteChanged(value, currentVolume);
+ if (value)
+ {
+ setVolumeIcon(0);
+ }
+ else
+ {
+ setVolumeIcon(currentVolume);
+ }
+}
+void VolumeSettingPage::changeSinkInputMute(bool value)
+{
+ KLOG_DEBUG() << "change sink input mute:" << value;
+ double currentVolume = m_sinkInput->volume() * 100;
+ if (value)
+ {
+ setVolumeIcon(0);
+ }
+ else
+ {
+ setVolumeIcon(currentVolume);
+ }
+}
+
void VolumeSettingPage::handleVolumeChanged(double value)
{
- QSignalBlocker blocker(ui->volumeSetting); // 为了避免拖动的同时设置位置会出现问题
- int currentVolume = round(value * 100); // 表示数值的时候向上取整
+ QSignalBlocker blocker(ui->volumeSetting); // 为了避免拖动的同时设置位置会出现问题
+ int currentVolume = round(value * 100); // 表示数值的时候向上取整
ui->volume->setText(QString::number(currentVolume) + "%");
setVolumeIcon(currentVolume);
ui->volumeSetting->setValue(currentVolume);
@@ -136,9 +167,9 @@ void VolumeSettingPage::handleVolumeChanged(double value)
void VolumeSettingPage::handleMuteButtonClicked()
{
if (m_audioNode == AUDIO_DEVICE)
- clickMuteButton(m_sink);
+ switchMute(m_sink);
else
- clickMuteButton(m_sinkInput);
+ switchMute(m_sinkInput);
}
void VolumeSettingPage::handleDefaultSinkChanged(int index)
@@ -154,7 +185,8 @@ void VolumeSettingPage::handleDefaultSinkChanged(int index)
QDBusPendingReply<QString> defaultSinkPath = m_audioInterface->GetDefaultSink();
m_sink = new AudioDeviceInterface(AUDIO_DBUS_NAME, defaultSinkPath, QDBusConnection::sessionBus(), this);
initAudioDevice();
- connect(m_sink, &AudioDeviceInterface::volumeChanged, this, &VolumeSettingPage::handleVolumeChanged);
+ connect(m_sink, &AudioDeviceInterface::volumeChanged, this, &VolumeSettingPage::handleVolumeChanged, Qt::UniqueConnection);
+ connect(m_sink, &AudioDeviceInterface::muteChanged, this, &VolumeSettingPage::changeSinkMute, Qt::UniqueConnection);
}
void VolumeSettingPage::handleSinkAdded(int index)
@@ -187,30 +219,17 @@ void VolumeSettingPage::handleSinkDelete(int index)
}
template <class Audio>
-void VolumeSettingPage::clickMuteButton(Audio *audio)
+void VolumeSettingPage::switchMute(Audio *audio)
{
- double currentVolumeDouble = audio->volume() * 100;
- int currentVolume = round(currentVolumeDouble);
-
- if (currentVolume != 0)
+ if (!audio->mute())
{
- m_volumeBeforeMute = currentVolume;
- if (!audio->mute())
- {
- audio->SetMute(true);
- }
- audio->SetVolume(0);
- KLOG_DEBUG(qLcAudio) << "current sink is mute :" << audio->mute();
+ audio->SetMute(true);
}
else
{
- if (m_volumeBeforeMute != 0)
- {
- //重新设置音量时,会自动解除静音状态
- audio->SetVolume(m_volumeBeforeMute / 100.0);
- m_volumeBeforeMute = 0;
- }
+ audio->SetMute(false);
}
+ KLOG_DEBUG() << "current defalut sink mute:" << audio->mute();
}
// XXX:频繁调用函数,需要优化
diff --git a/plugins/audio/src/system-tray/volume-setting-page.h b/plugins/audio/src/system-tray/volume-setting-page.h
index 80f0098..4a556fe 100644
--- a/plugins/audio/src/system-tray/volume-setting-page.h
+++ b/plugins/audio/src/system-tray/volume-setting-page.h
@@ -41,6 +41,8 @@ public:
void disableSettings();
public slots:
+ void changeSinkMute(bool value);
+ void changeSinkInputMute(bool value);
void handleVolumeChanged(double value);
void handleMuteButtonClicked();
void handleDefaultSinkChanged(int index);
@@ -57,10 +59,11 @@ private:
template <class Audio>
void initSettings(Audio *audio);
template <class Audio>
- void clickMuteButton(Audio *audio);
+ void switchMute(Audio *audio);
signals:
void volumeChanged(double value);
+ void sinkMuteChanged(bool mute, double currentVolume);
private:
Ui::VolumeSettingPage *ui;
--
2.33.0

View File

@ -1,39 +0,0 @@
From 51ade1eede326506f4814081ac4141a97082ff53 Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Fri, 25 Aug 2023 14:15:36 +0800
Subject: [PATCH 1/2] feature(network):When the gateway setting item is
0.0.0.0, the gateway setting item is null
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 当网关设置项为“0.0.0.0”时,网关设置项置空
Related #13150
---
.../network/src/plugin/setting-widget/ipv4-widget.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp b/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp
index 63d029c..8c39794 100644
--- a/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp
+++ b/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp
@@ -162,7 +162,14 @@ void Ipv4Widget::showSettings()
ui->ipv4Address->setText(address);
ui->ipv4Netmask->setText(netmask);
- ui->ipv4Gateway->setText(gateway);
+ if(gateway != "0.0.0.0")
+ {
+ ui->ipv4Gateway->setText(gateway);
+ }
+ else
+ {
+ ui->ipv4Gateway->clear();
+ }
}
QString preferredDNS = "";
QString alternateDNS = "";
--
2.33.0

View File

@ -0,0 +1,183 @@
From 2bae469f6fdd42c15d574a0d4642d13a2fcf3d8b Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Thu, 4 Jan 2024 11:17:57 +0800
Subject: [PATCH 06/17] fix(network):fixd an issue where the network tray icon
was incorrectly displayed when there was no primary connection
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复当没有主连接时,网络托盘图标显示不准确的问题
Closes #25475, #25037, #25032
---
plugins/network/src/general.h | 1 +
plugins/network/src/tray/network-tray.cpp | 90 +++++++++++++++++------
2 files changed, 68 insertions(+), 23 deletions(-)
diff --git a/plugins/network/src/general.h b/plugins/network/src/general.h
index 8aa4f67..c65ce78 100644
--- a/plugins/network/src/general.h
+++ b/plugins/network/src/general.h
@@ -24,6 +24,7 @@
enum NetworkState
{
+ UNKNOWN,
WIRED_CONNECTED,
WIRED_CONNECTED_BUT_NOT_ACCESS_INTERNET,
WIRELESS_CONNECTED,
diff --git a/plugins/network/src/tray/network-tray.cpp b/plugins/network/src/tray/network-tray.cpp
index 00b6685..db6e0cd 100644
--- a/plugins/network/src/tray/network-tray.cpp
+++ b/plugins/network/src/tray/network-tray.cpp
@@ -20,17 +20,17 @@
#include <QMenu>
#include <QPainter>
#include <QPainterPath>
+#include <QTcpSocket>
+#include <QTimer>
#include <QVBoxLayout>
#include "config.h"
+#include "logging-category.h"
#include "status-notification.h"
#include "status-notifier-manager.h"
#include "tray-page.h"
#include "utils.h"
#include "wired-tray-widget.h"
#include "wireless-tray-widget.h"
-#include <QTcpSocket>
-#include <QTimer>
-#include "logging-category.h"
using namespace NetworkManager;
@@ -359,42 +359,70 @@ void NetworkTray::getTrayGeometry()
void NetworkTray::updateTrayIcon()
{
auto status = NetworkManager::status();
- if (status != NetworkManager::Status::Connected)
+ if (status < NetworkManager::Status::ConnectedLinkLocal)
{
setTrayIcon(DISCONNECTED);
return;
}
+#define SET_TRAY_ICON_AND_CHECK_CONNECTIVITY_AND_RETURN(state) \
+ if (state != UNKNOWN) \
+ { \
+ setTrayIcon(state); \
+ checkInternetConnectivity(); \
+ return; \
+ }
+
+ NetworkState state = UNKNOWN;
// 判断主连接类型,托盘网络图标以主连接类型为准
// NetworkManager::primaryConnectionType() 更新不及时,暂时不用
+ /**
+ * NOTE:
+ * 注意特殊情况,如果当网络状态为已连接,但是没有主连接,则遍历所有已激活的连接,
+ * 按有线优先于无线的原则,如果存在激活的有线连接,则显示有线网络图标;其次显示无线网络图标
+ * 如果既不是有线也不是无线,则显示有线网络图标
+ */
ActiveConnection::Ptr primaryActiveConnection = primaryConnection();
- if (primaryActiveConnection.isNull())
+ if (!primaryActiveConnection.isNull())
{
- KLOG_INFO(qLcNetwork) << "update tray icon failed, primary active connection is null";
- return;
+ if (primaryActiveConnection->type() == ConnectionSettings::Wireless)
+ {
+ state = WIRELESS_CONNECTED_BUT_NOT_ACCESS_INTERNET;
+ }
+ else
+ {
+ state = WIRED_CONNECTED_BUT_NOT_ACCESS_INTERNET;
+ }
}
+ SET_TRAY_ICON_AND_CHECK_CONNECTIVITY_AND_RETURN(state);
- // NetworkManager::connectivity() 不准确使用checkConnectivity
- QDBusPendingReply<uint> reply = NetworkManager::checkConnectivity();
- reply.waitForFinished();
- uint result = reply.value();
-
- if (result == NetworkManager::Connectivity::Full)
+ KLOG_INFO(qLcNetwork) << "primary active connection is null";
+ ActiveConnection::List list = activeConnections();
+ for (auto connection : list)
{
- checkInternetConnectivity();
- return;
+ if (connection->type() == ConnectionSettings::ConnectionType::Wired)
+ {
+ state = WIRED_CONNECTED_BUT_NOT_ACCESS_INTERNET;
+ break;
+ }
}
+ SET_TRAY_ICON_AND_CHECK_CONNECTIVITY_AND_RETURN(state);
- NetworkState state;
- if (primaryActiveConnection->type() == ConnectionSettings::Wireless)
+ for (auto connection : list)
{
- state = WIRELESS_CONNECTED_BUT_NOT_ACCESS_INTERNET;
+ if (connection->type() == ConnectionSettings::ConnectionType::Wireless)
+ {
+ state = WIRELESS_CONNECTED_BUT_NOT_ACCESS_INTERNET;
+ break;
+ }
}
- else
+
+ //最后如果既不是有线也不是无线,则显示有线网络图标
+ if (state == UNKNOWN)
{
state = WIRED_CONNECTED_BUT_NOT_ACCESS_INTERNET;
}
- setTrayIcon(state);
+ SET_TRAY_ICON_AND_CHECK_CONNECTIVITY_AND_RETURN(state);
}
void NetworkTray::setTrayIcon(NetworkState state)
@@ -712,6 +740,15 @@ void NetworkTray::initTcpSocket()
void NetworkTray::checkInternetConnectivity()
{
+ // NetworkManager::connectivity() 不准确使用checkConnectivity
+ QDBusPendingReply<uint> reply = NetworkManager::checkConnectivity();
+ reply.waitForFinished();
+ uint result = reply.value();
+ if (result != NetworkManager::Connectivity::Full)
+ {
+ return;
+ }
+
QSettings confSettings(SETTINGS_PATH, QSettings::NativeFormat);
QVariant enable = confSettings.value(QString("Network/CheckInternetConnectivity"));
KLOG_DEBUG(qLcNetwork) << "check Internet Connectivity : " << enable;
@@ -728,11 +765,18 @@ void NetworkTray::checkInternetConnectivity()
void NetworkTray::internetConnected()
{
KLOG_DEBUG(qLcNetwork) << "Connectivity check pass";
- ActiveConnection::Ptr primaryActiveConnection = primaryConnection();
NetworkState state;
- if (primaryActiveConnection->type() == ConnectionSettings::Wireless)
+ ActiveConnection::Ptr primaryActiveConnection = primaryConnection();
+ if (!primaryActiveConnection.isNull())
{
- state = WIRELESS_CONNECTED;
+ if (primaryActiveConnection->type() == ConnectionSettings::Wireless)
+ {
+ state = WIRELESS_CONNECTED;
+ }
+ else
+ {
+ state = WIRED_CONNECTED;
+ }
}
else
{
--
2.33.0

View File

@ -0,0 +1,63 @@
From 3ccdcfbc6d104f1f691b7feaf6ed58daae21da63 Mon Sep 17 00:00:00 2001
From: niko_yhc <yinhongchang@kylinsec.com.cn>
Date: Mon, 8 Jan 2024 13:48:50 +0800
Subject: [PATCH 07/17] fix(application):add a compilation switch to control
whether the application-plugin is turned on
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 添加编译开关控制application-plugin是否打开
---
cmake/options.cmake | 3 ++-
data/CMakeLists.txt | 5 +++++
plugins/CMakeLists.txt | 4 +++-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/cmake/options.cmake b/cmake/options.cmake
index f21d2b9..bc56591 100644
--- a/cmake/options.cmake
+++ b/cmake/options.cmake
@@ -3,4 +3,5 @@ option(PASSWD_EXPIRATION_POLICY_VISIBLE "Is password expiration policy visible"
OPTION(ENABLE_USER_GROUP "Enable user group" OFF)
OPTION(ENABLE_NETWORK "Enable network plugin" ON)
-OPTION(ENABLE_AUDIO "Enable audio plugin" ON)
\ No newline at end of file
+OPTION(ENABLE_AUDIO "Enable audio plugin" ON)
+OPTION(ENABLE_APPLICATION "Enable application plugin" ON)
\ No newline at end of file
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index 9f66d68..8b1ed54 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -14,6 +14,11 @@ endif()
if(NOT ENABLE_USER_GROUP)
list(FILTER CATEGORY_DESKTOP EXCLUDE REGEX "group.desktop")
endif()
+
+if(NOT ENABLE_APPLICATION)
+ list(FILTER CATEGORY_DESKTOP EXCLUDE REGEX "application.desktop")
+endif()
+
install(FILES ${CATEGORY_DESKTOP} DESTINATION ${CATEGORY_DESKTOP_DIR})
# 安装主分类相关图标文件
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 9acb921..ecad7b6 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -8,7 +8,9 @@ add_subdirectory(timedate)
add_subdirectory(display)
add_subdirectory(keybinding)
add_subdirectory(authentication)
-add_subdirectory(application)
+if (ENABLE_APPLICATION)
+ add_subdirectory(application)
+endif()
if(ENABLE_NETWORK)
add_subdirectory(network)
endif()
--
2.33.0

View File

@ -1,46 +0,0 @@
From 6e8923c8712ce9875863408d3bd695375d8e8973 Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Tue, 29 Aug 2023 15:21:50 +0800
Subject: [PATCH 2/2] fix(audio):Fix parsing error when json contains Chinese
characters
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复json中包含中文字符时的解析错误
Related #13261
---
plugins/audio/src/plugin/input-page.cpp | 2 +-
plugins/audio/src/plugin/output-page.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/audio/src/plugin/input-page.cpp b/plugins/audio/src/plugin/input-page.cpp
index 00826b4..8b0ecaa 100644
--- a/plugins/audio/src/plugin/input-page.cpp
+++ b/plugins/audio/src/plugin/input-page.cpp
@@ -202,7 +202,7 @@ void InputPage::initActivedPort()
KLOG_DEBUG() << "getPorts:" << getPorts;
//解析默认source的端口信息
QJsonParseError jsonParseError;
- QJsonDocument doc = QJsonDocument::fromJson(getPorts.value().toLatin1(), &jsonParseError);
+ QJsonDocument doc = QJsonDocument::fromJson(getPorts.value().toUtf8(), &jsonParseError);
if (!doc.isNull() && jsonParseError.error == QJsonParseError::NoError)
{
if (doc.isArray() && jsonParseError.error == QJsonParseError::NoError)
diff --git a/plugins/audio/src/plugin/output-page.cpp b/plugins/audio/src/plugin/output-page.cpp
index ef52165..420cf98 100644
--- a/plugins/audio/src/plugin/output-page.cpp
+++ b/plugins/audio/src/plugin/output-page.cpp
@@ -98,7 +98,7 @@ void OutputPage::initActivedPort()
//解析默认sink的端口信息
QJsonParseError jsonParseError;
- QJsonDocument doc = QJsonDocument::fromJson(getPorts.value().toLatin1(), &jsonParseError);
+ QJsonDocument doc = QJsonDocument::fromJson(getPorts.value().toUtf8(), &jsonParseError);
if (!doc.isNull() && jsonParseError.error == QJsonParseError::NoError)
{
if (doc.isArray() && jsonParseError.error == QJsonParseError::NoError)
--
2.33.0

View File

@ -1,153 +0,0 @@
From 2c6ae961ff33c45c9d9d7758715af3b52d2db052 Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Thu, 7 Sep 2023 19:21:39 +0800
Subject: [PATCH] fix(audio-tray):Fixed an issue where the volume tray icon did
not change with the volume after the default Sink was changed
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复默认Sink变更后音量托盘图标不随音量大小改变的问题
Closed #14124
---
.../src/system-tray/audio-system-tray.cpp | 27 +++++++++++--------
.../audio/src/system-tray/audio-system-tray.h | 1 -
.../src/system-tray/volume-setting-page.cpp | 2 ++
.../src/system-tray/volume-setting-page.h | 22 ++++++++-------
4 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/plugins/audio/src/system-tray/audio-system-tray.cpp b/plugins/audio/src/system-tray/audio-system-tray.cpp
index 00e90f7..0c6aca6 100644
--- a/plugins/audio/src/system-tray/audio-system-tray.cpp
+++ b/plugins/audio/src/system-tray/audio-system-tray.cpp
@@ -41,7 +41,6 @@ AudioSystemTray::AudioSystemTray(QWidget *parent) : QWidget(parent)
initVolumeSettingPage(defaultSinkPath);
initMixedSettingPage();
- m_sink = new AudioDeviceInterface(AUDIO_DBUS_NAME, defaultSinkPath, QDBusConnection::sessionBus());
m_statusNotifierManager = new StatusNotifierManagerInterface(STATUS_NOTIFIER_MANAGER, STATUS_NOTIFIER_MANAGER_OBJECT_NAME, QDBusConnection::sessionBus(), this);
m_systemTray = new QSystemTrayIcon();
@@ -82,8 +81,11 @@ void AudioSystemTray::initMixedSettingPage()
void AudioSystemTray::initTrayIcon()
{
getTrayIconStyle();
- double currentVolumeDouble = m_sink->volume() * 100;
- KLOG_INFO() << "currentVolumeDouble" << round(currentVolumeDouble);
+
+ QDBusPendingReply<QString> defaultSinkPath = m_audioInterface->GetDefaultSink();
+ AudioDeviceInterface defaultSink (AUDIO_DBUS_NAME, defaultSinkPath, QDBusConnection::sessionBus());
+ double currentVolumeDouble = defaultSink.volume() * 100;
+ KLOG_INFO() << "current Volume Double" << round(currentVolumeDouble);
setTrayIcon(round(currentVolumeDouble));
}
@@ -117,11 +119,12 @@ void AudioSystemTray::initConnect()
{
connect(m_systemTray, &QSystemTrayIcon::activated, this, &AudioSystemTray::handleAudioTrayClicked);
- connect(m_sink, &AudioDeviceInterface::volumeChanged, [=](double value)
- {
- int currentVolume = round(value * 100); //表示数值的时候向上取整
- KLOG_DEBUG() << "m_sink volumeChanged :" << currentVolume;
- setTrayIcon(currentVolume); });
+ connect(m_volumeSettingPage,&VolumeSettingPage::volumeChanged,[=](double value)
+ {
+ int currentVolume = round(value * 100); //表示数值的时候向上取整
+ KLOG_DEBUG() << "m_sink volumeChanged :" << currentVolume;
+ setTrayIcon(currentVolume);
+ });
connect(m_statusNotifierManager, &StatusNotifierManagerInterface::StyleChanged, [=](const QString &style)
{
@@ -129,9 +132,11 @@ void AudioSystemTray::initConnect()
//重新获取style
getTrayIconStyle();
//获取当前音量值重新设置TrayIcon
- m_sink->volume();
- double currentVolumeDouble = m_sink->volume() * 100;
- setTrayIcon(round(currentVolumeDouble)); });
+ QDBusPendingReply<QString> defaultSinkPath = m_audioInterface->GetDefaultSink();
+ AudioDeviceInterface defaultSink (AUDIO_DBUS_NAME, defaultSinkPath, QDBusConnection::sessionBus());
+ double currentVolumeDouble = defaultSink.volume() * 100;
+ setTrayIcon(round(currentVolumeDouble));
+ });
}
void AudioSystemTray::handleAudioTrayClicked(QSystemTrayIcon::ActivationReason reason)
diff --git a/plugins/audio/src/system-tray/audio-system-tray.h b/plugins/audio/src/system-tray/audio-system-tray.h
index 16846e6..a61284e 100644
--- a/plugins/audio/src/system-tray/audio-system-tray.h
+++ b/plugins/audio/src/system-tray/audio-system-tray.h
@@ -68,7 +68,6 @@ private:
StatusNotifierManagerInterface* m_statusNotifierManager;
AudioInterface* m_audioInterface;
- AudioDeviceInterface* m_sink;
QString m_colorTheme;
int xTray, yTray, heightTray, widthTray;
diff --git a/plugins/audio/src/system-tray/volume-setting-page.cpp b/plugins/audio/src/system-tray/volume-setting-page.cpp
index fac69a6..54b8f10 100644
--- a/plugins/audio/src/system-tray/volume-setting-page.cpp
+++ b/plugins/audio/src/system-tray/volume-setting-page.cpp
@@ -132,6 +132,7 @@ void VolumeSettingPage::handleVolumeChanged(double value)
setVolumeIcon(currentVolume);
ui->volumeSetting->setValue(currentVolume);
ui->volumeSetting->blockSignals(false);
+ emit volumeChanged(value);
}
void VolumeSettingPage::handleMuteButtonClicked()
@@ -144,6 +145,7 @@ void VolumeSettingPage::handleMuteButtonClicked()
void VolumeSettingPage::handleDefaultSinkChanged(int index)
{
+ KLOG_DEBUG() << "Default Sink Changed";
// delete and restart init defaultSink
if (m_sink != nullptr)
{
diff --git a/plugins/audio/src/system-tray/volume-setting-page.h b/plugins/audio/src/system-tray/volume-setting-page.h
index 4719021..80f0098 100644
--- a/plugins/audio/src/system-tray/volume-setting-page.h
+++ b/plugins/audio/src/system-tray/volume-setting-page.h
@@ -40,16 +40,6 @@ public:
QPixmap trayIconColorSwitch(const QString &iconPath);
void disableSettings();
-private:
- void initDbusServiceWatcher();
- void initAudioDevice();
- void initAudioStream();
- template <class Audio>
- void initSettings(Audio *audio);
- template <class Audio>
- void clickMuteButton(Audio *audio);
-
-
public slots:
void handleVolumeChanged(double value);
void handleMuteButtonClicked();
@@ -60,6 +50,18 @@ public slots:
void setVolumeIcon(int value);
void hideLine();
+private:
+ void initDbusServiceWatcher();
+ void initAudioDevice();
+ void initAudioStream();
+ template <class Audio>
+ void initSettings(Audio *audio);
+ template <class Audio>
+ void clickMuteButton(Audio *audio);
+
+signals:
+ void volumeChanged(double value);
+
private:
Ui::VolumeSettingPage *ui;
AudioInterface *m_audioInterface;
--
2.33.0

View File

@ -0,0 +1,137 @@
From 3a30343a3958caafad6b27e1900c0e7b6b9ab26b Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Mon, 8 Jan 2024 15:04:41 +0800
Subject: [PATCH 08/17] refactor(account): Remove useless password encryption
interfaces and remove the dependency of libcrypt
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 删除目前无用的密码加密接口去除libcrypt的依赖
---
plugins/account/CMakeLists.txt | 7 +--
plugins/account/utils/passwd-helper.cpp | 57 -------------------------
plugins/account/utils/passwd-helper.h | 1 -
3 files changed, 2 insertions(+), 63 deletions(-)
diff --git a/plugins/account/CMakeLists.txt b/plugins/account/CMakeLists.txt
index 586c6c8..e96fa92 100644
--- a/plugins/account/CMakeLists.txt
+++ b/plugins/account/CMakeLists.txt
@@ -6,7 +6,6 @@ endif ()
pkg_search_module(CRYPTOPP REQUIRED cryptopp)
pkg_search_module(PAM REQUIRED pam)
-pkg_search_module(LIBCRYPT REQUIRED libcrypt)
file(GLOB_RECURSE ACCOUNT_SRC
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
@@ -29,8 +28,7 @@ target_include_directories(${TARGET_NAME} PRIVATE
${KIRAN_CC_DAEMON_INCLUDE_DIRS}
${KLOG_INCLUDE_DIRS}
${KIRAN_STYLE_INCLUDE_DIRS}
- ${CRYPTOPP_INCLUDE_DIRS}
- ${LIBCRYPT_INCLUDE_DIRS})
+ ${CRYPTOPP_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME}
common-widgets
@@ -43,7 +41,6 @@ target_link_libraries(${TARGET_NAME}
${KIRAN_CC_DAEMON_LIBRARIES}
${KLOG_LIBRARIES}
${KIRAN_STYLE_LIBRARIES}
- ${CRYPTOPP_LIBRARIES}
- ${LIBCRYPT_LIBRARIES})
+ ${CRYPTOPP_LIBRARIES})
install(TARGETS ${TARGET_NAME} DESTINATION ${PLUGIN_LIBS_DIR}/)
diff --git a/plugins/account/utils/passwd-helper.cpp b/plugins/account/utils/passwd-helper.cpp
index f6b76f2..a5641c7 100644
--- a/plugins/account/utils/passwd-helper.cpp
+++ b/plugins/account/utils/passwd-helper.cpp
@@ -14,7 +14,6 @@
#include "passwd-helper.h"
-#include <crypt.h>
#include <cryptopp/base64.h>
#include <cryptopp/cryptlib.h>
#include <cryptopp/hex.h>
@@ -33,62 +32,6 @@
using namespace CryptoPP;
-bool PasswdHelper::encryptPassword(const QString &pwd, QString &encrypted)
-{
- QByteArray byteArray = pwd.toLatin1();
- QString saltChar = "ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz./0123456789";
-
- QString rand16SaltChar;
-
- std::default_random_engine randomEngine;
- std::uniform_int_distribution<int> uniformIntDistribution(0, saltChar.size() - 1);
- for (int i = 0; i < 16; i++)
- {
- char ch = saltChar.at(uniformIntDistribution(randomEngine)).toLatin1();
- rand16SaltChar.append(ch);
- }
-
- QString salt = QString("$6$%1$").arg(rand16SaltChar);
- QByteArray saltByteArray = salt.toLatin1();
-
- char *cryptedResult = nullptr;
- QByteArray cryptedResultBuffer(100, 0);
-
- //NOTE:兼容低版本libcrypt不带有crypt_rn接口的版本
-#if 0
- forever
- {
- cryptedResult = crypt_rn(byteArray.data(),
- saltByteArray.data(),
- cryptedResultBuffer.data(),
- cryptedResultBuffer.size());
- if (cryptedResult == nullptr)
- {
- if (errno == ERANGE)
- {
- cryptedResultBuffer.resize(cryptedResultBuffer.size() * 2);
- continue;
- }
- else
- {
- KLOG_WARNING() << "encrypt passwd failed," << strerror(errno);
- }
- }
- break;
- }
-#else
- crypt_data cryptData{};
- cryptedResult = crypt_r(byteArray.data(),
- saltByteArray.data(),
- &cryptData);
-#endif
-
- if (cryptedResult)
- encrypted = cryptedResult;
-
- return cryptedResult != nullptr;
-}
-
bool PasswdHelper::encryptPasswordByRsa(const QString &publicKey, const QString &pwd, QString &encrypted)
{
CryptoPP::RandomPool random_pool;
diff --git a/plugins/account/utils/passwd-helper.h b/plugins/account/utils/passwd-helper.h
index b09d246..fc98068 100644
--- a/plugins/account/utils/passwd-helper.h
+++ b/plugins/account/utils/passwd-helper.h
@@ -18,7 +18,6 @@
class QString;
namespace PasswdHelper
{
-bool encryptPassword(const QString &pwd, QString &encrypted);
bool encryptPasswordByRsa(const QString &publicKey, const QString &pwd, QString &encrypted);
bool checkUserPassword(const QString &user, const QString &pwd);
} // namespace PasswdHelper
--
2.33.0

View File

@ -1,306 +0,0 @@
From 091bc92282fd07e989747ca23157f7af5113c723 Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Fri, 8 Sep 2023 15:53:56 +0800
Subject: [PATCH] fix(audio):The Sink/Source device list displays only active
ports. The port selection function is temporarily disabled
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 输入输出设备列表只显示目前已激活的端口,暂时禁用选择端口的功能
Related #13261
---
.../audio/src/dbus/audio-device-interface.cpp | 33 +++++++++
.../audio/src/dbus/audio-device-interface.h | 9 +++
plugins/audio/src/plugin/input-page.cpp | 69 +++++++------------
plugins/audio/src/plugin/input-page.h | 1 -
plugins/audio/src/plugin/output-page.cpp | 62 ++++++-----------
plugins/audio/src/plugin/output-page.h | 1 -
6 files changed, 89 insertions(+), 86 deletions(-)
diff --git a/plugins/audio/src/dbus/audio-device-interface.cpp b/plugins/audio/src/dbus/audio-device-interface.cpp
index a3a750f..7ec201d 100644
--- a/plugins/audio/src/dbus/audio-device-interface.cpp
+++ b/plugins/audio/src/dbus/audio-device-interface.cpp
@@ -13,6 +13,7 @@
*/
#include "audio-device-interface.h"
+#include <qt5-log-i.h>
/*
* Implementation of interface class AudioDeviceInterface
@@ -28,6 +29,38 @@ AudioDeviceInterface::~AudioDeviceInterface()
{
}
+QList<AudioPortInfo> AudioDeviceInterface::getPortsInfo()
+{
+ QDBusPendingReply<QString> getPorts = GetPorts();
+ KLOG_DEBUG() << "getPorts:" << getPorts;
+
+ //解析默认sink的端口信息
+ QJsonParseError jsonParseError;
+ QJsonDocument doc = QJsonDocument::fromJson(getPorts.value().toUtf8(), &jsonParseError);
+
+ if((doc.isNull()) || (jsonParseError.error != QJsonParseError::NoError))
+ {
+ return QList<AudioPortInfo>();
+ }
+
+ QList<AudioPortInfo> portInfoList;
+ if (doc.isArray() && jsonParseError.error == QJsonParseError::NoError)
+ {
+ QJsonArray array = doc.array();
+ for (int i = 0; i < array.count(); ++i)
+ {
+ QJsonObject object = array.at(i).toObject();
+ AudioPortInfo portInfo;
+ portInfo.description = object.value("description").toString();
+ portInfo.name = object.value("name").toString();
+ portInfo.priority = object.value("priority").toDouble();
+ portInfoList << portInfo;
+ }
+ }
+
+ return portInfoList;
+}
+
void sendPropertyChangedDetailSignal(AudioDeviceInterface *ptr, const QString &propertyName, QVariant value)
{
if (propertyName == QStringLiteral("active_port"))
diff --git a/plugins/audio/src/dbus/audio-device-interface.h b/plugins/audio/src/dbus/audio-device-interface.h
index 29fbe6d..8bea01a 100644
--- a/plugins/audio/src/dbus/audio-device-interface.h
+++ b/plugins/audio/src/dbus/audio-device-interface.h
@@ -26,6 +26,13 @@
#include <QtDBus/QtDBus>
#include "audio-device-interface.h"
+struct AudioPortInfo
+{
+ QString description;
+ QString name;
+ double priority;
+};
+
/*
* Proxy class for interface com.kylinsec.Kiran.SessionDaemon.Audio.Device
*/
@@ -103,6 +110,8 @@ public:
return qvariant_cast<double>(property("volume"));
}
+ QList<AudioPortInfo> getPortsInfo();
+
public Q_SLOTS: // METHODS
inline QDBusPendingReply<QString> GetPorts()
{
diff --git a/plugins/audio/src/plugin/input-page.cpp b/plugins/audio/src/plugin/input-page.cpp
index 8b0ecaa..11275ec 100644
--- a/plugins/audio/src/plugin/input-page.cpp
+++ b/plugins/audio/src/plugin/input-page.cpp
@@ -198,48 +198,28 @@ void InputPage::initInputDevice()
void InputPage::initActivedPort()
{
- QDBusPendingReply<QString> getPorts = m_defaultSource->GetPorts();
- KLOG_DEBUG() << "getPorts:" << getPorts;
- //解析默认source的端口信息
- QJsonParseError jsonParseError;
- QJsonDocument doc = QJsonDocument::fromJson(getPorts.value().toUtf8(), &jsonParseError);
- if (!doc.isNull() && jsonParseError.error == QJsonParseError::NoError)
- {
- if (doc.isArray() && jsonParseError.error == QJsonParseError::NoError)
- {
- QJsonArray array = doc.array();
- for (int i = 0; i < array.count(); ++i)
- {
- KLOG_DEBUG() << "array.at(i)" << array.at(i);
- QJsonObject object = array.at(i).toObject();
- QString description = object.value("description").toString();
- QString name = object.value("name").toString();
- double priority = object.value("priority").toDouble();
- KLOG_DEBUG() << "description" << description;
- KLOG_DEBUG() << "name" << name;
- KLOG_DEBUG() << "priority" << priority;
-
- ui->inputDevices->insertItem(i, description);
- ui->inputDevices->setItemData(i, name, Qt::UserRole); //激活端口所需信息
- //获取已激活的端口在comobox中的index
- if (m_defaultSource->active_port() == name)
- {
- m_defaultDeviceIndex = i;
- KLOG_DEBUG() << "m_defaultDeviceIndex" << m_defaultDeviceIndex;
- }
- }
- }
- //默认选中已激活的端口
- m_isValidPort = true;
- ui->inputDevices->setCurrentIndex(m_defaultDeviceIndex);
- ui->inputDevices->setEnabled(true);
- ui->volumeSetting->setEnabled(true);
- }
- else
+ QList<AudioPortInfo> portsInfo = m_defaultSource->getPortsInfo();
+
+ if(portsInfo.isEmpty())
{
KLOG_DEBUG() << "ports is null";
disableSettings();
+ return;
}
+
+ Q_FOREACH (auto portInfo, portsInfo)
+ {
+ if(m_defaultSource->active_port() == portInfo.name)
+ {
+ ui->inputDevices->addItem(portInfo.description,portInfo.name);
+ break;
+ }
+ }
+
+ //默认选中已激活的端口
+ m_isValidPort = true;
+ ui->inputDevices->setEnabled(true);
+ ui->volumeSetting->setEnabled(true);
}
void InputPage::initInputSettins()
@@ -304,13 +284,16 @@ void InputPage::disableSettings()
void InputPage::handleActivePortChanged(const QString &value)
{
KLOG_DEBUG() << "handleActivePortChanged :" << value;
- for (int i = 0; i < ui->inputDevices->count(); ++i)
+
+ QList<AudioPortInfo> portsInfo = m_defaultSource->getPortsInfo();
+
+ Q_FOREACH (auto portInfo, portsInfo)
{
- QString name = ui->inputDevices->itemData(i, Qt::UserRole).toString();
- if (name == value)
+ if(m_defaultSource->active_port() == portInfo.name)
{
- ui->inputDevices->setCurrentIndex(i);
- KLOG_DEBUG() << "handleActivePortChanged setCurrentIndex " << i;
+ ui->inputDevices->clear();
+ ui->inputDevices->addItem(portInfo.description,portInfo.name);
+ break;
}
}
}
diff --git a/plugins/audio/src/plugin/input-page.h b/plugins/audio/src/plugin/input-page.h
index 3b57daf..e9f6909 100644
--- a/plugins/audio/src/plugin/input-page.h
+++ b/plugins/audio/src/plugin/input-page.h
@@ -91,7 +91,6 @@ private:
AudioDeviceInterface *m_activedSource;
QMap<int, AudioDeviceInterface *> m_inputDevicesMap;
int m_defaultSourceIndex;
- int m_defaultDeviceIndex;
bool m_isValidPort = false;
QAudioInput *m_audioInput = nullptr;
diff --git a/plugins/audio/src/plugin/output-page.cpp b/plugins/audio/src/plugin/output-page.cpp
index 420cf98..1242b8a 100644
--- a/plugins/audio/src/plugin/output-page.cpp
+++ b/plugins/audio/src/plugin/output-page.cpp
@@ -93,47 +93,25 @@ void OutputPage::initOutputDevice()
void OutputPage::initActivedPort()
{
- QDBusPendingReply<QString> getPorts = m_defaultSink->GetPorts();
- KLOG_DEBUG() << "getPorts:" << getPorts;
-
- //解析默认sink的端口信息
- QJsonParseError jsonParseError;
- QJsonDocument doc = QJsonDocument::fromJson(getPorts.value().toUtf8(), &jsonParseError);
- if (!doc.isNull() && jsonParseError.error == QJsonParseError::NoError)
- {
- if (doc.isArray() && jsonParseError.error == QJsonParseError::NoError)
- {
- QJsonArray array = doc.array();
- for (int i = 0; i < array.count(); ++i)
- {
- KLOG_DEBUG() << "array.at(i)" << array.at(i);
- QJsonObject object = array.at(i).toObject();
- QString description = object.value("description").toString();
- QString name = object.value("name").toString();
- double priority = object.value("priority").toDouble();
- KLOG_DEBUG() << "description" << description;
- KLOG_DEBUG() << "name" << name;
- KLOG_DEBUG() << "priority" << priority;
- ui->outputDevices->insertItem(i, description);
- ui->outputDevices->setItemData(i, name, Qt::UserRole); //激活端口所需信息
-
- //获取已激活的端口在comobox中的index
- if (m_defaultSink->active_port() == name)
- {
- m_defaultDeviceIndex = i;
- }
- }
- }
- //默认选中已激活的端口
- ui->outputDevices->setCurrentIndex(m_defaultDeviceIndex);
- initOutputSettins();
- }
- else
+ QList<AudioPortInfo> portsInfo = m_defaultSink->getPortsInfo();
+ if(portsInfo.isEmpty())
{
//无激活端口则禁用音量设置和平衡
KLOG_DEBUG() << "default sink ports is null";
disableSettings();
+ return;
}
+
+ Q_FOREACH (auto portInfo, portsInfo)
+ {
+ if(m_defaultSink->active_port() == portInfo.name)
+ {
+ ui->outputDevices->addItem(portInfo.description,portInfo.name);
+ break;
+ }
+ }
+
+ initOutputSettins();
}
void OutputPage::initOutputSettins()
@@ -202,13 +180,15 @@ void OutputPage::initConnect()
void OutputPage::handleActivePortChanged(const QString &value)
{
KLOG_DEBUG() << "handleActivePortChanged :" << value;
- for (int i = 0; i < ui->outputDevices->count(); ++i)
+ QList<AudioPortInfo> portsInfo = m_defaultSink->getPortsInfo();
+
+ Q_FOREACH (auto portInfo, portsInfo)
{
- QString name = ui->outputDevices->itemData(i, Qt::UserRole).toString();
- if (name == value)
+ if(m_defaultSink->active_port() == portInfo.name)
{
- ui->outputDevices->setCurrentIndex(i);
- KLOG_DEBUG() << "handleActivePortChanged setCurrentIndex " << i;
+ ui->outputDevices->clear();
+ ui->outputDevices->addItem(portInfo.description,portInfo.name);
+ break;
}
}
}
diff --git a/plugins/audio/src/plugin/output-page.h b/plugins/audio/src/plugin/output-page.h
index abaf9a1..dea45e7 100644
--- a/plugins/audio/src/plugin/output-page.h
+++ b/plugins/audio/src/plugin/output-page.h
@@ -61,7 +61,6 @@ private:
AudioInterface *m_audioInterface;
QMap<int, AudioDeviceInterface *> m_outputDevicesMap;
AudioDeviceInterface *m_defaultSink;
- int m_defaultDeviceIndex;
QDBusServiceWatcher *m_dbusServiceWatcher;
};
--
2.33.0

View File

@ -0,0 +1,30 @@
From 24d7fe811440d3ab46a03db079136309f60519a8 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Mon, 8 Jan 2024 15:06:03 +0800
Subject: [PATCH 09/17] fix(translations): Fix translation errors in battery
settings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复电池设置中错误的翻译
---
translations/kiran-control-panel.zh_CN.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/translations/kiran-control-panel.zh_CN.ts b/translations/kiran-control-panel.zh_CN.ts
index 6fb278f..970c5a0 100644
--- a/translations/kiran-control-panel.zh_CN.ts
+++ b/translations/kiran-control-panel.zh_CN.ts
@@ -533,7 +533,7 @@
<message>
<location filename="../plugins/power/pages/battery-settings-page.ui" line="182"/>
<source>Reduce screen brightness when no power</source>
- <translation>低点亮时减少亮度</translation>
+ <translation>低电量时减少亮度</translation>
</message>
<message>
<location filename="../plugins/power/pages/battery-settings-page.ui" line="212"/>
--
2.33.0

View File

@ -0,0 +1,47 @@
From 2b6125c1a32d3de702a60a10e2baceee481f28c0 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Tue, 9 Jan 2024 16:59:21 +0800
Subject: [PATCH 10/17] fix(account): Fix the issue of setting default
selection sidebar errors
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复设置默认选择侧边栏错误的问题
Closes #24761
---
plugins/account/account-widget.cpp | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/plugins/account/account-widget.cpp b/plugins/account/account-widget.cpp
index 957b154..59b6cad 100644
--- a/plugins/account/account-widget.cpp
+++ b/plugins/account/account-widget.cpp
@@ -106,17 +106,15 @@ void AccountWidget::appendUser(const QString &userPath)
void AccountWidget::setDefaultSelectedUser()
{
- if (m_tabList->count() <= 1)
+ auto items = m_tabList->findItems(AccountsGlobalInfo::instance()->getCurrentUser(), Qt::MatchCaseSensitive);
+ if (items.size() >= 1)
{
- m_tabList->setCurrentRow(0);
- return;
+ auto userItem = items.at(0);
+ m_tabList->setCurrentRow(m_tabList->row(userItem));
}
-
- auto items = m_tabList->findItems(AccountsGlobalInfo::instance()->getCurrentUser(), Qt::MatchCaseSensitive);
- if (items.size() > 0)
+ else
{
- auto item = items.at(0);
- m_tabList->setCurrentRow(m_tabList->row(item));
+ m_tabList->setCurrentRow(0);
}
}
--
2.33.0

View File

@ -1,332 +0,0 @@
From 7c62cbc143a47fa47b432b5f8a57a5dda0d536eb Mon Sep 17 00:00:00 2001
From: niko_yhc <yinhongchang@kylinsec.com.cn>
Date: Tue, 12 Sep 2023 16:04:09 +0800
Subject: [PATCH] fix(kiran-control-panel):fits the Qt5.9.7 interface
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 适配Qt5.9.7接口,修复编译报错
Closes:#15019
---
lib/common-widgets/kiran-tips/kiran-tips.cpp | 4 +++
.../src/pages/face/face-page.cpp | 1 -
.../src/pages/finger/finger-page.cpp | 11 ++++----
.../src/pages/iris/iris-page.cpp | 1 -
.../src/pages/prefs/prefs-page.cpp | 16 ++++++------
.../src/pages/ukey/ukey-page.cpp | 1 -
.../src/widgets/general-bio-page.cpp | 8 ++++++
.../network/src/tray/wired-tray-widget.cpp | 10 ++++----
.../network/src/tray/wireless-tray-widget.cpp | 14 +++++------
plugins/power/src/upower-interface.cpp | 4 +++
.../hardware-information.cpp | 6 ++---
.../change-host-name-widget.cpp | 5 ----
.../system-information/system-information.cpp | 2 +-
src/main.cpp | 25 +++++++++++++++++++
14 files changed, 70 insertions(+), 38 deletions(-)
diff --git a/lib/common-widgets/kiran-tips/kiran-tips.cpp b/lib/common-widgets/kiran-tips/kiran-tips.cpp
index 7a8dcab..34f0fa2 100644
--- a/lib/common-widgets/kiran-tips/kiran-tips.cpp
+++ b/lib/common-widgets/kiran-tips/kiran-tips.cpp
@@ -279,7 +279,11 @@ QSize KiranTips::getRightSize() const
QFontMetrics fontMetrics(font);
QMargins layoutContentMargins = this->layout()->contentsMargins();
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
ui->label->setFixedWidth(fontMetrics.horizontalAdvance(ui->label->text()) + 10);
+#else
+ ui->label->setFixedWidth(fontMetrics.width(ui->label->text()) + 10);
+#endif
ui->label->setFixedHeight(fontMetrics.height());
QSize size;
diff --git a/plugins/authentication/src/pages/face/face-page.cpp b/plugins/authentication/src/pages/face/face-page.cpp
index 5e0a0db..4412631 100644
--- a/plugins/authentication/src/pages/face/face-page.cpp
+++ b/plugins/authentication/src/pages/face/face-page.cpp
@@ -23,7 +23,6 @@
#include <QBoxLayout>
#include <QLabel>
#include <QPushButton>
-#include <QRandomGenerator>
#include <QSpacerItem>
#include <QStackedWidget>
diff --git a/plugins/authentication/src/pages/finger/finger-page.cpp b/plugins/authentication/src/pages/finger/finger-page.cpp
index 86513a6..069ab94 100644
--- a/plugins/authentication/src/pages/finger/finger-page.cpp
+++ b/plugins/authentication/src/pages/finger/finger-page.cpp
@@ -29,7 +29,6 @@
#include <QComboBox>
#include <QLabel>
#include <QPushButton>
-#include <QRandomGenerator>
#include <QStackedWidget>
#include <QUuid>
@@ -43,11 +42,11 @@ enum FingerPageIndexEnum
};
const std::list<std::tuple<uint, QString>> FingerProgressRangePixmapList = {
- {0, ":/kcp-authentication/images/finger-0.svg"},
- {25, ":/kcp-authentication/images/finger-25.svg"},
- {50, ":/kcp-authentication/images/finger-50.svg"},
- {75, ":/kcp-authentication/images/finger-75.svg"},
- {100, ":/kcp-authentication/images/finger-100.svg"}};
+ std::make_tuple(0, ":/kcp-authentication/images/finger-0.svg"),
+ std::make_tuple(25, ":/kcp-authentication/images/finger-25.svg"),
+ std::make_tuple(50, ":/kcp-authentication/images/finger-50.svg"),
+ std::make_tuple(75, ":/kcp-authentication/images/finger-75.svg"),
+ std::make_tuple(100, ":/kcp-authentication/images/finger-100.svg")};
FingerPage::FingerPage(KiranAuthDBusProxy* proxy, FingerAuthType type, QWidget* parent)
: QWidget(parent),
diff --git a/plugins/authentication/src/pages/iris/iris-page.cpp b/plugins/authentication/src/pages/iris/iris-page.cpp
index 714c9c0..cacc801 100644
--- a/plugins/authentication/src/pages/iris/iris-page.cpp
+++ b/plugins/authentication/src/pages/iris/iris-page.cpp
@@ -23,7 +23,6 @@
#include <QBoxLayout>
#include <QLabel>
#include <QPushButton>
-#include <QRandomGenerator>
#include <QSpacerItem>
#include <QStackedWidget>
diff --git a/plugins/authentication/src/pages/prefs/prefs-page.cpp b/plugins/authentication/src/pages/prefs/prefs-page.cpp
index 8bad280..a50cc15 100644
--- a/plugins/authentication/src/pages/prefs/prefs-page.cpp
+++ b/plugins/authentication/src/pages/prefs/prefs-page.cpp
@@ -71,11 +71,11 @@ QWidget* PrefsPage::initAuthTypePage()
authTypeLayout->addStretch();
std::list<std::tuple<KADAuthType, QString>> authTypes = {
- {KAD_AUTH_TYPE_FINGERPRINT, tr("fingerprint")},
- {KAD_AUTH_TYPE_FINGERVEIN, tr("fingervein")},
- {KAD_AUTH_TYPE_UKEY, tr("ukey")},
- {KAD_AUTH_TYPE_IRIS, tr("iris")},
- {KAD_AUTH_TYPE_FACE, tr("face")}};
+ std::make_tuple(KAD_AUTH_TYPE_FINGERPRINT, tr("fingerprint")),
+ std::make_tuple(KAD_AUTH_TYPE_FINGERVEIN, tr("fingervein")),
+ std::make_tuple(KAD_AUTH_TYPE_UKEY, tr("ukey")),
+ std::make_tuple(KAD_AUTH_TYPE_IRIS, tr("iris")),
+ std::make_tuple(KAD_AUTH_TYPE_FACE, tr("face"))};
// fill auth types
for (auto iter : authTypes)
@@ -134,9 +134,9 @@ QWidget* PrefsPage::initAuthApplicationPage()
authAppLayout->addLayout(buttonLayout);
std::list<std::tuple<KADAuthApplication, QString>> authTypes = {
- {KAD_AUTH_APPLICATION_LOGIN, tr("login")},
- {KAD_AUTH_APPLICATION_UNLOCK, tr("unlock")},
- {KAD_AUTH_APPLICATION_EMPOWERMENT, tr("empowerment")}};
+ std::make_tuple(KAD_AUTH_APPLICATION_LOGIN, tr("login")),
+ std::make_tuple(KAD_AUTH_APPLICATION_UNLOCK, tr("unlock")),
+ std::make_tuple(KAD_AUTH_APPLICATION_EMPOWERMENT, tr("empowerment"))};
// fill auth applications
for (auto iter : authTypes)
diff --git a/plugins/authentication/src/pages/ukey/ukey-page.cpp b/plugins/authentication/src/pages/ukey/ukey-page.cpp
index 38051ca..bdf4033 100644
--- a/plugins/authentication/src/pages/ukey/ukey-page.cpp
+++ b/plugins/authentication/src/pages/ukey/ukey-page.cpp
@@ -27,7 +27,6 @@
#include <QJsonValue>
#include <QLabel>
#include <QPushButton>
-#include <QRandomGenerator>
#include <QSpacerItem>
UKeyPage::UKeyPage(KiranAuthDBusProxy* proxy, QWidget* parent)
diff --git a/plugins/authentication/src/widgets/general-bio-page.cpp b/plugins/authentication/src/widgets/general-bio-page.cpp
index 36d0ef9..1047c3e 100644
--- a/plugins/authentication/src/widgets/general-bio-page.cpp
+++ b/plugins/authentication/src/widgets/general-bio-page.cpp
@@ -12,7 +12,10 @@
#include <QComboBox>
#include <QLabel>
#include <QPushButton>
+#include <QTime>
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
#include <QRandomGenerator>
+#endif
#define MAX_FEATURE_NUMBER 1000
@@ -45,7 +48,12 @@ QString GeneralBioPage::autoGenerateFeatureName()
for (int i = 0; i <= 10; ++i)
{
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
auto featureNumber = QRandomGenerator::global()->bounded(1, MAX_FEATURE_NUMBER);
+#else
+ qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
+ auto featureNumber = qrand() % MAX_FEATURE_NUMBER + 1;
+#endif
auto temp = QString("%1 %2").arg(m_featureNamePrefix).arg(featureNumber);
if (!m_featureNameSet.contains(temp))
diff --git a/plugins/network/src/tray/wired-tray-widget.cpp b/plugins/network/src/tray/wired-tray-widget.cpp
index 02fac75..67b2224 100644
--- a/plugins/network/src/tray/wired-tray-widget.cpp
+++ b/plugins/network/src/tray/wired-tray-widget.cpp
@@ -59,11 +59,11 @@ void WiredTrayWidget::initUI()
void WiredTrayWidget::initConnection()
{
- connect(m_connectionList, &TrayConnectionList::connectionUpdated, this, &WiredTrayWidget::handleConnectionUpdated, Qt::UniqueConnection);
- connect(m_connectionList, &TrayConnectionList::activateSelectedConnection, this, &WiredTrayWidget::handleActivateSelectedConnection, Qt::UniqueConnection);
- connect(m_connectionList, &TrayConnectionList::disconnect, this, &WiredTrayWidget::handleDisconnect, Qt::UniqueConnection);
- connect(m_connectionList, &TrayConnectionList::cancelConnection, this, &WiredTrayWidget::handleCancelConnection, Qt::UniqueConnection);
- connect(m_connectionList, &TrayConnectionList::sizeChanged, this, &WiredTrayWidget::sizeChanged, Qt::UniqueConnection);
+ connect(m_connectionList.data(), &TrayConnectionList::connectionUpdated, this, &WiredTrayWidget::handleConnectionUpdated, Qt::UniqueConnection);
+ connect(m_connectionList.data(), &TrayConnectionList::activateSelectedConnection, this, &WiredTrayWidget::handleActivateSelectedConnection, Qt::UniqueConnection);
+ connect(m_connectionList.data(), &TrayConnectionList::disconnect, this, &WiredTrayWidget::handleDisconnect, Qt::UniqueConnection);
+ connect(m_connectionList.data(), &TrayConnectionList::cancelConnection, this, &WiredTrayWidget::handleCancelConnection, Qt::UniqueConnection);
+ connect(m_connectionList.data(), &TrayConnectionList::sizeChanged, this, &WiredTrayWidget::sizeChanged, Qt::UniqueConnection);
connect(m_wiredDevice.data(), &WiredDevice::carrierChanged, this, &WiredTrayWidget::handleCarrierChanged, Qt::UniqueConnection);
connect(m_wiredDevice.data(), &Device::stateChanged, this, &WiredTrayWidget::handleStateChanged, Qt::UniqueConnection);
diff --git a/plugins/network/src/tray/wireless-tray-widget.cpp b/plugins/network/src/tray/wireless-tray-widget.cpp
index 2054d99..7680376 100644
--- a/plugins/network/src/tray/wireless-tray-widget.cpp
+++ b/plugins/network/src/tray/wireless-tray-widget.cpp
@@ -55,19 +55,19 @@ void WirelessTrayWidget::initUI()
void WirelessTrayWidget::initConnection()
{
- connect(m_connectionList, &TrayConnectionList::activateSelectedWirelessNetwork, this, &WirelessTrayWidget::handleActivateSelectedWirelessNetwork);
- connect(m_connectionList, &TrayConnectionList::disconnect, this, &WirelessTrayWidget::handleDisconnect);
- connect(m_connectionList, &TrayConnectionList::cancelConnection, this, &WirelessTrayWidget::handleCancelConnection);
- connect(m_connectionList, &TrayConnectionList::ignoreConnection, this, &WirelessTrayWidget::handleIgnoreConnection);
+ connect(m_connectionList.data(), &TrayConnectionList::activateSelectedWirelessNetwork, this, &WirelessTrayWidget::handleActivateSelectedWirelessNetwork);
+ connect(m_connectionList.data(), &TrayConnectionList::disconnect, this, &WirelessTrayWidget::handleDisconnect);
+ connect(m_connectionList.data(), &TrayConnectionList::cancelConnection, this, &WirelessTrayWidget::handleCancelConnection);
+ connect(m_connectionList.data(), &TrayConnectionList::ignoreConnection, this, &WirelessTrayWidget::handleIgnoreConnection);
connect(m_wirelessDevice.data(), &WirelessDevice::networkDisappeared, this, &WirelessTrayWidget::handleNetworkDisappeared);
connect(m_wirelessDevice.data(), &WirelessDevice::networkAppeared, this, &WirelessTrayWidget::handleNetworkAppeared);
- connect(m_connectionList, &TrayConnectionList::sendPasswordToWirelessSetting, this, &WirelessTrayWidget::setSecurityPskAndActivateWirelessConnection);
- connect(m_connectionList, &TrayConnectionList::sendSsidToWireless, this, &WirelessTrayWidget::handleActivateHiddenNetwork);
+ connect(m_connectionList.data(), &TrayConnectionList::sendPasswordToWirelessSetting, this, &WirelessTrayWidget::setSecurityPskAndActivateWirelessConnection);
+ connect(m_connectionList.data(), &TrayConnectionList::sendSsidToWireless, this, &WirelessTrayWidget::handleActivateHiddenNetwork);
connect(m_devicePtr.data(), &Device::stateChanged, this, &WirelessTrayWidget::handleDeviceStateChanged, Qt::UniqueConnection);
- connect(m_connectionList, &TrayConnectionList::sizeChanged, this, &WirelessTrayWidget::sizeChanged);
+ connect(m_connectionList.data(), &TrayConnectionList::sizeChanged, this, &WirelessTrayWidget::sizeChanged);
connect(SignalForward::instance(), &SignalForward::wirelessConnectionAdded, this, &WirelessTrayWidget::handleNotifierConnectionAdded);
connect(SignalForward::instance(), &SignalForward::connectionRemoved, this, &WirelessTrayWidget::handleNotifierConnectionRemoved);
diff --git a/plugins/power/src/upower-interface.cpp b/plugins/power/src/upower-interface.cpp
index f929fbd..aa7960b 100644
--- a/plugins/power/src/upower-interface.cpp
+++ b/plugins/power/src/upower-interface.cpp
@@ -32,7 +32,11 @@ bool UPowerInterface::haveBattery()
}
#endif
+#if UP_CHECK_VERSION(0, 99, 8)
auto devices = up_client_get_devices2(upClient);
+#else
+ auto devices = up_client_get_devices(upClient);
+#endif
void *device = nullptr;
UpDeviceKind kind;
for (int i = 0; i < devices->len; i++)
diff --git a/plugins/system/src/pages/hardware-information/hardware-information.cpp b/plugins/system/src/pages/hardware-information/hardware-information.cpp
index 9e4ae2e..5232390 100644
--- a/plugins/system/src/pages/hardware-information/hardware-information.cpp
+++ b/plugins/system/src/pages/hardware-information/hardware-information.cpp
@@ -88,9 +88,9 @@ void HardwareInformation::initUI(void)
ui->label_CPU_info->setToolTip(cpu);
QList<std::tuple<QStringList, QGridLayout *> > hardwareMap = {
- {disks, ui->gridLayout_hard_disk},
- {graphics, ui->gridLayout_graphics_card},
- {eths, ui->gridLayout_network_card}};
+ std::make_tuple(disks, ui->gridLayout_hard_disk),
+ std::make_tuple(graphics, ui->gridLayout_graphics_card),
+ std::make_tuple(eths, ui->gridLayout_network_card)};
for (auto hardwareInitTuple : hardwareMap)
{
QStringList infos = std::get<0>(hardwareInitTuple);
diff --git a/plugins/system/src/pages/system-information/change-host-name-widget.cpp b/plugins/system/src/pages/system-information/change-host-name-widget.cpp
index c8ea9f6..7cad825 100644
--- a/plugins/system/src/pages/system-information/change-host-name-widget.cpp
+++ b/plugins/system/src/pages/system-information/change-host-name-widget.cpp
@@ -61,11 +61,6 @@ void ChangeHostNameWidget::initUI()
setIcon(QIcon(":/images/kylin-about.png"));
ui->btn_save->setEnabled(false);
-
- auto screen = QApplication::screenAt(QCursor::pos());
- auto screenGeometry = screen->geometry();
- this->move(screenGeometry.x() + (screenGeometry.width() - this->width()) / 2,
- screenGeometry.y() + (screenGeometry.height() - this->height()) / 2);
}
void ChangeHostNameWidget::setNewHostName()
diff --git a/plugins/system/src/pages/system-information/system-information.cpp b/plugins/system/src/pages/system-information/system-information.cpp
index c249b69..9866d01 100644
--- a/plugins/system/src/pages/system-information/system-information.cpp
+++ b/plugins/system/src/pages/system-information/system-information.cpp
@@ -268,7 +268,7 @@ void SystemInformation::handleChangeHostName()
{
if (hostNameWidget == nullptr)
{
- hostNameWidget = new ChangeHostNameWidget;
+ hostNameWidget = new ChangeHostNameWidget(this);
}
hostNameWidget->setAttribute(Qt::WA_QuitOnClose, false);
hostNameWidget->installEventFilter(this);
diff --git a/src/main.cpp b/src/main.cpp
index 2e75c10..2ff2737 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -123,6 +123,27 @@ void dumpPluginManagerInfo()
#endif
}
+#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
+static QScreen *screenAt(const QPoint &point)
+{
+ QVarLengthArray<const QScreen *, 8> visitedScreens;
+ for (const QScreen *screen : QGuiApplication::screens()) {
+ if (visitedScreens.contains(screen))
+ continue;
+
+ // The virtual siblings include the screen itself, so iterate directly
+ for (QScreen *sibling : screen->virtualSiblings()) {
+ if (sibling->geometry().contains(point))
+ return sibling;
+
+ visitedScreens.append(sibling);
+ }
+ }
+
+ return nullptr;
+}
+#endif
+
int main(int argc, char *argv[])
{
KiranSingleApplication app(argc,
@@ -165,7 +186,11 @@ int main(int argc, char *argv[])
PanelWindow w;
w.jump(defaultCategory,defaultSubItem);
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
auto screen = QApplication::screenAt(QCursor::pos());
+#else
+ auto screen = screenAt(QCursor::pos());
+#endif
QRect screenGeometry = screen->geometry();
w.resize(1031, 742);
w.move(screenGeometry.x() + (screenGeometry.width() - w.width()) / 2,
--
2.27.0

View File

@ -0,0 +1,56 @@
From 783eee898cda93ed345a91000834b972c971c327 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Tue, 9 Jan 2024 20:05:45 +0800
Subject: [PATCH 11/17] fix(build): delete useless methods
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 删除无用的方法
---
plugins/appearance/utils/exclusion-group.cpp | 13 -------------
plugins/appearance/utils/exclusion-group.h | 4 ----
2 files changed, 17 deletions(-)
diff --git a/plugins/appearance/utils/exclusion-group.cpp b/plugins/appearance/utils/exclusion-group.cpp
index 12fb734..8db48ca 100644
--- a/plugins/appearance/utils/exclusion-group.cpp
+++ b/plugins/appearance/utils/exclusion-group.cpp
@@ -125,19 +125,6 @@ void ExclusionGroup::removeExclusionItem(ExclusionWidget* widget)
m_exclusionItems.remove(widget);
}
-template <class T,typename = std::enable_if<std::is_base_of<ExclusionWidget, T>::value>>
-QList<T*> ExclusionGroup::getExclusionItems()
-{
- QList<T*> list;
-
- for( auto item : m_exclusionItems)
- {
- list << qobject_cast<T>(item);
- }
-
- return list;
-}
-
void ExclusionGroup::onItemSelectedChanged(bool selected)
{
auto item = qobject_cast<ExclusionWidget*>(sender());
diff --git a/plugins/appearance/utils/exclusion-group.h b/plugins/appearance/utils/exclusion-group.h
index 4ca9bd0..7d66a1f 100644
--- a/plugins/appearance/utils/exclusion-group.h
+++ b/plugins/appearance/utils/exclusion-group.h
@@ -65,10 +65,6 @@ public:
void addExclusionItem(ExclusionWidget* widget);
void removeExclusionItem(ExclusionWidget* widget);
-
- template <class T,typename = std::enable_if<std::is_base_of<ExclusionWidget, T>::value>>
- QList<T*> getExclusionItems();
-
signals:
void currentItemChanged();
--
2.33.0

View File

@ -1,214 +0,0 @@
From 5160a4eab524c2208ef3f4743331a762f7f50ca7 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Fri, 15 Sep 2023 11:18:58 +0800
Subject: [PATCH] fix(tray icon): Fixed an issue where the tray icon was not
displayed due to late registration of DBus tray service
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复了由于DBus托盘服务注册晚导致托盘图标不显示的问题
Closes #14006,#11856
---
plugins/audio/src/system-tray/main.cpp | 63 ++++++++----------------
plugins/network/src/tray/main.cpp | 67 ++++++++++----------------
2 files changed, 47 insertions(+), 83 deletions(-)
diff --git a/plugins/audio/src/system-tray/main.cpp b/plugins/audio/src/system-tray/main.cpp
index 169eb4d..431e6c9 100644
--- a/plugins/audio/src/system-tray/main.cpp
+++ b/plugins/audio/src/system-tray/main.cpp
@@ -20,13 +20,13 @@
#include <QApplication>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
+#include <QDBusServiceWatcher>
#include <QDBusReply>
#include <QDateTime>
#include <QFile>
-#include <QTimer>
#include <QTranslator>
-#define MAX_WAIT_COUNTS 10
+#define DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER "org.kde.StatusNotifierWatcher"
int main(int argc, char *argv[])
{
@@ -39,56 +39,35 @@ int main(int argc, char *argv[])
if (translator.load(QLocale(), "kiran-cpanel-audio", ".", TRANSLATE_PREFIX, ".qm"))
{
a.installTranslator(&translator);
- KLOG_INFO() << "installTranslator load:" << a.installTranslator(&translator);
+ KLOG_DEBUG() << "installTranslator load:" << a.installTranslator(&translator);
}
else
- KLOG_INFO() << "installTranslator failed";
+ {
+ KLOG_WARNING() << "installTranslator failed";
+ }
AudioSystemTray *audioSystemTray = nullptr;
- QTimer timer;
- timer.setInterval(1000);
- int waitCounts = 0;
- QObject::connect(&timer, &QTimer::timeout, [&]()
- {
- if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.StatusNotifierWatcher"))
- {
- KLOG_INFO() << "org.kde.StatusNotifierWatcher isServiceRegistered" << QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.StatusNotifierWatcher");
- KLOG_INFO() << "SessionDaemon.Audio isServiceRegistered " << QDBusConnection::sessionBus().interface()->isServiceRegistered("com.kylinsec.Kiran.SessionDaemon.Audio");
- KLOG_INFO() << "QSystemTrayIcon::isSystemTrayAvailable():" << QSystemTrayIcon::isSystemTrayAvailable();
-
- KLOG_INFO() << "init AudioSystemTray";
- audioSystemTray = new AudioSystemTray;
- KLOG_INFO() << "wait loop : new AudioSystemTray sucess ";
- KLOG_INFO() << "currentDateTime:"<<QDateTime::currentDateTime();
- timer.stop();
- }
- else
- {
- waitCounts++;
- KLOG_INFO() << "waitCounts:" << waitCounts;
- if (waitCounts > MAX_WAIT_COUNTS)
- {
- KLOG_INFO() << "超过等待次数,程序退出";
- return QApplication::quit();
- }
- } });
-
- if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.StatusNotifierWatcher"))
+ if (QDBusConnection::sessionBus().interface()->isServiceRegistered(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER))
{
- KLOG_INFO() << "org.kde.StatusNotifierWatcher isServiceRegistered" << QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.StatusNotifierWatcher");
- KLOG_INFO() << "SessionDaemon.Audio isServiceRegistered " << QDBusConnection::sessionBus().interface()->isServiceRegistered("com.kylinsec.Kiran.SessionDaemon.Audio");
- KLOG_INFO() << "QSystemTrayIcon::isSystemTrayAvailable():" << QSystemTrayIcon::isSystemTrayAvailable();
-
- KLOG_INFO() << "init AudioSystemTray";
+ KLOG_DEBUG() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is registered,create audio tray icon";
audioSystemTray = new AudioSystemTray;
- KLOG_INFO() << "new AudioSystemTray sucess ";
}
else
{
- timer.start();
- KLOG_INFO() << "start wait loop";
- KLOG_INFO() << "currentDateTime:" << QDateTime::currentDateTime();
+ KLOG_WARNING() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is not registered,wait";
+ QDBusServiceWatcher* dbusServiceWatcher = new QDBusServiceWatcher;
+ dbusServiceWatcher->setConnection(QDBusConnection::sessionBus());
+ dbusServiceWatcher->addWatchedService(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER);
+ QObject::connect(dbusServiceWatcher, &QDBusServiceWatcher::serviceRegistered,
+ [&dbusServiceWatcher, &audioSystemTray](const QString& service)
+ {
+ if (service != DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER)
+ return;
+ KLOG_INFO() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is registered,create audio tray icon";
+ audioSystemTray = new AudioSystemTray;
+ dbusServiceWatcher->removeWatchedService(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER);
+ });
}
return QApplication::exec();
}
diff --git a/plugins/network/src/tray/main.cpp b/plugins/network/src/tray/main.cpp
index 26b04c7..2a62bf1 100644
--- a/plugins/network/src/tray/main.cpp
+++ b/plugins/network/src/tray/main.cpp
@@ -17,67 +17,52 @@
#include <QApplication>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
-#include <QTimer>
+#include <QDBusServiceWatcher>
#include <QTranslator>
#include "config.h"
#include "network-tray.h"
-#define MAX_WAIT_COUNTS 10
-int main(int argc, char *argv[]) {
+#define DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER "org.kde.StatusNotifierWatcher"
+
+int main(int argc, char* argv[])
+{
KiranApplication a(argc, argv);
klog_qt5_init("", "kylinsec-session", "kiran-cpanel-network", "kiran-cpanel-network");
KLOG_INFO() << "autostart!";
+
QTranslator translator;
if (translator.load(QLocale(), "kiran-cpanel-network", ".", TRANSLATE_PREFIX, ".qm"))
{
a.installTranslator(&translator);
- KLOG_INFO() << "installTranslator load:" << a.installTranslator(&translator);
+ KLOG_DEBUG() << "installTranslator load:" << a.installTranslator(&translator);
}
else
- KLOG_INFO() << "installTranslator failed";
-
- NetworkTray *tray = nullptr;
- QTimer timer;
- timer.setInterval(1000);
- int waitCounts = 0;
- QObject::connect(&timer, &QTimer::timeout, [&]() {
- if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.StatusNotifierWatcher"))
- {
- KLOG_INFO() << "org.kde.StatusNotifierWatcher isServiceRegistered" << QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.StatusNotifierWatcher");
- KLOG_INFO() << "QSystemTrayIcon::isSystemTrayAvailable():" << QSystemTrayIcon::isSystemTrayAvailable();
-
- KLOG_INFO() << "init NetworkTray";
- tray = new NetworkTray;
- KLOG_INFO() << "wait loop : new NetworkTray sucess ";
- KLOG_INFO() << "currentDateTime:"<<QDateTime::currentDateTime();
- timer.stop();
- }
- else
- {
- waitCounts++;
- KLOG_INFO() << "waitCounts:" << waitCounts;
- if (waitCounts > MAX_WAIT_COUNTS)
- {
- KLOG_INFO() << "超过等待次数,程序退出";
- return QApplication::quit();
- }
- }
- });
+ {
+ KLOG_WARNING() << "installTranslator failed";
+ }
- if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.StatusNotifierWatcher"))
+ NetworkTray* tray = nullptr;
+ if (QDBusConnection::sessionBus().interface()->isServiceRegistered(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER))
{
- KLOG_INFO() << "org.kde.StatusNotifierWatcher isServiceRegistered" << QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.StatusNotifierWatcher");
- KLOG_INFO() << "QSystemTrayIcon::isSystemTrayAvailable():" << QSystemTrayIcon::isSystemTrayAvailable();
- KLOG_INFO() << "init NetworkTray";
+ KLOG_DEBUG() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is registered,create network tray icon";
tray = new NetworkTray;
- KLOG_INFO() << "new NetworkTray sucess ";
}
else
{
- timer.start();
- KLOG_INFO() << "start wait loop";
- KLOG_INFO() << "currentDateTime:" << QDateTime::currentDateTime();
+ KLOG_WARNING() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is not registered,wait";
+ QDBusServiceWatcher* dbusServiceWatcher = new QDBusServiceWatcher;
+ dbusServiceWatcher->setConnection(QDBusConnection::sessionBus());
+ dbusServiceWatcher->addWatchedService(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER);
+ QObject::connect(dbusServiceWatcher, &QDBusServiceWatcher::serviceRegistered,
+ [&dbusServiceWatcher, &tray](const QString& service)
+ {
+ if (service != DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER)
+ return;
+ KLOG_INFO() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is registered,create network tray icon";
+ tray = new NetworkTray;
+ dbusServiceWatcher->removeWatchedService(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER);
+ });
}
return QApplication::exec();
--
2.33.0

View File

@ -0,0 +1,39 @@
From 4f311e12f5c61c56aece10097d106a980f633c85 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Tue, 9 Jan 2024 17:09:06 +0800
Subject: [PATCH 12/17] fix(font): Fix the issue of ineffective font changes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复字体更改后不生效的问题
Closes #25084
---
plugins/appearance/pages/font/fonts.cpp | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/plugins/appearance/pages/font/fonts.cpp b/plugins/appearance/pages/font/fonts.cpp
index e722123..c1c6875 100644
--- a/plugins/appearance/pages/font/fonts.cpp
+++ b/plugins/appearance/pages/font/fonts.cpp
@@ -113,14 +113,9 @@ void Fonts::initConnections()
connect(AppearanceGlobalInfo::instance(), &AppearanceGlobalInfo::fontChanged,
this, &Fonts::onBackendFontChanged);
- for (auto fontTypeCombos : m_fontTypeComboBoxMap.values())
+ for (auto fontTypeCombo : m_comboFontTypesMap.keys())
{
- auto fontNameComboBox = fontTypeCombos.first;
- auto fontSizeComboBox = fontTypeCombos.second;
-
- connect(fontNameComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
- this, &Fonts::onCurrentFontFamilyChanged);
- connect(fontSizeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ connect(fontTypeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &Fonts::onCurrentFontFamilyChanged);
}
--
2.33.0

View File

@ -1,48 +0,0 @@
From 5628b4b31eeb7493abe41bb9a6935955f0ca090a Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Fri, 15 Sep 2023 16:19:15 +0800
Subject: [PATCH] fix(network-tray):Improved the notification logic. "Wired
NIC: xxx is unavailable" and "Network is Unavailable" are no longer displayed
during sleep recovery.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 完善通知弹窗逻辑从休眠中恢复过程中不再提示“有线网卡xxx不可用”和“网络不可用”。
Close #15619
---
plugins/network/src/tray/network-tray.cpp | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/plugins/network/src/tray/network-tray.cpp b/plugins/network/src/tray/network-tray.cpp
index 7397e28..dd5ff12 100644
--- a/plugins/network/src/tray/network-tray.cpp
+++ b/plugins/network/src/tray/network-tray.cpp
@@ -473,9 +473,21 @@ void NetworkTray::handleDeviceStateChanged(NetworkManager::Device::State newstat
}
}
- // 设备变为不可用时,如果无线和有线均不可用则显示网络不可用的提示
- if (newstate == Device::Unavailable || newstate == Device::Unmanaged || newstate == Device::UnknownState)
+ QSet<Device::State> unavailableStates = {
+ Device::Unavailable,
+ Device::Unmanaged,
+ Device::UnknownState
+ };
+
+ // 非休眠的情况下,从可用状态到不可用状态通知
+ if (!unavailableStates.contains(oldstate)
+ &&
+ unavailableStates.contains(newstate)
+ &&
+ reason != Device::SleepingReason
+ )
{
+ // 设备变为不可用时,如果无线和有线均不可用则显示网络不可用的提示
KLOG_DEBUG() << "device is unavailable";
if ((NetworkUtils::getAvailableDeviceList(Device::Ethernet).count() == 0) &&
(NetworkUtils::getAvailableDeviceList(Device::Wifi).count() == 0))
--
2.33.0

View File

@ -1,370 +0,0 @@
From 2fcd30a538df01ae8505cf5c1baf26d18b1d2cef Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Mon, 18 Sep 2023 10:39:58 +0800
Subject: [PATCH] fix(network):Modify DNS Settings and display DNS details
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 自动获取IPDNS网络详情显示自动获取到的DNS
手动配置DNS网络详情中DNS服务器仅显示手动配置的DNS
Close #14000
---
.../connection-details-widget.cpp | 51 +++++--
.../details-page/connection-details-widget.ui | 6 +-
.../src/plugin/setting-widget/ipv4-widget.cpp | 135 +++++++++---------
.../src/plugin/setting-widget/ipv4-widget.ui | 8 +-
4 files changed, 116 insertions(+), 84 deletions(-)
diff --git a/plugins/network/src/plugin/details-page/connection-details-widget.cpp b/plugins/network/src/plugin/details-page/connection-details-widget.cpp
index d94b1bd..235c48d 100644
--- a/plugins/network/src/plugin/details-page/connection-details-widget.cpp
+++ b/plugins/network/src/plugin/details-page/connection-details-widget.cpp
@@ -67,7 +67,7 @@ void ConnectionDetailsWidget::init()
void ConnectionDetailsWidget::initUI()
{
QList<KiranFrame *> widgets = {ui->securityTypeWidget, ui->frequencyBandWidget, ui->channelWidget, ui->InterfaceWidget,
- ui->macWidget, ui->ipv4Widget, ui->gatewayWidget, ui->preferredDNSWidget, ui->subnetMaskWidget,
+ ui->macWidget, ui->ipv4Widget, ui->gatewayWidget, ui->DNSWidget, ui->subnetMaskWidget,
ui->ipv6Widget, ui->ipv6GatewayWidget, ui->prefixWidget, ui->rateWidget};
for (auto widget : widgets)
@@ -76,7 +76,7 @@ void ConnectionDetailsWidget::initUI()
}
QList<QLabel *> labels = {ui->securityType, ui->frequencyBand, ui->channel, ui->networkInterface,
- ui->mac, ui->ipv4, ui->ipv4Gateway, ui->preferredDNS, ui->subnetMask,
+ ui->mac, ui->ipv4, ui->ipv4Gateway, ui->DNS, ui->subnetMask,
ui->ipv6, ui->ipv6Gateway, ui->prefix, ui->rate};
for (auto label : labels)
@@ -151,25 +151,54 @@ void ConnectionDetailsWidget::setIpDetails()
ui->subnetMask->setText(netmask);
ui->ipv4Gateway->setText(gateway);
- QString preferredDNS = "-";
Dhcp4Config::Ptr dhcp = m_activeConnection->dhcp4Config();
auto dhcpOptions = dhcp->options();
+
+ QStringList tmpDNS;
+
+ QStringList dhcpDns;
if (!dhcpOptions.isEmpty())
{
QVariant domainNameServers = dhcpOptions.value("domain_name_servers");
- // 以空格为分隔
- QStringList dns = domainNameServers.toString().split(" ");
- preferredDNS = dns.value(0);
+ dhcpDns = domainNameServers.toString().split(" ");
}
- else
+
+ Ipv4Setting::Ptr ipv4Setting = m_connection->settings()->setting(Setting::Ipv4).dynamicCast<Ipv4Setting>();
+ QList<QHostAddress> ipv4SettingDNS = ipv4Setting->dns();
+
+ QStringList manualDNS;
+
+ for(auto &address : ipv4SettingDNS)
+ {
+ manualDNS << address.toString();
+ }
+ /**
+ * NOTE:
+ * 1、自动获取IPDNS网络详情显示自动获取到的DNS
+ * 2、手动配置DNS网络详情中DNS服务器仅显示手动配置的DNS
+ */
+
+ QString detailsDNS;
+ manualDNS.isEmpty() ? tmpDNS = dhcpDns : tmpDNS = manualDNS;
+ if(!tmpDNS.isEmpty())
{
- Ipv4Setting::Ptr ipv4Setting = m_connection->settings()->setting(Setting::Ipv4).dynamicCast<Ipv4Setting>();
- if (!ipv4Setting->dns().isEmpty())
+ // 以空格为分隔,删除最后一个;
+ for(auto &dns : tmpDNS)
{
- preferredDNS = ipv4Setting->dns().value(0).toString();
+ detailsDNS.append(dns);
+ detailsDNS.append(";");
}
+ if(detailsDNS.endsWith(";"))
+ {
+ detailsDNS.remove(detailsDNS.size() - 1,1);
+ }
+ }
+ else
+ {
+ detailsDNS = "-";
}
- ui->preferredDNS->setText(preferredDNS);
+
+ ui->DNS->setText(detailsDNS);
IpConfig ipV6Config = m_activeConnection->ipV6Config();
IpAddress ipv6Address = ipV6Config.addresses().value(0);
diff --git a/plugins/network/src/plugin/details-page/connection-details-widget.ui b/plugins/network/src/plugin/details-page/connection-details-widget.ui
index c83af72..b781390 100644
--- a/plugins/network/src/plugin/details-page/connection-details-widget.ui
+++ b/plugins/network/src/plugin/details-page/connection-details-widget.ui
@@ -518,7 +518,7 @@
</widget>
</item>
<item>
- <widget class="KiranFrame" name="preferredDNSWidget" native="true">
+ <widget class="KiranFrame" name="DNSWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -556,7 +556,7 @@
<item>
<widget class="QLabel" name="label_15">
<property name="text">
- <string>Preferred DNS</string>
+ <string>DNS</string>
</property>
</widget>
</item>
@@ -574,7 +574,7 @@
</spacer>
</item>
<item>
- <widget class="QLabel" name="preferredDNS">
+ <widget class="QLabel" name="DNS">
<property name="text">
<string>TextLabel</string>
</property>
diff --git a/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp b/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp
index 8c39794..8dc420f 100644
--- a/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp
+++ b/plugins/network/src/plugin/setting-widget/ipv4-widget.cpp
@@ -74,65 +74,68 @@ void Ipv4Widget::setErrorTips(KiranTips *errorTips)
void Ipv4Widget::saveSettings()
{
- if (m_ipv4Setting != nullptr)
+ if (m_ipv4Setting == nullptr)
{
- IpAddress ipv4Address;
- Ipv4Setting::ConfigMethod method = ui->ipv4Method->currentData().value<NetworkManager::Ipv4Setting::ConfigMethod>();
- if (method == Ipv4Setting::ConfigMethod::Automatic)
- {
- m_ipv4Setting->setMethod(method);
- ipv4Address.setIp(QHostAddress(""));
- ipv4Address.setNetmask(QHostAddress(""));
- ipv4Address.setGateway(QHostAddress(""));
- m_ipv4Setting->setAddresses(QList<NetworkManager::IpAddress>() << ipv4Address);
- }
- else if (method == Ipv4Setting::ConfigMethod::Manual)
- {
- m_ipv4Setting->setMethod(method);
+ return;
+ }
+
+ IpAddress ipv4Address;
+ Ipv4Setting::ConfigMethod method = ui->ipv4Method->currentData().value<NetworkManager::Ipv4Setting::ConfigMethod>();
+ if (method == Ipv4Setting::ConfigMethod::Automatic)
+ {
+ m_ipv4Setting->setMethod(method);
+ ipv4Address.setIp(QHostAddress(""));
+ ipv4Address.setNetmask(QHostAddress(""));
+ ipv4Address.setGateway(QHostAddress(""));
+ m_ipv4Setting->setAddresses(QList<NetworkManager::IpAddress>() << ipv4Address);
+ }
+ else if (method == Ipv4Setting::ConfigMethod::Manual)
+ {
+ m_ipv4Setting->setMethod(method);
- ipv4Address.setIp(QHostAddress(ui->ipv4Address->text()));
- QString netMask = ui->ipv4Netmask->text();
- if (!netMask.contains("."))
+ ipv4Address.setIp(QHostAddress(ui->ipv4Address->text()));
+ QString netMask = ui->ipv4Netmask->text();
+ if (!netMask.contains("."))
+ {
+ int netPrefix = netMask.toInt();
+ KLOG_DEBUG() << "netMask.toInt():" << netMask.toInt();
+ if ((netPrefix > 0) & (netPrefix < 33))
{
- int netPrefix = netMask.toInt();
- KLOG_DEBUG() << "netMask.toInt():" << netMask.toInt();
- if ((netPrefix > 0) & (netPrefix < 33))
- {
- ipv4Address.setPrefixLength(netPrefix);
- }
- else
- {
- KLOG_DEBUG() << "Net prefix length error";
- }
+ ipv4Address.setPrefixLength(netPrefix);
}
else
{
- ipv4Address.setNetmask(QHostAddress(netMask));
+ KLOG_DEBUG() << "Net prefix length error";
}
-
- ipv4Address.setGateway(QHostAddress(ui->ipv4Gateway->text()));
- KLOG_DEBUG() << "ipv4Address.ip():" << ipv4Address.ip();
- KLOG_DEBUG() << "ipv4Address.netmask():" << ipv4Address.netmask();
- KLOG_DEBUG() << "ipv4Address.prefixLength():" << ipv4Address.prefixLength();
- KLOG_DEBUG() << "ipv4Address.gateway():" << ipv4Address.gateway();
-
- QList<IpAddress> ipv4AddresseList;
- ipv4AddresseList << ipv4Address;
- m_ipv4Setting->setAddresses(ipv4AddresseList);
- }
-
- QList<QHostAddress> ipv4DNS;
- if (!ui->ipv4PreferredDNS->text().isEmpty())
- {
- ipv4DNS << QHostAddress(ui->ipv4PreferredDNS->text());
}
- if (!ui->ipv4AlternateDNS->text().isEmpty())
+ else
{
- ipv4DNS << QHostAddress(ui->ipv4AlternateDNS->text());
+ ipv4Address.setNetmask(QHostAddress(netMask));
}
- KLOG_DEBUG() << "ipv4DNS:" << ipv4DNS;
- m_ipv4Setting->setDns(ipv4DNS);
+
+ ipv4Address.setGateway(QHostAddress(ui->ipv4Gateway->text()));
+ KLOG_DEBUG() << "ipv4Address.ip():" << ipv4Address.ip();
+ KLOG_DEBUG() << "ipv4Address.netmask():" << ipv4Address.netmask();
+ KLOG_DEBUG() << "ipv4Address.prefixLength():" << ipv4Address.prefixLength();
+ KLOG_DEBUG() << "ipv4Address.gateway():" << ipv4Address.gateway();
+
+ QList<IpAddress> ipv4AddresseList;
+ ipv4AddresseList << ipv4Address;
+ m_ipv4Setting->setAddresses(ipv4AddresseList);
+ }
+
+ QList<QHostAddress> ipv4DNS;
+ if (!ui->ipv4FirstDNS->text().isEmpty())
+ {
+ ipv4DNS << QHostAddress(ui->ipv4FirstDNS->text());
+ }
+ if (!ui->ipv4SecondDNS->text().isEmpty())
+ {
+ ipv4DNS << QHostAddress(ui->ipv4SecondDNS->text());
}
+ KLOG_DEBUG() << "ipv4DNS:" << ipv4DNS;
+ m_ipv4Setting->setDns(ipv4DNS);
+
}
void Ipv4Widget::showSettings()
@@ -171,20 +174,20 @@ void Ipv4Widget::showSettings()
ui->ipv4Gateway->clear();
}
}
- QString preferredDNS = "";
- QString alternateDNS = "";
+ QString firstDNS = "";
+ QString secondDNS = "";
if (!m_ipv4Setting->dns().isEmpty())
{
- preferredDNS = m_ipv4Setting->dns().at(0).toString();
+ firstDNS = m_ipv4Setting->dns().at(0).toString();
if (m_ipv4Setting->dns().count() >= 2)
{
- alternateDNS = m_ipv4Setting->dns().at(1).toString();
+ secondDNS = m_ipv4Setting->dns().at(1).toString();
}
}
- KLOG_DEBUG() << "preferredDNS:" << preferredDNS;
- KLOG_DEBUG() << "alternateDNS:" << alternateDNS;
- ui->ipv4PreferredDNS->setText(preferredDNS);
- ui->ipv4AlternateDNS->setText(alternateDNS);
+ KLOG_DEBUG() << "firstDNS:" << firstDNS;
+ KLOG_DEBUG() << "secondDNS:" << secondDNS;
+ ui->ipv4FirstDNS->setText(firstDNS);
+ ui->ipv4SecondDNS->setText(secondDNS);
}
else
resetSettings();
@@ -197,8 +200,8 @@ void Ipv4Widget::resetSettings()
ui->ipv4Address->clear();
ui->ipv4Netmask->clear();
ui->ipv4Gateway->clear();
- ui->ipv4PreferredDNS->clear();
- ui->ipv4AlternateDNS->clear();
+ ui->ipv4FirstDNS->clear();
+ ui->ipv4SecondDNS->clear();
}
void Ipv4Widget::clearPtr()
@@ -271,27 +274,27 @@ bool Ipv4Widget::isInputValid()
}
}
- QString preferredDNS = ui->ipv4PreferredDNS->text();
- if (!preferredDNS.isEmpty())
+ QString firstDNS = ui->ipv4FirstDNS->text();
+ if (!firstDNS.isEmpty())
{
- if (!isIpv4AddressValid(preferredDNS))
+ if (!isIpv4AddressValid(firstDNS))
{
QString error = QString(tr("Ipv4 Preferred DNS invalid"));
m_errorTip->setText(error);
- m_errorTip->showTipAroundWidget(ui->ipv4PreferredDNS);
+ m_errorTip->showTipAroundWidget(ui->ipv4FirstDNS);
KLOG_DEBUG() << "Ipv4 Preferred DNS invalid";
return false;
}
}
- QString alternateDNS = ui->ipv4AlternateDNS->text();
- if (!alternateDNS.isEmpty())
+ QString secondDNS = ui->ipv4SecondDNS->text();
+ if (!secondDNS.isEmpty())
{
- if (!isIpv4AddressValid(alternateDNS))
+ if (!isIpv4AddressValid(secondDNS))
{
QString error = QString(tr("Ipv4 Alternate DNS invalid"));
m_errorTip->setText(error);
- m_errorTip->showTipAroundWidget(ui->ipv4AlternateDNS);
+ m_errorTip->showTipAroundWidget(ui->ipv4SecondDNS);
KLOG_DEBUG() << "Ipv4 Alternate DNS invalid";
return false;
}
diff --git a/plugins/network/src/plugin/setting-widget/ipv4-widget.ui b/plugins/network/src/plugin/setting-widget/ipv4-widget.ui
index 026e26d..93b2355 100644
--- a/plugins/network/src/plugin/setting-widget/ipv4-widget.ui
+++ b/plugins/network/src/plugin/setting-widget/ipv4-widget.ui
@@ -187,12 +187,12 @@
<item>
<widget class="QLabel" name="label_16">
<property name="text">
- <string>Preferred DNS</string>
+ <string>DNS 1</string>
</property>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="ipv4PreferredDNS">
+ <widget class="QLineEdit" name="ipv4FirstDNS">
<property name="minimumSize">
<size>
<width>0</width>
@@ -220,12 +220,12 @@
<item>
<widget class="QLabel" name="label_14">
<property name="text">
- <string>Alternate DNS</string>
+ <string>DNS 2</string>
</property>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="ipv4AlternateDNS">
+ <widget class="QLineEdit" name="ipv4SecondDNS">
<property name="minimumSize">
<size>
<width>0</width>
--
2.33.0

View File

@ -0,0 +1,82 @@
From 0422be13648a36784fcffc5a04ba725c7984b290 Mon Sep 17 00:00:00 2001
From: yuanxing <yuanxing@kylinsec.com.cn>
Date: Thu, 11 Jan 2024 23:23:37 +0800
Subject: [PATCH 13/17] fix(theme):change the light and dark theme name
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修改深浅色主题名为冰晶白、曜岩黑
Fixes #24747
---
plugins/appearance/pages/theme/theme-page.cpp | 2 +-
plugins/appearance/pages/theme/theme-page.ui | 9 +--------
translations/kiran-control-panel.zh_CN.ts | 4 ++--
3 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/plugins/appearance/pages/theme/theme-page.cpp b/plugins/appearance/pages/theme/theme-page.cpp
index 7c303b7..24a5c7a 100644
--- a/plugins/appearance/pages/theme/theme-page.cpp
+++ b/plugins/appearance/pages/theme/theme-page.cpp
@@ -27,7 +27,7 @@
#include <QPushButton>
#define DARK_THEME "Kiran-dark"
-#define LIGHT_THEME "Kiran"
+#define LIGHT_THEME "Kiran-white"
#define THEME_AUTO_NAME "Kiran-auto"
#define SETTING_THEME_NUM 2
diff --git a/plugins/appearance/pages/theme/theme-page.ui b/plugins/appearance/pages/theme/theme-page.ui
index eecc81e..7c61009 100644
--- a/plugins/appearance/pages/theme/theme-page.ui
+++ b/plugins/appearance/pages/theme/theme-page.ui
@@ -78,7 +78,7 @@
<item>
<widget class="QLabel" name="label_theme">
<property name="text">
- <string>Dark and Light Theme</string>
+ <string>Themes Settings</string>
</property>
</widget>
</item>
@@ -103,13 +103,6 @@
<property name="spacing">
<number>10</number>
</property>
- <item>
- <widget class="QLabel" name="label_theme_setting">
- <property name="text">
- <string>Themes Settings</string>
- </property>
- </widget>
- </item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_choose_widget">
<property name="spacing">
diff --git a/translations/kiran-control-panel.zh_CN.ts b/translations/kiran-control-panel.zh_CN.ts
index 970c5a0..8e39486 100644
--- a/translations/kiran-control-panel.zh_CN.ts
+++ b/translations/kiran-control-panel.zh_CN.ts
@@ -5303,7 +5303,7 @@ This is line 50 of the test text</source>
<message>
<location filename="../plugins/appearance/pages/theme/theme-page.cpp" line="151"/>
<source>Light Theme</source>
- <translation>浅色</translation>
+ <translation>冰晶白</translation>
</message>
<message>
<location filename="../plugins/appearance/pages/theme/theme-page.cpp" line="152"/>
@@ -5313,7 +5313,7 @@ This is line 50 of the test text</source>
<message>
<location filename="../plugins/appearance/pages/theme/theme-page.cpp" line="153"/>
<source>Dark Theme</source>
- <translation>深色</translation>
+ <translation>曜岩黑</translation>
</message>
<message>
<location filename="../plugins/appearance/pages/theme/theme-page.cpp" line="82"/>
--
2.33.0

View File

@ -0,0 +1,482 @@
From 55049f4ee286633b486936c7f4d19d3d426453a0 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Mon, 15 Jan 2024 16:31:01 +0800
Subject: [PATCH 14/17] fix(shortcut): add custom app icon,Error prompt for
modifying input shortcut keys
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修改录入快捷键错误提示,新增自定义应用图标显示
Closes #25199,#25198
---
plugins/keybinding/shortcut.cpp | 79 ++++++++++++----
plugins/keybinding/shortcut.h | 10 +-
translations/kiran-control-panel.zh_CN.ts | 106 ++++++++++++----------
3 files changed, 127 insertions(+), 68 deletions(-)
diff --git a/plugins/keybinding/shortcut.cpp b/plugins/keybinding/shortcut.cpp
index bab4ad1..84c0cba 100644
--- a/plugins/keybinding/shortcut.cpp
+++ b/plugins/keybinding/shortcut.cpp
@@ -31,12 +31,15 @@
#include <QKeyEvent>
#include <QtConcurrentRun>
-Q_DECLARE_METATYPE(QList<ShortcutInfoPtr>)
+#define DEFAULT_APP_ICON "application-script-blank"
+#define APP_ICON_WIDTH 20
+Q_DECLARE_METATYPE(QList<ShortcutInfoPtr>)
using namespace Kiran;
-Shortcut::Shortcut(QWidget *parent) : QWidget(parent),
- ui(new Ui::Shortcut)
+Shortcut::Shortcut(QWidget *parent)
+ : QWidget(parent),
+ ui(new Ui::Shortcut)
{
ui->setupUi(this);
init();
@@ -100,16 +103,24 @@ void Shortcut::initUI()
}
QHBoxLayout *hLayoutCustomApp = new QHBoxLayout(ui->lineEdit_custom_app);
+ m_customAppIcon = new QLabel;
+ m_customAppIcon->setFixedSize(24, 24);
+ m_customAppIcon->setPixmap(QIcon::fromTheme(DEFAULT_APP_ICON).pixmap(20, 20));
+ hLayoutCustomApp->addWidget(m_customAppIcon, 0, Qt::AlignVCenter);
+
+ hLayoutCustomApp->addStretch();
+
m_btnCustomApp = new QToolButton;
m_btnCustomApp->setObjectName("btn_custom_app");
m_btnCustomApp->setAccessibleName("ButtonAddCustomApp");
m_btnCustomApp->setText(tr("Add"));
m_btnCustomApp->setFixedSize(56, 30);
m_btnCustomApp->setCursor(Qt::PointingHandCursor);
- hLayoutCustomApp->addStretch();
hLayoutCustomApp->addWidget(m_btnCustomApp);
- ui->lineEdit_custom_app->setTextMargins(0, 0, m_btnCustomApp->width(), 0);
+
+ ui->lineEdit_custom_app->setTextMargins(25, 0, m_btnCustomApp->width(), 0);
connect(m_btnCustomApp, &QToolButton::clicked, this, &Shortcut::openFileSys);
+ connect(ui->lineEdit_custom_app,&QLineEdit::textChanged,this,&Shortcut::handleCustomAppTextChanged);
QHBoxLayout *hLayoutModifyApp = new QHBoxLayout(ui->lineEdit_modify_app);
m_btnModifyApp = new QToolButton;
@@ -354,7 +365,7 @@ bool Shortcut::isValidKeycode(QList<int> keycodes)
return !pureModifier;
}
-bool Shortcut::getExecFromDesktop(QString fileName, QString &exec)
+bool Shortcut::extractDesktopInfo(const QString &fileName, QString &exec, QString &icon)
{
QSettings settings(fileName, QSettings::IniFormat);
QString str = settings.value("Desktop Entry/Exec").toString();
@@ -368,6 +379,10 @@ bool Shortcut::getExecFromDesktop(QString fileName, QString &exec)
str = str.replace("%u", "", Qt::CaseInsensitive);
exec = str;
+
+ str = settings.value("Desktop Entry/Icon").toString();
+ icon = str.isEmpty() ? DEFAULT_APP_ICON : str;
+
return true;
}
@@ -376,23 +391,38 @@ void Shortcut::openFileSys()
QToolButton *senderbtn = qobject_cast<QToolButton *>(sender());
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(senderbtn->parent());
- QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "/usr/share/applications");
+ QString fileName = QFileDialog::getOpenFileName(this,
+ tr("Open File"),
+ "/usr/share/applications",
+ tr("Desktop entries(*.desktop)"));
if (fileName.isNull())
return;
- QString exec = fileName;
- if (fileName.endsWith(".desktop"))
+ QString cmd;
+ QString icon = DEFAULT_APP_ICON;
+ if (!extractDesktopInfo(fileName, cmd, icon))
{
- QString tmp;
- if (!getExecFromDesktop(fileName, tmp))
- {
- KLOG_ERROR(qLcKeybinding) << "cant't get Exec key from " << fileName;
- return;
- }
- exec = tmp;
+ KLOG_ERROR(qLcKeybinding) << "cant't get Exec key from " << fileName;
+ KiranMessageBox::message(this, tr("Error"),
+ "Extracting the program to be executed from the application's desktop file failed",
+ KiranMessageBox::Ok);
+ return;
+ }
+
+ // 缓存该次添加的应用以及图标信息
+ // 后续启动命令修改的时候,应复位图标
+ m_lastIcon = icon;
+ m_lastIconExec = cmd;
+
+ QIcon appIcon = QIcon::fromTheme(icon);
+ if( appIcon.isNull() )
+ {
+ m_lastIcon = DEFAULT_APP_ICON;
+ appIcon = QIcon::fromTheme(DEFAULT_APP_ICON);
}
- lineEdit->setText(exec);
+ m_customAppIcon->setPixmap(appIcon.pixmap(QSize(APP_ICON_WIDTH,APP_ICON_WIDTH)));
+ lineEdit->setText(cmd);
}
void Shortcut::handleSearchTimerTimeout()
@@ -787,6 +817,16 @@ void Shortcut::handleResetClicked()
}
}
+void Shortcut::handleCustomAppTextChanged(const QString& text)
+{
+ // 直接编辑自定义应用输入框,修改命令
+ // 导致和desktop读取出来的不一致时清空图标
+ if( !text.isEmpty() && text != m_lastIconExec )
+ {
+ m_customAppIcon->setPixmap(QIcon::fromTheme(DEFAULT_APP_ICON).pixmap(20,20));
+ }
+}
+
void Shortcut::handleInputKeycode(QList<int> keycodes)
{
CustomLineEdit *senderLineEdit = qobject_cast<CustomLineEdit *>(sender());
@@ -803,8 +843,9 @@ void Shortcut::handleInputKeycode(QList<int> keycodes)
{
KiranMessageBox::message(nullptr,
tr("Failed"),
- QString(tr("Cannot use shortcut \"%1\", Because you cannot enter with this key."
- "Please try again using Ctrl, Alt, or Shift at the same time."))
+ QString(tr("Cannot use shortcut \"%1\","
+ "Please keep pressing the modifier keys such as Ctrl,"
+ "Alt, and Shift before pressing the last key of the shortcut key"))
.arg(keyStr),
KiranMessageBox::Ok);
return;
diff --git a/plugins/keybinding/shortcut.h b/plugins/keybinding/shortcut.h
index fc078fb..3504b1b 100644
--- a/plugins/keybinding/shortcut.h
+++ b/plugins/keybinding/shortcut.h
@@ -35,6 +35,8 @@ class ShortcutItem;
class KeyMap;
class CustomLineEdit;
class KeybindingBackEndProxy;
+class QLabel;
+
class Shortcut : public QWidget
{
Q_OBJECT
@@ -59,7 +61,7 @@ private:
ShortcutItem *createShortcutItem(QVBoxLayout *parent, ShortcutInfoPtr shortcutInfo, int type);
bool isConflict(QString &originName, QString newKeyCombination);
bool isValidKeycode(QList<int> keycodes);
- bool getExecFromDesktop(QString fileName, QString &exec);
+ bool extractDesktopInfo(const QString& fileName, QString &exec, QString &icon);
void updateShorcut(ShortcutInfoPtr newShortcut);
void insertShortcut(ShortcutInfoPtr shortcutInfo);
void clearFilterItems();
@@ -72,6 +74,7 @@ public slots:
void handledShortcutDeleted(QString result);
void handleShortcutChanged(QString result);
+ void handleCustomAppTextChanged(const QString& text);
void handleInputKeycode(QList<int> keycodes);
void handleItemDeleteClicked(QString uid);
@@ -96,8 +99,13 @@ private:
QList<ShortcutItem *> m_shortcutItem;
QList<ShortcutItem *> m_filterItem;
+ //记录上次通过应用打开的desktop文件记录的Exec和Icon
+ QString m_lastIconExec;
+ QString m_lastIcon;
+
QToolButton *m_btnModifyApp;
QToolButton *m_btnCustomApp;
+ QLabel *m_customAppIcon;
CustomLineEdit *m_lECustomKey;
CustomLineEdit *m_lEModifyKey;
diff --git a/translations/kiran-control-panel.zh_CN.ts b/translations/kiran-control-panel.zh_CN.ts
index 970c5a0..31fc01e 100644
--- a/translations/kiran-control-panel.zh_CN.ts
+++ b/translations/kiran-control-panel.zh_CN.ts
@@ -33,18 +33,18 @@
<name>AccountWidget</name>
<message>
<location filename="../plugins/account/account-widget.cpp" line="100"/>
- <location filename="../plugins/account/account-widget.cpp" line="420"/>
+ <location filename="../plugins/account/account-widget.cpp" line="418"/>
<source>disable</source>
<translation type="unfinished">禁用</translation>
</message>
<message>
<location filename="../plugins/account/account-widget.cpp" line="100"/>
- <location filename="../plugins/account/account-widget.cpp" line="420"/>
+ <location filename="../plugins/account/account-widget.cpp" line="418"/>
<source>enable</source>
<translation type="unfinished">启用</translation>
</message>
<message>
- <location filename="../plugins/account/account-widget.cpp" line="225"/>
+ <location filename="../plugins/account/account-widget.cpp" line="223"/>
<source>Create new user</source>
<translation type="unfinished">创建新用户</translation>
</message>
@@ -2983,22 +2983,22 @@
<translation>请用分号分隔多个DNS</translation>
</message>
<message>
- <location filename="../plugins/network/src/plugin/setting-widget/ipv6-widget.cpp" line="234"/>
+ <location filename="../plugins/network/src/plugin/setting-widget/ipv6-widget.cpp" line="236"/>
<source>Ipv6 DNS invalid</source>
<translation>无效的Ipv6 DNS</translation>
</message>
<message>
- <location filename="../plugins/network/src/plugin/setting-widget/ipv6-widget.cpp" line="250"/>
+ <location filename="../plugins/network/src/plugin/setting-widget/ipv6-widget.cpp" line="252"/>
<source>Ipv6 address can not be empty</source>
<translation>Ipv6地址不能为空</translation>
</message>
<message>
- <location filename="../plugins/network/src/plugin/setting-widget/ipv6-widget.cpp" line="261"/>
+ <location filename="../plugins/network/src/plugin/setting-widget/ipv6-widget.cpp" line="263"/>
<source>Ipv6 address invalid</source>
<translation>无效的Ipv6地址</translation>
</message>
<message>
- <location filename="../plugins/network/src/plugin/setting-widget/ipv6-widget.cpp" line="274"/>
+ <location filename="../plugins/network/src/plugin/setting-widget/ipv6-widget.cpp" line="276"/>
<source>Ipv6 Gateway invalid</source>
<translation>无效的Ipv6网关</translation>
</message>
@@ -4675,8 +4675,8 @@ This is line 50 of the test text</source>
</message>
<message>
<location filename="../plugins/keybinding/shortcut.ui" line="210"/>
- <location filename="../plugins/keybinding/shortcut.cpp" line="163"/>
- <location filename="../plugins/keybinding/shortcut.cpp" line="550"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="174"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="580"/>
<source>Edit</source>
<translation>编辑</translation>
</message>
@@ -4688,8 +4688,8 @@ This is line 50 of the test text</source>
<message>
<location filename="../plugins/keybinding/shortcut.ui" line="346"/>
<location filename="../plugins/keybinding/shortcut.ui" line="551"/>
- <location filename="../plugins/keybinding/shortcut.cpp" line="106"/>
- <location filename="../plugins/keybinding/shortcut.cpp" line="118"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="116"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="129"/>
<source>Add</source>
<translation>添加</translation>
</message>
@@ -4742,7 +4742,7 @@ This is line 50 of the test text</source>
<message>
<location filename="../plugins/keybinding/shortcut.ui" line="589"/>
<source>Cancel</source>
- <translation type="unfinished">取消</translation>
+ <translation>取消</translation>
</message>
<message>
<location filename="../plugins/keybinding/shortcut.ui" line="635"/>
@@ -4772,7 +4772,7 @@ This is line 50 of the test text</source>
<message>
<location filename="../plugins/keybinding/shortcut.ui" line="770"/>
<source>Save</source>
- <translation type="unfinished">保存</translation>
+ <translation>保存</translation>
</message>
<message>
<location filename="../plugins/keybinding/shortcut.ui" line="805"/>
@@ -4782,129 +4782,139 @@ This is line 50 of the test text</source>
<message>
<location filename="../plugins/keybinding/shortcut.ui" line="808"/>
<source>return</source>
- <translation type="unfinished">返回</translation>
+ <translation>返回</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="87"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="90"/>
<source>Please enter a search keyword...</source>
<translation>请输入搜索关键字...</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="99"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="102"/>
<source>Required</source>
<translation>必填</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="127"/>
- <location filename="../plugins/keybinding/shortcut.cpp" line="134"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="138"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="145"/>
<source>Please press the new shortcut key</source>
<translation>请输入新快捷键</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="161"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="172"/>
<source>Finished</source>
<translation>完成</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="215"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="226"/>
<source>failed to load shortcut key data!</source>
<translation>加载快捷键数据失败!</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="257"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="268"/>
<source>List shortcut failed,error:%1</source>
<translation>列出快捷键失败,错误:%1</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="300"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="311"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="406"/>
<source>Error</source>
<translation>错误</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="301"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="312"/>
<source>Get shortcut failed,error:</source>
<translation>获取快捷键失败,错误:</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="379"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="395"/>
<source>Open File</source>
<translation>打开文件</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="603"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="397"/>
+ <source>Desktop entries(*.desktop)</source>
+ <translation>桌面文件(*.desktop)</translation>
+ </message>
+ <message>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="633"/>
<source>System</source>
<translation>系统</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="605"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="635"/>
<source>Sound</source>
<translation>声音</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="655"/>
- <location filename="../plugins/keybinding/shortcut.cpp" line="705"/>
- <location filename="../plugins/keybinding/shortcut.cpp" line="726"/>
- <location filename="../plugins/keybinding/shortcut.cpp" line="761"/>
- <location filename="../plugins/keybinding/shortcut.cpp" line="782"/>
- <location filename="../plugins/keybinding/shortcut.cpp" line="805"/>
- <location filename="../plugins/keybinding/shortcut.cpp" line="825"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="685"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="735"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="756"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="791"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="812"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="845"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="866"/>
<source>Failed</source>
<translation>失败</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="656"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="686"/>
<source>Delete shortcut failed,error:</source>
<translation>删除快捷键失败,错误:</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="669"/>
- <location filename="../plugins/keybinding/shortcut.cpp" line="744"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="699"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="774"/>
<source>Warning</source>
- <translation type="unfinished">警告</translation>
+ <translation>警告</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="670"/>
- <location filename="../plugins/keybinding/shortcut.cpp" line="745"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="700"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="775"/>
<source>Please complete the shortcut information!</source>
<translation>请完善快捷键信息!</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="679"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="709"/>
<source>Set shortcut</source>
<translation>设置快捷键</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="680"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="710"/>
<source>Are you sure you want to disable this shortcut?</source>
<translation>是否确定要禁用此快捷键?</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="706"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="736"/>
<source>Modify system shortcut failed,error:</source>
<translation>修改系统快捷键失败,错误:</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="727"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="757"/>
<source>Modify custom shortcut failed,error:</source>
<translation>修改自定义快捷键失败,错误:</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="762"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="792"/>
<source>Add custom shortcut failed,error:</source>
<translation>添加自定义快捷键失败,错误:</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="783"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="813"/>
<source>Reset shortcut failed,error:</source>
<translation>重置快捷键失败,错误:</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="806"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="846"/>
+ <source>Cannot use shortcut &quot;%1&quot;,Please keep pressing the modifier keys such as Ctrl,Alt, and Shift before pressing the last key of the shortcut key</source>
+ <translation>无法使用快捷键&quot;%1&quot;, 请保持按压Ctrl、Alt、Shift等修饰键后再按压快捷键的最后一个键</translation>
+ </message>
+ <message>
<source>Cannot use shortcut &quot;%1&quot;, Because you cannot enter with this key.Please try again using Ctrl, Alt, or Shift at the same time.</source>
- <translation>无法使用快捷键&quot;%1&quot;,因为使用此键将无法输入请同时使用CtrlAltShift再试一次。</translation>
+ <translation type="vanished">无法使用快捷键&quot;%1&quot;,因为使用此键将无法输入请同时使用CtrlAltShift再试一次。</translation>
</message>
<message>
- <location filename="../plugins/keybinding/shortcut.cpp" line="826"/>
+ <location filename="../plugins/keybinding/shortcut.cpp" line="867"/>
<source>Shortcut keys %1 are already used in %2,Please try again!</source>
<translation>快捷键%1已用于%2请再试一次</translation>
</message>
--
2.33.0

View File

@ -1,288 +0,0 @@
From 60cfb83ae452e20c1d974eb431b2be551db3432e Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Thu, 21 Sep 2023 10:21:23 +0800
Subject: [PATCH 1/2] fix(tray):Fixed the tray menu using the X11 platform,
which caused the missing voice and network icon in the lower right corner,
and the network icon in the taskbar was formatted incorrectly
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复托盘菜单使用X11平台从而导致的右下角缺少声音和网络图标以及任务栏网络图标格式不对的问题
Closes #13353,#11856,#14006
---
CMakeLists.txt | 1 +
include/dbus-tray-monitor.h | 111 +++++++++++++++++++++++++
plugins/audio/CMakeLists.txt | 3 +-
plugins/audio/src/system-tray/main.cpp | 28 +++----
plugins/network/CMakeLists.txt | 1 +
plugins/network/src/tray/main.cpp | 29 +++----
6 files changed, 141 insertions(+), 32 deletions(-)
create mode 100644 include/dbus-tray-monitor.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bdffa50..210c938 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,6 +77,7 @@ target_link_libraries(${PROJECT_NAME}
${KIRAN_STYLE_LIBRARIES}
${GLIB_2_LIBRARIES})
+list(FILTER INCLUDE_SRC EXCLUDE REGEX ".*bus-tray-monitor.h$")
install(FILES "${CMAKE_SOURCE_DIR}/data/kiran-control-panel.svg" DESTINATION ${INSTALL_DATADIR}/icons/hicolor/)
install(FILES ${INCLUDE_SRC} DESTINATION ${KCP_INSTALL_INCLUDE}/)
install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.desktop" DESTINATION "${INSTALL_DATADIR}/applications/")
diff --git a/include/dbus-tray-monitor.h b/include/dbus-tray-monitor.h
new file mode 100644
index 0000000..652e7b1
--- /dev/null
+++ b/include/dbus-tray-monitor.h
@@ -0,0 +1,111 @@
+/**
+ * Copyright (c) 2022 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: luoqing <luoqing@kylinsec.com.cn>
+ */
+
+#pragma once
+#include <qt5-log-i.h>
+#include <QDBusConnection>
+#include <QDBusInterface>
+#include <QDBusServiceWatcher>
+#include <QDBusArgument>
+#include <QMap>
+#include <QObject>
+
+#define KDE_STATUS_NOTIFIER_WATCHER_SERVICE "org.kde.StatusNotifierWatcher"
+#define KDE_STATUS_NOTIFIER_WATCHER_PATH "/StatusNotifierWatcher"
+#define FREEDESKTOP_DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
+#define FREEDESKTOP_DBUS_PROPERTIES_CHANGED_METHOD "PropertiesChanged"
+
+#define KDE_STATUS_NOTIFIER_HOST "org.kde.StatusNotifierHost"
+
+namespace KiranControlPanel
+{
+class DBusTrayMonitor : public QObject
+{
+ Q_OBJECT
+public:
+ DBusTrayMonitor(QObject *parent = nullptr)
+ : QObject(parent),
+ m_connection(QDBusConnection::sessionBus()),
+ m_statusNotifierHostRegistered(false)
+ {
+
+ QDBusInterface trayWatcherInterface(KDE_STATUS_NOTIFIER_WATCHER_SERVICE, KDE_STATUS_NOTIFIER_WATCHER_PATH,
+ KDE_STATUS_NOTIFIER_WATCHER_SERVICE, QDBusConnection::sessionBus());
+
+ // 确认托盘服务Watcher是否存在检测Watcher IsStatusNotifierHostRegistered是否为true(满足QDBusTray可用的条件具体可参考Qt代码)
+ if (trayWatcherInterface.isValid() && trayWatcherInterface.property("IsStatusNotifierHostRegistered").toBool())
+ {
+ m_statusNotifierHostRegistered = true;
+ }
+ else
+ {
+ // 托盘服务Watcher不存在/Host未注册/IsStatusNotifierHostRegistered属性未更新
+ // 连接到DBus Daemon,处理Watcher属性变化信号
+ m_connection.connect(KDE_STATUS_NOTIFIER_WATCHER_SERVICE,
+ KDE_STATUS_NOTIFIER_WATCHER_PATH,
+ FREEDESKTOP_DBUS_PROPERTIES_INTERFACE,
+ FREEDESKTOP_DBUS_PROPERTIES_CHANGED_METHOD,
+ this, SLOT(onWatcherServicePropertyChanged(QDBusMessage)));
+ }
+ }
+
+ ~DBusTrayMonitor() {}
+
+ bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+
+private slots:
+ void onWatcherServicePropertyChanged(QDBusMessage msg)
+ {
+ // 若Host已注册过无需判断
+ if (m_statusNotifierHostRegistered)
+ return;
+
+ QList<QVariant> args = msg.arguments();
+ QVariantMap changedProps = qdbus_cast<QVariantMap>(args.at(1).value<QDBusArgument>());
+ for (auto iter = changedProps.begin(); iter != changedProps.end(); iter++)
+ {
+ if (iter.key() != "IsStatusNotifierHostRegistered")
+ continue;
+
+ // IsStatusNotifierHostRegistered,属性变为true
+ // 发出DBus托盘服务可用信号(只在托盘初始化时发出)
+ // 后续属性变化不关注
+ if (iter.value().toBool())
+ {
+ m_statusNotifierHostRegistered = true;
+ KLOG_DEBUG() << "notifier host registered,dbus tray available!";
+ emit dbusTrayAvailable();
+ }
+ break;
+ }
+ }
+
+signals:
+ void dbusTrayAvailable();
+
+private:
+ QDBusConnection m_connection;
+ bool m_statusNotifierHostRegistered;
+};
+
+static bool isDBusTrayAvailable()
+{
+ bool dbusTrayAvailable = false;
+ DBusTrayMonitor conn;
+ if (conn.isStatusNotifierHostRegistered())
+ dbusTrayAvailable = true;
+ return dbusTrayAvailable;
+}
+
+} // namespace KiranControlPanel
diff --git a/plugins/audio/CMakeLists.txt b/plugins/audio/CMakeLists.txt
index ea568f1..55b07b2 100644
--- a/plugins/audio/CMakeLists.txt
+++ b/plugins/audio/CMakeLists.txt
@@ -44,7 +44,8 @@ add_executable(${TRAY_PROCESS}
${DBUS_SRC}
${SYSTEM_TRAY_SRC}
${AUDIO_QM_FILES}
- ${QRC})
+ ${QRC}
+ ${PROJECT_SOURCE_DIR}/include/dbus-tray-monitor.h)
target_include_directories(${TRAY_PROCESS} PRIVATE
${CMAKE_BINARY_DIR}
diff --git a/plugins/audio/src/system-tray/main.cpp b/plugins/audio/src/system-tray/main.cpp
index 431e6c9..8c36383 100644
--- a/plugins/audio/src/system-tray/main.cpp
+++ b/plugins/audio/src/system-tray/main.cpp
@@ -25,6 +25,7 @@
#include <QDateTime>
#include <QFile>
#include <QTranslator>
+#include "dbus-tray-monitor.h"
#define DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER "org.kde.StatusNotifierWatcher"
@@ -47,27 +48,24 @@ int main(int argc, char *argv[])
}
AudioSystemTray *audioSystemTray = nullptr;
-
- if (QDBusConnection::sessionBus().interface()->isServiceRegistered(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER))
+ if (KiranControlPanel::isDBusTrayAvailable())
{
- KLOG_DEBUG() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is registered,create audio tray icon";
+ KLOG_DEBUG() << KDE_STATUS_NOTIFIER_HOST << "is registered,create network tray icon";
audioSystemTray = new AudioSystemTray;
}
else
{
- KLOG_WARNING() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is not registered,wait";
- QDBusServiceWatcher* dbusServiceWatcher = new QDBusServiceWatcher;
- dbusServiceWatcher->setConnection(QDBusConnection::sessionBus());
- dbusServiceWatcher->addWatchedService(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER);
- QObject::connect(dbusServiceWatcher, &QDBusServiceWatcher::serviceRegistered,
- [&dbusServiceWatcher, &audioSystemTray](const QString& service)
+ KLOG_WARNING() << KDE_STATUS_NOTIFIER_HOST << "is not registered,wait";
+
+ auto dBusTrayMonitor = new KiranControlPanel::DBusTrayMonitor();
+ QObject::connect(dBusTrayMonitor, &KiranControlPanel::DBusTrayMonitor::dbusTrayAvailable, [&audioSystemTray]()
{
- if (service != DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER)
- return;
- KLOG_INFO() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is registered,create audio tray icon";
- audioSystemTray = new AudioSystemTray;
- dbusServiceWatcher->removeWatchedService(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER);
- });
+ if(audioSystemTray == nullptr)
+ {
+ KLOG_DEBUG() << KDE_STATUS_NOTIFIER_HOST << "is registered,create network tray icon";
+ audioSystemTray = new AudioSystemTray;
+ }
+ });
}
return QApplication::exec();
}
diff --git a/plugins/network/CMakeLists.txt b/plugins/network/CMakeLists.txt
index 7ea6479..94de67a 100644
--- a/plugins/network/CMakeLists.txt
+++ b/plugins/network/CMakeLists.txt
@@ -55,6 +55,7 @@ add_executable(${TRAY_PROCESS}
${COMMON_SRC}
${QRC}
${NETWORK_QM_FILES}
+ ${PROJECT_SOURCE_DIR}/include/dbus-tray-monitor.h
)
target_include_directories(${TRAY_PROCESS} PRIVATE
diff --git a/plugins/network/src/tray/main.cpp b/plugins/network/src/tray/main.cpp
index 2a62bf1..5c4bb65 100644
--- a/plugins/network/src/tray/main.cpp
+++ b/plugins/network/src/tray/main.cpp
@@ -20,10 +20,9 @@
#include <QDBusServiceWatcher>
#include <QTranslator>
#include "config.h"
+#include "dbus-tray-monitor.h"
#include "network-tray.h"
-#define DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER "org.kde.StatusNotifierWatcher"
-
int main(int argc, char* argv[])
{
KiranApplication a(argc, argv);
@@ -43,26 +42,24 @@ int main(int argc, char* argv[])
}
NetworkTray* tray = nullptr;
- if (QDBusConnection::sessionBus().interface()->isServiceRegistered(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER))
+ if (KiranControlPanel::isDBusTrayAvailable())
{
- KLOG_DEBUG() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is registered,create network tray icon";
+ KLOG_DEBUG() << KDE_STATUS_NOTIFIER_HOST << "is registered,create network tray icon";
tray = new NetworkTray;
}
else
{
- KLOG_WARNING() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is not registered,wait";
- QDBusServiceWatcher* dbusServiceWatcher = new QDBusServiceWatcher;
- dbusServiceWatcher->setConnection(QDBusConnection::sessionBus());
- dbusServiceWatcher->addWatchedService(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER);
- QObject::connect(dbusServiceWatcher, &QDBusServiceWatcher::serviceRegistered,
- [&dbusServiceWatcher, &tray](const QString& service)
+ KLOG_WARNING() << KDE_STATUS_NOTIFIER_HOST << "is not registered,wait";
+
+ auto dBusTrayMonitor = new KiranControlPanel::DBusTrayMonitor();
+ QObject::connect(dBusTrayMonitor, &KiranControlPanel::DBusTrayMonitor::dbusTrayAvailable, [&tray]()
{
- if (service != DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER)
- return;
- KLOG_INFO() << DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER << "is registered,create network tray icon";
- tray = new NetworkTray;
- dbusServiceWatcher->removeWatchedService(DBUS_SERVICE_KDE_STATUS_NOTIFIER_WATCHER);
- });
+ if(tray == nullptr)
+ {
+ KLOG_DEBUG() << KDE_STATUS_NOTIFIER_HOST << "is registered,create network tray icon";
+ tray = new NetworkTray;
+ }
+ });
}
return QApplication::exec();
--
2.33.0

View File

@ -1,81 +0,0 @@
From c385edb7f7babef4d46ca77f1a979dd9f139b16e Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Thu, 21 Sep 2023 10:33:42 +0800
Subject: [PATCH 2/2] fix(network-tray):Fixed an issue where the size Settings
of widgets that are not currently displaying pages in the stackwidget did not
take effect when multiple nics were present during tray initialization
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复在托盘初始化时存在多个网卡时stackwidget中当前未显示页面的widget的设置大小未生效的问题
Close #13862
---
plugins/network/src/tray/tray-page.cpp | 35 ++++++++++++++++++++++++++
plugins/network/src/tray/tray-page.h | 3 +++
2 files changed, 38 insertions(+)
diff --git a/plugins/network/src/tray/tray-page.cpp b/plugins/network/src/tray/tray-page.cpp
index 753abc4..2e50f22 100644
--- a/plugins/network/src/tray/tray-page.cpp
+++ b/plugins/network/src/tray/tray-page.cpp
@@ -53,6 +53,41 @@ void TrayPage::initUI()
{
setSingleDeviceWidget();
}
+
+ /**
+ * NOTE:
+ * 此处是修复当存在多个网卡时stackwidget中当前未显示页面的widget的大小有问题
+ * 推测原因在于在初始化时在页面未show的状态下设置widget的尺寸不生效存在问题。
+ */
+ repolish(this);
+}
+
+void TrayPage::repolish(QWidget *w)
+{
+ QList<const QObject *> children;
+ children.reserve(w->children().size() + 1);
+ for (auto child: qAsConst(w->children()))
+ children.append(child);
+ children.append(w);
+ updateObjects(children);
+}
+
+void TrayPage::updateObjects(const QList<const QObject *>& objects)
+{
+ QEvent event(QEvent::StyleChange);
+ for (const QObject *object : objects)
+ {
+ if (auto widget = qobject_cast<QWidget*>(const_cast<QObject*>(object)))
+ {
+ widget->style()->polish(widget);
+ QCoreApplication::sendEvent(widget, &event);
+ QList<const QObject *> children;
+ children.reserve(widget->children().size() + 1);
+ for (auto child: qAsConst(widget->children()))
+ children.append(child);
+ updateObjects(children);
+ }
+ }
}
void TrayPage::initConnection()
diff --git a/plugins/network/src/tray/tray-page.h b/plugins/network/src/tray/tray-page.h
index 28948a4..66a84f2 100644
--- a/plugins/network/src/tray/tray-page.h
+++ b/plugins/network/src/tray/tray-page.h
@@ -44,6 +44,9 @@ public:
QSize trayPageSize();
+ void repolish(QWidget *w);
+ void updateObjects(const QList<const QObject *>& objects);
+
public slots:
void handleDeviceComboBoxChanged(int index);
void handleAdjustedTraySize(QSize sizeHint);
--
2.33.0

View File

@ -0,0 +1,669 @@
From 26d4b8d60a30821c398ef4be3b6352f5041a56a3 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Mon, 15 Jan 2024 17:28:15 +0800
Subject: [PATCH 15/17] fix(power): profile mode using kiran-cc-daemon power
interface
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 计算机模式接口使用控制中心后端所提供的接口
Closes #25242
---
plugins/power/CMakeLists.txt | 9 +-
...com.kylinsec.Kiran.SessionDaemon.Power.xml | 16 ++
.../power/data/net.hadess.PowerProfiles.xml | 144 ------------------
plugins/power/dbus/power-profiles-wrapper.cpp | 124 ---------------
plugins/power/dbus/power-profiles-wrapper.h | 50 ------
plugins/power/pages/general-settings-page.cpp | 47 ++++--
plugins/power/pages/general-settings-page.h | 4 +-
translations/kiran-control-panel.zh_CN.ts | 59 ++++---
8 files changed, 86 insertions(+), 367 deletions(-)
delete mode 100644 plugins/power/data/net.hadess.PowerProfiles.xml
delete mode 100644 plugins/power/dbus/power-profiles-wrapper.cpp
delete mode 100644 plugins/power/dbus/power-profiles-wrapper.h
diff --git a/plugins/power/CMakeLists.txt b/plugins/power/CMakeLists.txt
index 37d025d..99dc819 100644
--- a/plugins/power/CMakeLists.txt
+++ b/plugins/power/CMakeLists.txt
@@ -7,6 +7,7 @@ set(TARGET_NAME kiran-cpanel-power)
pkg_search_module(UPOWER_GLIB REQUIRED upower-glib)
set(POWER_PLUGIN_DBUS_SRC_LIST "")
+
# com.kylinsec.Kiran.SessionDaemon.Power
set(KSD_POWER_XML data/com.kylinsec.Kiran.SessionDaemon.Power.xml)
set_source_files_properties(${KSD_POWER_XML}
@@ -17,13 +18,7 @@ kiran_qt5_add_dbus_interface_ex(KSD_POWER_SRC
ksd_power_proxy
KSDPowerProxy)
list(APPEND POWER_PLUGIN_DBUS_SRC_LIST ${KSD_POWER_SRC})
-# net.hadess.PowerProfiles
-set(POWERPROFILES_XML data/net.hadess.PowerProfiles.xml)
-kiran_qt5_add_dbus_interface_ex(POWER_PROFILES_SRC
- ${POWERPROFILES_XML}
- power_profiles_proxy
- PowerProfilesProxy)
-list(APPEND POWER_PLUGIN_DBUS_SRC_LIST ${POWER_PROFILES_SRC})
+
# org.gnome.SessionManager.xml - kiran-session-manager
set(GNOME_SESSION_MANAGER_XML data/org.gnome.SessionManager.xml)
kiran_qt5_add_dbus_interface_ex(GNOME_SESSION_MANAGER_SOUCE
diff --git a/plugins/power/data/com.kylinsec.Kiran.SessionDaemon.Power.xml b/plugins/power/data/com.kylinsec.Kiran.SessionDaemon.Power.xml
index 281ffdb..c32bbb5 100644
--- a/plugins/power/data/com.kylinsec.Kiran.SessionDaemon.Power.xml
+++ b/plugins/power/data/com.kylinsec.Kiran.SessionDaemon.Power.xml
@@ -82,6 +82,13 @@
<description>Enable cpu save energy when the ups or battery power is low.</description>
</method>
+ <method name="SwitchProfile">
+ <arg type="i" name="mode" direction="in">
+ <description>The profile mode. Refer to PowerProfileMode in power-i.h</description>
+ </arg>
+ <description>Switch profile mode.</description>
+ </method>
+
<property name="OnBattery" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<description>Indicates whether the system is running on battery power.</description>
@@ -107,6 +114,11 @@
<description>Whether does the cpu save energy when the ups or battery power is low.</description>
</property>
+ <property name="ActiveProfile" type="i" access="read">
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
+ <description>The active profile mode.</description>
+ </property>
+
<signal name="IdleActionChanged">
<arg name="device" type="i" />
<arg name="supply" type="i" />
@@ -120,5 +132,9 @@
<arg name="device" type="i" />
</signal>
+ <signal name="ActiveProfileChanged">
+ <arg name="active_profile" type="i" />
+ </signal>
+
</interface>
</node>
diff --git a/plugins/power/data/net.hadess.PowerProfiles.xml b/plugins/power/data/net.hadess.PowerProfiles.xml
deleted file mode 100644
index a3241fb..0000000
--- a/plugins/power/data/net.hadess.PowerProfiles.xml
+++ /dev/null
@@ -1,144 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
-"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-
-<node>
-
- <!--
- net.hadess.PowerProfiles:
- @short_description: Power Profiles daemon
-
- The power-profiles-daemon API is meant to be used by parts of the OS or
- desktop environment to switch system power profiles based on user choice,
- or user intent.
-
- OS components would typically use the "Profiles" property to construct
- their UI (2 or 3 profiles available), and monitor the "ActiveProfile"
- and the "PerformanceDegraded" properties to update that UI. The UI
- would try to set the "ActiveProfile" property if the user selected
- a different one.
-
- Note that the reason why the project exists and how it is different from
- existing projects is explained <ulink href=" https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/blob/master/README.md">
- in the project's README file</ulink>.
-
- The object path will be "/net/hadess/PowerProfiles".
- -->
- <interface name="net.hadess.PowerProfiles">
-
- <!--
- HoldProfile:
-
- This forces the passed profile (either 'power-saver' or 'performance')
- to be activated until either the caller quits, "ReleaseProfile" is
- called, or the "ActiveProfile" is changed by the user.
-
- This should be used programmatically by OS components when, eg. high-
- performance workloads are started with the "performance" profile, or
- battery will soon be critically low with the "power-saver" profile.
-
- When conflicting profiles are requested to be held, the 'power-saver' profile
- will be activated in preference to the 'performance' profile.
-
- Those holds will be automatically cancelled if the user manually switches
- to another profile, and the "ProfileReleased" signal will be emitted.
- -->
- <method name="HoldProfile">
- <arg name="profile" type="s" direction="in"/>
- <arg name="reason" type="s" direction="in"/>
- <arg name="application_id" type="s" direction="in" />
- <arg name="cookie" type="u" direction="out"/>
- </method>
-
- <!--
- ReleaseProfile:
-
- This removes the hold that was set on a profile.
- -->
- <method name="ReleaseProfile">
- <arg name="cookie" type="u" direction="in"/>
- </method>
-
- <!--
- ProfileReleased:
-
- This signal will be emitted if the profile is released because the
- "ActiveProfile" was manually changed. The signal will only be emitted
- to the process that originally called "HoldProfile".
- -->
- <signal name="ProfileReleased">
- <arg name="cookie" type="u" direction="out"/>
- </signal>
-
- <!--
- ActiveProfile:
-
- The type of the currently active profile. It might change automatically
- if a profile is held, using the "HoldProfile" function.
- -->
- <property name="ActiveProfile" type="s" access="readwrite"/>
-
- <!--
- PerformanceInhibited:
-
- This property is deprecated, and unused since version 0.9.
- -->
- <property name="PerformanceInhibited" type="s" access="read"/>
-
- <!--
- PerformanceDegraded:
-
- This will be set if the performance power profile is running in degraded
- mode, with the value being used to identify the reason for that degradation.
- As new reasons can be added, it is recommended that front-ends show a generic
- reason if they do not recognise the value. Possible values are:
- - "lap-detected" (the computer is sitting on the user's lap)
- - "high-operating-temperature" (the computer is close to overheating)
- - "" (the empty string, if not performance is not degraded)
- -->
- <property name="PerformanceDegraded" type="s" access="read"/>
-
- <!--
- Profiles:
-
- An array of key-pair values representing each profile. The key named
- "Driver" (s) identifies the power-profiles-daemon backend code used to
- implement the profile.
-
- The key named "Profile" (s) will be one of:
- - "power-saver" (battery saving profile)
- - "balanced" (the default profile)
- - "performance" (a profile that does not care about noise or battery consumption)
-
- Only one of each type of profile will be listed, with the daemon choosing the
- more appropriate "driver" for each profile type.
-
- This list is guaranteed to be sorted in the same order that the profiles
- are listed above.
- -->
- <property name="Profiles" type="aa{sv}" access="read">
- <annotation name="org.qtproject.QtDBus.QtTypeName" value="QList&lt;QVariantMap&gt;"/>
- </property>
-
- <!--
- Actions:
-
- An array of strings listing each one of the "actions" implemented in
- the running daemon. This is used by API users to figure out whether
- particular functionality is available in a version of the daemon.
- -->
- <property name="Actions" type="as" access="read"/>
-
- <!--
- ActiveProfileHolds:
-
- A list of dictionaries representing the current profile holds.
- The keys in the dict are "ApplicationId", "Profile" and "Reason",
- and correspond to the "application_id", "profile" and "reason" arguments
- passed to the HoldProfile() method.
- -->
- <property name="ActiveProfileHolds" type="aa{sv}" access="read">
- <annotation name="org.qtproject.QtDBus.QtTypeName" value="QList&lt;QVariantMap&gt;"/>
- </property>
-
- </interface>
-</node>
diff --git a/plugins/power/dbus/power-profiles-wrapper.cpp b/plugins/power/dbus/power-profiles-wrapper.cpp
deleted file mode 100644
index 6262fdc..0000000
--- a/plugins/power/dbus/power-profiles-wrapper.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * Copyright (c) 2020 ~ 2023 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: liuxinhao <liuxinhao@kylinsec.com.cn>
- */
-#include "power-profiles-wrapper.h"
-#include <qt5-log-i.h>
-#include <QDBusConnection>
-#include <QDBusConnectionInterface>
-#include <QDBusMessage>
-#include <QVariantList>
-#include "power_profiles_proxy.h"
-
-#define POWERPROFILES_SERVICE_NAME "net.hadess.PowerProfiles"
-#define POWERPROFILES_SERVICE_PATH "/net/hadess/PowerProfiles"
-#define POWERPROFILES_SERVICE_PROPERTY_ACTIVE_PROFILE "ActiveProfile"
-#define POWERPROFILES_SERVICE_PROPERTY_PROFILES "Profiles"
-
-#define FREEDESKTOP_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
-#define FREEDESKTOP_PROPERTIES_METHOD_GET "Get"
-#define FREEDESKTOP_PROPERTIES_METHOD_SET "Set"
-#define FREEDESKTOP_PROPERTIES_SIGNAL_PROPERTIES_CHANGED "PropertiesChanged"
-
-Q_DECLARE_METATYPE(QList<QVariantMap>)
-PowerProfilesWrapper::PowerProfilesWrapper(QObject* parent)
- : QObject(parent),
- m_profileProxy(new PowerProfilesProxy(POWERPROFILES_SERVICE_NAME, POWERPROFILES_SERVICE_PATH, QDBusConnection::systemBus(), this))
-{
- qDBusRegisterMetaType<QList<QVariantMap>>();
- if (QDBusConnection::systemBus().interface()->isServiceRegistered(POWERPROFILES_SERVICE_NAME))
- {
- m_isValid = true;
- auto powerProfiles = m_profileProxy->profiles();
- for (auto powerProfile : powerProfiles)
- {
- KLOG_DEBUG() << powerProfile["Profile"].toString()<< powerProfile["Driver"].toString();
- if (powerProfile.contains("Profile"))
- {
- m_profiles << profileNameTransToLocale(powerProfile["Profile"].toString());
- }
- }
-
- auto activeProfile = m_profileProxy->activeProfile();
- m_activeProfile = activeProfile;
- connect(m_profileProxy, &PowerProfilesProxy::ActiveProfileChanged,
- this, &PowerProfilesWrapper::onActiveProfileChanged);
- }
- else
- {
- KLOG_WARNING() << "power profiles init failed," << POWERPROFILES_SERVICE_NAME << "isn't registered";
- }
-}
-
-PowerProfilesWrapper::~PowerProfilesWrapper()
-{
-}
-
-bool PowerProfilesWrapper::isValid()
-{
- return m_isValid;
-}
-
-QStringList PowerProfilesWrapper::supportedProfiles()
-{
- return m_profiles;
-}
-
-QString PowerProfilesWrapper::activeProfile()
-{
- return profileNameTransToLocale(m_activeProfile);
-}
-
-void PowerProfilesWrapper::setActiveProfile(const QString& profileName)
-{
- QString value = localeTransToProfileName(profileName);
- m_profileProxy->setActiveProfile(value);
-}
-
-void PowerProfilesWrapper::onActiveProfileChanged(const QString& profileName)
-{
- m_activeProfile = profileName;
- QString localeProfileName = profileNameTransToLocale(profileName);
- emit activeProfileChanged(localeProfileName);
-}
-
-QString PowerProfilesWrapper::profileNameTransToLocale(const QString& profileName)
-{
- QMap<QString, QString> transMap = {
- {"power-saver", tr("power-saver")},
- {"balanced", tr("balanced")},
- {"performance", tr("performance")}};
-
- QString localeProfileName = profileName;
- if (transMap.contains(profileName))
- {
- localeProfileName = transMap[profileName];
- }
-
- return localeProfileName;
-}
-
-QString PowerProfilesWrapper::localeTransToProfileName(const QString& locale)
-{
- QMap<QString, QString> transMap = {
- {tr("power-saver"), "power-saver"},
- {tr("balanced"), "balanced"},
- {tr("performance"), "performance"}};
-
- QString profileName = locale;
- if (transMap.contains(locale))
- {
- profileName = transMap[locale];
- }
-
- return profileName;
-}
diff --git a/plugins/power/dbus/power-profiles-wrapper.h b/plugins/power/dbus/power-profiles-wrapper.h
deleted file mode 100644
index 0e5723c..0000000
--- a/plugins/power/dbus/power-profiles-wrapper.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (c) 2020 ~ 2023 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: liuxinhao <liuxinhao@kylinsec.com.cn>
- */
-#pragma once
-
-#include <QObject>
-#include <QDBusMessage>
-
-class PowerProfilesProxy;
-class PowerProfilesWrapper : public QObject
-{
- Q_OBJECT
-public:
- PowerProfilesWrapper(QObject* parent = nullptr);
- ~PowerProfilesWrapper();
-
- bool isValid();
-
- QStringList supportedProfiles();
- QString activeProfile();
- void setActiveProfile(const QString& profileName);
-
-private slots:
- void onActiveProfileChanged(const QString& profileName);
-
-signals:
- void activeProfileChanged(const QString& profileName);
-
-private:
- // 由英文的ProfileName装换成本地locale的翻译文本
- QString profileNameTransToLocale(const QString& profileName);
- // 由于locale的翻译文本转换成英文的ProfileName
- QString localeTransToProfileName(const QString& locale);
-
-private:
- PowerProfilesProxy* m_profileProxy = nullptr;
- bool m_isValid = false;
- QString m_activeProfile;
- QStringList m_profiles;
-};
\ No newline at end of file
diff --git a/plugins/power/pages/general-settings-page.cpp b/plugins/power/pages/general-settings-page.cpp
index 9176a00..430d103 100644
--- a/plugins/power/pages/general-settings-page.cpp
+++ b/plugins/power/pages/general-settings-page.cpp
@@ -19,7 +19,6 @@
#include <QListView>
#include <QSignalBlocker>
#include "dbus/kwin-color-correct.h"
-#include "dbus/power-profiles-wrapper.h"
#include "dbus/power.h"
#include "kiran-message-box.h"
#include "kiran-session-daemon/power-i.h"
@@ -41,8 +40,7 @@ GeneralSettingsPage::GeneralSettingsPage(QWidget* parent)
: QWidget(parent),
ui(new Ui::GeneralSettingsPage),
m_powerInterface(PowerInterface::getInstance()),
- m_kwinColorCorrect(new KWinColorCorrect(this)),
- m_powerprofiles(new PowerProfilesWrapper(this))
+ m_kwinColorCorrect(new KWinColorCorrect(this))
{
ui->setupUi(this);
init();
@@ -147,13 +145,18 @@ void GeneralSettingsPage::initUI()
}
// 初始化计算机模式
- if (m_powerprofiles->isValid())
+ struct PowerProfileInfo
{
- ui->combo_computerMode->addItems(m_powerprofiles->supportedProfiles());
- }
- else
+ QString name;
+ int index;
+ };
+ QList<PowerProfileInfo> profiles = {
+ {tr("Energy-saving mode"), POWER_PROFILE_MODE_SAVER},
+ {tr("Balanced mode"), POWER_PROFILE_MODE_BALANCED},
+ {tr("High performance mode"), POWER_PROFILE_MODE_PERFORMANCE}};
+ for (auto profile : profiles)
{
- ui->widget_computerMode->setVisible(false);
+ ui->combo_computerMode->addItem(profile.name, profile.index);
}
/// 初始化QSlider,和延迟设置的Timer
@@ -209,7 +212,7 @@ void GeneralSettingsPage::initConnection()
connect(ui->combo_closingLid, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &GeneralSettingsPage::updateEventAction);
- connect(ui->combo_computerMode, &QComboBox::currentTextChanged,
+ connect(ui->combo_computerMode, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &GeneralSettingsPage::updateCurrentComputerMode);
connect(&m_brightnessSettingTimer, &QTimer::timeout,
@@ -271,10 +274,15 @@ void GeneralSettingsPage::load()
updateEventActionComboCurrent(ui->combo_closingLid, POWER_EVENT_LID_CLOSED);
// 计算机模式
- if (m_powerprofiles->isValid())
+ QSignalBlocker blocker(ui->combo_computerMode);
+ int activePorfileComboxIdx = ui->combo_computerMode->findData(m_powerInterface->activeProfile());
+ if (activePorfileComboxIdx != -1)
{
- QSignalBlocker blocker(ui->combo_computerMode);
- ui->combo_computerMode->setCurrentText(m_powerprofiles->activeProfile());
+ ui->combo_computerMode->setCurrentIndex(activePorfileComboxIdx);
+ }
+ else
+ {
+ KLOG_ERROR() << "can not fidn current active computer mode in combobox:" << m_powerInterface->activeProfile();
}
// 显示器亮度调整
@@ -496,9 +504,20 @@ void GeneralSettingsPage::onSliderColorTempValueChanged(int value)
m_colorTempSettingTimer.start();
}
-void GeneralSettingsPage::updateCurrentComputerMode(const QString& text)
+void GeneralSettingsPage::updateCurrentComputerMode(int idx)
{
- m_powerprofiles->setActiveProfile(text);
+ auto computerMode = ui->combo_computerMode->itemData(idx);
+ auto reply = m_powerInterface->SwitchProfile(computerMode.toInt());
+ reply.waitForFinished();
+ if (reply.isError())
+ {
+ KLOG_ERROR() << "set current computer mode" << computerMode.toInt()
+ << "failed," << reply.error();
+ }
+ else
+ {
+ KLOG_DEBUG() << "set current computer mode" << computerMode.toInt();
+ }
}
void GeneralSettingsPage::setUiBrightnessPercent(int percent)
diff --git a/plugins/power/pages/general-settings-page.h b/plugins/power/pages/general-settings-page.h
index 63e8591..e270253 100644
--- a/plugins/power/pages/general-settings-page.h
+++ b/plugins/power/pages/general-settings-page.h
@@ -29,7 +29,6 @@ class PowerInterface;
class KiranSwitchButton;
class QGSettings;
class KWinColorCorrect;
-class PowerProfilesWrapper;
class GeneralSettingsPage : public QWidget
{
Q_OBJECT
@@ -62,13 +61,12 @@ private slots:
void onSwitchAutoColorTempToggoled(bool checked);
void updateColorTempatureValue();
void onSliderColorTempValueChanged(int value);
- void updateCurrentComputerMode(const QString& text);
+ void updateCurrentComputerMode(int idx);
private:
Ui::GeneralSettingsPage *ui;
PowerInterface* m_powerInterface;
KWinColorCorrect* m_kwinColorCorrect;
- PowerProfilesWrapper* m_powerprofiles;
QTimer m_brightnessSettingTimer;
QTimer m_idleTimeSettingTimer;
QTimer m_colorTempSettingTimer;
diff --git a/translations/kiran-control-panel.zh_CN.ts b/translations/kiran-control-panel.zh_CN.ts
index 31fc01e..83cac3b 100644
--- a/translations/kiran-control-panel.zh_CN.ts
+++ b/translations/kiran-control-panel.zh_CN.ts
@@ -2297,50 +2297,65 @@
<translation>待机时唤醒需要输入密码</translation>
</message>
<message>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="121"/>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="134"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="119"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="132"/>
<source>shutdown</source>
<translation>关机</translation>
</message>
<message>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="122"/>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="128"/>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="133"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="120"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="126"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="131"/>
<source>hibernate</source>
<translation>休眠</translation>
</message>
<message>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="123"/>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="127"/>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="132"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="121"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="125"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="130"/>
<source>suspend</source>
<translation>待机</translation>
</message>
<message>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="124"/>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="129"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="122"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="127"/>
<source>display off</source>
<translation>关闭显示器</translation>
</message>
<message>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="125"/>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="130"/>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="135"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="123"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="128"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="133"/>
<source>do nothing</source>
<translation>不执行操作</translation>
</message>
<message>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="414"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="154"/>
+ <source>Energy-saving mode</source>
+ <translation>节能模式</translation>
+ </message>
+ <message>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="155"/>
+ <source>Balanced mode</source>
+ <translation>平衡模式</translation>
+ </message>
+ <message>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="156"/>
+ <source>High performance mode</source>
+ <translation>高性能模式</translation>
+ </message>
+ <message>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="422"/>
<source>ERROR</source>
<translation>错误</translation>
</message>
<message>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="530"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="549"/>
<source>%1hour</source>
<translation>%1小时</translation>
</message>
<message>
- <location filename="../plugins/power/pages/general-settings-page.cpp" line="534"/>
+ <location filename="../plugins/power/pages/general-settings-page.cpp" line="553"/>
<source>%1minute</source>
<translation>%1分钟</translation>
</message>
@@ -4329,22 +4344,16 @@ This is line 50 of the test text</source>
<context>
<name>PowerProfilesWrapper</name>
<message>
- <location filename="../plugins/power/dbus/power-profiles-wrapper.cpp" line="97"/>
- <location filename="../plugins/power/dbus/power-profiles-wrapper.cpp" line="113"/>
<source>power-saver</source>
- <translation>省电模式</translation>
+ <translation type="vanished">省电模式</translation>
</message>
<message>
- <location filename="../plugins/power/dbus/power-profiles-wrapper.cpp" line="98"/>
- <location filename="../plugins/power/dbus/power-profiles-wrapper.cpp" line="114"/>
<source>balanced</source>
- <translation>平衡模式</translation>
+ <translation type="vanished">平衡模式</translation>
</message>
<message>
- <location filename="../plugins/power/dbus/power-profiles-wrapper.cpp" line="99"/>
- <location filename="../plugins/power/dbus/power-profiles-wrapper.cpp" line="115"/>
<source>performance</source>
- <translation>性能模式</translation>
+ <translation type="vanished">性能模式</translation>
</message>
</context>
<context>
--
2.33.0

View File

@ -0,0 +1,35 @@
From b3ac61f93e733f3ec0d9cea4452d0eee159e8957 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Mon, 15 Jan 2024 17:52:29 +0800
Subject: [PATCH 16/17] fix(launcher): Fix the space before the parameter
causing a jump event when the launcher jumps
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复启动器跳转时参数前的空格导致跳转失败
Closes #24794
---
src/main.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/main.cpp b/src/main.cpp
index 981fdbf..4258832 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -65,7 +65,11 @@ void processCommandLine()
cmdParser.process(*singleApp);
QString category = cmdParser.value(categoryOption);
+ category = category.trimmed();
+
QString subItem = cmdParser.value(subItemOption);
+ subItem = subItem.trimmed();
+
if( !subItem.isEmpty() && category.isEmpty() )
{
std::cerr << "failed to set sub item without category" << std::endl;
--
2.33.0

View File

@ -1,125 +0,0 @@
From 74f15f8c5e6bf30a990ebf71def1c29581e67c85 Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Tue, 17 Oct 2023 09:33:24 +0800
Subject: [PATCH] fix(tray):Fixed an issue where the popup was in the wrong
position when the tray was at the top of the screen
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复托盘在屏幕顶部时,弹窗位置不对的问题
Related #17279
---
.../src/system-tray/audio-system-tray.cpp | 32 +++++++++++++------
.../audio/src/system-tray/audio-system-tray.h | 2 +-
plugins/network/src/tray/network-tray.cpp | 16 +++++++---
3 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/plugins/audio/src/system-tray/audio-system-tray.cpp b/plugins/audio/src/system-tray/audio-system-tray.cpp
index 0c6aca6..cc4015d 100644
--- a/plugins/audio/src/system-tray/audio-system-tray.cpp
+++ b/plugins/audio/src/system-tray/audio-system-tray.cpp
@@ -162,7 +162,19 @@ void AudioSystemTray::setVolumeSettingPos()
int pageWidth = 300;
int pageHeight = 66;
- m_volumenPopup->setGeometry(xTray - pageWidth / 2, yTray - pageHeight - offset, pageWidth, pageHeight);
+ int showPosY;
+ // 托盘程序在顶端
+ if(m_yTray == 0)
+ {
+ showPosY = m_heightTray - offset;
+ }
+ else
+ {
+ //托盘程序在底部
+ showPosY = m_yTray - pageHeight - offset;
+ }
+
+ m_volumenPopup->setGeometry(m_xTray - pageWidth / 2, showPosY, pageWidth, pageHeight);
}
void AudioSystemTray::handleMixedSettingClicked()
@@ -180,7 +192,7 @@ void AudioSystemTray::setMixedSettingPos()
int width = m_mixedPopup->sizeHint().width();
m_mixedPopup->setFixedHeight(height + offset * 2);
- m_mixedPopup->move(xTray - width / 2, yTray - height - offset);
+ m_mixedPopup->move(m_xTray - width / 2, m_yTray - height - offset);
}
void AudioSystemTray::handleAdjustedMixedSettingPageSize()
@@ -228,15 +240,15 @@ void AudioSystemTray::getTrayGeometry()
}
}
}
- heightTray = static_cast<int>(height);
- widthTray = static_cast<int>(width);
- xTray = static_cast<int>(x);
- yTray = static_cast<int>(y);
+ m_heightTray = static_cast<int>(height);
+ m_widthTray = static_cast<int>(width);
+ m_xTray = static_cast<int>(x);
+ m_yTray = static_cast<int>(y);
KLOG_DEBUG() << "getTrayGeometry ";
- KLOG_DEBUG() << "heightTray" << heightTray;
- KLOG_DEBUG() << "widthTray" << widthTray;
- KLOG_DEBUG() << "xTray" << xTray;
- KLOG_DEBUG() << "yTray" << yTray;
+ KLOG_DEBUG() << "heightTray" << m_heightTray;
+ KLOG_DEBUG() << "widthTray" << m_widthTray;
+ KLOG_DEBUG() << "xTray" << m_xTray;
+ KLOG_DEBUG() << "yTray" << m_yTray;
}
// XXX:频繁调用函数,需要优化
diff --git a/plugins/audio/src/system-tray/audio-system-tray.h b/plugins/audio/src/system-tray/audio-system-tray.h
index a61284e..fd5f150 100644
--- a/plugins/audio/src/system-tray/audio-system-tray.h
+++ b/plugins/audio/src/system-tray/audio-system-tray.h
@@ -70,7 +70,7 @@ private:
AudioInterface* m_audioInterface;
QString m_colorTheme;
- int xTray, yTray, heightTray, widthTray;
+ int m_xTray, m_yTray, m_heightTray, m_widthTray;
QDBusServiceWatcher *m_dbusServiceWatcher;
};
diff --git a/plugins/network/src/tray/network-tray.cpp b/plugins/network/src/tray/network-tray.cpp
index dd5ff12..c43d8ff 100644
--- a/plugins/network/src/tray/network-tray.cpp
+++ b/plugins/network/src/tray/network-tray.cpp
@@ -305,16 +305,24 @@ void NetworkTray::showOrHideTrayPage()
void NetworkTray::setTrayPagePos()
{
- // KLOG_DEBUG() << "this->sizeHint():" << this->sizeHint();
- // KLOG_DEBUG() << "this->size():" << this->size();
-
int pageHeight = this->size().height();
int pageWidth = this->size().width();
getTrayGeometry();
// 抵消KiranRoundedTrayPopup的margin
int offset = 8;
- this->move(m_xTray - pageWidth / 2, m_yTray - pageHeight + offset);
+ int showPosY;
+ // 托盘程序在顶端
+ if(m_yTray == 0)
+ {
+ showPosY = m_heightTray - offset;
+ }
+ else
+ {
+ //托盘程序在底部
+ showPosY = m_yTray - pageHeight + offset;
+ }
+ this->move(m_xTray - pageWidth / 2, showPosY);
}
void NetworkTray::getTrayGeometry()
--
2.33.0

View File

@ -0,0 +1,75 @@
From 251cff7db6e926b9df02276acf49d80c8e8b958f Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Tue, 9 Jan 2024 17:13:10 +0800
Subject: [PATCH 17/17] fix(audio):fixed volume tray icon level display not
meeting requirements
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复音量托盘图标级别显示不符合需求
Close #25235
---
plugins/audio/src/system-tray/audio-system-tray.cpp | 4 ++--
plugins/audio/src/system-tray/volume-setting-page.cpp | 4 ++--
plugins/network/src/signal-forward.cpp | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/plugins/audio/src/system-tray/audio-system-tray.cpp b/plugins/audio/src/system-tray/audio-system-tray.cpp
index ed4412f..b20ad15 100644
--- a/plugins/audio/src/system-tray/audio-system-tray.cpp
+++ b/plugins/audio/src/system-tray/audio-system-tray.cpp
@@ -266,12 +266,12 @@ void AudioSystemTray::setTrayIcon(int value)
icon.addPixmap(trayIconColorSwitch("kcp-audio-mute"));
icon.addPixmap(trayIconColorSwitch("kcp-audio-mute", 64));
}
- else if (0 < value && value <= 33)
+ else if (0 < value && value <= 34)
{
icon.addPixmap(trayIconColorSwitch("kcp-audio-low"));
icon.addPixmap(trayIconColorSwitch("kcp-audio-low", 64));
}
- else if (33 < value && value <= 66)
+ else if (33 < value && value <= 67)
{
icon.addPixmap(trayIconColorSwitch("kcp-audio-medium"));
icon.addPixmap(trayIconColorSwitch("kcp-audio-medium", 64));
diff --git a/plugins/audio/src/system-tray/volume-setting-page.cpp b/plugins/audio/src/system-tray/volume-setting-page.cpp
index dbb1cd8..d95b039 100644
--- a/plugins/audio/src/system-tray/volume-setting-page.cpp
+++ b/plugins/audio/src/system-tray/volume-setting-page.cpp
@@ -239,11 +239,11 @@ void VolumeSettingPage::setVolumeIcon(int value)
{
ui->muteButton->setIcon(trayIconColorSwitch("kcp-audio-mute"));
}
- else if (0 < value && value <= 33)
+ else if (0 < value && value <= 34)
{
ui->muteButton->setIcon(trayIconColorSwitch("kcp-audio-low"));
}
- else if (33 < value && value <= 66)
+ else if (33 < value && value <= 67)
{
ui->muteButton->setIcon(trayIconColorSwitch("kcp-audio-medium"));
}
diff --git a/plugins/network/src/signal-forward.cpp b/plugins/network/src/signal-forward.cpp
index 82f4de9..de8415d 100644
--- a/plugins/network/src/signal-forward.cpp
+++ b/plugins/network/src/signal-forward.cpp
@@ -172,10 +172,10 @@ void SignalForward::addDevice(const QString &uni)
switch (device->type())
{
case Device::Type::Ethernet:
- emit wiredDeviceAdded(uni);;
+ emit wiredDeviceAdded(uni);
break;
case Device::Type::Wifi:
- emit wirelessDeviceAdded(uni);;
+ emit wirelessDeviceAdded(uni);
break;
default:
emit otherDeviceAdded(uni);
--
2.33.0

View File

@ -1,30 +0,0 @@
From e21e0b228328722ded74ffa92668338544d9c0cd Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Thu, 19 Oct 2023 13:59:27 +0800
Subject: [PATCH 2/2] fix(network-tray):Fixed a flash issue when the tray
position changed from bottom to top, the first time to click the tray, the
page display position is not correct, resulting in a flash issue
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复托盘位置由底部变为顶部时,第一次点击托盘,页面显示位置不对,导致的闪现问题
---
plugins/network/src/tray/network-tray.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugins/network/src/tray/network-tray.cpp b/plugins/network/src/tray/network-tray.cpp
index c43d8ff..9834a0e 100644
--- a/plugins/network/src/tray/network-tray.cpp
+++ b/plugins/network/src/tray/network-tray.cpp
@@ -282,6 +282,7 @@ void NetworkTray::showOrHideTrayPage()
this->hide();
else
{
+ setTrayPagePos();
// XXX:托盘界面在不可见的情况不方便去修改size和位置暂时先显示后在调整大小和位置
// this->setFixedSize(258, 258);
this->show();
--
2.33.0

View File

@ -1,29 +1,30 @@
Name: kiran-control-panel
Version: 2.5.5
Release: 13%{?dist}
Version: 2.6.0
Release: 6%{?dist}
Summary: Kiran Control Panel
Summary(zh_CN): Kiran桌面控制面板
License: MulanPSL-2.0
Source0: %{name}-%{version}.tar.gz
Patch0001: 0001-fix-network-After-receiving-the-Connection-Update-si.patch
Patch0002: 0002-feature-display-When-switching-resolutions-refresh-r.patch
Patch0003: 0003-fix-wallpaper-change-system-wallpaper-xml-path-to-ki.patch
Patch0004: 0004-fix-wallpaper-don-t-call-xmlWriter-if-system-backgro.patch
Patch0005: 0005-fix-account-Fixed-issues-related-to-creating-and-del.patch
Patch0006: 0006-feature-network-When-the-gateway-setting-item-is-0.0.patch
Patch0007: 0007-fix-audio-Fix-parsing-error-when-json-contains-Chine.patch
Patch0008: 0008-fix-audio-tray-Fixed-an-issue-where-the-volume-tray-.patch
Patch0009: 0009-fix-audio-The-Sink-Source-device-list-displays-only-.patch
Patch0010: 0010-fix-kiran-control-panel-fits-the-Qt5.9.7-interface.patch
Patch0011: 0011-fix-tray-icon-Fixed-an-issue-where-the-tray-icon-was.patch
Patch0012: 0012-fix-network-tray-Improved-the-notification-logic.-Wi.patch
Patch0013: 0013-fix-network-Modify-DNS-Settings-and-display-DNS-deta.patch
Patch0014: 0014-fix-tray-Fixed-the-tray-menu-using-the-X11-platform-.patch
Patch0015: 0015-fix-network-tray-Fixed-an-issue-where-the-size-Setti.patch
Patch0016: 0016-fix-tray-Fixed-an-issue-where-the-popup-was-in-the-w.patch
Patch0017: 0017-fix-network-tray-Fixed-a-flash-issue-when-the-tray-p.patch
Patch0000: 0000-fix-pkgconfig-Fix-the-issue-of-incorrect-content-in-.patch
Patch0001: 0001-fix-appearance-remove-the-Kiran-and-Adwaita-icon-the.patch
Patch0002: 0002-fix-plugins-Fix-runtime-plugin-loading-errors.patch
Patch0003: 0003-fix-LC_TIME-set-LC_TIME-to-UTF-8.patch
Patch0004: 0004-fix-network-fix-compile-issues-QString-SkipEmptyPart.patch
Patch0005: 0005-fix-audio-listen-to-mute-property-change-to-fix-shor.patch
Patch0006: 0006-fix-network-fixd-an-issue-where-the-network-tray-ico.patch
Patch0007: 0007-fix-application-add-a-compilation-switch-to-control-.patch
Patch0008: 0008-refactor-account-Remove-useless-password-encryption-.patch
Patch0009: 0009-fix-translations-Fix-translation-errors-in-battery-s.patch
Patch00010: 0010-fix-account-Fix-the-issue-of-setting-default-selecti.patch
Patch00011: 0011-fix-build-delete-useless-methods.patch
Patch00012: 0012-fix-font-Fix-the-issue-of-ineffective-font-changes.patch
Patch00013: 0013-fix-theme-change-the-light-and-dark-theme-name.patch
Patch00014: 0014-fix-shortcut-add-custom-app-icon-Error-prompt-for-mo.patch
Patch00015: 0015-fix-power-profile-mode-using-kiran-cc-daemon-power-i.patch
Patch00016: 0016-fix-launcher-Fix-the-space-before-the-parameter-caus.patch
Patch00017: 0017-fix-audio-fixed-volume-tray-icon-level-display-not-m.patch
BuildRequires: gcc-c++
BuildRequires: cmake >= 3.2
@ -49,6 +50,8 @@ BuildRequires: kiran-qt5-integration-devel
BuildRequires: kiran-qdbusxml2cpp
BuildRequires: kiran-cc-daemon-devel
BuildRequires: kiran-authentication-service-devel >= 2.5
BuildRequires: libqtxdg-devel
BuildRequires: kf5-kconfig-devel
Requires: qt5-qtbase
Requires: qt5-qtbase-gui
@ -63,7 +66,6 @@ Requires: kiran-qt5-integration >= 2.4
Requires: kiran-system-daemon >= 2.4
Requires: kiran-session-daemon >= 2.4
Requires: kiran-authentication-service >= 2.5
Requires: kiran-wallpapers >= 2.3.0-6
Requires: glib2
Requires: upower
@ -71,6 +73,8 @@ Requires: zeromq
Requires: libnotify
Requires: pam
Requires: cryptopp
Requires: libqtxdg
Requires: kf5-kconfig
Requires: NetworkManager-l2tp
#Requires: NetworkManager-pptp
@ -79,7 +83,6 @@ Requires: NetworkManager-l2tp
Requires: group-service
%endif
Obsoletes: kiran-cpanel-account < 2.3
Obsoletes: kiran-cpanel-appearance < 2.3
Obsoletes: kiran-cpanel-display < 2.3
@ -130,15 +133,7 @@ Summary: Development files for kiran control panel plugin
%build
%{__mkdir} -p %{buildroot}
%if "%{ks_custom_name}" == "GC"
%cmake -DENABLE_USER_GROUP:BOOL=ON \
-DENABLE_NETWORK:BOOL=OFF \
-DENABLE_AUDIO:BOOL=OFF \
-DMOUSE_WHEEL_TEST_VISIBLE:BOOL=ON \
-DMODIFIER_LOCK_TIPS_VISIBLE:BOOL=ON
%else
%cmake
%endif
%cmake
make %{?_smp_mflags}
@ -152,22 +147,18 @@ make %{?_smp_mflags}
%{_datadir}/kiran-control-panel/*
%{_datadir}/icons/hicolor/*
%exclude %{_datadir}/applications/kiran-control-panel.desktop
#account
%{_sysconfdir}/kiran-cpanel-account/
%{_libexecdir}/kiran-avatar-editor
%{_datadir}/kiran-cpanel-account/*
%if "%{ks_custom_name}" != "GC"
#audio
%{_sysconfdir}/xdg/autostart/kiran-audio-status-icon.desktop
%{_bindir}/kiran-audio-status-icon
#network
%{_sysconfdir}/xdg/autostart/kiran-network-status-icon.desktop
%{_bindir}/kiran-network-status-icon
/etc/NetworkManager/conf.d/00-server.conf
%endif
#audio
%{_sysconfdir}/xdg/autostart/kiran-audio-status-icon.desktop
%{_bindir}/kiran-audio-status-icon
#network
%{_sysconfdir}/xdg/autostart/kiran-network-status-icon.desktop
%{_bindir}/kiran-network-status-icon
/etc/NetworkManager/conf.d/00-server.conf
%files -n kiran-cpanel-launcher
%{_bindir}/kiran-cpanel-launcher
@ -181,6 +172,9 @@ make %{?_smp_mflags}
rm -rf %{buildroot}
%changelog
* Thu Jan 18 2024 luoqing <luoqing@kylinsec.com.cn> - 2.6.0-6
- Update to 2.6.0-6
* Mon Oct 23 2023 luoqing <luoqing@kylinsec.com.cn> - 2.5.5-13
- KYOS-F: Fixed a flash issue when the tray position changed from bottom to top, the first time to click the tray, the page display position is not correct, resulting in a flash issue