475 lines
19 KiB
Diff
475 lines
19 KiB
Diff
From 7b743193e9baf70403f29d90cf7f0cd280adba67 Mon Sep 17 00:00:00 2001
|
|
From: yuanxing <yuanxing@kylinsec.com.cn>
|
|
Date: Thu, 13 Jul 2023 10:42:11 +0800
|
|
Subject: [PATCH 2/2] fix(keybord):add modifier lock tip with option
|
|
MODIFIER_LOCK_TIPS_VISIBLE
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
- 添加编译选项MODIFIER_LOCK_TIPS_VISIBLE来显示修饰键锁定提示
|
|
|
|
Fix #9379
|
|
---
|
|
plugins/keyboard/CMakeLists.txt | 7 ++
|
|
....kylinsec.Kiran.SessionDaemon.Keyboard.xml | 29 ++++++
|
|
.../src/pages/general/general-page.cpp | 98 ++++++++++++++++---
|
|
.../keyboard/src/pages/general/general-page.h | 7 +-
|
|
.../src/pages/general/general-page.ui | 87 +++++++++++++++-
|
|
.../kiran-cpanel-keyboard.zh_CN.ts | 38 ++++---
|
|
6 files changed, 233 insertions(+), 33 deletions(-)
|
|
|
|
diff --git a/plugins/keyboard/CMakeLists.txt b/plugins/keyboard/CMakeLists.txt
|
|
index f00f095..1d14652 100644
|
|
--- a/plugins/keyboard/CMakeLists.txt
|
|
+++ b/plugins/keyboard/CMakeLists.txt
|
|
@@ -1,5 +1,7 @@
|
|
set(TARGET_NAME kiran-cpanel-keyboard)
|
|
|
|
+option(MODIFIER_LOCK_TIPS_VISIBLE "Is modifire lock tips visible" OFF)
|
|
+
|
|
file(GLOB TS_FILES "translation/*.ts")
|
|
qt5_create_translation(KEYBOARD_QM ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
|
|
|
|
@@ -36,6 +38,11 @@ target_link_libraries(${TARGET_NAME}
|
|
${KLOG_LIBRARIES}
|
|
${KIRAN_STYLE_LIBRARIES})
|
|
|
|
+if (MODIFIER_LOCK_TIPS_VISIBLE)
|
|
+ add_definitions(-DMODIFIER_LOCK_TIPS)
|
|
+endif ()
|
|
+
|
|
+
|
|
install(TARGETS ${TARGET_NAME}
|
|
DESTINATION ${PLUGIN_LIBS_INSTALL_DIR}/)
|
|
|
|
diff --git a/plugins/keyboard/data/com.kylinsec.Kiran.SessionDaemon.Keyboard.xml b/plugins/keyboard/data/com.kylinsec.Kiran.SessionDaemon.Keyboard.xml
|
|
index 4c7c1a9..9f535fa 100644
|
|
--- a/plugins/keyboard/data/com.kylinsec.Kiran.SessionDaemon.Keyboard.xml
|
|
+++ b/plugins/keyboard/data/com.kylinsec.Kiran.SessionDaemon.Keyboard.xml
|
|
@@ -48,6 +48,35 @@
|
|
<description>clear layout option.</description>
|
|
</method>
|
|
|
|
+ <method name="SwitchCapsLockTips">
|
|
+ <arg type="b" name="enabled" direction="in">
|
|
+ <summary>enable option.</summary>
|
|
+ </arg>
|
|
+ <description>Switch CapsLock Tips option.</description>
|
|
+ </method>
|
|
+
|
|
+ <method name="SwitchNumLockTips">
|
|
+ <arg type="b" name="enabled" direction="in">
|
|
+ <summary>enable option.</summary>
|
|
+ </arg>
|
|
+ <description>Switch NumLock tips option.</description>
|
|
+ </method>
|
|
+
|
|
+ <property name="modifier_lock_enabled" type="b" access="readwrite">
|
|
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
|
|
+ <description>Whether capslock and numlock is enabled.</description>
|
|
+ </property>
|
|
+
|
|
+ <property name="capslock_tips_enabled" type="b" access="readwrite">
|
|
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
|
|
+ <description>Whether capslock tips is enabled.</description>
|
|
+ </property>
|
|
+
|
|
+ <property name="numlock_tips_enabled" type="b" access="readwrite">
|
|
+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
|
|
+ <description>Whether numlock tips is enabled.</description>
|
|
+ </property>
|
|
+
|
|
<property name="repeat_enabled" type="b" access="readwrite">
|
|
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
|
|
<description>Whether repeat to trigger KeyPress and KeyRelease event when key is pressed.</description>
|
|
diff --git a/plugins/keyboard/src/pages/general/general-page.cpp b/plugins/keyboard/src/pages/general/general-page.cpp
|
|
index 39608a9..dceb93f 100644
|
|
--- a/plugins/keyboard/src/pages/general/general-page.cpp
|
|
+++ b/plugins/keyboard/src/pages/general/general-page.cpp
|
|
@@ -12,19 +12,22 @@
|
|
* Author: yuanxing <yuanxing@kylinsec.com.cn>
|
|
*/
|
|
|
|
-#include "ui_general-page.h"
|
|
#include "general-page.h"
|
|
#include "keyboard_backEnd_proxy.h"
|
|
+#include "ui_general-page.h"
|
|
|
|
#include <kiran-log/qt5-log-i.h>
|
|
+#include <kiran-session-daemon/keyboard-i.h>
|
|
#include <QSharedPointer>
|
|
#include <iostream>
|
|
-#include <kiran-session-daemon/keyboard-i.h>
|
|
|
|
GeneralPage::GeneralPage(QWidget *parent)
|
|
: QWidget(parent),
|
|
- ui(new Ui::GeneralPage),
|
|
- m_keyboardInterface(new KeyboardBackEndProxy(KEYBOARD_DBUS_NAME,KEYBOARD_OBJECT_PATH,QDBusConnection::sessionBus(),this))
|
|
+ ui(new Ui::GeneralPage),
|
|
+ m_keyboardInterface(new KeyboardBackEndProxy(KEYBOARD_DBUS_NAME, KEYBOARD_OBJECT_PATH, QDBusConnection::sessionBus(), this)),
|
|
+ m_modifierLockEnabled(false),
|
|
+ m_capslockTipsEnabled(false),
|
|
+ m_numlockTipsEnabled(false)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
@@ -46,17 +49,62 @@ void GeneralPage::init()
|
|
m_timer = new QTimer(this);
|
|
m_timer->setInterval(100);
|
|
m_timer->setSingleShot(true);
|
|
- connect(m_timer, &QTimer::timeout,this,&GeneralPage::handleSaverTimerTimeOut);
|
|
+ connect(m_timer, &QTimer::timeout, this, &GeneralPage::handleSaverTimerTimeOut);
|
|
|
|
ui->lineEdit_key->setPlaceholderText(tr("Enter characters to test the settings"));
|
|
|
|
+#ifdef MODIFIER_LOCK_TIPS
|
|
+ // 修饰键提示开关
|
|
+ m_modifierLockEnabled = m_keyboardInterface->modifier_lock_enabled();
|
|
+ connect(m_keyboardInterface, &KeyboardBackEndProxy::modifier_lock_enabledChanged, [this](bool enabled) {
|
|
+ KLOG_DEBUG() << "keyboard general setting modifier lock enable changed:" << enabled;
|
|
+ m_modifierLockEnabled = enabled;
|
|
+ ui->widget_modifier_lock->setVisible(enabled);
|
|
+ ui->switch_capsLock_tip->setChecked(m_keyboardInterface->capslock_tips_enabled());
|
|
+ ui->switch_numLock_tip->setChecked(m_keyboardInterface->numlock_tips_enabled());
|
|
+ });
|
|
+
|
|
+ if (m_modifierLockEnabled)
|
|
+ {
|
|
+ //大小写锁定提示
|
|
+ m_capslockTipsEnabled = m_keyboardInterface->capslock_tips_enabled();
|
|
+ ui->switch_capsLock_tip->setChecked(m_capslockTipsEnabled);
|
|
+
|
|
+ connect(ui->switch_capsLock_tip, &KiranSwitchButton::toggled,
|
|
+ this, &GeneralPage::handleSwitchCapsLockTipToggled);
|
|
+ connect(m_keyboardInterface, &KeyboardBackEndProxy::capslock_tips_enabledChanged, [this](bool enabled) {
|
|
+ KLOG_DEBUG() << "keyboard general setting capslock tips enable changed:" << enabled;
|
|
+ m_capslockTipsEnabled = enabled;
|
|
+ ui->switch_capsLock_tip->setChecked(enabled);
|
|
+ });
|
|
+
|
|
+ //数字键盘锁定提示
|
|
+ m_numlockTipsEnabled = m_keyboardInterface->numlock_tips_enabled();
|
|
+ ui->switch_numLock_tip->setChecked(m_numlockTipsEnabled);
|
|
+
|
|
+ connect(ui->switch_numLock_tip, &KiranSwitchButton::toggled,
|
|
+ this, &GeneralPage::handleSwitchNumLockTipsToggled);
|
|
+ connect(m_keyboardInterface, &KeyboardBackEndProxy::numlock_tips_enabledChanged, [this](bool enabled) {
|
|
+ KLOG_DEBUG() << "keyboard general setting numlock tips enable changed:" << enabled;
|
|
+ m_numlockTipsEnabled = enabled;
|
|
+ ui->switch_numLock_tip->setChecked(enabled);
|
|
+ });
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ ui->widget_modifier_lock->hide();
|
|
+ }
|
|
+#else
|
|
+ ui->widget_modifier_lock->hide();
|
|
+#endif
|
|
+
|
|
// 重复键开关
|
|
m_repeateEnabled = m_keyboardInterface->repeat_enabled();
|
|
ui->switch_repeatKey->setChecked(m_repeateEnabled);
|
|
handleSwitchRepeatKeyToggled(m_repeateEnabled);
|
|
- connect(ui->switch_repeatKey,&KiranSwitchButton::toggled,
|
|
- this,&GeneralPage::handleSwitchRepeatKeyToggled);
|
|
- connect(m_keyboardInterface,&KeyboardBackEndProxy::repeat_enabledChanged,[this](bool enabled){
|
|
+ connect(ui->switch_repeatKey, &KiranSwitchButton::toggled,
|
|
+ this, &GeneralPage::handleSwitchRepeatKeyToggled);
|
|
+ connect(m_keyboardInterface, &KeyboardBackEndProxy::repeat_enabledChanged, [this](bool enabled) {
|
|
KLOG_DEBUG() << "keyboard general setting repeat enable changed:" << enabled;
|
|
m_repeateEnabled = enabled;
|
|
ui->switch_repeatKey->setChecked(enabled);
|
|
@@ -65,30 +113,30 @@ void GeneralPage::init()
|
|
// 重复键延时设置
|
|
m_delay = m_keyboardInterface->repeat_delay();
|
|
ui->hslider_delay->setValue(m_delay);
|
|
- connect(ui->hslider_delay,&QSlider::valueChanged,[this](int value){
|
|
+ connect(ui->hslider_delay, &QSlider::valueChanged, [this](int value) {
|
|
m_timer->start();
|
|
});
|
|
- connect(m_keyboardInterface,&KeyboardBackEndProxy::repeat_delayChanged,[this](int delay){
|
|
- if( m_delay!=delay )
|
|
+ connect(m_keyboardInterface, &KeyboardBackEndProxy::repeat_delayChanged, [this](int delay) {
|
|
+ if (m_delay != delay)
|
|
{
|
|
KLOG_DEBUG() << "keyboard general setting repeat delay changed:" << delay;
|
|
- m_delay=delay;
|
|
+ m_delay = delay;
|
|
ui->hslider_delay->setValue(m_delay);
|
|
}
|
|
});
|
|
|
|
-
|
|
// 重复键间隔设置
|
|
m_interval = m_keyboardInterface->repeat_interval();
|
|
ui->hslider_interval->setValue(m_interval);
|
|
- connect(ui->hslider_interval,&QSlider::valueChanged,[this](int value){
|
|
+ connect(ui->hslider_interval, &QSlider::valueChanged, [this](int value) {
|
|
m_timer->start();
|
|
});
|
|
- connect(m_keyboardInterface,&KeyboardBackEndProxy::repeat_intervalChanged,[this](int interval){
|
|
+ connect(m_keyboardInterface, &KeyboardBackEndProxy::repeat_intervalChanged, [this](int interval) {
|
|
if (m_interval != (ui->hslider_interval->maximum() - interval + 10))
|
|
{
|
|
KLOG_DEBUG() << "keyboard general setting repeat interval changed:" << interval;
|
|
- m_interval = ui->hslider_interval->maximum() - interval + 10;;
|
|
+ m_interval = ui->hslider_interval->maximum() - interval + 10;
|
|
+ ;
|
|
ui->hslider_interval->setValue(m_interval);
|
|
}
|
|
});
|
|
@@ -127,3 +175,21 @@ void GeneralPage::handleSwitchRepeatKeyToggled(bool checked)
|
|
m_keyboardInterface->setRepeat_enabled(checked);
|
|
}
|
|
}
|
|
+
|
|
+void GeneralPage::handleSwitchCapsLockTipToggled(bool checked)
|
|
+{
|
|
+ if (m_capslockTipsEnabled != checked)
|
|
+ {
|
|
+ m_capslockTipsEnabled = checked;
|
|
+ m_keyboardInterface->setCapslock_tips_enabled(checked);
|
|
+ }
|
|
+}
|
|
+
|
|
+void GeneralPage::handleSwitchNumLockTipsToggled(bool checked)
|
|
+{
|
|
+ if (m_numlockTipsEnabled != checked)
|
|
+ {
|
|
+ m_numlockTipsEnabled = checked;
|
|
+ m_keyboardInterface->setNumlock_tips_enabled(checked);
|
|
+ }
|
|
+}
|
|
diff --git a/plugins/keyboard/src/pages/general/general-page.h b/plugins/keyboard/src/pages/general/general-page.h
|
|
index e7cce52..985c6dd 100644
|
|
--- a/plugins/keyboard/src/pages/general/general-page.h
|
|
+++ b/plugins/keyboard/src/pages/general/general-page.h
|
|
@@ -38,14 +38,19 @@ private:
|
|
private slots:
|
|
void handleSaverTimerTimeOut();
|
|
void handleSwitchRepeatKeyToggled(bool checked);
|
|
+ void handleSwitchCapsLockTipToggled(bool checked);
|
|
+ void handleSwitchNumLockTipsToggled(bool checked);
|
|
|
|
private:
|
|
Ui::GeneralPage *ui;
|
|
- KeyboardBackEndProxy* m_keyboardInterface;
|
|
+ KeyboardBackEndProxy *m_keyboardInterface;
|
|
QTimer *m_timer = nullptr;
|
|
bool m_repeateEnabled = false;
|
|
qint32 m_delay;
|
|
qint32 m_interval;
|
|
+ bool m_modifierLockEnabled;
|
|
+ bool m_capslockTipsEnabled;
|
|
+ bool m_numlockTipsEnabled;
|
|
};
|
|
|
|
#endif // GENERALPAGE_H
|
|
diff --git a/plugins/keyboard/src/pages/general/general-page.ui b/plugins/keyboard/src/pages/general/general-page.ui
|
|
index e5e12aa..62337f4 100644
|
|
--- a/plugins/keyboard/src/pages/general/general-page.ui
|
|
+++ b/plugins/keyboard/src/pages/general/general-page.ui
|
|
@@ -6,8 +6,8 @@
|
|
<rect>
|
|
<x>0</x>
|
|
<y>0</y>
|
|
- <width>556</width>
|
|
- <height>425</height>
|
|
+ <width>605</width>
|
|
+ <height>497</height>
|
|
</rect>
|
|
</property>
|
|
<property name="windowTitle">
|
|
@@ -29,6 +29,89 @@
|
|
<property name="bottomMargin">
|
|
<number>40</number>
|
|
</property>
|
|
+ <item>
|
|
+ <widget class="QWidget" name="widget_modifier_lock" native="true">
|
|
+ <layout class="QVBoxLayout" name="verticalLayout_5">
|
|
+ <property name="spacing">
|
|
+ <number>16</number>
|
|
+ </property>
|
|
+ <property name="leftMargin">
|
|
+ <number>0</number>
|
|
+ </property>
|
|
+ <property name="topMargin">
|
|
+ <number>0</number>
|
|
+ </property>
|
|
+ <property name="rightMargin">
|
|
+ <number>0</number>
|
|
+ </property>
|
|
+ <property name="bottomMargin">
|
|
+ <number>0</number>
|
|
+ </property>
|
|
+ <item>
|
|
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
|
|
+ <item>
|
|
+ <widget class="QLabel" name="label_5">
|
|
+ <property name="text">
|
|
+ <string>Capslock Tip</string>
|
|
+ </property>
|
|
+ </widget>
|
|
+ </item>
|
|
+ <item>
|
|
+ <spacer name="horizontalSpacer_6">
|
|
+ <property name="orientation">
|
|
+ <enum>Qt::Horizontal</enum>
|
|
+ </property>
|
|
+ <property name="sizeHint" stdset="0">
|
|
+ <size>
|
|
+ <width>40</width>
|
|
+ <height>20</height>
|
|
+ </size>
|
|
+ </property>
|
|
+ </spacer>
|
|
+ </item>
|
|
+ <item>
|
|
+ <widget class="KiranSwitchButton" name="switch_capsLock_tip">
|
|
+ <property name="text">
|
|
+ <string/>
|
|
+ </property>
|
|
+ </widget>
|
|
+ </item>
|
|
+ </layout>
|
|
+ </item>
|
|
+ <item>
|
|
+ <layout class="QHBoxLayout" name="horizontalLayout_8">
|
|
+ <item>
|
|
+ <widget class="QLabel" name="label_7">
|
|
+ <property name="text">
|
|
+ <string>Numlock Tip</string>
|
|
+ </property>
|
|
+ </widget>
|
|
+ </item>
|
|
+ <item>
|
|
+ <spacer name="horizontalSpacer_7">
|
|
+ <property name="orientation">
|
|
+ <enum>Qt::Horizontal</enum>
|
|
+ </property>
|
|
+ <property name="sizeHint" stdset="0">
|
|
+ <size>
|
|
+ <width>40</width>
|
|
+ <height>20</height>
|
|
+ </size>
|
|
+ </property>
|
|
+ </spacer>
|
|
+ </item>
|
|
+ <item>
|
|
+ <widget class="KiranSwitchButton" name="switch_numLock_tip">
|
|
+ <property name="text">
|
|
+ <string/>
|
|
+ </property>
|
|
+ </widget>
|
|
+ </item>
|
|
+ </layout>
|
|
+ </item>
|
|
+ </layout>
|
|
+ </widget>
|
|
+ </item>
|
|
<item>
|
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
<property name="spacing">
|
|
diff --git a/plugins/keyboard/translation/kiran-cpanel-keyboard.zh_CN.ts b/plugins/keyboard/translation/kiran-cpanel-keyboard.zh_CN.ts
|
|
index 882cf4b..8eb7cbe 100644
|
|
--- a/plugins/keyboard/translation/kiran-cpanel-keyboard.zh_CN.ts
|
|
+++ b/plugins/keyboard/translation/kiran-cpanel-keyboard.zh_CN.ts
|
|
@@ -17,68 +17,78 @@
|
|
<translation></translation>
|
|
</message>
|
|
<message>
|
|
- <location filename="../src/pages/general/general-page.ui" line="40"/>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="55"/>
|
|
+ <source>Capslock Tip</source>
|
|
+ <translation>大写锁定提示</translation>
|
|
+ </message>
|
|
+ <message>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="86"/>
|
|
+ <source>Numlock Tip</source>
|
|
+ <translation>数字键盘锁定提示</translation>
|
|
+ </message>
|
|
+ <message>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="123"/>
|
|
<source>Repeat Key</source>
|
|
<translation>重复键</translation>
|
|
</message>
|
|
<message>
|
|
- <location filename="../src/pages/general/general-page.ui" line="47"/>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="130"/>
|
|
<source>(Repeat a key while holding it down)</source>
|
|
<translation>(按住某一键时重复该键)</translation>
|
|
</message>
|
|
<message>
|
|
- <location filename="../src/pages/general/general-page.ui" line="67"/>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="150"/>
|
|
<source>SwitchRepeatKey</source>
|
|
<translation type="unfinished"></translation>
|
|
</message>
|
|
<message>
|
|
- <location filename="../src/pages/general/general-page.ui" line="86"/>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="169"/>
|
|
<source>Delay</source>
|
|
<translation>延时</translation>
|
|
</message>
|
|
<message>
|
|
- <location filename="../src/pages/general/general-page.ui" line="108"/>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="191"/>
|
|
<source>SliderRepeatDelay</source>
|
|
<translation type="unfinished"></translation>
|
|
</message>
|
|
<message>
|
|
- <location filename="../src/pages/general/general-page.ui" line="132"/>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="215"/>
|
|
<source>Short</source>
|
|
<translation>短</translation>
|
|
</message>
|
|
<message>
|
|
- <location filename="../src/pages/general/general-page.ui" line="152"/>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="235"/>
|
|
<source>Long</source>
|
|
<translation>长</translation>
|
|
</message>
|
|
<message>
|
|
- <location filename="../src/pages/general/general-page.ui" line="170"/>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="253"/>
|
|
<source>Interval</source>
|
|
<translation>速度</translation>
|
|
</message>
|
|
<message>
|
|
- <location filename="../src/pages/general/general-page.ui" line="192"/>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="275"/>
|
|
<source>SliderRepeatInterval</source>
|
|
<translation type="unfinished"></translation>
|
|
</message>
|
|
<message>
|
|
- <location filename="../src/pages/general/general-page.ui" line="219"/>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="302"/>
|
|
<source>Slow</source>
|
|
<translation>慢</translation>
|
|
</message>
|
|
<message>
|
|
- <location filename="../src/pages/general/general-page.ui" line="239"/>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="322"/>
|
|
<source>Fast</source>
|
|
<translation>快</translation>
|
|
</message>
|
|
<message>
|
|
- <location filename="../src/pages/general/general-page.ui" line="255"/>
|
|
- <location filename="../src/pages/general/general-page.cpp" line="51"/>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="338"/>
|
|
+ <location filename="../src/pages/general/general-page.cpp" line="54"/>
|
|
<source>Enter characters to test the settings</source>
|
|
<translation>输入字符来测试设置</translation>
|
|
</message>
|
|
<message>
|
|
- <location filename="../src/pages/general/general-page.ui" line="274"/>
|
|
+ <location filename="../src/pages/general/general-page.ui" line="357"/>
|
|
<source>EditTestRepeatKey</source>
|
|
<translation type="unfinished"></translation>
|
|
</message>
|
|
--
|
|
2.27.0
|
|
|