diff --git a/CMakeLists.txt b/CMakeLists.txt
index f976cb85fc33a539510ec8bcec1e391baafc57ba..9a38952cce24e7b92973cf57d1066199e1aa6049 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,7 @@ set(CMAKE_AUTORCC ON)
find_package(PkgConfig REQUIRED)
find_package(Qt5 COMPONENTS Widgets Svg DBus LinguistTools Network)
+find_package(KiranDBusGenerate REQUIRED)
pkg_search_module(KIRAN_WIDGETS_QT5 REQUIRED kiranwidgets-qt5)
pkg_search_module(KLOG_QT5 REQUIRED klog-qt5)
pkg_search_module(KIRAN_CC_DAEMON REQUIRED kiran-cc-daemon)
@@ -24,7 +25,7 @@ pkg_get_variable(CPANEL_PLUGIN_DIR kiran-control-panel plugin_location)
pkg_get_variable(CPANEL_DESKTOP_DIR kiran-control-panel plugin_desktop_location)
set(DATA_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}")
-set(TRANSLATIONS_DIR "${DATA_DIR}/${PROJECT_NAME}/translation/")
+set(TRANSLATIONS_DIR "${DATA_DIR}/${PROJECT_NAME}/translations/")
set(TS_FILES "${PROJECT_SOURCE_DIR}/translations/kiran-cpanel-mouse.zh_CN.ts" )
#添加config.h.in文件
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..ee5839968a2bf86c93283efc09d40fd050b7cfa2
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,127 @@
+ 木兰宽松许可证, 第2版
+
+ 木兰宽松许可证, 第2版
+ 2020年1月 http://license.coscl.org.cn/MulanPSL2
+
+
+ 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
+
+ 0. 定义
+
+ “软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
+
+ “贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
+
+ “贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
+
+ “法人实体”是指提交贡献的机构及其“关联实体”。
+
+ “关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
+
+ 1. 授予版权许可
+
+ 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
+
+ 2. 授予专利许可
+
+ 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
+
+ 3. 无商标许可
+
+ “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
+
+ 4. 分发限制
+
+ 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
+
+ 5. 免责声明与责任限制
+
+ “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
+
+ 6. 语言
+ “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
+
+ 条款结束
+
+ 如何将木兰宽松许可证,第2版,应用到您的软件
+
+ 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
+
+ 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
+
+ 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
+
+ 3, 请将如下声明文本放入每个源文件的头部注释中。
+
+ Copyright (c) [Year] [name of copyright holder]
+ [Software Name] 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.
+
+
+ Mulan Permissive Software License,Version 2
+
+ Mulan Permissive Software License,Version 2 (Mulan PSL v2)
+ January 2020 http://license.coscl.org.cn/MulanPSL2
+
+ Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
+
+ 0. Definition
+
+ Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
+
+ Contribution means the copyrightable work licensed by a particular Contributor under this License.
+
+ Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
+
+ Legal Entity means the entity making a Contribution and all its Affiliates.
+
+ Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
+
+ 1. Grant of Copyright License
+
+ Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
+
+ 2. Grant of Patent License
+
+ Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
+
+ 3. No Trademark License
+
+ No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4.
+
+ 4. Distribution Restriction
+
+ You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
+
+ 5. Disclaimer of Warranty and Limitation of Liability
+
+ THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+ 6. Language
+
+ THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
+
+ END OF THE TERMS AND CONDITIONS
+
+ How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
+
+ To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
+
+ i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
+
+ ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package;
+
+ iii Attach the statement to the appropriate annotated syntax at the beginning of each source file.
+
+
+ Copyright (c) [Year] [name of copyright holder]
+ [Software Name] 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.
diff --git a/README.md b/README.md
index 439fe61d2a47df22be12392274e82d0fa5682cef..1c20c4fc42626aa958e21d2f1149bb433d31b45c 100644
--- a/README.md
+++ b/README.md
@@ -2,10 +2,10 @@ kiran-cpanel-mouse
- 编译
安装编译依赖
- sudo yum install qt5-qtbase-devel kiranwidgets-qt5-devel qt5-linguist kiran-cc-daemon-devel kiran-cc-daemon cmake zlog-devel
+ sudo yum install qt5-qtbase-devel kiran-widgets-qt5-devel qt5-linguist kiran-cc-daemon-devel cmake kiran-log-qt5-devel kiran-control-panel-devel kiran-qdbusxml2cpp
源码根目录下创建build目录mkdir build
进行build目录,执行cmake -DCMAKE_INSTALL_PREFIX=/usr .. 生成Makefile
- 执行make进行编译,生成可执行文件位于build下的kiran-cpanel-mouse
+ 执行make进行编译,生成控制中心插件libkiran-cpanel-mouse.so
- 安装
在build目录下执行sudo make install
@@ -14,5 +14,5 @@ kiran-cpanel-mouse
在build目录下执行sudo make uninstall
- 运行
-编译安装运行后执行kiran-cpanel-mouse
+编译安装运行后执行kiran-cpanel-launcher --cpanel-plugin kiran-cpanel-mouse
diff --git a/config/kiran-cpanel-mouse.desktop.in b/config/kiran-cpanel-mouse.desktop.in
index 1967f4bd088d010c7a9a85fd3fe7f319b2896ab2..13306da066d0ad60d51a4c427c8d2bed06888a52 100644
--- a/config/kiran-cpanel-mouse.desktop.in
+++ b/config/kiran-cpanel-mouse.desktop.in
@@ -6,7 +6,7 @@ Name[zh_CN]=鼠标设置
Comment=Kiran Cpanel Mouse
Comment[zh_CN]=设置鼠标首选项
Exec=kiran-cpanel-launcher --cpanel-plugin=kiran-cpanel-mouse
-Icon=@ICON_DIR@/kiran-cpanel-mouse.png
+Icon=kcp-mouse
Terminal=false
Type=Application
X-KIRAN-NoDisplay=true
diff --git a/resources/images/CMakeLists.txt b/resources/images/CMakeLists.txt
index 8dbcb2a66c2cecddfcb9043fe86108e8852b8a1a..6bf5c52a76f3d465d1b9d2158d2a8a8fa3a52398 100644
--- a/resources/images/CMakeLists.txt
+++ b/resources/images/CMakeLists.txt
@@ -1,5 +1,15 @@
-install(FILES "kcp-mouse.png"
- DESTINATION ${DATA_DIR}/${PROJECT_NAME}/icons/ )
+set(KCP_ICON_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor)
+
+install(FILES "kcp-mouse-24.png"
+ DESTINATION ${KCP_ICON_INSTALL_PATH}/24x24/apps RENAME kcp-mouse.png)
+install(FILES "kcp-mouse-32.png"
+ DESTINATION ${KCP_ICON_INSTALL_PATH}/32x32/apps RENAME kcp-mouse.png)
+install(FILES "kcp-mouse-48.png"
+ DESTINATION ${KCP_ICON_INSTALL_PATH}/48x48/apps RENAME kcp-mouse.png)
+install(FILES "kcp-mouse-64.png"
+ DESTINATION ${KCP_ICON_INSTALL_PATH}/64x64/apps RENAME kcp-mouse.png)
+install(FILES "kcp-mouse-96.png"
+ DESTINATION ${KCP_ICON_INSTALL_PATH}/96x96/apps RENAME kcp-mouse.png)
install(FILES "kcm-page-mouse.svg"
DESTINATION ${DATA_DIR}/${PROJECT_NAME}/icons/ )
diff --git a/resources/images/kcp-mouse-24.png b/resources/images/kcp-mouse-24.png
new file mode 100644
index 0000000000000000000000000000000000000000..a7717140eefa754fb6d2df1829fb0644cca1eb69
Binary files /dev/null and b/resources/images/kcp-mouse-24.png differ
diff --git a/resources/images/kcp-mouse-32.png b/resources/images/kcp-mouse-32.png
new file mode 100644
index 0000000000000000000000000000000000000000..cc38287b494365b4e8ad28c11c6d87bce9c2f127
Binary files /dev/null and b/resources/images/kcp-mouse-32.png differ
diff --git a/resources/images/kcp-mouse-48.png b/resources/images/kcp-mouse-48.png
new file mode 100644
index 0000000000000000000000000000000000000000..2023f8804610558ce558e4ca9c32cc4d5b1ce0df
Binary files /dev/null and b/resources/images/kcp-mouse-48.png differ
diff --git a/resources/images/kcp-mouse-64.png b/resources/images/kcp-mouse-64.png
new file mode 100644
index 0000000000000000000000000000000000000000..15f0368e3fc0529be21f8d2581f43befa4c9a8a4
Binary files /dev/null and b/resources/images/kcp-mouse-64.png differ
diff --git a/resources/images/kcp-mouse-96.png b/resources/images/kcp-mouse-96.png
new file mode 100644
index 0000000000000000000000000000000000000000..626f2c526ff1886af03cac7eb2a68b76cea14366
Binary files /dev/null and b/resources/images/kcp-mouse-96.png differ
diff --git a/resources/images/kcp-mouse.png b/resources/images/kcp-mouse.png
deleted file mode 100644
index 829cd0925ab26cc1526224bbe7bb1de656acf549..0000000000000000000000000000000000000000
Binary files a/resources/images/kcp-mouse.png and /dev/null differ
diff --git a/resources/resources.qrc b/resources/resources.qrc
index 2b77da7bd4e65a8f5d33e3a87d708d4bdfe854c6..6ad60b0db8810c2890080b43c60053facacd73c1 100644
--- a/resources/resources.qrc
+++ b/resources/resources.qrc
@@ -8,6 +8,6 @@
images/disable_on.png
images/kcm-page-mouse.svg
images/kcm-page-touchpad.svg
- images/kcp-mouse.png
+ images/kcp-mouse-24.png
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 44f9638b77fcc6d273f7f6bd565b6c5a6a3ef7d1..c71e7adf455cfe17c473195372d72ea683aa9cfa 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,23 +10,25 @@ file(GLOB_RECURSE HEADERS "*.h")
file(GLOB_RECURSE FORMS "*.ui")
file(GLOB_RECURSE RESOURCES "${PROJECT_SOURCE_DIR}/resources/*.qrc")
-qt5_create_translation( QM_FILES ${TS_FILES} )
+qt5_create_translation( QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES} )
set_source_files_properties(${MOUSE_DBUS} PROPERTIES
- CLASSNAME "KSMMouseProxy"
+ CLASSNAME "MouseBackEndProxy"
+ NO_NAMESPACE true
)
set_source_files_properties(${TOUCHPAD_DBUS} PROPERTIES
- CLASSNAME "KSMTouchPadProxy"
+ CLASSNAME "TouchPadBackEndProxy"
+ NO_NAMESPACE true
)
-qt5_add_dbus_interface(MOUSE_PROXY
+kiran_qt5_add_dbus_interface(MOUSE_PROXY
${MOUSE_DBUS}
- KSMMouseProxy
+ mouse_backEnd_proxy
)
-qt5_add_dbus_interface(TOUCHPAD_PROXY
+kiran_qt5_add_dbus_interface(TOUCHPAD_PROXY
${TOUCHPAD_DBUS}
- KSMTouchPadProxy
+ touchPad_backEnd_proxy
)
add_library(${PROJECT_NAME} SHARED
diff --git a/src/kcm-manager.cpp b/src/kcm-manager.cpp
index 3c828deeff5bcafbf0ea0d0d48a3cf7335d824fe..5403c118e071a80d5fbc1354e4de68e52bf6b004 100644
--- a/src/kcm-manager.cpp
+++ b/src/kcm-manager.cpp
@@ -16,17 +16,10 @@
#include
#include
#include
-#include "KSMMouseProxy.h"
-#include "KSMTouchPadProxy.h"
+#include "mouse_backEnd_proxy.h"
+#include "touchPad_backEnd_proxy.h"
KCMManager::KCMManager(QObject *parent) : QObject(parent)
{
- m_mouseInterface = QSharedPointer(new KSMMouseProxy(MOUSE_DBUS_NAME,
- MOUSE_OBJECT_PATH,
- QDBusConnection::sessionBus()));
-
- m_touchPadInterface = QSharedPointer(new KSMTouchPadProxy(TOUCHPAD_DBUS_NAME,
- TOUCHPAD_OBJECT_PATH,
- QDBusConnection::sessionBus()));
}
KCMManager::~KCMManager()
@@ -40,13 +33,20 @@ bool KCMManager::isValidConnect()
return true;
}
-QSharedPointer KCMManager::getMouseInterface()
+QSharedPointer KCMManager::getMouseInterface()
{
+ m_mouseInterface = QSharedPointer(new MouseBackEndProxy(MOUSE_DBUS_NAME,
+ MOUSE_OBJECT_PATH,
+ QDBusConnection::sessionBus()));
+
return m_mouseInterface;
}
-QSharedPointer KCMManager::getTouchPadInterface()
+QSharedPointer KCMManager::getTouchPadInterface()
{
+ m_touchPadInterface = QSharedPointer(new TouchPadBackEndProxy(TOUCHPAD_DBUS_NAME,
+ TOUCHPAD_OBJECT_PATH,
+ QDBusConnection::sessionBus()));
return m_touchPadInterface;
}
diff --git a/src/kcm-manager.h b/src/kcm-manager.h
index 13a172c563016c6956d15aeea1be34568e8cfec1..1b854fec1d21bb58683f9cd98beead4be5a324d2 100644
--- a/src/kcm-manager.h
+++ b/src/kcm-manager.h
@@ -18,8 +18,8 @@
#include
#include
-class KSMMouseProxy;
-class KSMTouchPadProxy;
+class MouseBackEndProxy;
+class TouchPadBackEndProxy;
class KCMManager : public QObject
{
Q_OBJECT
@@ -28,13 +28,13 @@ public:
~KCMManager();
bool isValidConnect();
- QSharedPointer getMouseInterface();
- QSharedPointer getTouchPadInterface();
+ QSharedPointer getMouseInterface();
+ QSharedPointer getTouchPadInterface();
bool hasTouchPad();
private:
- QSharedPointer m_mouseInterface;
- QSharedPointer m_touchPadInterface;
+ QSharedPointer m_mouseInterface;
+ QSharedPointer m_touchPadInterface;
};
#endif // KCMMANAGER_H
diff --git a/src/kcp-interface.cpp b/src/kcp-interface.cpp
index d0cf2852db8e208a13d56a83b0881019d5af9731..ddf504480ffe9884d37e3ac26f78a47d23fe4e83 100644
--- a/src/kcp-interface.cpp
+++ b/src/kcp-interface.cpp
@@ -15,13 +15,18 @@
#include "kcp-interface.h"
#include
#include
+#include
+#include
#include
+#include
+#include
#include
#include
#include
#include "config/config.h"
#include "kcm-manager.h"
#include "mouse-page.h"
+#include "touchPad_backEnd_proxy.h"
#include "touchpad-page.h"
KcpInterface::KcpInterface()
@@ -78,12 +83,19 @@ void KcpInterface::uninit()
int KcpInterface::init()
{
m_kcmManager = new KCMManager;
- if (!m_kcmManager->isValidConnect())
+ if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(MOUSE_DBUS_NAME).value() &&
+ !QDBusConnection::sessionBus().interface()->isServiceRegistered(TOUCHPAD_DBUS_NAME).value())
{
- KLOG_DEBUG() << "Connect mouse or touchpad dbus service failed!";
+ KLOG_INFO() << "Connect mouse or touchpad dbus service failed!";
return -1;
}
- m_hasTouchPad = m_kcmManager->hasTouchPad();
+
+ QSharedPointer touchPadInterface = m_kcmManager->getTouchPadInterface();
+ m_hasTouchPad = touchPadInterface->has_touchpad();
+ touchPadInterface.clear();
+
+ if (!m_hasTouchPad)
+ KLOG_INFO() << "system don't have touchPad";
//加载翻译文件
if (m_translator != nullptr)
{
diff --git a/src/mouse-page.cpp b/src/mouse-page.cpp
index ec04c6c8fa0992118bc8dbbfe22cc026f5fb47f3..d0bf8b3ecd95159a54651be4eae51d21b0b2f6be 100644
--- a/src/mouse-page.cpp
+++ b/src/mouse-page.cpp
@@ -16,8 +16,8 @@
#include
#include
#include
-#include "KSMMouseProxy.h"
#include "kcm-manager.h"
+#include "mouse_backEnd_proxy.h"
#include "ui_mouse-page.h"
#define TIMEOUT 100
@@ -75,7 +75,6 @@ void MousePage::initUI()
delete kcmManager;
kcmManager = nullptr;
- setStyleSheet("#scrollAreaWidgetContents{border-left:1px solid #2d2d2d;}");
QStringList hand_mode;
hand_mode << tr("Right Hand Mode") << tr("Left Hand Mode");
ui->comboBox_hand_mode->addItems(hand_mode);
@@ -100,21 +99,39 @@ void MousePage::initComponent()
m_mouseLeftHand = currentIntex;
m_mouseInterface->setLeft_handed(m_mouseLeftHand);
});
+ connect(
+ m_mouseInterface.data(), &MouseBackEndProxy::left_handedChanged, this,
+ [this](bool value) {
+ if (m_mouseLeftHand != value)
+ {
+ m_mouseLeftHand = value;
+ ui->comboBox_hand_mode->blockSignals(true);
+ ui->comboBox_hand_mode->setCurrentIndex(m_mouseLeftHand);
+ ui->comboBox_hand_mode->blockSignals(false);
+ }
+ },
+ Qt::QueuedConnection);
m_mouseMotionAcceleration = m_mouseInterface->motion_acceleration();
int speed = m_mouseMotionAcceleration / 2.0 * SLIDER_MAXIMUN + SLIDER_MAXIMUN / 2;
ui->slider_speed->setValue(speed);
- // 监听滑动条值变化信号,当用户拖动滑动条时,只有在鼠标松开后才会根据值范围确定滑动条值
- connect(ui->slider_speed, &QSlider::sliderPressed, [this]() {
- m_mousePressed = true;
- });
- connect(ui->slider_speed, &QSlider::sliderReleased, [this]() {
- m_mousePressed = false;
- emit ui->slider_speed->valueChanged(ui->slider_speed->value());
- });
connect(ui->slider_speed, &QSlider::valueChanged, this, &MousePage::onSliderValueChange);
+ connect(
+ m_mouseInterface.data(), &MouseBackEndProxy::motion_accelerationChanged, this,
+ [this](double value) {
+ if (m_mouseMotionAcceleration != value)
+ {
+ m_mouseMotionAcceleration = value;
+ int speed = value / 2.0 * SLIDER_MAXIMUN + SLIDER_MAXIMUN / 2;
+ ui->slider_speed->blockSignals(true);
+ ui->slider_speed->setValue(speed);
+ ui->slider_speed->blockSignals(false);
+ }
+ },
+ Qt::QueuedConnection);
+
m_mouseNaturalScroll = m_mouseInterface->natural_scroll();
ui->checkBox_natural_scroll->setChecked(m_mouseNaturalScroll);
connect(ui->checkBox_natural_scroll, &KiranSwitchButton::toggled,
@@ -122,6 +139,18 @@ void MousePage::initComponent()
m_mouseNaturalScroll = ischecked;
m_mouseInterface->setNatural_scroll(ischecked);
});
+ connect(
+ m_mouseInterface.data(), &MouseBackEndProxy::natural_scrollChanged, this,
+ [this](bool value) {
+ if (m_mouseNaturalScroll != value)
+ {
+ m_mouseNaturalScroll = value;
+ ui->checkBox_natural_scroll->blockSignals(true);
+ ui->checkBox_natural_scroll->setChecked(value);
+ ui->checkBox_natural_scroll->blockSignals(false);
+ }
+ },
+ Qt::QueuedConnection);
m_middleEmulationEnabled = m_mouseInterface->middle_emulation_enabled();
ui->checkBox_middle_emulation->setChecked(m_middleEmulationEnabled);
@@ -130,6 +159,18 @@ void MousePage::initComponent()
m_middleEmulationEnabled = ischecked;
m_mouseInterface->setMiddle_emulation_enabled(ischecked);
});
+ connect(
+ m_mouseInterface.data(), &MouseBackEndProxy::middle_emulation_enabledChanged, this,
+ [this](bool value) {
+ if (m_middleEmulationEnabled != value)
+ {
+ m_middleEmulationEnabled = value;
+ ui->checkBox_middle_emulation->blockSignals(true);
+ ui->checkBox_middle_emulation->setChecked(value);
+ ui->checkBox_middle_emulation->blockSignals(false);
+ }
+ },
+ Qt::QueuedConnection);
}
void MousePage::onSliderValueChange()
diff --git a/src/mouse-page.h b/src/mouse-page.h
index 4eaa695a11096b673b5a7742e634c05d87e8e60c..aae0816392b409da3bc4df4fc7fdb0931182bb78 100644
--- a/src/mouse-page.h
+++ b/src/mouse-page.h
@@ -20,7 +20,7 @@
#include
#include
-class KSMMouseProxy;
+class MouseBackEndProxy;
class KiranSwitchButton;
class KiranListItem;
class KiranSwitchButton;
@@ -47,15 +47,13 @@ public slots:
private:
Ui::MousePage *ui;
- QSharedPointer m_mouseInterface;
+ QSharedPointer m_mouseInterface;
bool m_mouseLeftHand = false;
bool m_mouseNaturalScroll = false;
bool m_middleEmulationEnabled = false;
double m_mouseMotionAcceleration = 0.0;
- //鼠标是否按下的标志位
- bool m_mousePressed = false;
QTimer *m_timer = nullptr;
};
diff --git a/src/touchpad-page.cpp b/src/touchpad-page.cpp
index db801c4ed2303fd5235edeb0af3d4eac74794c0b..33ee2b25079caae5106f9e529bcf6831d2f2cd83 100644
--- a/src/touchpad-page.cpp
+++ b/src/touchpad-page.cpp
@@ -14,13 +14,14 @@
#include "touchpad-page.h"
#include
+#include
#include
#include
#include
-#include "KSMTouchPadProxy.h"
+#include "touchPad_backEnd_proxy.h"
#include "ui_touchpad-page.h"
-#define TIMEOUT 100
+#define TIMEOUT 2000
#define SLIDER_MINIMUM 0
#define SLIDER_MAXIMUN 100
#define PAGE_BASE_SIZE_WIDTH 700
@@ -70,7 +71,6 @@ void TouchPadPage::initUI()
delete kcmManager;
kcmManager = nullptr;
- setStyleSheet("#scrollAreaWidgetContents{border-left:1px solid #2d2d2d;}");
m_comboBoxList = this->findChildren();
m_checkBoxList = {ui->checkBox_tap_to_click,
ui->checkBox_tp_natural_scroll,
@@ -85,7 +85,7 @@ void TouchPadPage::initUI()
ui->slider_tp_speed->setPageStep((SLIDER_MAXIMUN - SLIDER_MINIMUM) / 20);
ui->slider_tp_speed->setSingleStep((SLIDER_MAXIMUN - SLIDER_MINIMUM) / 20);
- //TODO: 暂时隐藏触摸板点击方法功能
+ ///TODO: 暂时隐藏触摸板点击方法功能
ui->widget_tp_click_mode->hide();
initComponent();
@@ -96,16 +96,29 @@ void TouchPadPage::initUI()
*/
void TouchPadPage::initComponent()
{
+ //触摸板是否开启
m_touchPadEnabled = m_touchPadInterface->touchpad_enabled();
ui->checkBox_tp_disable_touchpad->setChecked(m_touchPadEnabled);
if (!m_touchPadEnabled)
- {
- //若禁用触摸板,则禁用触摸板相关设置控件
- setDisableWidget(true);
- }
+ setDisableWidget(true); //若禁用触摸板,则禁用触摸板相关设置控件
+
connect(ui->checkBox_tp_disable_touchpad, &QCheckBox::toggled, this,
&TouchPadPage::onDisabelTouchPadToggled);
+ connect(
+ m_touchPadInterface.data(), &TouchPadBackEndProxy::touchpad_enabledChanged, this,
+ [this](bool value) {
+ if (m_touchPadEnabled != value)
+ {
+ m_touchPadEnabled = value;
+ ui->checkBox_tp_disable_touchpad->blockSignals(true);
+ ui->checkBox_tp_disable_touchpad->setChecked(value);
+ ui->checkBox_tp_disable_touchpad->blockSignals(false);
+ setDisableWidget(!value);
+ }
+ },
+ Qt::QueuedConnection);
+ //选择触摸板使用模式
m_touchPadLeftHand = m_touchPadInterface->left_handed();
ui->comboBox_tp_hand_mode->setCurrentIndex(m_touchPadLeftHand);
connect(ui->comboBox_tp_hand_mode, QOverload::of(&QComboBox::currentIndexChanged),
@@ -113,21 +126,40 @@ void TouchPadPage::initComponent()
m_touchPadLeftHand = currentIntex;
m_touchPadInterface->setLeft_handed(m_touchPadLeftHand);
});
+ connect(
+ m_touchPadInterface.data(), &TouchPadBackEndProxy::left_handedChanged, this,
+ [this](bool value) {
+ if (m_touchPadLeftHand != value)
+ {
+ m_touchPadLeftHand = value;
+ ui->comboBox_tp_hand_mode->blockSignals(true);
+ ui->comboBox_tp_hand_mode->setCurrentIndex(value);
+ ui->comboBox_tp_hand_mode->blockSignals(false);
+ }
+ },
+ Qt::QueuedConnection);
+ //触摸板移动加速
m_touchPadMotionAcceleration = m_touchPadInterface->motion_acceleration();
int speed = m_touchPadMotionAcceleration / 2.0 * SLIDER_MAXIMUN + SLIDER_MAXIMUN / 2;
ui->slider_tp_speed->setValue(speed);
- connect(ui->slider_tp_speed, &QSlider::sliderPressed, [this]() {
- m_mousePressed = true;
- });
- connect(ui->slider_tp_speed, &QSlider::sliderReleased, [this]() {
- m_mousePressed = false;
- emit ui->slider_tp_speed->valueChanged(ui->slider_tp_speed->value());
- });
- // 监听滑动条值变化信号,当用户拖动滑动条时,只有在鼠标松开后才会根据值范围确定滑动条值
connect(ui->slider_tp_speed, &QSlider::valueChanged, this, &TouchPadPage::onSliderValueChange);
+ connect(
+ m_touchPadInterface.data(), &TouchPadBackEndProxy::motion_accelerationChanged, this,
+ [this](double value) {
+ if (m_touchPadMotionAcceleration != value)
+ {
+ m_touchPadMotionAcceleration = value;
+ int speed = value / 2.0 * SLIDER_MAXIMUN + SLIDER_MAXIMUN / 2;
+ ui->slider_tp_speed->blockSignals(true);
+ ui->slider_tp_speed->setValue(speed);
+ ui->slider_tp_speed->blockSignals(false);
+ }
+ },
+ Qt::QueuedConnection);
+ //点击模式
m_clickMethod = m_touchPadInterface->click_method();
ui->comboBox_tp_click_mode->setCurrentIndex(m_clickMethod);
connect(ui->comboBox_tp_click_mode, QOverload::of(&QComboBox::currentIndexChanged),
@@ -135,7 +167,14 @@ void TouchPadPage::initComponent()
m_clickMethod = currentIndex;
m_touchPadInterface->setClick_method(m_clickMethod);
});
+ connect(
+ m_touchPadInterface.data(), &TouchPadBackEndProxy::click_methodChanged, this,
+ [this](int value) {
+ setValue(ui->comboBox_tp_click_mode, m_clickMethod, value);
+ },
+ Qt::QueuedConnection);
+ //滚动方式
m_scrollMethod = m_touchPadInterface->scroll_method();
ui->comboBox_tp_move_win_mode->setCurrentIndex(m_scrollMethod);
connect(ui->comboBox_tp_move_win_mode, QOverload::of(&QComboBox::currentIndexChanged),
@@ -143,7 +182,14 @@ void TouchPadPage::initComponent()
m_scrollMethod = currentIndex;
m_touchPadInterface->setScroll_method(m_scrollMethod);
});
+ connect(
+ m_touchPadInterface.data(), &TouchPadBackEndProxy::scroll_methodChanged, this,
+ [this](int value) {
+ setValue(ui->comboBox_tp_move_win_mode, m_scrollMethod, value);
+ },
+ Qt::QueuedConnection);
+ //是否为自然滚动
m_touchPadNaturalScroll = m_touchPadInterface->natural_scroll();
ui->checkBox_tp_natural_scroll->setChecked(m_touchPadNaturalScroll);
connect(ui->checkBox_tp_natural_scroll, &KiranSwitchButton::toggled,
@@ -151,7 +197,14 @@ void TouchPadPage::initComponent()
m_touchPadNaturalScroll = isNaturalScroll;
m_touchPadInterface->setNatural_scroll(m_touchPadNaturalScroll);
});
+ connect(
+ m_touchPadInterface.data(), &TouchPadBackEndProxy::natural_scrollChanged, this,
+ [this](bool value) {
+ setValue(ui->checkBox_tp_natural_scroll, m_touchPadNaturalScroll, value);
+ },
+ Qt::QueuedConnection);
+ //打字时触摸板禁用
m_disabelWhileTyping = m_touchPadInterface->disable_while_typing();
ui->checkBox_disable_while_typing->setChecked(m_disabelWhileTyping);
connect(ui->checkBox_disable_while_typing, &KiranSwitchButton::toggled,
@@ -159,7 +212,14 @@ void TouchPadPage::initComponent()
m_disabelWhileTyping = disabelWhileTyping;
m_touchPadInterface->setDisable_while_typing(m_disabelWhileTyping);
});
+ connect(
+ m_touchPadInterface.data(), &TouchPadBackEndProxy::disable_while_typingChanged, this,
+ [this](bool value) {
+ setValue(ui->checkBox_disable_while_typing, m_disabelWhileTyping, value);
+ },
+ Qt::QueuedConnection);
+ //轻击(不按下)触摸板功能是否生效
m_tapToClick = m_touchPadInterface->tap_to_click();
ui->checkBox_tap_to_click->setChecked(m_tapToClick);
connect(ui->checkBox_tap_to_click, &KiranSwitchButton::toggled,
@@ -167,6 +227,34 @@ void TouchPadPage::initComponent()
m_tapToClick = isTapToClick;
m_touchPadInterface->setTap_to_click(m_tapToClick);
});
+ connect(
+ m_touchPadInterface.data(), &TouchPadBackEndProxy::tap_to_clickChanged, this,
+ [this](bool value) {
+ setValue(ui->checkBox_tap_to_click, m_tapToClick, value);
+ },
+ Qt::QueuedConnection);
+}
+
+void TouchPadPage::setValue(KiranSwitchButton *receiveWidget, bool &origVal, bool newVal)
+{
+ if (origVal != newVal)
+ {
+ origVal = newVal;
+ receiveWidget->blockSignals(true);
+ receiveWidget->setChecked(newVal);
+ receiveWidget->blockSignals(false);
+ }
+}
+
+void TouchPadPage::setValue(QComboBox *receiveWidget, int &origVal, int newVal)
+{
+ if (origVal != newVal)
+ {
+ origVal = newVal;
+ receiveWidget->blockSignals(true);
+ receiveWidget->setCurrentIndex(newVal);
+ receiveWidget->blockSignals(false);
+ }
}
QSize TouchPadPage::sizeHint() const
@@ -216,12 +304,5 @@ void TouchPadPage::onDisabelTouchPadToggled(bool disabled)
{
m_touchPadEnabled = disabled;
m_touchPadInterface->setTouchpad_enabled(m_touchPadEnabled);
- if (disabled)
- {
- setDisableWidget(false);
- }
- else
- {
- setDisableWidget(true);
- }
+ setDisableWidget(!disabled);
}
diff --git a/src/touchpad-page.h b/src/touchpad-page.h
index 2c691b0d7fa42b9f200922afb3ccf882d11d9fbb..501057b62a311effcfa4785552da2d4f0ce82fd6 100644
--- a/src/touchpad-page.h
+++ b/src/touchpad-page.h
@@ -25,7 +25,7 @@ class TouchPadPage;
}
class KiranSwitchButton;
-class KSMTouchPadProxy;
+class TouchPadBackEndProxy;
class TouchPadPage : public QWidget
{
Q_OBJECT
@@ -36,13 +36,14 @@ public:
public:
void initUI();
-
virtual QSize sizeHint() const override;
private:
void addComboBoxItem();
void setDisableWidget(bool);
void initComponent();
+ void setValue(KiranSwitchButton *receiveWidget, bool &origVal, bool newVal);
+ void setValue(QComboBox *receiveWidget, int &origVal, int newVal);
public slots:
void onSliderValueChange();
@@ -50,7 +51,7 @@ public slots:
private:
Ui::TouchPadPage *ui;
- QSharedPointer m_touchPadInterface;
+ QSharedPointer m_touchPadInterface;
QList m_comboBoxList;
QList m_checkBoxList;
QList m_labelList;
@@ -64,8 +65,6 @@ private:
int m_clickMethod = 0;
int m_scrollMethod = 0;
- //鼠标是否按下的标志位
- bool m_mousePressed = false;
QTimer *m_timer = nullptr;
};
diff --git a/translations/kiran-cpanel-mouse.zh_CN.ts b/translations/kiran-cpanel-mouse.zh_CN.ts
index e69ae797836855be4b38a600e39795164fc8e2b0..e071184d3b90d259ebf8d7db9804de65e17831c4 100644
--- a/translations/kiran-cpanel-mouse.zh_CN.ts
+++ b/translations/kiran-cpanel-mouse.zh_CN.ts
@@ -123,54 +123,61 @@
MousePage
-
+
+
Form
-
+
+
Select Mouse Hand
选择鼠标手持模式
-
+
+
Mouse Motion Acceleration
鼠标移动加速
-
+
+
Slow
慢
-
+
+
Fast
快
-
+
+
Natural Scroll
是否为自然滚动
-
+
+
Middle Emulation Enabled
同时按下左右键模拟中键
-
+
Right Hand Mode
右手模式
-
+
Left Hand Mode
左手模式
@@ -259,98 +266,109 @@
TouchPadPage
-
+
+
Form
-
+
+
TouchPad Enabled
开启触摸板
-
+
+
Select TouchPad Hand
选择触摸板使用模式
-
+
+
TouchPad Motion Acceleration
触摸板移动加速
-
+
+
Slow
慢
-
+
+
Fast
快
-
+
+
Select Click Method
设置点击触摸板方式
-
+
+
Select Scroll Method
滚动窗口方式
-
+
+
Natural Scroll
是否为自然滚动
-
+
+
Enabled while Typing
打字时触摸板禁用
-
+
+
Tap to Click
轻击(不按下)触摸板功能是否生效
-
+
Right Hand Mode
右手模式
-
+
Left Hand Mode
左手模式
-
+
Press and Tap
按键和轻触
-
+
Tap
轻触
-
+
Two Finger Scroll
两指滑动
-
+
Edge Scroll
边缘滑动