merge from upstream/4.0.0.0
|
@ -1,8 +1,6 @@
|
|||
qt5_wrap_cpp(BiometricAuth_SRC
|
||||
biometricdeviceinfo.h
|
||||
biometricproxy.h
|
||||
biometricauthwidget.h
|
||||
biometricdeviceswidget.h
|
||||
biometricproxy.h
|
||||
giodbus.h
|
||||
uniauthservice.h
|
||||
)
|
||||
|
@ -10,9 +8,7 @@ qt5_wrap_cpp(BiometricAuth_SRC
|
|||
set(BiometricAuth_SRC
|
||||
${BiometricAuth_SRC}
|
||||
biometricdeviceinfo.cpp
|
||||
biometricproxy.cpp
|
||||
biometricauthwidget.cpp
|
||||
biometricdeviceswidget.cpp
|
||||
biometricproxy.cpp
|
||||
giodbus.cpp
|
||||
uniauthservice.cpp
|
||||
)
|
||||
|
@ -20,11 +16,12 @@ set(BiometricAuth_SRC
|
|||
include_directories(
|
||||
${Qt5Core_INCLUDE_DIRS}
|
||||
${Qt5Widgets_INCLUDE_DIRS}
|
||||
${Qt5DBus_INCLUDE_DIRS}
|
||||
${OpenCV_INCLUDE_DIRS}
|
||||
${Qt5DBus_INCLUDE_DIRS}
|
||||
${GLIB2_INCLUDE_DIRS}
|
||||
${GIOUNIX2_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
|
||||
add_library(BiometricAuth STATIC ${BiometricAuth_SRC})
|
||||
target_link_libraries(BiometricAuth Qt5::Core Qt5::DBus Qt5::Widgets ${OpenCV_LIBS} ${GIOUNIX2_LIBRARIES})
|
||||
target_link_libraries(BiometricAuth Qt5::Core Qt5::DBus Qt5::Widgets
|
||||
${GIOUNIX2_LIBRARIES})
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -12,9 +12,8 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "biometricauthwidget.h"
|
||||
#include <QLabel>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -12,9 +12,8 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef BIOMETRICAUTHWIDGET_H
|
||||
#define BIOMETRICAUTHWIDGET_H
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -12,9 +12,8 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "biometricdeviceinfo.h"
|
||||
|
||||
|
@ -67,6 +66,8 @@ QString DeviceType::getDeviceType_tr(int deviceType)
|
|||
return tr("Face");
|
||||
case VoicePrint:
|
||||
return tr("VoicePrint");
|
||||
case LOGINOPT_TYPE_GENERAL_UKEY:
|
||||
return tr("ukey");
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
return tr("QRCode");
|
||||
default:
|
||||
|
@ -126,10 +127,33 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, DeviceInfo &deviceInf
|
|||
return arg;
|
||||
}
|
||||
|
||||
/* For the type FeatureInfo */
|
||||
QDBusArgument &operator<<(QDBusArgument &argument, const FeatureInfo &featureInfo)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument << featureInfo.uid << featureInfo.biotype
|
||||
<< featureInfo.device_shortname << featureInfo.index
|
||||
<< featureInfo.index_name;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, FeatureInfo &featureInfo)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument >> featureInfo.uid >> featureInfo.biotype
|
||||
>> featureInfo.device_shortname >> featureInfo.index
|
||||
>> featureInfo.index_name;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
void registerMetaType()
|
||||
{
|
||||
qRegisterMetaType<DeviceInfo>("DeviceInfo");
|
||||
qDBusRegisterMetaType<DeviceInfo>();
|
||||
qRegisterMetaType<FeatureInfo>("FeatureInfo");
|
||||
qDBusRegisterMetaType<FeatureInfo>();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -12,9 +12,8 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef BIOMETRICDEVICEINFO_H
|
||||
#define BIOMETRICDEVICEINFO_H
|
||||
|
@ -212,20 +211,35 @@ struct DeviceInfo
|
|||
int OpsStatus;
|
||||
};
|
||||
|
||||
|
||||
struct FeatureInfo {
|
||||
int uid;
|
||||
int biotype;
|
||||
QString device_shortname;
|
||||
int index;
|
||||
QString index_name;
|
||||
};
|
||||
|
||||
class QDBusArgument;
|
||||
|
||||
QDBusArgument &operator <<(QDBusArgument &arg, const DeviceInfo &deviceInfo);
|
||||
const QDBusArgument &operator >>(const QDBusArgument &arg, DeviceInfo &deviceInfo);
|
||||
QDBusArgument &operator<<(QDBusArgument &argument, const FeatureInfo &featureInfo);
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, FeatureInfo &featureInfo);
|
||||
|
||||
void registerMetaType();
|
||||
|
||||
typedef std::shared_ptr<DeviceInfo> DeviceInfoPtr;
|
||||
typedef QList<DeviceInfoPtr> DeviceList;
|
||||
typedef QMap<int, DeviceList> DeviceMap;
|
||||
typedef std::shared_ptr<FeatureInfo> FeatureInfoPtr;
|
||||
typedef QList<FeatureInfoPtr> FeatureList;
|
||||
typedef QMap<QString, FeatureList> FeatureMap;
|
||||
|
||||
QDebug operator <<(QDebug stream, const DeviceInfo &deviceInfo);
|
||||
|
||||
Q_DECLARE_METATYPE(DeviceInfo)
|
||||
Q_DECLARE_METATYPE(FeatureInfo)
|
||||
|
||||
/**
|
||||
* @brief 获取默认设备
|
||||
|
@ -266,6 +280,8 @@ enum LOGINOPT_TYPE {
|
|||
LOGINOPT_TYPE_IRIS, // 虹膜
|
||||
LOGINOPT_TYPE_VOICEPRINT, // 声纹
|
||||
LOGINOPT_TYPE_FINGERVEIN, // 指静脉
|
||||
LOGINOPT_TYPE_GENERAL_UKEY, // 普通的ukey
|
||||
LOGINOPT_TYPE_ADVANCED_UKEY, // 高阶的ukey
|
||||
LOGINOPT_TYPE_QRCODE, // 二维码
|
||||
LOGINOPT_TYPE_OTHERS, // 其他
|
||||
LOGINOPT_TYPE_COUNT
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -12,9 +12,8 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "biometricdeviceswidget.h"
|
||||
#include <QLabel>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -12,9 +12,8 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef BIOMETRICDEVICESWIDGET_H
|
||||
#define BIOMETRICDEVICESWIDGET_H
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -12,12 +12,12 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "biometricproxy.h"
|
||||
#include <QDebug>
|
||||
#include <QDBusArgument>
|
||||
|
||||
BiometricProxy::BiometricProxy(QObject *parent)
|
||||
: QDBusAbstractInterface(BIOMETRIC_DBUS_SERVICE,
|
||||
|
@ -37,6 +37,41 @@ QDBusPendingCall BiometricProxy::Identify(int drvid, int uid, int indexStart, in
|
|||
return asyncCallWithArgumentList(QStringLiteral("Identify"), argList);
|
||||
}
|
||||
|
||||
QDBusPendingCall BiometricProxy::UkeyIdentify(int drvid, int type, int uid)
|
||||
{
|
||||
QList<QVariant> argList;
|
||||
argList << drvid << type << uid;
|
||||
return asyncCallWithArgumentList(QStringLiteral("UkeyIdentify"), argList);
|
||||
}
|
||||
|
||||
bool BiometricProxy::GetHasUkeyFeature(int uid, int indexStart, int indexEnd)
|
||||
{
|
||||
QList<QDBusVariant> qlist;
|
||||
FeatureInfo *featureInfo;
|
||||
int listsize;
|
||||
QDBusMessage result = call(QStringLiteral("GetAllFeatureList"),uid,indexStart,indexEnd);
|
||||
if(result.type() == QDBusMessage::ErrorMessage)
|
||||
{
|
||||
qWarning() << "GetDevList error:" << result.errorMessage();
|
||||
return false;
|
||||
}
|
||||
QList<QVariant> variantList = result.arguments();
|
||||
listsize = variantList[0].value<int>();
|
||||
variantList[1].value<QDBusArgument>() >> qlist;
|
||||
for (int i = 0; i < listsize; i++) {
|
||||
featureInfo = new FeatureInfo;
|
||||
qlist[i].variant().value<QDBusArgument>() >> *featureInfo;
|
||||
if(featureInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
delete featureInfo;
|
||||
return true;
|
||||
}
|
||||
delete featureInfo;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
int BiometricProxy::GetFeatureCount(int uid, int indexStart, int indexEnd)
|
||||
{
|
||||
QDBusMessage result = call(QStringLiteral("GetDevList"));
|
||||
|
@ -68,6 +103,17 @@ int BiometricProxy::GetFeatureCount(int uid, int indexStart, int indexEnd)
|
|||
return res;
|
||||
}
|
||||
|
||||
int BiometricProxy::SetExtraInfo(QString info_type,QString extra_info)
|
||||
{
|
||||
QDBusReply<int> reply = call(QStringLiteral("SetExtraInfo"), info_type, extra_info);
|
||||
if(!reply.isValid())
|
||||
{
|
||||
qWarning() << "SetExtraInfo error:" << reply.error();
|
||||
return -1;
|
||||
}
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
int BiometricProxy::StopOps(int drvid, int waiting)
|
||||
{
|
||||
QDBusReply<int> reply = call(QStringLiteral("StopOps"), drvid, waiting);
|
||||
|
@ -145,6 +191,28 @@ DeviceList BiometricProxy::GetDevList()
|
|||
return deviceList;
|
||||
}
|
||||
|
||||
FeatureMap BiometricProxy::GetUserFeatures(int uid)
|
||||
{
|
||||
FeatureMap featureMap;
|
||||
QList<QDBusVariant> qlist;
|
||||
int listsize;
|
||||
QDBusMessage result = call(QStringLiteral("GetAllFeatureList"), uid, 0, -1);
|
||||
if(result.type() == QDBusMessage::ErrorMessage)
|
||||
{
|
||||
qWarning() << "GetDevList error:" << result.errorMessage();
|
||||
return featureMap;
|
||||
}
|
||||
QList<QVariant> variantList = result.arguments();
|
||||
listsize = variantList[0].value<int>();
|
||||
variantList[1].value<QDBusArgument>() >> qlist;
|
||||
for (int i = 0; i < listsize; i++) {
|
||||
FeatureInfoPtr pFeatureInfo = std::make_shared<FeatureInfo>();
|
||||
qlist[i].variant().value<QDBusArgument>() >> *pFeatureInfo;
|
||||
featureMap[pFeatureInfo->device_shortname].append(pFeatureInfo);
|
||||
}
|
||||
return featureMap;
|
||||
}
|
||||
|
||||
int BiometricProxy::GetDevCount()
|
||||
{
|
||||
QDBusMessage result = call(QStringLiteral("GetDevList"));
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -12,9 +12,8 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef BIOMETRICPROXY_H
|
||||
#define BIOMETRICPROXY_H
|
||||
|
@ -65,6 +64,21 @@ public Q_SLOTS:
|
|||
* @return 结果:<int result, int uid> (结果,用户id)
|
||||
*/
|
||||
QDBusPendingCall Identify(int drvid, int uid, int indexStart = 0, int indexEnd = -1);
|
||||
/**
|
||||
* @brief 使用指定id的设备进行用户认证
|
||||
* @param drvid 驱动(设备)id
|
||||
* @param type ukey的认证类型,2表示pin认证(需通过setExtraInfo设置pin码,3表示指纹认证)
|
||||
* @param uid 用户id
|
||||
* @return 结果:<int result, int uid> (结果,用户id)
|
||||
*/
|
||||
QDBusPendingCall UkeyIdentify(int drvid, int type, int uid);
|
||||
/**
|
||||
* @brief 设置一些认证时所需的额外的信息
|
||||
* @param info_type 额外的信息类型,ukey pincode认证时传 "pincode"
|
||||
* @param extra_info 额外的信息内容,ukey pincode认证时传PIN码内容
|
||||
* @return 结果:<int result> (设置额外信息的结果)
|
||||
*/
|
||||
int SetExtraInfo(QString info_type, QString extra_info);
|
||||
/**
|
||||
* @brief 终止设备上正在进行的操作
|
||||
* @param drvid 设备id
|
||||
|
@ -80,6 +94,14 @@ public Q_SLOTS:
|
|||
* @return
|
||||
*/
|
||||
int GetFeatureCount(int uid, int indexStart = 0, int indexEnd = -1);
|
||||
/**
|
||||
* @brief 获取当前用户已连接设备对应特征数目
|
||||
* @param uid 用户id
|
||||
* @param indexStart 用于认证的特征索引范围
|
||||
* @param indexEnd
|
||||
* @return 返回是否存在ukey特征
|
||||
*/
|
||||
bool GetHasUkeyFeature(int uid, int indexStart = 0, int indexEnd = -1);
|
||||
/**
|
||||
* @brief 获取已连接的设备列表
|
||||
* @return
|
||||
|
@ -117,7 +139,12 @@ public Q_SLOTS:
|
|||
StatusReslut UpdateStatus(int drvid);
|
||||
int GetUserDevCount(int uid);
|
||||
int GetUserDevFeatureCount(int uid,int drvid);
|
||||
|
||||
/**
|
||||
* @brief GetUserFeatures 获取用户所有特征
|
||||
* @param uid 用户id
|
||||
* @return 特征信息列表
|
||||
*/
|
||||
FeatureMap GetUserFeatures(int uid);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,23 @@
|
|||
/*
|
||||
* Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "giodbus.h"
|
||||
#include <gio/gio.h>
|
||||
#include <gio-unix-2.0/gio/gunixfdlist.h>
|
||||
#include <gio/gunixfdlist.h>
|
||||
#include <glib.h>
|
||||
|
||||
int get_server_gvariant_stdout (int drvid)
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Copyright (C) 2021 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef GIODBUS_H
|
||||
#define GIODBUS_H
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -12,9 +12,8 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
|
|
@ -5,10 +5,13 @@ find_package(Qt5 COMPONENTS Core Widgets DBus X11Extras Xml Network Svg)
|
|||
find_package(PkgConfig REQUIRED)
|
||||
find_package(OpenCV REQUIRED)
|
||||
find_package(PkgConfig)
|
||||
find_package(KF5Screen REQUIRED)
|
||||
find_package(KF5Wayland REQUIRED)
|
||||
|
||||
pkg_check_modules(GIOUNIX2 REQUIRED gio-unix-2.0)
|
||||
pkg_check_modules(GLIB2 REQUIRED glib-2.0 gio-2.0)
|
||||
pkg_check_modules(kylin-nm-base REQUIRED kylin-nm-base)
|
||||
|
||||
pkg_check_modules(KScreen REQUIRED kscreen2)
|
||||
|
||||
# 是否是intel项目
|
||||
option (USE_INTEL "intel项目" OFF)
|
||||
|
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
@ -1,7 +1,21 @@
|
|||
pkg_check_modules(GLIB REQUIRED glib-2.0)
|
||||
find_package(X11 REQUIRED)
|
||||
find_package(KF5WindowSystem)
|
||||
|
||||
include_directories(
|
||||
${Qt5Core_INCLUDE_DIRS}
|
||||
${Qt5Widgets_INCLUDE_DIRS}
|
||||
${Qt5DBus_INCLUDE_DIRS}
|
||||
${GLIB2_INCLUDE_DIRS}
|
||||
${KF5Wayland_LIBRARIES}
|
||||
)
|
||||
|
||||
qt5_wrap_cpp(Common_SRC
|
||||
autoresize.h
|
||||
checkbutton.h
|
||||
commonfunc.h
|
||||
glibinterface.h
|
||||
plasma-shell-manager.h
|
||||
)
|
||||
|
||||
set(Common_SRC
|
||||
|
@ -9,14 +23,9 @@ set(Common_SRC
|
|||
autoresize.cpp
|
||||
checkbutton.cpp
|
||||
commonfunc.cpp
|
||||
glibinterface.cpp
|
||||
plasma-shell-manager.cpp
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${Qt5Core_INCLUDE_DIRS}
|
||||
${Qt5Widgets_INCLUDE_DIRS}
|
||||
${Qt5DBus_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
|
||||
add_library(Common STATIC ${Common_SRC})
|
||||
target_link_libraries(Common Qt5::Core Qt5::DBus Qt5::Widgets)
|
||||
target_link_libraries(Common Qt5::Core Qt5::DBus Qt5::Widgets ${GIOUNIX2_LIBRARIES} ${KF5Wayland_LIBRARIES} -lKF5WaylandClient -lKF5WaylandServer KF5::WindowSystem)
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
/*
|
||||
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
@ -13,10 +12,9 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
**/
|
||||
|
||||
#include "checkbutton.h"
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
/*
|
||||
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
@ -13,10 +12,9 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
**/
|
||||
|
||||
#ifndef CHECKBUTTON_H
|
||||
#define CHECKBUTTON_H
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
/*
|
||||
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
@ -13,15 +12,15 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
**/
|
||||
|
||||
#include <QMimeType>
|
||||
#include <QSettings>
|
||||
#include <QMimeDatabase>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QFileInfo>
|
||||
#include <QFontMetrics>
|
||||
#include "commonfunc.h"
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
/*
|
||||
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
@ -13,10 +12,9 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
**/
|
||||
|
||||
#ifndef COMMONFUNC_H
|
||||
#define COMMONFUNC_H
|
||||
|
@ -25,6 +23,8 @@
|
|||
#include <QFont>
|
||||
#include <QPixmap>
|
||||
|
||||
#define G_FONT_SIZE (11.0)
|
||||
|
||||
bool ispicture(QString filepath);
|
||||
QString getSystemVersion();
|
||||
QString getSystemDistrib();
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "glibinterface.h"
|
||||
#include <QString>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#define STYLE_TYPE_SCHEMA "org.ukui.style"
|
||||
#define KEY_SYSTEM_FONT_SIZE "system-font-size"
|
||||
#define DEFAULT_FONT_SIZE (10.0)
|
||||
|
||||
double getDefaultFontSize()
|
||||
{
|
||||
GSettingsSchemaSource *schema_source = NULL;
|
||||
GSettingsSchema *schema = NULL;
|
||||
|
||||
schema_source = g_settings_schema_source_get_default();
|
||||
if(schema_source){
|
||||
schema = g_settings_schema_source_lookup (schema_source,KEY_SYSTEM_FONT_SIZE,TRUE);
|
||||
if(schema){
|
||||
GVariant *size;
|
||||
unsigned long length;
|
||||
GSettings *gs;
|
||||
|
||||
gs = g_settings_new(STYLE_TYPE_SCHEMA);
|
||||
size = g_settings_get_default_value(gs, KEY_SYSTEM_FONT_SIZE);
|
||||
QString fontsize(g_variant_get_string(size,&length));
|
||||
g_object_unref(gs);
|
||||
|
||||
return fontsize.toDouble();
|
||||
}
|
||||
}
|
||||
return DEFAULT_FONT_SIZE;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef GLIBINTERFACE_H
|
||||
#define GLIBINTERFACE_H
|
||||
|
||||
double getDefaultFontSize();
|
||||
|
||||
#endif // LOCKWIDGET_H
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
/*
|
||||
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
|
||||
#include "plasma-shell-manager.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <KWayland/Client/connection_thread.h>
|
||||
#include <KWayland/Client/registry.h>
|
||||
|
||||
#include <KWayland/Client/surface.h>
|
||||
#include <unistd.h>
|
||||
#include <QDebug>
|
||||
|
||||
static PlasmaShellManager* global_instance = nullptr;
|
||||
|
||||
PlasmaShellManager *PlasmaShellManager::getInstance()
|
||||
{
|
||||
if (!global_instance)
|
||||
{
|
||||
global_instance = new PlasmaShellManager;
|
||||
qDebug() << "Here create instance...";
|
||||
}
|
||||
qDebug() << "Return instance";
|
||||
return global_instance;
|
||||
}
|
||||
|
||||
bool PlasmaShellManager::setAppWindowActive()
|
||||
{
|
||||
if (!supportPlasmaWindowManagement())
|
||||
return false;
|
||||
|
||||
m_appWindow->requestActivate();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PlasmaShellManager::setAppWindowKeepAbove(bool keep)
|
||||
{
|
||||
if (!supportPlasmaWindowManagement())
|
||||
{
|
||||
qDebug() << "false";
|
||||
return false;
|
||||
}
|
||||
if(keep != m_appWindow->isKeepAbove()) {
|
||||
qDebug() << "to keep above";
|
||||
m_appWindow->requestToggleKeepAbove();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PlasmaShellManager::setMaximized(QWindow *window)
|
||||
{
|
||||
if (!supportShell())
|
||||
return false;
|
||||
|
||||
auto surface = KWayland::Client::Surface::fromWindow(window);
|
||||
if (!surface)
|
||||
return false;
|
||||
|
||||
auto shellSurface = m_shell->createSurface(surface, window);
|
||||
if (!shellSurface)
|
||||
return false;
|
||||
|
||||
shellSurface->setMaximized();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PlasmaShellManager::setRole(QWindow *window, KWayland::Client::PlasmaShellSurface::Role role)
|
||||
{
|
||||
if (!supportPlasmaShell())
|
||||
return false;
|
||||
|
||||
auto surface = KWayland::Client::Surface::fromWindow(window);
|
||||
if (!surface)
|
||||
return false;
|
||||
|
||||
auto plasmaShellSurface = m_plasmaShell->createSurface(surface, window);
|
||||
if (!plasmaShellSurface)
|
||||
return false;
|
||||
|
||||
plasmaShellSurface->setRole(role);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PlasmaShellManager::setPos(QWindow *window, const QPoint &pos)
|
||||
{
|
||||
if (!supportPlasmaShell())
|
||||
return false;
|
||||
|
||||
auto surface = KWayland::Client::Surface::fromWindow(window);
|
||||
if (!surface)
|
||||
return false;
|
||||
|
||||
auto plasmaShellSurface = m_plasmaShell->createSurface(surface, window);
|
||||
if (!plasmaShellSurface)
|
||||
return false;
|
||||
|
||||
plasmaShellSurface->setPosition(pos);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PlasmaShellManager::supportPlasmaShell()
|
||||
{
|
||||
return m_plasmaShell;
|
||||
}
|
||||
|
||||
bool PlasmaShellManager::supportShell()
|
||||
{
|
||||
return m_shell;
|
||||
}
|
||||
|
||||
bool PlasmaShellManager::supportPlasmaWindowManagement()
|
||||
{
|
||||
return m_windowManager && m_appWindow;
|
||||
}
|
||||
|
||||
bool PlasmaShellManager::supportFakeInput()
|
||||
{
|
||||
return m_fakeInput;
|
||||
}
|
||||
|
||||
bool PlasmaShellManager::supportKeyState()
|
||||
{
|
||||
return m_keyState;
|
||||
}
|
||||
|
||||
KWayland::Client::Keystate::State PlasmaShellManager::getKeyState(KWayland::Client::Keystate::Key key)
|
||||
{
|
||||
if(!supportKeyState()){
|
||||
return KWayland::Client::Keystate::Unlocked;
|
||||
}
|
||||
|
||||
return m_keyStateMap[key];
|
||||
}
|
||||
|
||||
void PlasmaShellManager::setKeyPressed(quint32 key)
|
||||
{
|
||||
if(!supportFakeInput())
|
||||
return ;
|
||||
|
||||
m_fakeInput->requestKeyboardKeyPress(key);
|
||||
m_fakeInput->requestKeyboardKeyRelease(key);
|
||||
}
|
||||
|
||||
PlasmaShellManager::PlasmaShellManager(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_keyStateMap.insert(KWayland::Client::Keystate::Key::CapsLock,KWayland::Client::Keystate::Unlocked);
|
||||
m_keyStateMap.insert(KWayland::Client::Keystate::Key::NumLock,KWayland::Client::Keystate::Unlocked);
|
||||
m_keyStateMap.insert(KWayland::Client::Keystate::Key::ScrollLock,KWayland::Client::Keystate::Unlocked);
|
||||
|
||||
auto connection = KWayland::Client::ConnectionThread::fromApplication(qApp);
|
||||
auto registry = new KWayland::Client::Registry(this);
|
||||
registry->create(connection->display());
|
||||
|
||||
connect(registry, &KWayland::Client::Registry::plasmaShellAnnounced, this, [=](){
|
||||
qDebug() << "plasmaShellAnnounced...";
|
||||
const auto interface = registry->interface(KWayland::Client::Registry::Interface::PlasmaShell);
|
||||
if (interface.name != 0) {
|
||||
qDebug() << "createPlasmaShell...";
|
||||
m_plasmaShell = registry->createPlasmaShell(interface.name, interface.version, this);
|
||||
}
|
||||
});
|
||||
|
||||
connect(registry, &KWayland::Client::Registry::plasmaWindowManagementAnnounced, this, [=](){
|
||||
qDebug() << "plasmaWindowManagementAnnounced";
|
||||
const auto interface = registry->interface(KWayland::Client::Registry::Interface::PlasmaWindowManagement);
|
||||
if (interface.name != 0) {
|
||||
qDebug() << "createPlasmaWindowManagement";
|
||||
m_windowManager = registry->createPlasmaWindowManagement(interface.name, interface.version, this);
|
||||
}
|
||||
if(m_windowManager) {
|
||||
connect(m_windowManager, &KWayland::Client::PlasmaWindowManagement::windowCreated,
|
||||
[this](KWayland::Client::PlasmaWindow *window) {
|
||||
qDebug()<< "PlasmaWindow...";
|
||||
if (window->pid() == getpid()) {
|
||||
if(isFirstCreate) {
|
||||
isFirstCreate = false;
|
||||
m_appWindow = window;
|
||||
|
||||
connect(m_appWindow, &KWayland::Client::PlasmaWindow::activeChanged,
|
||||
[this]() {
|
||||
this->setAppWindowKeepAbove(true);
|
||||
this->setAppWindowActive();
|
||||
});
|
||||
connect(m_appWindow, &KWayland::Client::PlasmaWindow::keepAboveChanged,
|
||||
[this]() {
|
||||
this->setAppWindowKeepAbove(true);
|
||||
this->setAppWindowActive();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
connect(registry, &KWayland::Client::Registry::shellAnnounced, this, [=](){
|
||||
const auto interface = registry->interface(KWayland::Client::Registry::Interface::Shell);
|
||||
if (interface.name != 0) {
|
||||
m_shell = registry->createShell(interface.name, interface.version, this);
|
||||
}
|
||||
});
|
||||
|
||||
connect(registry, &KWayland::Client::Registry::fakeInputAnnounced, this, [=](){
|
||||
qDebug()<<"fakeInputAnnounced";
|
||||
const auto interface = registry->interface(KWayland::Client::Registry::Interface::FakeInput);
|
||||
if (interface.name != 0) {
|
||||
qDebug()<<"createFakeInput";
|
||||
m_fakeInput = registry->createFakeInput(interface.name, interface.version);
|
||||
m_fakeInput->authenticate("ukui-screensaver-dialog","virual keyboard");
|
||||
}
|
||||
});
|
||||
|
||||
connect(registry, &KWayland::Client::Registry::keystateAnnounced, this, [=](){
|
||||
qDebug()<<"keystateAnnounced";
|
||||
const auto interface = registry->interface(KWayland::Client::Registry::Interface::Keystate);
|
||||
if (interface.name != 0) {
|
||||
qDebug()<<"createKeyState";
|
||||
m_keyState = registry->createKeystate(interface.name, interface.version);
|
||||
if(m_keyState){
|
||||
connect(m_keyState, &KWayland::Client::Keystate::stateChanged,
|
||||
[this](KWayland::Client::Keystate::Key key,KWayland::Client::Keystate::State state) {
|
||||
qDebug()<<"key = "<<key<<"state = "<<state;
|
||||
m_keyStateMap[key] = state;
|
||||
emit keyStateChanged();
|
||||
});
|
||||
m_keyState->fetchStates();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
registry->setup();
|
||||
connection->roundtrip();
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef PLASMASHELLMANAGER_H
|
||||
#define PLASMASHELLMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWindow>
|
||||
#include <QMap>
|
||||
#include <KWayland/Client/plasmawindowmanagement.h>
|
||||
#include <KWayland/Client/plasmashell.h>
|
||||
#include <KWayland/Client/shell.h>
|
||||
#include <KWayland/Client/fakeinput.h>
|
||||
#include <KWayland/Client/keystate.h>
|
||||
|
||||
class PlasmaShellManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static PlasmaShellManager *getInstance();
|
||||
|
||||
bool setAppWindowActive();
|
||||
bool setAppWindowKeepAbove(bool keep);
|
||||
bool setMaximized(QWindow *window);
|
||||
bool setRole(QWindow *window, KWayland::Client::PlasmaShellSurface::Role role);
|
||||
bool setPos(QWindow *window, const QPoint &pos);
|
||||
void setKeyPressed(quint32 key);
|
||||
|
||||
bool supportPlasmaShell();
|
||||
bool supportShell();
|
||||
bool supportPlasmaWindowManagement();
|
||||
bool supportFakeInput();
|
||||
bool supportKeyState();
|
||||
KWayland::Client::Keystate::State getKeyState(KWayland::Client::Keystate::Key key);
|
||||
Q_SIGNALS:
|
||||
void keyStateChanged();
|
||||
|
||||
private:
|
||||
explicit PlasmaShellManager(QObject *parent = nullptr);
|
||||
|
||||
KWayland::Client::PlasmaShell *m_plasmaShell = nullptr;
|
||||
KWayland::Client::Shell *m_shell = nullptr;
|
||||
KWayland::Client::PlasmaWindowManagement *m_windowManager = nullptr;
|
||||
KWayland::Client::PlasmaWindow *m_appWindow = nullptr;
|
||||
KWayland::Client::FakeInput *m_fakeInput = nullptr;
|
||||
KWayland::Client::Keystate *m_keyState = nullptr;
|
||||
|
||||
bool isFirstCreate = true;
|
||||
|
||||
QMap<KWayland::Client::Keystate::Key,KWayland::Client::Keystate::State> m_keyStateMap;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // PLASMASHELLMANAGER_H
|
|
@ -2470,6 +2470,7 @@ void KylinNM::enWifiDone()
|
|||
|
||||
qDebug()<<"debug: already turn on the switch of wifi network";
|
||||
syslog(LOG_DEBUG, "Already turn on the switch of wifi network");
|
||||
QTimer::singleShot(200, this, &KylinNM::onConnectChanged);
|
||||
}
|
||||
void KylinNM::disWifiDone()
|
||||
{
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef SWIPEGESTURERECOGNIZER_H
|
||||
#define SWIPEGESTURERECOGNIZER_H
|
||||
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "switchbutton.h"
|
||||
|
||||
SwitchButton::SwitchButton(QWidget *parent) : QWidget(parent)
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef SWITCHBUTTON_H
|
||||
#define SWITCHBUTTON_H
|
||||
|
||||
|
|
|
@ -4,21 +4,33 @@ set(CMAKE_AUTOMOC ON)
|
|||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/Common)
|
||||
|
||||
qt5_add_resources(VirtualKeyboard_SRC
|
||||
src/keyboard.qrc)
|
||||
|
||||
qt5_wrap_cpp(VirtualKeyboard_SRC
|
||||
src/fakekeyboard.h
|
||||
)
|
||||
|
||||
set(VirtualKeyboard_SRC
|
||||
${VirtualKeyboard_SRC}
|
||||
src/cursormonitor.cpp
|
||||
src/keyboardwidget.cpp
|
||||
src/virtualkeyboard.cpp
|
||||
src/x11keyboard.cpp
|
||||
src/keyboard.qrc)
|
||||
src/charsmorewidget.cpp
|
||||
src/charswidget.cpp
|
||||
src/dragwidget.cpp
|
||||
src/kbbutton.cpp
|
||||
src/kbtitle.cpp
|
||||
src/letterswidget.cpp
|
||||
src/numberswidget.cpp
|
||||
src/virtualkeyboardwidget.cpp
|
||||
src/x11keyboard.cpp
|
||||
src/qtkeyboard.cpp
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${Qt5Core_INCLUDE_DIRS}
|
||||
${Qt5Widgets_INCLUDE_DIRS}
|
||||
)
|
||||
)
|
||||
|
||||
add_library(VirtualKeyboard STATIC ${VirtualKeyboard_SRC})
|
||||
target_link_libraries(VirtualKeyboard Qt5::Core Qt5::Widgets)
|
||||
target_link_libraries(VirtualKeyboard Qt5::Core Qt5::Widgets Qt5::X11Extras Common)
|
||||
|
|
|
@ -1,18 +1,26 @@
|
|||
SOURCES += \
|
||||
$$PWD/src/keyboardwidget.cpp \
|
||||
$$PWD/src/x11keyboard.cpp \
|
||||
$$PWD/src/cursormonitor.cpp \
|
||||
$$PWD/src/virtualkeyboard.cpp
|
||||
$$PWD/src/charsmorewidget.cpp \
|
||||
$$PWD/src/charswidget.cpp \
|
||||
$$PWD/src/dragwidget.cpp \
|
||||
$$PWD/src/kbbutton.cpp \
|
||||
$$PWD/src/kbtitle.cpp \
|
||||
$$PWD/src/letterswidget.cpp \
|
||||
$$PWD/src/numberswidget.cpp \
|
||||
$$PWD/src/virtualkeyboardwidget.cpp \
|
||||
$$PWD/src/x11keyboard.cpp
|
||||
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/src/keyboardwidget.h \
|
||||
$$PWD/src/x11keyboard.h \
|
||||
$$PWD/src/cursormonitor.h \
|
||||
$$PWD/src/virtualkeyboard.h
|
||||
|
||||
FORMS += \
|
||||
$$PWD/src/keyboardwidget.ui
|
||||
$$PWD/src/charsmorewidget.h \
|
||||
$$PWD/src/charswidget.h \
|
||||
$$PWD/src/commondef.h \
|
||||
$$PWD/src/dragwidget.h \
|
||||
$$PWD/src/kbbutton.h \
|
||||
$$PWD/src/kbtitle.h \
|
||||
$$PWD/src/letterswidget.h \
|
||||
$$PWD/src/numberswidget.h \
|
||||
$$PWD/src/virtualkeyboardwidget.h \
|
||||
$$PWD/src/x11keyboard.h
|
||||
|
||||
|
||||
RESOURCES += \
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "charsmorewidget.h"
|
||||
#include "commondef.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QScrollArea>
|
||||
#include <QScrollBar>
|
||||
#include <QVariant>
|
||||
#include <QDebug>
|
||||
|
||||
CharsMoreWidget::CharsMoreWidget(QWidget *parent/* = nullptr*/)
|
||||
: QWidget(parent)
|
||||
{
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);//背景透明
|
||||
setWindowFlags(Qt::FramelessWindowHint |
|
||||
Qt::WindowStaysOnTopHint |
|
||||
Qt::WindowDoesNotAcceptFocus);
|
||||
initUI();
|
||||
}
|
||||
|
||||
CharsMoreWidget::~CharsMoreWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CharsMoreWidget::adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical/* = false*/, bool floatStatus)
|
||||
{
|
||||
QMap<QWidget*, QRect>::iterator itGeometry = m_mapBtnGeometrys.begin();
|
||||
for (; itGeometry != m_mapBtnGeometrys.end(); itGeometry ++) {
|
||||
QWidget *widget = itGeometry.key();
|
||||
if (widget) {
|
||||
QRect oldGeometry = itGeometry.value();
|
||||
QRect newGeometry = oldGeometry;
|
||||
if (floatStatus) {
|
||||
newGeometry.setX(oldGeometry.x()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
|
||||
newGeometry.setY(oldGeometry.y()*lfHeightScale);
|
||||
newGeometry.setWidth(oldGeometry.width()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
|
||||
newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
|
||||
} else {
|
||||
newGeometry.setX(oldGeometry.x()*lfWidthScale);
|
||||
newGeometry.setY(oldGeometry.y()*lfHeightScale);
|
||||
newGeometry.setWidth(oldGeometry.width()*lfWidthScale);
|
||||
newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
|
||||
}
|
||||
widget->setGeometry(newGeometry);
|
||||
}
|
||||
}
|
||||
|
||||
QChar chChars[] = {',', '.', '?', '!', '\'', ':', '~', '@', ';', '"',
|
||||
'/', '(', ')', '_', '+', '=', '`', '^', '#', '*',
|
||||
'%', '&', '\\', '[', ']', '<', '>', '{', '}', '|',
|
||||
'$', '-'};
|
||||
for (int n = 0; n < sizeof(chChars)/sizeof(QChar); n++) { //单独更新符号btn的高度
|
||||
QString objName = QString("btn_%1").arg(QString(chChars[n]));
|
||||
KBButton *btn = findChild<KBButton*>(objName);
|
||||
btn->setFixedHeight(KEYBOARD_FIXED_DEFAULT_NORMAL_CHARSMORE_BTN_HEIGHT *lfHeightScale);
|
||||
}
|
||||
//更新listfarame的高度
|
||||
listFrame->setFixedHeight(KEYBOARD_FIXED_DEFAULT_NORMAL_CHARSMORE_BTN_HEIGHT *m_vlayoutBtnList->count() *lfHeightScale);
|
||||
}
|
||||
|
||||
void CharsMoreWidget::onBtnClicked(QChar charId)
|
||||
{
|
||||
QObject *obj = sender();
|
||||
KBButton *btn = static_cast<KBButton*>(obj);
|
||||
QString objName = btn->objectName();
|
||||
int lastUnderline = objName.lastIndexOf('_');
|
||||
int start = strlen("btn_");
|
||||
int keyLength = lastUnderline - start;
|
||||
QString keyName = objName.mid(start, keyLength);
|
||||
if (keyName == BTN_RETURN) {
|
||||
Q_EMIT specialBtnClicked(PAGE_CHAR);
|
||||
} else if (charId != QChar::Null) {
|
||||
Q_EMIT normalBtnClicked(charId);
|
||||
} else {
|
||||
Q_EMIT specialBtnClicked(keyName);
|
||||
}
|
||||
}
|
||||
|
||||
void CharsMoreWidget::initUI()
|
||||
{
|
||||
// all chars
|
||||
m_vlayoutBtnList = new QVBoxLayout();
|
||||
m_vlayoutBtnList->setContentsMargins(8,0,0,0);
|
||||
m_vlayoutBtnList->setSpacing(1);
|
||||
listFrame = new QFrame();
|
||||
listFrame->setLayout(m_vlayoutBtnList);
|
||||
listFrame->setStyleSheet("QFrame{border-radius: 8px}");
|
||||
m_scrollFrame = new QScrollArea(this);
|
||||
m_scrollFrame->setContentsMargins(0, 0, 0, 0);
|
||||
m_scrollFrame->setFocusPolicy(Qt::NoFocus);
|
||||
m_scrollFrame->setStyleSheet("QScrollArea {background-color: #C0FFFFFF; border-radius:8px;}");
|
||||
m_scrollFrame->viewport()->setStyleSheet("background-color:transparent;");
|
||||
m_scrollFrame->verticalScrollBar()->setProperty("drawScrollBarGroove", false);
|
||||
m_scrollFrame->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_scrollFrame->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
m_scrollFrame->setWidgetResizable(true);
|
||||
m_scrollFrame->setWidget(listFrame);
|
||||
m_scrollFrame->setGeometry(KEYBOARD_FIXED_DEFAULT_CHARSMORE_L1, 0,
|
||||
KEYBOARD_FIXED_DEFAULT_CHARSMORE_LIST_WIDTH, KEYBOARD_FIXED_DEFAULT_CHARSMORE_LIST_HEIGHT);
|
||||
listFrame->setGeometry(KEYBOARD_FIXED_DEFAULT_CHARSMORE_L1, 0,
|
||||
KEYBOARD_FIXED_DEFAULT_CHARSMORE_LIST_WIDTH, KEYBOARD_FIXED_DEFAULT_CHARSMORE_LIST_HEIGHT);
|
||||
m_mapBtnGeometrys[m_scrollFrame] = m_scrollFrame->geometry();
|
||||
m_mapBtnGeometrys[listFrame] = listFrame->geometry();
|
||||
QChar chChars[] = {',', '.', '?', '!', '\'', ':', '~', '@', ';', '"',
|
||||
'/', '(', ')', '_', '+', '=', '`', '^', '#', '*',
|
||||
'%', '&', '\\', '[', ']', '<', '>', '{', '}', '|',
|
||||
'$', '-', ' ', ' ', ' ', ' '};
|
||||
QHBoxLayout *lastLayout = nullptr;
|
||||
for (int n = 0; n < sizeof(chChars)/sizeof(QChar); n++) {
|
||||
KBButton *charBtn = new KBButton(listFrame);
|
||||
charBtn->setCharId(chChars[n]);
|
||||
charBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_NORMAL,
|
||||
KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_FONT_COLOR_PRESS,
|
||||
KBButton::BORDER_RADIUS_NONE);
|
||||
if ((n%KEYBOARD_FIXED_DEFAULT_CHARSMORE_LIST_COLS) == 0) {
|
||||
lastLayout = new QHBoxLayout();
|
||||
lastLayout->setContentsMargins(0,0,0,0);
|
||||
lastLayout->setSpacing(1);
|
||||
m_vlayoutBtnList->addLayout(lastLayout);
|
||||
}
|
||||
if (chChars[n] == ' ') {
|
||||
charBtn->setDisabled(true);
|
||||
} else {
|
||||
charBtn->setObjectName(QString("btn_%1").arg(QString(chChars[n])));
|
||||
}
|
||||
charBtn->setFixedHeight(KEYBOARD_FIXED_DEFAULT_NORMAL_CHARSMORE_BTN_HEIGHT);
|
||||
lastLayout->addWidget(charBtn);
|
||||
m_mapSubWidgetListRects[charBtn] = charBtn->geometry();
|
||||
connect(charBtn, &KBButton::clicked, this, &CharsMoreWidget::onBtnClicked);
|
||||
}
|
||||
// backspace
|
||||
KBButton *backspaceBtn = new KBButton(this);
|
||||
backspaceBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_CHARSMORE_L1+(KEYBOARD_FIXED_DEFAULT_CHARSMORE_LIST_WIDTH+KEYBOARD_FIXED_DEFAULT_CHARSMORE_HSPACING),
|
||||
0,
|
||||
KEYBOARD_FIXED_DEFAULT_CHARSMORE_BTN_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_CHARSMORE_BTN_HEIGHT);
|
||||
backspaceBtn->setObjectName("btn_backspace");
|
||||
backspaceBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
backspaceBtn->setIcon(QIcon(":/images/images/delet.svg"));
|
||||
m_mapBtnGeometrys[backspaceBtn] = backspaceBtn->geometry();
|
||||
connect(backspaceBtn, &KBButton::clicked, this, &CharsMoreWidget::onBtnClicked);
|
||||
// enter
|
||||
KBButton *enterBtn = new KBButton(this);
|
||||
enterBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_CHARSMORE_L1+(KEYBOARD_FIXED_DEFAULT_CHARSMORE_LIST_WIDTH+KEYBOARD_FIXED_DEFAULT_CHARSMORE_HSPACING),
|
||||
(KEYBOARD_FIXED_DEFAULT_CHARSMORE_BTN_HEIGHT+KEYBOARD_FIXED_DEFAULT_CHARSMORE_VSPACING)*1,
|
||||
KEYBOARD_FIXED_DEFAULT_CHARSMORE_BTN_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_CHARSMORE_BTN_HEIGHT);
|
||||
enterBtn->setObjectName("btn_enter");
|
||||
enterBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
enterBtn->setIcon(QIcon(":/images/images/enter.svg"));
|
||||
connect(enterBtn, &KBButton::clicked, this, &CharsMoreWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[enterBtn] = enterBtn->geometry();
|
||||
// return
|
||||
KBButton *returnBtn = new KBButton(this);
|
||||
returnBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_CHARSMORE_L1+(KEYBOARD_FIXED_DEFAULT_CHARSMORE_LIST_WIDTH+KEYBOARD_FIXED_DEFAULT_CHARSMORE_HSPACING),
|
||||
(KEYBOARD_FIXED_DEFAULT_CHARSMORE_BTN_HEIGHT+KEYBOARD_FIXED_DEFAULT_CHARSMORE_VSPACING)*2,
|
||||
KEYBOARD_FIXED_DEFAULT_CHARSMORE_BTN_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_CHARSMORE_BTN_HEIGHT);
|
||||
returnBtn->setObjectName("btn_return");
|
||||
returnBtn->setText(tr("&&?!"));
|
||||
returnBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
connect(returnBtn, &KBButton::clicked, this, &CharsMoreWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[returnBtn] = returnBtn->geometry();
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef CHARSMOREWIDGETS_H
|
||||
#define CHARSMOREWIDGETS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "kbbutton.h"
|
||||
#include <QMap>
|
||||
|
||||
class QVBoxLayout;
|
||||
class QHBoxLayout;
|
||||
class QScrollArea;
|
||||
class QFrame;
|
||||
class CharsMoreWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CharsMoreWidget(QWidget *parent = nullptr);
|
||||
~CharsMoreWidget();
|
||||
void adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical = false, bool floatStatus = false);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onBtnClicked(QChar charId);
|
||||
|
||||
Q_SIGNALS:
|
||||
void clicked(int nKeyId);
|
||||
void specialBtnClicked(QString keyName);
|
||||
void normalBtnClicked(QChar charId);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
|
||||
private:
|
||||
QMap<QWidget*, QRect> m_mapBtnGeometrys;
|
||||
QMap<QWidget*, QRect> m_mapSubWidgetListRects;
|
||||
QVBoxLayout *m_vlayoutBtnList = nullptr;
|
||||
QScrollArea *m_scrollFrame = nullptr;
|
||||
QFrame *listFrame = nullptr;
|
||||
};
|
||||
|
||||
#endif // CHARSMOREWIDGETS_H
|
|
@ -0,0 +1,255 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "charswidget.h"
|
||||
|
||||
#include "commondef.h"
|
||||
#include <QDebug>
|
||||
|
||||
CharsWidget::CharsWidget(QWidget *parent/* = nullptr*/)
|
||||
: QWidget(parent)
|
||||
{
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);//背景透明
|
||||
initUI();
|
||||
}
|
||||
|
||||
CharsWidget::~CharsWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CharsWidget::initUI()
|
||||
{
|
||||
// line 1
|
||||
QChar chLine1[] = {'1','2','3','4','5','6','7','8','9','0'};
|
||||
for (int n = 0; n < sizeof(chLine1)/sizeof(QChar); n++) {
|
||||
KBButton *charBtn = new KBButton(this);
|
||||
charBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L1+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*n,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
charBtn->setCharId(chLine1[n]);
|
||||
charBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_NORMAL,KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_FONT_COLOR_PRESS);
|
||||
connect(charBtn, &KBButton::clicked, this, &CharsWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[charBtn] = charBtn->geometry();
|
||||
}
|
||||
// backspace
|
||||
KBButton *backspaceBtn = new KBButton(this);
|
||||
backspaceBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L1+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*10,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
backspaceBtn->setObjectName("btn_backspace");
|
||||
backspaceBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
connect(backspaceBtn, &KBButton::clicked, this, &CharsWidget::onBtnClicked);
|
||||
backspaceBtn->setIcon(QIcon(":/images/images/delet.svg"));
|
||||
m_mapBtnGeometrys[backspaceBtn] = backspaceBtn->geometry();
|
||||
|
||||
// line 2
|
||||
QChar chLine2[] = {'~','/',':',';','(',')','@','"','\''};
|
||||
for (int n = 0; n < sizeof(chLine2)/sizeof(QChar); n++) {
|
||||
KBButton *charBtn = new KBButton(this);
|
||||
charBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L2+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*n,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING),
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
charBtn->setCharId(chLine2[n]);
|
||||
charBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_NORMAL,KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_FONT_COLOR_PRESS);
|
||||
connect(charBtn, &KBButton::clicked, this, &CharsWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[charBtn] = charBtn->geometry();
|
||||
}
|
||||
// enter
|
||||
KBButton *enterBtn = new KBButton(this);
|
||||
enterBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L2+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*9,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING),
|
||||
KEYBOARD_FIXED_DEFAULT_ENTERBTN_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
enterBtn->setObjectName("btn_enter");
|
||||
enterBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
connect(enterBtn, &KBButton::clicked, this, &CharsWidget::onBtnClicked);
|
||||
enterBtn->setIcon(QIcon(":/images/images/enter.svg"));
|
||||
m_mapBtnGeometrys[enterBtn] = enterBtn->geometry();
|
||||
|
||||
// line 3
|
||||
QChar chLine3[] = {'-','_','#','%','$','+','^',',','.','!'};
|
||||
for (int n = 0; n < sizeof(chLine3)/sizeof(QChar); n++) {
|
||||
KBButton *charBtn = new KBButton(this);
|
||||
charBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L3+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*(n+1),
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*2,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
charBtn->setCharId(chLine3[n]);
|
||||
charBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_NORMAL,KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_FONT_COLOR_PRESS);
|
||||
connect(charBtn, &KBButton::clicked, this, &CharsWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[charBtn] = charBtn->geometry();
|
||||
}
|
||||
// more
|
||||
KBButton *moreBtn = new KBButton(this);
|
||||
moreBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L3,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*2,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
moreBtn->setObjectName("btn_more");
|
||||
moreBtn->setText(tr("More"));
|
||||
moreBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
connect(moreBtn, &KBButton::clicked, this, &CharsWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[moreBtn] = moreBtn->geometry();
|
||||
|
||||
// line 4
|
||||
KBButton *returnBtn = new KBButton(this);
|
||||
returnBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
returnBtn->setObjectName("btn_return");
|
||||
returnBtn->setText(tr("ABC"));
|
||||
returnBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
connect(returnBtn, &KBButton::clicked, this, &CharsWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[returnBtn] = returnBtn->geometry();
|
||||
|
||||
KBButton *numBtn = new KBButton(this);
|
||||
numBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING),
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
numBtn->setObjectName("btn_number");
|
||||
numBtn->setText(tr("123"));
|
||||
numBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
connect(numBtn, &KBButton::clicked, this, &CharsWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[numBtn] = numBtn->geometry();
|
||||
|
||||
KBButton *threedBtn = new KBButton(this);
|
||||
threedBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*2,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
threedBtn->setObjectName("btn_threed");
|
||||
threedBtn->setCharId(('&'));
|
||||
threedBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_NORMAL,KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_FONT_COLOR_PRESS);
|
||||
connect(threedBtn, &KBButton::clicked, this, &CharsWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[threedBtn] = threedBtn->geometry();
|
||||
|
||||
KBButton *spaceBtn = new KBButton(this);
|
||||
spaceBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_SPACEBTN_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
spaceBtn->setObjectName("btn_space");
|
||||
spaceBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_FONT_COLOR_PRESS);
|
||||
spaceBtn->setIcon(QIcon(":/images/images/space.svg"));
|
||||
connect(spaceBtn, &KBButton::clicked, this, &CharsWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[spaceBtn] = spaceBtn->geometry();
|
||||
|
||||
KBButton *whBtn = new KBButton(this);
|
||||
whBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*8,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
whBtn->setCharId('?');
|
||||
whBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_NORMAL,KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_FONT_COLOR_PRESS);
|
||||
connect(whBtn, &KBButton::clicked, this, &CharsWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[whBtn] = whBtn->geometry();
|
||||
|
||||
KBButton *leftBtn = new KBButton(this);
|
||||
leftBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*9,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
leftBtn->setObjectName("btn_left");
|
||||
leftBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
leftBtn->setIcon(QIcon(":/images/images/left.svg"));
|
||||
connect(leftBtn, &KBButton::clicked, this, &CharsWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[leftBtn] = leftBtn->geometry();
|
||||
|
||||
KBButton *rightBtn = new KBButton(this);
|
||||
rightBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*10,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
rightBtn->setObjectName("btn_right");
|
||||
rightBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
rightBtn->setIcon(QIcon(":/images/images/right.svg"));
|
||||
connect(rightBtn, &KBButton::clicked, this, &CharsWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[rightBtn] = rightBtn->geometry();
|
||||
}
|
||||
|
||||
void CharsWidget::adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical/* = false*/, bool floatStatus)
|
||||
{
|
||||
QMap<KBButton*, QRect>::iterator itGeometry = m_mapBtnGeometrys.begin();
|
||||
for (; itGeometry != m_mapBtnGeometrys.end(); itGeometry ++) {
|
||||
KBButton *button = itGeometry.key();
|
||||
if (button) {
|
||||
QRect oldGeometry = itGeometry.value();
|
||||
QRect newGeometry = oldGeometry;
|
||||
if (floatStatus) {
|
||||
newGeometry.setX(oldGeometry.x()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
|
||||
newGeometry.setY(oldGeometry.y()*lfHeightScale);
|
||||
newGeometry.setWidth(oldGeometry.width()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
|
||||
newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
|
||||
} else {
|
||||
newGeometry.setX(oldGeometry.x()*lfWidthScale);
|
||||
newGeometry.setY(oldGeometry.y()*lfHeightScale);
|
||||
newGeometry.setWidth(oldGeometry.width()*lfWidthScale);
|
||||
newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
|
||||
}
|
||||
button->setGeometry(newGeometry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CharsWidget::onBtnClicked(QChar charId)
|
||||
{
|
||||
QObject *obj = sender();
|
||||
KBButton *btn = static_cast<KBButton*>(obj);
|
||||
QString objName = btn->objectName();
|
||||
int lastUnderline = objName.lastIndexOf('_');
|
||||
int start = strlen("btn_");
|
||||
int keyLength = lastUnderline - start;
|
||||
QString keyName = objName.mid(start, keyLength);
|
||||
if (keyName == BTN_RETURN) {
|
||||
Q_EMIT specialBtnClicked(PAGE_LETTER);
|
||||
} else if (keyName == "more") {
|
||||
Q_EMIT specialBtnClicked(PAGE_CHARSMORE);
|
||||
} else if (keyName == "number") {
|
||||
Q_EMIT specialBtnClicked(PAGE_NUMBER);
|
||||
} else if (charId != QChar::Null) {
|
||||
Q_EMIT normalBtnClicked(charId);
|
||||
} else {
|
||||
Q_EMIT specialBtnClicked(keyName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef CHARSWIDGET_H
|
||||
#define CHARSWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "kbbutton.h"
|
||||
#include <QMap>
|
||||
|
||||
class CharsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CharsWidget(QWidget *parent = nullptr);
|
||||
virtual ~CharsWidget();
|
||||
|
||||
void adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical = false, bool floatStatus = false);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onBtnClicked(QChar charId);
|
||||
|
||||
Q_SIGNALS:
|
||||
void clicked(int nKeyId);
|
||||
void specialBtnClicked(QString keyName);
|
||||
void normalBtnClicked(QChar c);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
|
||||
private:
|
||||
QMap<KBButton*, QRect> m_mapBtnGeometrys;
|
||||
|
||||
};
|
||||
|
||||
#endif // CHARSWIDGET_H
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef COMMONDEF_H
|
||||
#define COMMONDEF_H
|
||||
|
||||
#define KEYBOARD_PARENT_DEFAULT_WIDTH 1620
|
||||
#define KEYBOARD_PARENT_DEFAULT_HEIGHT 1080
|
||||
|
||||
#define KEYBOARD_FIXED_DEFAULT_WIDTH 1620
|
||||
#define KEYBOARD_DRAGSHOW_FIXED_DEFAULT_HEIGHT 428
|
||||
|
||||
#define KEYBOARD_DRAGSHOW_FIXED_DEFAULT_WIDTH 1458
|
||||
#define KEYBOARD_DRAGHIDE_FIXED_DEFAULT_HEIGHT 404
|
||||
|
||||
#define KEYBOARD_TITLEBTN_DEFAULT_WIDTH 56
|
||||
#define KEYBOARD_TITLEBTN_DEFAULT_HEIGHT 56
|
||||
#define KEYBOARD_TITLE_DEFAULT_HEIGHT 68
|
||||
|
||||
#define KEYBOARD_DRAGBTN_DEFAULT_WIDTH 56
|
||||
#define KEYBOARD_DRAGBTN_DEFAULT_HEIGHT 4
|
||||
#define KEYBOARD_DRAG_DEFAULT_HEIGHT 26
|
||||
|
||||
#define KEYBOARD_FLOAT_PERCENTAGE 0.9
|
||||
|
||||
#define KEYBOARD_FIXED_DEFAULT_LMARGIN 22 // 左边距
|
||||
#define KEYBOARD_FIXED_DEFAULT_RMARGIN 22 // 右边距
|
||||
#define KEYBOARD_FIXED_DEFAULT_TMARGIN 8 // 上边距
|
||||
#define KEYBOARD_FIXED_DEFAULT_BMARGIN 16 // 下边距
|
||||
|
||||
#define KEYBOAED_FIXED_DEFAULT_VSPACING 8 // 垂直间隔
|
||||
#define KEYBOAED_FIXED_DEFAULT_HSPACING 8 // 水平间隔
|
||||
// letters
|
||||
#define KEYBOARD_FIXED_DEFAULT_LETTER_L1 (KEYBOARD_FIXED_DEFAULT_LMARGIN+0) // 字符页面左起点
|
||||
#define KEYBOARD_FIXED_DEFAULT_LETTER_L2 (KEYBOARD_FIXED_DEFAULT_LMARGIN+72) // 字符页面左起点
|
||||
#define KEYBOARD_FIXED_DEFAULT_LETTER_L3 (KEYBOARD_FIXED_DEFAULT_LMARGIN+0) // 字符页面左起点
|
||||
#define KEYBOARD_FIXED_DEFAULT_LETTER_L4 (KEYBOARD_FIXED_DEFAULT_LMARGIN+0) // 字符页面左起点
|
||||
#define KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH 136 // 字符按钮宽度
|
||||
#define KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT 72 // 字符按钮高度
|
||||
#define KEYBOARD_FIXED_DEFAULT_LETTER_ENTWIDTH 208
|
||||
#define KEYBOARD_FIXED_DEFAULT_LETTER_SPCWIDTH 712
|
||||
#define KEYBOARD_FIXED_DEFAULT_TITLEBTN_WIDTH 56
|
||||
#define KEYBOARD_FIXED_DEFAULT_TITLEBTN_HEIGHT 56
|
||||
|
||||
#define KEYBOARD_FIXED_DEFAULT_ENTERBTN_WIDTH 208
|
||||
#define KEYBOARD_FIXED_DEFAULT_SPACEBTN_WIDTH 712
|
||||
|
||||
#define KEYBOARD_LETTER_COLOR_NORMAL "#FFFFFF"
|
||||
#define KEYBOARD_LETTER_COLOR_PRESSED "#DDE0E4"
|
||||
#define KEYBOARD_LETTER_COLOR_BORDER_NORMAL "#95A0AD"
|
||||
#define KEYBOARD_LETTER_COLOR_BORDER_PRESSED "#95A0AD"
|
||||
|
||||
#define KEYBOARD_OTHER_COLOR_NORMAL "#CED3D9"
|
||||
#define KEYBOARD_OTHER_COLOR_PRESSED "#3790FA"
|
||||
#define KEYBOARD_OTHER_COLOR_BORDER_NORMAL "#95A0AD"
|
||||
#define KEYBOARD_OTHER_COLOR_BORDER_PRESSED "#1174E5"
|
||||
|
||||
#define KEYBOARD_FONT_COLOR_PRESS "#262626"
|
||||
#define KEYBOARD_OTHER_FONT_COLOR_PRESS "#FFFFFF"
|
||||
|
||||
//numbers
|
||||
#define KEYBOARD_FIXED_DEFAULT_NUMBER_L1 (KEYBOARD_FIXED_DEFAULT_LMARGIN+0)
|
||||
#define KEYBOARD_FIXED_DEFAULT_NUMBER_L2 (KEYBOARD_FIXED_DEFAULT_LMARGIN+0)
|
||||
#define KEYBOARD_FIXED_DEFAULT_NUMBER_L3 (KEYBOARD_FIXED_DEFAULT_LMARGIN+0)
|
||||
#define KEYBOARD_FIXED_DEFAULT_NUMBER_L4 (KEYBOARD_FIXED_DEFAULT_LMARGIN+0)
|
||||
|
||||
#define KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH 306 // 数字按钮宽度
|
||||
#define KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT 72 // 数字按钮高度
|
||||
#define KEYBOARD_FIXED_DEFAULT_NUMBER_CHARS_HEIGHT 230 // 数字字符按钮高度
|
||||
|
||||
// chars more
|
||||
|
||||
#define KEYBOARD_FIXED_DEFAULT_CHARSMORE_L1 (KEYBOARD_FIXED_DEFAULT_LMARGIN+0)
|
||||
#define KEYBOARD_FIXED_DEFAULT_CHARSMORE_HSPACING 16
|
||||
#define KEYBOARD_FIXED_DEFAULT_CHARSMORE_VSPACING 16
|
||||
|
||||
#define KEYBOARD_FIXED_DEFAULT_CHARSMORE_LIST_COLS 6
|
||||
#define KEYBOARD_FIXED_DEFAULT_CHARSMORE_LIST_WIDTH 1350 // 字符列表宽度
|
||||
#define KEYBOARD_FIXED_DEFAULT_CHARSMORE_LIST_HEIGHT 315 // 字符列表高度
|
||||
#define KEYBOARD_FIXED_DEFAULT_CHARSMORE_BTN_WIDTH 214 // 按钮宽度
|
||||
#define KEYBOARD_FIXED_DEFAULT_CHARSMORE_BTN_HEIGHT 94 // 功能按钮高度
|
||||
#define KEYBOARD_FIXED_DEFAULT_NORMAL_CHARSMORE_BTN_HEIGHT 80 // 符号按钮高度
|
||||
|
||||
//iconsize
|
||||
#define KEYBOARD_FIXED_DEFAULT_ICONSIZE QSize(25, 25)
|
||||
|
||||
//keyName
|
||||
#define PAGE_CHAR "page_char"
|
||||
#define PAGE_NUMBER "page_number"
|
||||
#define PAGE_CHARSMORE "page_charmore"
|
||||
#define PAGE_LETTER "page_letter"
|
||||
#define BTN_FLOAT "float"
|
||||
#define BTN_CLOSE "close"
|
||||
#define BTN_RETURN "return"
|
||||
#define BTN_BACK "backspace"
|
||||
#define BTN_ENTER "enter"
|
||||
#define BTN_SHIFT "shift"
|
||||
#define BTN_CTRL "ctrl"
|
||||
#define BTN_ALT "alt"
|
||||
#define BTN_SPACE "space"
|
||||
#define BTN_RIGHT "right"
|
||||
#define BTN_LEFT "left"
|
||||
#define BTN_CAPSLOCK "capslock"
|
||||
|
||||
|
||||
|
||||
#endif // COMMONDEF_H
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -12,9 +12,8 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "cursormonitor.h"
|
||||
#include <X11/Xlib.h>
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "dragwidget.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QDebug>
|
||||
#include "commondef.h"
|
||||
|
||||
DragWidget::DragWidget(QWidget *parent/* = nullptr*/)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setAttribute(Qt::WA_TranslucentBackground);//背景透明
|
||||
initUI();
|
||||
}
|
||||
|
||||
DragWidget::~DragWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DragWidget::initUI()
|
||||
{
|
||||
setFixedHeight(KEYBOARD_DRAG_DEFAULT_HEIGHT);
|
||||
|
||||
m_labelDrag = new QLabel(this);
|
||||
m_labelDrag->setPixmap(QPixmap(":/images/images/drag.svg"));
|
||||
m_labelDrag->setGeometry((KEYBOARD_PARENT_DEFAULT_WIDTH - KEYBOARD_TITLEBTN_DEFAULT_WIDTH)/2,
|
||||
(this->height() - KEYBOARD_TITLEBTN_DEFAULT_HEIGHT)/2,
|
||||
KEYBOARD_TITLEBTN_DEFAULT_WIDTH, KEYBOARD_TITLEBTN_DEFAULT_HEIGHT);
|
||||
m_mapSubGeometrys[m_labelDrag] = m_labelDrag->geometry();
|
||||
}
|
||||
|
||||
void DragWidget::adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical/* = false*/, bool floatStatus)
|
||||
{
|
||||
setFixedHeight(KEYBOARD_DRAG_DEFAULT_HEIGHT*lfHeightScale);
|
||||
QMap<QLabel*, QRect>::iterator itGeometry = m_mapSubGeometrys.begin();
|
||||
for (; itGeometry != m_mapSubGeometrys.end(); itGeometry ++) {
|
||||
QLabel *label = itGeometry.key();
|
||||
if (label) {
|
||||
QRect oldGeometry = itGeometry.value();
|
||||
QRect newGeometry = oldGeometry;
|
||||
if (floatStatus) {
|
||||
newGeometry.setX(oldGeometry.x()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
|
||||
newGeometry.setY(oldGeometry.y()*lfHeightScale);
|
||||
newGeometry.setWidth(oldGeometry.width()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
|
||||
newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
|
||||
} else {
|
||||
newGeometry.setX(oldGeometry.x()*lfWidthScale);
|
||||
newGeometry.setY(oldGeometry.y()*lfHeightScale);
|
||||
newGeometry.setWidth(oldGeometry.width()*lfWidthScale);
|
||||
newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
|
||||
}
|
||||
label->setGeometry(newGeometry);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef DRAGWIDGET_H
|
||||
#define DRAGWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QMap>
|
||||
|
||||
class DragWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DragWidget(QWidget *parent = nullptr);
|
||||
virtual ~DragWidget();
|
||||
|
||||
public:
|
||||
void adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical = false, bool floatStatus = false);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
|
||||
private:
|
||||
QLabel *m_labelDrag = nullptr;
|
||||
QMap<QLabel*, QRect> m_mapSubGeometrys;
|
||||
};
|
||||
|
||||
#endif // DRAGWIDGET_H
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef FAKEKEYBOARD_H
|
||||
#define FAKEKEYBOARD_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMetaEnum>
|
||||
|
||||
class Modifier : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Modifier(){}
|
||||
|
||||
enum MOD{
|
||||
UNKNOWN = -1,
|
||||
CTRL,
|
||||
SHIFT,
|
||||
ALT,
|
||||
SUPER
|
||||
};
|
||||
Q_ENUM(MOD)
|
||||
|
||||
static QString getModifierName(int mod)
|
||||
{
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<Modifier::MOD>();
|
||||
const char* modName = metaEnum.valueToKey(mod);
|
||||
QString result = QString(modName).toLower();
|
||||
return result;
|
||||
}
|
||||
static MOD getModifier(const QString &modName)
|
||||
{
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<Modifier::MOD>();
|
||||
MOD mod = (MOD)metaEnum.keyToValue(modName.toUpper().toLocal8Bit().data());
|
||||
return mod;
|
||||
}
|
||||
};
|
||||
|
||||
class FuncKey : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FuncKey(){}
|
||||
|
||||
enum FUNCKEY {
|
||||
UNKNOWN = -1,
|
||||
SPACE = 0,
|
||||
BACKSPACE,
|
||||
ENTER,
|
||||
HOME,
|
||||
END,
|
||||
PGUP,
|
||||
PGDN,
|
||||
INSERT,
|
||||
DELETE,
|
||||
UP,
|
||||
DOWN,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
CAPSLOCK
|
||||
};
|
||||
Q_ENUM(FUNCKEY)
|
||||
static QString getKeyName(int key)
|
||||
{
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<FuncKey::FUNCKEY>();
|
||||
const char* keyName = metaEnum.valueToKey(key);
|
||||
QString result = QString(keyName).toLower();
|
||||
return result;
|
||||
}
|
||||
static FUNCKEY getKey(const QString &keyName)
|
||||
{
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<FuncKey::FUNCKEY>();
|
||||
FUNCKEY key = (FUNCKEY)metaEnum.keyToValue(keyName.toUpper().toLocal8Bit().data());
|
||||
return key;
|
||||
}
|
||||
};
|
||||
|
||||
class FakeKeyboard : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FakeKeyboard(QObject *parent = nullptr)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual void addModifier(Modifier::MOD mod) = 0;
|
||||
virtual void removeModifier(Modifier::MOD mod) = 0;
|
||||
virtual bool hasModifier(Modifier::MOD mod) = 0;
|
||||
virtual QList<Modifier::MOD> getAllModifier() = 0;
|
||||
virtual void clearModifier() = 0;
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void onKeyPressed(QChar c) = 0;
|
||||
virtual void onKeyPressed(FuncKey::FUNCKEY key) = 0;
|
||||
};
|
||||
|
||||
#endif // FAKEKEYBOARD_H
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<g id="默认">
|
||||
<path fill="#FFFFFF" d="M41.1,9c3.2,0,5.9,2.6,5.9,5.9v20.2c0,3.2-2.6,5.9-5.9,5.9H18.3L4,25L18.3,9H41.1 M41.1,6H16.9L0,25
|
||||
l16.9,19h24.2c4.9,0,8.9-4,8.9-8.9V14.9C50,10,46,6,41.1,6z"/>
|
||||
|
||||
<line fill="none" stroke="#FFFFFF" stroke-width="3" stroke-linecap="round" stroke-miterlimit="10" x1="40" y1="15" x2="20" y2="35"/>
|
||||
|
||||
<line fill="none" stroke="#FFFFFF" stroke-width="3" stroke-linecap="round" stroke-miterlimit="10" x1="20" y1="15" x2="40" y2="35"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 837 B |
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<g id="点击" opacity="0.6">
|
||||
<path fill="#FFFFFF" d="M41.1,9c3.2,0,5.9,2.6,5.9,5.9v20.2c0,3.2-2.6,5.9-5.9,5.9H18.3L4,25L18.3,9H41.1 M41.1,6H16.9L0,25
|
||||
l16.9,19h24.2c4.9,0,8.9-4,8.9-8.9V14.9C50,10,46,6,41.1,6z"/>
|
||||
|
||||
<line fill="none" stroke="#FFFFFF" stroke-width="3" stroke-linecap="round" stroke-miterlimit="10" x1="40" y1="15" x2="20" y2="35"/>
|
||||
|
||||
<line fill="none" stroke="#FFFFFF" stroke-width="3" stroke-linecap="round" stroke-miterlimit="10" x1="20" y1="15" x2="40" y2="35"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 851 B |
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#FFFFFF;}
|
||||
</style>
|
||||
<path class="st0" d="M25,6.5L43.3,27H35v17H15V27H6.7L25,6.5 M22.8,4.5L3,26.7C1.8,28,2.7,30,4.5,30H12v15c0,1.1,0.9,2,2,2h22
|
||||
c1.1,0,2-0.9,2-2V30h7.5c1.7,0,2.6-2,1.5-3.3L27.2,4.5C26,3.2,24,3.2,22.8,4.5z"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 621 B |
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<g id="点击" opacity="0.6">
|
||||
<path fill="#FFFFFF" d="M25,6.5L43.3,27H35v17H15V27H6.7L25,6.5 M22.8,4.5L3,26.7C1.8,28,2.7,30,4.5,30H12v15c0,1.1,0.9,2,2,2h22
|
||||
c1.1,0,2-0.9,2-2V30h7.5c1.7,0,2.6-2,1.5-3.3L27.2,4.5C26,3.2,24,3.2,22.8,4.5z"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 599 B |
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<path fill="#67B204" d="M25,6.5L43.3,27H35v17H15V27H6.7L25,6.5 M22.8,4.5L3,26.7C1.8,28,2.7,30,4.5,30H12v15c0,1.1,0.9,2,2,2h22
|
||||
c1.1,0,2-0.9,2-2V30h7.5c1.7,0,2.6-2,1.5-3.3L27.2,4.5C26,3.2,24,3.2,22.8,4.5z"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 560 B |
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<path fill="#4A692A" d="M25,6.5L43.3,27H35v17H15V27H6.7L25,6.5 M22.8,4.5L3,26.7C1.8,28,2.7,30,4.5,30H12v15c0,1.1,0.9,2,2,2h22
|
||||
c1.1,0,2-0.9,2-2V30h7.5c1.7,0,2.6-2,1.5-3.3L27.2,4.5C26,3.2,24,3.2,22.8,4.5z"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 560 B |
|
@ -1,22 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<g id="键盘">
|
||||
<g id="默认">
|
||||
<path fill="#FFFFFF" d="M47,5v29H3V5H47 M50,2H0v35h50V2z"/>
|
||||
<rect x="8" y="10" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="15" y="10" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="23" y="10" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="31" y="10" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="39" y="10" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="8" y="18" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="15" y="18" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="23" y="18" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="31" y="18" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="39" y="18" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="13" y="26" fill="#FFFFFF" width="24" height="3"/>
|
||||
</g>
|
||||
</g>
|
||||
<polygon fill="#FFFFFF" points="29,41 25,45 21,41 18,41 25,48 32,41 "/>
|
||||
</svg>
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M17.6566 19.0719C18.0471 19.4624 18.6802 19.4624 19.0708 19.0719C19.4613 18.6814 19.4613 18.0482 19.0708 17.6577L6.34285 4.92976C5.95232 4.53923 5.31916 4.53923 4.92864 4.92976C4.53811 5.32028 4.53811 5.95345 4.92864 6.34397L17.6566 19.0719Z" fill="#262626"/>
|
||||
<path d="M17.6566 4.92961C18.0471 4.53909 18.6803 4.53909 19.0708 4.92961C19.4613 5.32014 19.4613 5.9533 19.0708 6.34383L6.3429 19.0717C5.95238 19.4623 5.31921 19.4623 4.92869 19.0717C4.53816 18.6812 4.53816 18.0481 4.92869 17.6575L17.6566 4.92961Z" fill="#262626"/>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 639 B |
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<g id="键盘" opacity="0.6">
|
||||
<g id="默认">
|
||||
<path fill="#FFFFFF" d="M47,5v29H3V5H47 M50,2H0v35h50V2z"/>
|
||||
<rect x="8" y="10" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="15" y="10" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="23" y="10" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="31" y="10" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="39" y="10" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="8" y="18" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="15" y="18" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="23" y="18" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="31" y="18" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="39" y="18" fill="#FFFFFF" width="3" height="3"/>
|
||||
<rect x="13" y="26" fill="#FFFFFF" width="24" height="3"/>
|
||||
</g>
|
||||
</g>
|
||||
<polygon opacity="0.6" fill="#FFFFFF" enable-background="new " points="29,41 25,45 21,41 18,41 25,48 32,41 "/>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.2 KiB |
|
@ -0,0 +1,5 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M21.5 7.12778V16.8722H23.5V7.12778H21.5ZM5.6834 18.1172L2.14546 12.3607L0.44154 13.4079L3.97948 19.1645L5.6834 18.1172ZM2.14546 11.6393L5.6834 5.88275L3.97948 4.83553L0.44154 10.5921L2.14546 11.6393ZM19.1222 19.25H7.70917V21.25H19.1222V19.25ZM7.70917 4.75L19.1222 4.75V2.75H7.70917V4.75ZM2.14546 12.3607C2.00948 12.1395 2.00948 11.8605 2.14546 11.6393L0.44154 10.5921C-0.0892174 11.4557 -0.0892166 12.5443 0.44154 13.4079L2.14546 12.3607ZM21.5 16.8722C21.5 18.1854 20.4354 19.25 19.1222 19.25V21.25C21.54 21.25 23.5 19.29 23.5 16.8722H21.5ZM23.5 7.12778C23.5 4.71 21.54 2.75 19.1222 2.75V4.75C20.4354 4.75 21.5 5.81457 21.5 7.12778H23.5ZM5.6834 5.88275C6.116 5.17887 6.88297 4.75 7.70917 4.75V2.75C6.18804 2.75 4.77596 3.5396 3.97948 4.83553L5.6834 5.88275ZM3.97948 19.1645C4.77596 20.4604 6.18805 21.25 7.70917 21.25V19.25C6.88297 19.25 6.116 18.8211 5.6834 18.1172L3.97948 19.1645Z" fill="#262626"/>
|
||||
<rect x="8.0498" y="8.46484" width="2" height="12" rx="1" transform="rotate(-45 8.0498 8.46484)" fill="#262626"/>
|
||||
<rect width="2" height="12" rx="1" transform="matrix(0.707107 0.707107 0.707107 -0.707107 8.05078 15.5352)" fill="#363940"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<title>画板 15</title>
|
||||
<g id="下">
|
||||
<polygon id="默认" fill="#FFFFFF" points="25,32 38,17 12,17 "/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 466 B |
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<polygon id="点击" opacity="0.6" fill="#FFFFFF" enable-background="new " points="25,32 38,17 12,17 "/>
|
||||
</svg>
|
Before Width: | Height: | Size: 460 B |
|
@ -0,0 +1,3 @@
|
|||
<svg width="56" height="4" viewBox="0 0 56 4" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="56" height="4" rx="2" fill="#1D1D1D"/>
|
||||
</svg>
|
After Width: | Height: | Size: 153 B |
|
@ -1,11 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 70 50" enable-background="new 0 0 70 50" xml:space="preserve">
|
||||
<path display="none" fill="none" stroke="#FFFFFF" stroke-width="3" stroke-miterlimit="10" d="M36.5,9.5h2c5.5,0,10,4.5,10,10l0,0
|
||||
c0,5.5-4.5,10-10,10H5"/>
|
||||
<polyline fill="none" stroke="#FFFFFF" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
|
||||
21,16 3,29.5 21,43 "/>
|
||||
<path fill="none" stroke="#FFFFFF" stroke-width="3" stroke-linecap="round" stroke-miterlimit="10" d="M50,12.5h12.7
|
||||
c3.3,0,6,2.7,6,6v4.8c0,3.3-2.7,6-6,6H5"/>
|
||||
</svg>
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M2 17H18C20.2091 17 22 15.2091 22 13V3" stroke="#363940" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M7 12L2 17L7 22" stroke="#363940" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 828 B After Width: | Height: | Size: 344 B |
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" opacity="0.6" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
x="0px" y="0px" viewBox="0 0 70 50" enable-background="new 0 0 70 50" xml:space="preserve">
|
||||
<polyline opacity="0.6" fill="none" stroke="#FFFFFF" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" enable-background="new " points="
|
||||
21,16 3,29.5 21,43 "/>
|
||||
<path opacity="0.6" fill="none" stroke="#FFFFFF" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" enable-background="new " d="
|
||||
M50,12.5h12.7c3.3,0,6,2.7,6,6v4.8c0,3.3-2.7,6-6,6H5"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 794 B |
|
@ -0,0 +1,6 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M2 8V15.6C2 17.8402 2 18.9603 2.43597 19.816C2.81947 20.5686 3.43139 21.1805 4.18404 21.564C5.03968 22 6.15979 22 8.4 22H15.6C17.8402 22 18.9603 22 19.816 21.564C20.5686 21.1805 21.1805 20.5686 21.564 19.816C22 18.9603 22 17.8402 22 15.6V8" stroke="#262626" stroke-width="2" stroke-linecap="round"/>
|
||||
<path d="M8.29289 15.7071C7.90237 15.3166 7.90237 14.6834 8.29289 14.2929C8.68342 13.9024 9.31658 13.9024 9.70711 14.2929L8.29289 15.7071ZM12 18L12.7071 18.7071C12.3166 19.0976 11.6834 19.0976 11.2929 18.7071L12 18ZM14.2929 14.2929C14.6834 13.9024 15.3166 13.9024 15.7071 14.2929C16.0976 14.6834 16.0976 15.3166 15.7071 15.7071L14.2929 14.2929ZM9.70711 14.2929L12.7071 17.2929L11.2929 18.7071L8.29289 15.7071L9.70711 14.2929ZM11.2929 17.2929L14.2929 14.2929L15.7071 15.7071L12.7071 18.7071L11.2929 17.2929Z" fill="#262626"/>
|
||||
<path d="M11 16C11 16.5523 11.4477 17 12 17C12.5523 17 13 16.5523 13 16L11 16ZM13 8C13 7.44772 12.5523 7 12 7C11.4477 7 11 7.44772 11 8L13 8ZM13 16L13 8L11 8L11 16L13 16Z" fill="#262626"/>
|
||||
<path d="M2 8H22V8C22 6.13623 22 5.20435 21.6955 4.46927C21.2895 3.48915 20.5108 2.71046 19.5307 2.30448C18.7956 2 17.8638 2 16 2H8C6.13623 2 5.20435 2 4.46927 2.30448C3.48915 2.71046 2.71046 3.48915 2.30448 4.46927C2 5.20435 2 6.13623 2 8V8Z" stroke="#262626" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,6 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M2 16V8.4C2 6.15979 2 5.03969 2.43597 4.18404C2.81947 3.43139 3.43139 2.81947 4.18404 2.43597C5.03968 2 6.15979 2 8.4 2H15.6C17.8402 2 18.9603 2 19.816 2.43597C20.5686 2.81947 21.1805 3.43139 21.564 4.18404C22 5.03969 22 6.15979 22 8.4V16" stroke="#262626" stroke-width="2" stroke-linecap="round"/>
|
||||
<path d="M8.29289 8.29289C7.90237 8.68342 7.90237 9.31658 8.29289 9.70711C8.68342 10.0976 9.31658 10.0976 9.70711 9.70711L8.29289 8.29289ZM12 6L12.7071 5.29289C12.3166 4.90237 11.6834 4.90237 11.2929 5.29289L12 6ZM14.2929 9.70711C14.6834 10.0976 15.3166 10.0976 15.7071 9.70711C16.0976 9.31658 16.0976 8.68342 15.7071 8.29289L14.2929 9.70711ZM9.70711 9.70711L12.7071 6.70711L11.2929 5.29289L8.29289 8.29289L9.70711 9.70711ZM11.2929 6.70711L14.2929 9.70711L15.7071 8.29289L12.7071 5.29289L11.2929 6.70711Z" fill="#262626"/>
|
||||
<path d="M11 16C11 16.5523 11.4477 17 12 17C12.5523 17 13 16.5523 13 16L11 16ZM13 6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6L13 6ZM13 16L13 6L11 6L11 16L13 16Z" fill="#262626"/>
|
||||
<path d="M2 16H22V16C22 17.8638 22 18.7956 21.6955 19.5307C21.2895 20.5108 20.5108 21.2895 19.5307 21.6955C18.7956 22 17.8638 22 16 22H8C6.13623 22 5.20435 22 4.46927 21.6955C3.48915 21.2895 2.71046 20.5108 2.30448 19.5307C2 18.7956 2 17.8638 2 16V16Z" stroke="#262626" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
|
@ -1,7 +1,3 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="左" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<title>画板 19</title>
|
||||
<polygon id="默认" fill="#FFFFFF" points="18,25 33,12 33,38 "/>
|
||||
</svg>
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M17 2L7 12L17 22" stroke="#262626" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 439 B After Width: | Height: | Size: 213 B |
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="左" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<title>画板 20</title>
|
||||
<polygon id="点击" opacity="0.6" fill="#FFFFFF" enable-background="new " points="18,25 33,12 33,38 "/>
|
||||
</svg>
|
Before Width: | Height: | Size: 481 B |
|
@ -0,0 +1,3 @@
|
|||
<svg width="20" height="22" viewBox="0 0 20 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.34569 0.738189C9.22632 -0.246061 10.7737 -0.246064 11.6543 0.738188L19.4361 9.43558C20.7058 10.8547 19.6923 13.0988 17.7817 13.0988H15.1658V19.7993C15.1658 21.0147 14.1746 22 12.9519 22H7.04809C5.82538 22 4.83417 21.0147 4.83417 19.7993V13.0988H2.21826C0.30769 13.0988 -0.705754 10.8547 0.563946 9.43558L8.34569 0.738189Z" fill="white"/>
|
||||
</svg>
|
After Width: | Height: | Size: 493 B |
|
@ -1,6 +1,3 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<polygon id="默认" fill="#FFFFFF" points="33,25 18,12 18,38 "/>
|
||||
</svg>
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7 2L17 12L7 22" stroke="#262626" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 418 B After Width: | Height: | Size: 212 B |
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<polygon id="点击" opacity="0.6" fill="#FFFFFF" enable-background="new " points="33,25 18,12 18,38 "/>
|
||||
</svg>
|
Before Width: | Height: | Size: 460 B |
|
@ -0,0 +1,3 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M17.1658 13.0988H16.1658V14.0988V20.7993C16.1658 21.4568 15.628 22 14.9519 22H9.04809C8.372 22 7.83417 21.4568 7.83417 20.7993V14.0988V13.0988H6.83417H4.21826C3.15987 13.0988 2.62398 11.8682 3.30919 11.1024L11.0909 2.40498C11.5741 1.86501 12.4259 1.86501 12.9091 2.40498L20.6908 11.1024C21.376 11.8682 20.8401 13.0988 19.7817 13.0988H17.1658Z" stroke="#262626" stroke-width="2"/>
|
||||
</svg>
|
After Width: | Height: | Size: 492 B |
|
@ -0,0 +1,4 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.0341 1.74795C13.1587 0.763701 11.6206 0.763704 10.7453 1.74795L3.01004 10.4453C1.74793 11.8644 2.75531 14.1085 4.65446 14.1085H7.25473V20.8091C7.25473 22.0245 8.24002 23.0098 9.45543 23.0098H11.5414C11.5046 22.9464 11.4694 22.8818 11.436 22.8162C11.1594 22.2734 11.0713 21.7339 11.0339 21.2767C10.9999 20.8604 10.9999 20.3689 11 19.8641V19.8641L11 19.8003V19.2003L11 19.1365V19.1364C10.9999 18.6317 10.9999 18.1401 11.0339 17.7238C11.0713 17.2666 11.1594 16.7272 11.436 16.1843C11.7917 15.4863 12.3438 14.9093 13.0225 14.5233C13.2626 11.9856 15.3995 10.0003 18 10.0003C19.8088 10.0003 21.3933 10.9608 22.2712 12.3995C22.4233 11.7508 22.2879 11.0284 21.7693 10.4453L14.0341 1.74795Z" fill="white"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M15 16.0192C14.6078 16.0431 14.3295 16.097 14.092 16.218C13.7157 16.4097 13.4097 16.7157 13.218 17.092C13 17.5198 13 18.0799 13 19.2V19.8C13 20.9201 13 21.4802 13.218 21.908C13.4097 22.2843 13.7157 22.5903 14.092 22.782C14.5198 23 15.0799 23 16.2 23H19.8C20.9201 23 21.4802 23 21.908 22.782C22.2843 22.5903 22.5903 22.2843 22.782 21.908C23 21.4802 23 20.9201 23 19.8V19.2C23 18.0799 23 17.5198 22.782 17.092C22.5903 16.7157 22.2843 16.4097 21.908 16.218C21.6705 16.097 21.3922 16.0431 21 16.0192V15C21 13.3431 19.6569 12 18 12C16.3431 12 15 13.3431 15 15V16.0192ZM17 16H19V15C19 14.4477 18.5523 14 18 14C17.4477 14 17 14.4477 17 15V16Z" fill="white"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1,10 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_3756_117108)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M20 10V13H4V10C4 9.45 3.55 9 3 9C2.45 9 2 9.45 2 10V14C2 14.55 2.45 15 3 15H21C21.55 15 22 14.55 22 14V10C22 9.45 21.55 9 21 9C20.45 9 20 9.45 20 10Z" fill="#1D1D1D"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_3756_117108">
|
||||
<rect width="24" height="24" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 470 B |
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50"><defs><style>.cls-1{fill:#fff;}</style></defs><title>画板 11</title><g id="优麒麟"><path id="默认" class="cls-1" d="M25,6A19,19,0,1,0,44,25,19,19,0,0,0,25,6Zm7,4.48a2.75,2.75,0,1,1-2.75,2.76A2.75,2.75,0,0,1,32,10.48ZM25.11,13a12.12,12.12,0,0,1,3.26.45,3.66,3.66,0,0,0,5.29,3.08A12.08,12.08,0,0,1,37.2,24.2l-4.27.06a7.86,7.86,0,0,0-11-6.33l-2.19-3.68A12.07,12.07,0,0,1,25.11,13Zm3.26,13.91.6,1.21L27.8,29.2l.08.91H26.24l1.27-1.81-.44-.54-1.23,1v.64l-1.59,0,1-.95,1-1.19-.84-.58-.86.44-1.17.46-1-.18-.63,1-.2,1.39H20l1.12-1.31-.33-.78-.25-1.54-.81-2,1.46-2.7,1.35-.83L24,19.11l-.4,1,.22,0,1.53-1.54-.65,1.9L25,21.91l-1,1.35,1.49,1.09,2.08.83,1.48-.78.87-1.27,1.42-.44-.26,1.85-.91.32-.67-.13-1.21.69Zm-17.08.88A2.75,2.75,0,1,1,14,25a2.75,2.75,0,0,1-2.75,2.75h0Zm2.06.28a3.67,3.67,0,0,0,0-6,12.14,12.14,0,0,1,5-7l2.18,3.67a7.86,7.86,0,0,0-.11,12.72l-2.09,3.74A12.14,12.14,0,0,1,13.36,28.07ZM32.08,39.54a2.75,2.75,0,1,1,2.75-2.75,2.75,2.75,0,0,1-2.75,2.75Zm1.73-6a3.67,3.67,0,0,0-5.4,3.22,12.11,12.11,0,0,1-8.7-.81l2.08-3.73a7.86,7.86,0,0,0,11.15-6.4l4.27-.06a12.08,12.08,0,0,1-3.4,7.77Z"/></g></svg>
|
Before Width: | Height: | Size: 1.1 KiB |
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50"><defs><style>.cls-1{fill:#fff;opacity:0.4;}</style></defs><title>画板 12</title><g id="优麒麟"><path id="点击" class="cls-1" d="M25,6A19,19,0,1,0,44,25,19,19,0,0,0,25,6Zm7,4.48a2.75,2.75,0,1,1-2.75,2.76A2.75,2.75,0,0,1,32,10.48ZM25.11,13a12.12,12.12,0,0,1,3.26.45,3.66,3.66,0,0,0,5.29,3.08A12.08,12.08,0,0,1,37.2,24.2l-4.27.06a7.86,7.86,0,0,0-11-6.33l-2.19-3.68A12.07,12.07,0,0,1,25.11,13Zm3.26,13.91.6,1.21L27.8,29.2l.08.91H26.24l1.27-1.81-.44-.54-1.23,1v.64l-1.59,0,1-.95,1-1.19-.84-.58-.86.44-1.17.46-1-.18-.63,1-.2,1.39H20l1.12-1.31-.33-.78-.25-1.54-.81-2,1.46-2.7,1.35-.83L24,19.11l-.4,1,.22,0,1.53-1.54-.65,1.9L25,21.91l-1,1.35,1.49,1.09,2.08.83,1.48-.78.87-1.27,1.42-.44-.26,1.85-.91.32-.67-.13-1.21.69Zm-17.08.88A2.75,2.75,0,1,1,14,25a2.75,2.75,0,0,1-2.75,2.75h0Zm2.06.28a3.67,3.67,0,0,0,0-6,12.14,12.14,0,0,1,5-7l2.18,3.67a7.86,7.86,0,0,0-.11,12.72l-2.09,3.74A12.14,12.14,0,0,1,13.36,28.07ZM32.08,39.54a2.75,2.75,0,1,1,2.75-2.75,2.75,2.75,0,0,1-2.75,2.75Zm1.73-6a3.67,3.67,0,0,0-5.4,3.22,12.11,12.11,0,0,1-8.7-.81l2.08-3.73a7.86,7.86,0,0,0,11.15-6.4l4.27-.06a12.08,12.08,0,0,1-3.4,7.77Z"/></g></svg>
|
Before Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,5 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="3" y="10.5" width="18" height="12" rx="3" stroke="#262626" stroke-width="2" stroke-linejoin="round"/>
|
||||
<path d="M17.25 6.75V6.75C17.25 3.85051 14.8995 1.5 12 1.5V1.5C9.10051 1.5 6.75 3.85051 6.75 6.75V10.5" stroke="#262626" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<rect x="11.25" y="14.25" width="1.5" height="4.5" rx="0.75" fill="#262626"/>
|
||||
</svg>
|
After Width: | Height: | Size: 479 B |
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<title>画板 13</title>
|
||||
<g id="上">
|
||||
<polygon id="默认" fill="#FFFFFF" points="25,17 12,32 38,32 "/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 466 B |
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
|
||||
<polygon id="默认" opacity="0.6" fill="#FFFFFF" enable-background="new " points="25,17 12,32 38,32 "/>
|
||||
</svg>
|
Before Width: | Height: | Size: 460 B |
|
@ -0,0 +1,182 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "kbbutton.h"
|
||||
#include "commondef.h"
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
|
||||
KBButton::KBButton(QWidget *parent/* = nullptr*/)
|
||||
: QPushButton(parent)
|
||||
{
|
||||
this->installEventFilter(this);
|
||||
this->setIconSize(KEYBOARD_FIXED_DEFAULT_ICONSIZE);
|
||||
this->setFocusPolicy(Qt::NoFocus);
|
||||
connect(this, &QPushButton::clicked, this, [&,this]() {
|
||||
if (m_charId.isLetter()) {
|
||||
if (m_isShift) {
|
||||
if (m_isCaps) {
|
||||
m_charId = m_charId.toLower();
|
||||
} else {
|
||||
m_charId = m_charId.toUpper();
|
||||
}
|
||||
} else {
|
||||
if (m_isCaps) {
|
||||
m_charId = m_charId.toUpper();
|
||||
} else {
|
||||
m_charId = m_charId.toLower();
|
||||
}
|
||||
}
|
||||
}
|
||||
Q_EMIT clicked(m_charId);
|
||||
});
|
||||
}
|
||||
|
||||
KBButton::~KBButton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool KBButton::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (m_clrNormal == KEYBOARD_LETTER_COLOR_NORMAL)
|
||||
return QPushButton::eventFilter(watched, event);
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
QPixmap pressIcon = this->icon().pixmap(QSize(24, 24));
|
||||
pressIcon = drawSymbolicColoredPixmap(pressIcon, "white");
|
||||
this->setIcon(pressIcon);
|
||||
} else if (event->type() == QEvent::MouseButtonRelease) {
|
||||
QPixmap releaseIcon = this->icon().pixmap(QSize(24, 24));
|
||||
releaseIcon = drawSymbolicColoredPixmap(releaseIcon, "black");
|
||||
this->setIcon(releaseIcon);
|
||||
}
|
||||
return QPushButton::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void KBButton::setCharId(QChar charId)
|
||||
{
|
||||
m_charId = charId;
|
||||
if (charId == '&') {
|
||||
setText("&&");
|
||||
} else {
|
||||
setText(m_charId);
|
||||
}
|
||||
}
|
||||
|
||||
void KBButton::updateStyleSheet(QString clrNormal, QString clrHover, QString clrChecked, QString clrBoard, QString clrBoardPress, QString clrFontPress, int radius, bool is_lock)
|
||||
{
|
||||
QString strBorderRadius = QString("border-top-left-radius: %1px; border-top-right-radius: %2px; border-bottom-right-radius: %3px;border-bottom-left-radius: %4px;")
|
||||
.arg((radius&BORDER_RADIUS_LT)?8:0)
|
||||
.arg((radius&BORDER_RADIUS_TR)?8:0)
|
||||
.arg((radius&BORDER_RADIUS_RB)?8:0)
|
||||
.arg((radius&BORDER_RADIUS_LB)?8:0);
|
||||
if (!is_lock) {
|
||||
setStyleSheet(QString("QPushButton{%1 border: 2px solid %2; border-width: 0px 0px 2px 0px; background: %3; color: #262626}"
|
||||
// "QPushButton:hover{border: 2px solid %4; border-width: 2px 0px 0px 0px; background: %5;}"
|
||||
"QPushButton:pressed{border: 2px solid %4; border-width: 2px 0px 0px 0px; background: %5; color: %6}"
|
||||
"QPushButton:checked{border: 2px solid %7; border-width: 2px 0px 0px 0px; background: %8; color: %9}")
|
||||
.arg(strBorderRadius).arg(clrBoard).arg(clrNormal).arg(clrBoardPress).arg(clrHover).arg(clrFontPress).arg(clrBoardPress).arg(clrChecked).arg(clrFontPress)
|
||||
);
|
||||
} else {
|
||||
setStyleSheet(QString("QPushButton{%1 border: 2px solid %2; border-width: 0px 0px 2px 0px; background: %3; color: #FFFFFF}"
|
||||
// "QPushButton:hover{border: 2px solid %4; border-width: 2px 0px 0px 0px; background: %5;}"
|
||||
"QPushButton:pressed{border: 2px solid %4; border-width: 2px 0px 0px 0px; background: %5; color: %6}"
|
||||
"QPushButton:checked{border: 2px solid %7; border-width: 2px 0px 0px 0px; background: %8; color: %9}")
|
||||
.arg(strBorderRadius).arg(clrBoard).arg(clrNormal).arg(clrBoardPress).arg(clrHover).arg(clrFontPress).arg(clrBoardPress).arg(clrChecked).arg(clrFontPress)
|
||||
);
|
||||
}
|
||||
m_clrBoard = clrBoard;
|
||||
m_clrNormal = clrNormal;
|
||||
m_clrBoardPress = clrBoardPress;
|
||||
m_clrHover = clrHover;
|
||||
m_clrChecked = clrChecked;
|
||||
if (m_clrNormal == KEYBOARD_LETTER_COLOR_NORMAL) {
|
||||
sysFont.setPixelSize(32);
|
||||
this->setFont(sysFont);
|
||||
this->setIconSize(QSize(32, 32));
|
||||
} else {
|
||||
sysFont.setPixelSize(24);
|
||||
this->setFont(sysFont);
|
||||
this->setIconSize(QSize(24, 24));
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap KBButton::drawSymbolicColoredPixmap(const QPixmap &source, QString cgColor)
|
||||
{
|
||||
QImage img = source.toImage();
|
||||
for (int x = 0; x < img.width(); x++) {
|
||||
for (int y = 0; y < img.height(); y++) {
|
||||
auto color = img.pixelColor(x, y);
|
||||
if (color.alpha() > 0) {
|
||||
if ( "white" == cgColor) {
|
||||
color.setRed(255);
|
||||
color.setGreen(255);
|
||||
color.setBlue(255);
|
||||
img.setPixelColor(x, y, color);
|
||||
} else if( "black" == cgColor) {
|
||||
color.setRed(0);
|
||||
color.setGreen(0);
|
||||
color.setBlue(0);
|
||||
img.setPixelColor(x, y, color);
|
||||
} else if ("gray"== cgColor) {
|
||||
color.setRed(152);
|
||||
color.setGreen(163);
|
||||
color.setBlue(164);
|
||||
img.setPixelColor(x, y, color);
|
||||
} else if ("blue" == cgColor){
|
||||
color.setRed(61);
|
||||
color.setGreen(107);
|
||||
color.setBlue(229);
|
||||
img.setPixelColor(x, y, color);
|
||||
} else {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return QPixmap::fromImage(img);
|
||||
}
|
||||
|
||||
void KBButton::setShiftState(bool isShift)
|
||||
{
|
||||
if (m_isShift != isShift) {
|
||||
if (m_charId.isLetter()) {
|
||||
if (isShift) {
|
||||
setText(m_charId.toUpper());
|
||||
} else {
|
||||
setText(m_charId.toLower());
|
||||
}
|
||||
}
|
||||
m_isShift = isShift;
|
||||
}
|
||||
}
|
||||
|
||||
void KBButton::setCapsStatus(bool isCaps)
|
||||
{
|
||||
m_isCaps = isCaps;
|
||||
setShiftState(m_isCaps);
|
||||
}
|
||||
|
||||
void KBButton::setCtrlState(bool isCtrl)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void KBButton::setAltState(bool isAlt)
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef KBBUTTON_H
|
||||
#define KBBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
class KBButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum BORDER_RADIUS{
|
||||
BORDER_RADIUS_NONE,
|
||||
BORDER_RADIUS_LT = 1,
|
||||
BORDER_RADIUS_TR = 2,
|
||||
BORDER_RADIUS_RB = 4,
|
||||
BORDER_RADIUS_LB = 8,
|
||||
BORDER_RADIUS_ALL = 0xF,
|
||||
};
|
||||
KBButton(QWidget *parent = nullptr);
|
||||
virtual ~KBButton();
|
||||
|
||||
void setCharId(QChar charId);
|
||||
void updateStyleSheet(QString clrNormal, QString clrHover, QString clrChecked, QString clrBoard, QString clrBoardPress, QString clrFontPress, int radius = BORDER_RADIUS_ALL, bool is_lock = false);
|
||||
void setShiftState(bool isShift);
|
||||
void setCapsStatus(bool isCaps);
|
||||
void setCtrlState(bool isCtrl);
|
||||
void setAltState(bool isAlt);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
Q_SIGNALS:
|
||||
void clicked(QChar charId);
|
||||
|
||||
private:
|
||||
QPixmap drawSymbolicColoredPixmap(const QPixmap &source, QString cgColor);
|
||||
|
||||
private:
|
||||
int m_nKeyId = -1;
|
||||
bool m_isShift = false;
|
||||
bool m_isCtrl = false;
|
||||
bool m_isAlt = false;
|
||||
bool m_isCaps = false;
|
||||
QChar m_charId = QChar::Null;
|
||||
QString m_clrBoard;
|
||||
QString m_clrNormal;
|
||||
QString m_clrBoardPress;
|
||||
QString m_clrHover;
|
||||
QString m_clrChecked;
|
||||
QFont sysFont;
|
||||
};
|
||||
|
||||
#endif // KBBUTTON_H
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "kbtitle.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include "commondef.h"
|
||||
#include <QDebug>
|
||||
|
||||
KBTitle::KBTitle(QWidget *parent/* = nullptr*/)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setAttribute(Qt::WA_TranslucentBackground);//背景透明
|
||||
initUI();
|
||||
initConnections();
|
||||
}
|
||||
|
||||
KBTitle::~KBTitle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void KBTitle::initUI()
|
||||
{
|
||||
setFixedHeight(KEYBOARD_TITLE_DEFAULT_HEIGHT);
|
||||
QString strBtnStyle = "QPushButton{ text-align:center; color: rgb(255, 255, 255, 255); border: none; border-radius: 4px; outline: none;}"
|
||||
"QPushButton:hover{ background-color: rgb(255,255,255,15%); }"
|
||||
"QPushButton::pressed { background-color: rgba(255,255,255,40%); }"
|
||||
"QPushButton::checked { background-color: rgba(255,255,255,40%); }";
|
||||
|
||||
m_btnFloat = new QPushButton(this);
|
||||
m_btnFloat->setFlat(true);
|
||||
m_btnFloat->setIcon(QIcon(":/images/images/float.svg"));
|
||||
m_btnFloat->setObjectName("btn_float");
|
||||
m_btnFloat->setIconSize(KEYBOARD_FIXED_DEFAULT_ICONSIZE);
|
||||
m_btnFloat->setGeometry(1484, 8, KEYBOARD_TITLEBTN_DEFAULT_WIDTH, KEYBOARD_TITLEBTN_DEFAULT_HEIGHT);
|
||||
m_btnFloat->setStyleSheet(strBtnStyle);
|
||||
m_mapSubGeometrys[m_btnFloat] = m_btnFloat->geometry();
|
||||
|
||||
m_btnClose = new QPushButton(this);
|
||||
m_btnClose->setFlat(true);
|
||||
m_btnClose->setIcon(QIcon(":/images/images/close.svg"));
|
||||
m_btnClose->setIconSize(KEYBOARD_FIXED_DEFAULT_ICONSIZE);
|
||||
m_btnClose->setObjectName("btn_close");
|
||||
m_btnClose->setGeometry(1548, 8, KEYBOARD_TITLEBTN_DEFAULT_WIDTH, KEYBOARD_TITLEBTN_DEFAULT_HEIGHT);
|
||||
m_btnClose->setStyleSheet(strBtnStyle);
|
||||
m_mapSubGeometrys[m_btnClose] = m_btnClose->geometry();
|
||||
}
|
||||
|
||||
void KBTitle::initConnections()
|
||||
{
|
||||
connect(m_btnFloat, &QPushButton::clicked, this, &KBTitle::onBtnClicked);
|
||||
connect(m_btnClose, &QPushButton::clicked, this, &KBTitle::onBtnClicked);
|
||||
}
|
||||
|
||||
void KBTitle::onBtnClicked()
|
||||
{
|
||||
QObject *obj = sender();
|
||||
QPushButton *btn = static_cast<QPushButton*>(obj);
|
||||
QString objName = btn->objectName();
|
||||
int lastUnderline = objName.lastIndexOf('_');
|
||||
int start = strlen("btn_");
|
||||
int keyLength = lastUnderline - start;
|
||||
QString keyName = objName.mid(start, keyLength);
|
||||
if (keyName == BTN_FLOAT) {
|
||||
if (floatStatus) {
|
||||
btn->setIcon(QIcon(":/images/images/float.svg"));
|
||||
} else {
|
||||
btn->setIcon(QIcon(":/images/images/float-restore.svg"));
|
||||
}
|
||||
floatStatus = !floatStatus;
|
||||
}
|
||||
|
||||
Q_EMIT btnClicked(keyName);
|
||||
}
|
||||
|
||||
void KBTitle::adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical/* = false*/, bool floatStatus)
|
||||
{
|
||||
setFixedHeight(KEYBOARD_TITLE_DEFAULT_HEIGHT*lfHeightScale);
|
||||
QMap<QPushButton*, QRect>::iterator itGeometry = m_mapSubGeometrys.begin();
|
||||
for (; itGeometry != m_mapSubGeometrys.end(); itGeometry ++) {
|
||||
QPushButton *button = itGeometry.key();
|
||||
if (button) {
|
||||
QRect oldGeometry = itGeometry.value();
|
||||
QRect newGeometry = oldGeometry;
|
||||
if (floatStatus) {
|
||||
newGeometry.setX(oldGeometry.x()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
|
||||
newGeometry.setY(oldGeometry.y()*lfHeightScale);
|
||||
newGeometry.setWidth(oldGeometry.width()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
|
||||
newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
|
||||
} else {
|
||||
newGeometry.setX(oldGeometry.x()*lfWidthScale);
|
||||
newGeometry.setY(oldGeometry.y()*lfHeightScale);
|
||||
newGeometry.setWidth(oldGeometry.width()*lfWidthScale);
|
||||
newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
|
||||
}
|
||||
button->setGeometry(newGeometry);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef KBTITLE_H
|
||||
#define KBTITLE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QMap>
|
||||
|
||||
class KBTitle : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KBTitle(QWidget *parent = nullptr);
|
||||
virtual ~KBTitle();
|
||||
|
||||
public:
|
||||
void adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical = false, bool floatStatus = false);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onBtnClicked();
|
||||
|
||||
Q_SIGNALS:
|
||||
void btnClicked(QString keyName);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void initConnections();
|
||||
|
||||
private:
|
||||
QPushButton *m_btnFloat = nullptr;
|
||||
QPushButton *m_btnClose = nullptr;
|
||||
QMap<QPushButton*, QRect> m_mapSubGeometrys;
|
||||
bool floatStatus = false;
|
||||
};
|
||||
|
||||
#endif // KBTITLE_H
|
|
@ -1,27 +1,17 @@
|
|||
<RCC>
|
||||
<qresource prefix="/qss">
|
||||
<file>keyboard.qss</file>
|
||||
</qresource>
|
||||
<qresource prefix="/images">
|
||||
<file>images/backspace_click.svg</file>
|
||||
<file>images/backspace.svg</file>
|
||||
<file>images/capslock_click.svg</file>
|
||||
<file>images/capslock_hl.svg</file>
|
||||
<file>images/capslock.svg</file>
|
||||
<file>images/down_click.svg</file>
|
||||
<file>images/down.svg</file>
|
||||
<file>images/enter_click.svg</file>
|
||||
<file>images/enter.svg</file>
|
||||
<file>images/left_click.svg</file>
|
||||
<file>images/left.svg</file>
|
||||
<file>images/right_click.svg</file>
|
||||
<file>images/right.svg</file>
|
||||
<file>images/super_click.svg</file>
|
||||
<file>images/super.svg</file>
|
||||
<file>images/up.svg</file>
|
||||
<file>images/close_click.svg</file>
|
||||
<file>images/close.svg</file>
|
||||
<file>images/capslock_hl_click.svg</file>
|
||||
<file>images/up_click.svg</file>
|
||||
<file>images/unlock.svg</file>
|
||||
<file>images/space.svg</file>
|
||||
<file>images/shift.svg</file>
|
||||
<file>images/float.svg</file>
|
||||
<file>images/float-restore.svg</file>
|
||||
<file>images/drag.svg</file>
|
||||
<file>images/delet.svg</file>
|
||||
<file>images/shift_lock.svg</file>
|
||||
<file>images/rectangle.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
QPushButton
|
||||
{
|
||||
border: none;
|
||||
font: 24px;
|
||||
color: white;
|
||||
background: #35322f;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
QPushButton::pressed
|
||||
{
|
||||
color: gray;
|
||||
background: #2a2826;
|
||||
}
|
||||
|
||||
#btn_backspace, #btn_enter, #btn_shift_l,
|
||||
#btn_shift_r, #btn_ctrl_l, #btn_ctrl_r,
|
||||
#btn_alt_l, #btn_alt_r, #btn_super
|
||||
{
|
||||
font: 16px;
|
||||
background: #1e1b18
|
||||
}
|
||||
|
||||
#btn_backspace::pressed, #btn_enter::pressed, #btn_shift_l::pressed,
|
||||
#btn_shift_r::pressed, #btn_ctrl_l::pressed, #btn_ctrl_r::pressed,
|
||||
#btn_alt_l::pressed, #btn_alt_r::pressed, #btn_super::pressed
|
||||
{
|
||||
background: #181613;
|
||||
color: gray;
|
||||
}
|
||||
|
||||
#btn_letter, #btn_symbol, #btn_number,
|
||||
#btn_insert, #btn_delete, #btn_home,
|
||||
#btn_end, #btn_pgup, #btn_pgdn, #btn_close
|
||||
{
|
||||
font: 16px;
|
||||
}
|
|
@ -1,459 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
**/
|
||||
#include "keyboardwidget.h"
|
||||
#include "ui_keyboardwidget.h"
|
||||
#include <QDebug>
|
||||
#include <QMap>
|
||||
#include <QVector>
|
||||
|
||||
#define SYMBOL_KEY_COUNT 29
|
||||
#define SYMBOL_PAGE_COUNT 2
|
||||
|
||||
#define BUTTON_BG "QPushButton{background:#1E1B18}"
|
||||
#define BUTTON_BG_PRESSED "QPushButton{background: #181613;}"
|
||||
#define BUTTON_BG_HL "QPushButton{background:#80c342}"
|
||||
#define BUTTON_BG_HL_PRESSED "QPushButton{background:#486E25}"
|
||||
|
||||
|
||||
QChar symbols[SYMBOL_PAGE_COUNT][SYMBOL_KEY_COUNT] =
|
||||
{ {'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
|
||||
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l',
|
||||
'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/'},
|
||||
{'!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
|
||||
'`', '-', '=', '[', ']', '\\', '|', '{', '}',
|
||||
'~','<', '>', ':', ';', '\'', '"', '_', '+', '?'}};
|
||||
|
||||
|
||||
KeyboardWidget::KeyboardWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::KeyboardWidget),
|
||||
capsLock(false),
|
||||
isShift(false),
|
||||
page(0)
|
||||
{
|
||||
vKeyboard = new X11Keyboard(this);
|
||||
connect(this, SIGNAL(keyPressed(QChar)),
|
||||
vKeyboard, SLOT(onKeyPressed(QChar)));
|
||||
connect(this, SIGNAL(keyPressed(FuncKey::FUNCKEY)),
|
||||
vKeyboard, SLOT(onKeyPressed(FuncKey::FUNCKEY)));
|
||||
|
||||
ui->setupUi(this);
|
||||
bindSingal();
|
||||
setDefaultIcon();
|
||||
}
|
||||
|
||||
KeyboardWidget::~KeyboardWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void KeyboardWidget::resizeEvent(QResizeEvent */*event*/)
|
||||
{
|
||||
int w = width();
|
||||
int h = height();
|
||||
int mainLeftMargin = ui->hl_main->contentsMargins().left();
|
||||
int mainRightMargin = ui->hl_main->contentsMargins().right();
|
||||
int mainTopMargin = ui->hl_main->contentsMargins().left();
|
||||
int mainBottomMargin = ui->hl_main->contentsMargins().right();
|
||||
int mainSpacing = ui->hl_main->spacing();
|
||||
int itemSpacing = ui->hl_1->spacing();
|
||||
|
||||
int btnWidthCount = w - 11 * itemSpacing - mainSpacing- mainLeftMargin - mainRightMargin;
|
||||
int btnHeightCount = h - 3 * itemSpacing - mainTopMargin - mainBottomMargin;
|
||||
double btnWidth = btnWidthCount / 12;
|
||||
double btnHeight = btnHeightCount / 4;
|
||||
for(int i = 0; i <= 28; i++) {
|
||||
QString btnObjName = "btn_" + QString::number(i);
|
||||
QPushButton *btn = ui->page_letter->findChild<QPushButton*>(btnObjName);
|
||||
btn->setFixedSize(btnWidth, btnHeight);
|
||||
}
|
||||
ui->btn_ctrl_l->setFixedSize(btnWidth * 1.3, btnHeight);
|
||||
ui->btn_ctrl_r->setFixedSize(btnWidth * 1.3, btnHeight);
|
||||
ui->btn_alt_l->setFixedSize(btnWidth, btnHeight);
|
||||
ui->btn_alt_r->setFixedSize(btnWidth, btnHeight);
|
||||
ui->btn_super->setFixedSize(btnWidth, btnHeight);
|
||||
ui->btn_shift_l->setFixedSize(btnWidth, btnHeight);
|
||||
ui->btn_shift_r->setFixedHeight(btnHeight);
|
||||
ui->spacer_2->changeSize(btnWidth / 2, 20);
|
||||
|
||||
|
||||
for(int i = 1; i <= 9; i++) {
|
||||
QString btnObjName = "btn_num_" + QString::number(i);
|
||||
QPushButton *btn = ui->page_number->findChild<QPushButton*>(btnObjName);
|
||||
btn->setFixedWidth(btnWidth);
|
||||
}
|
||||
ui->btn_backspace_num->setFixedSize(btnWidth,btnHeight);
|
||||
ui->btn_insert->setFixedWidth(btnWidth);
|
||||
ui->btn_delete->setFixedWidth(btnWidth);
|
||||
ui->btn_home->setFixedWidth(btnWidth);
|
||||
ui->btn_end->setFixedWidth(btnWidth);
|
||||
ui->btn_pgup->setFixedWidth(btnWidth);
|
||||
ui->btn_pgdn->setFixedWidth(btnWidth);
|
||||
ui->btn_up->setFixedSize(btnWidth,btnHeight);
|
||||
ui->btn_down->setFixedSize(btnWidth,btnHeight);
|
||||
ui->btn_left->setFixedSize(btnWidth,btnHeight);
|
||||
ui->btn_right->setFixedSize(btnWidth,btnHeight);
|
||||
|
||||
ui->btn_close->setFixedHeight(btnHeight);
|
||||
ui->btn_letter->setFixedHeight(btnHeight);
|
||||
ui->btn_symbol->setFixedHeight(btnHeight);
|
||||
ui->btn_number->setFixedHeight(btnHeight);
|
||||
|
||||
setIconSize();
|
||||
}
|
||||
|
||||
float hScale = 0.6;
|
||||
float wScale = hScale;
|
||||
#define SET_ICON_SIZE_SCALE(btn) \
|
||||
ui->btn_##btn->setIconSize(QSize(ui->btn_##btn->width() * hScale, ui->btn_##btn->height() * wScale));
|
||||
|
||||
#define SET_ICON_SIZE(btn) \
|
||||
ui->btn_##btn->setIconSize(QSize(ui->btn_##btn->width(), ui->btn_##btn->height()));
|
||||
|
||||
#define SET_SHIFT_ICON_SIZE_SCALE(btn) \
|
||||
ui->btn_##btn->setIconSize(QSize(ui->btn_##btn->height() * 0.4, ui->btn_##btn->height() * 0.4));
|
||||
|
||||
#define SET_ENTER_ICON_SIZE_SCALE(btn) \
|
||||
ui->btn_##btn->setIconSize(QSize(ui->btn_##btn->width() * 0.4, ui->btn_##btn->height() * 0.4));
|
||||
|
||||
void KeyboardWidget::setIconSize()
|
||||
{
|
||||
SET_ICON_SIZE_SCALE(backspace);
|
||||
SET_ICON_SIZE_SCALE(backspace_num);
|
||||
SET_ENTER_ICON_SIZE_SCALE(enter);
|
||||
SET_ICON_SIZE_SCALE(enter_num);
|
||||
SET_ICON_SIZE_SCALE(close);
|
||||
SET_ICON_SIZE_SCALE(super);
|
||||
|
||||
SET_SHIFT_ICON_SIZE_SCALE(shift_l);
|
||||
SET_SHIFT_ICON_SIZE_SCALE(shift_r);
|
||||
SET_ICON_SIZE(up);
|
||||
SET_ICON_SIZE(down);
|
||||
SET_ICON_SIZE(left);
|
||||
SET_ICON_SIZE(right);
|
||||
}
|
||||
|
||||
void KeyboardWidget::bindSingal()
|
||||
{
|
||||
for(auto obj : ui->page_letter->children()) {
|
||||
if(obj->metaObject()->className() == QString("QPushButton")) {
|
||||
QPushButton *btn = static_cast<QPushButton*>(obj);
|
||||
btn->setFocusPolicy(Qt::NoFocus);
|
||||
connect(btn, &QPushButton::clicked, this, &KeyboardWidget::onButtonClicked);
|
||||
connect(btn, &QPushButton::pressed, this, &KeyboardWidget::onButtonPressed);
|
||||
connect(btn, &QPushButton::released, this, &KeyboardWidget::onButtonReleased);
|
||||
}
|
||||
}
|
||||
for(auto obj : ui->page_number->children()) {
|
||||
if(obj->metaObject()->className() == QString("QPushButton")) {
|
||||
QPushButton *btn = static_cast<QPushButton*>(obj);
|
||||
btn->setFocusPolicy(Qt::NoFocus);
|
||||
connect(btn, &QPushButton::clicked, this, &KeyboardWidget::onButtonClicked);
|
||||
connect(btn, &QPushButton::pressed, this, &KeyboardWidget::onButtonPressed);
|
||||
connect(btn, &QPushButton::released, this, &KeyboardWidget::onButtonReleased);
|
||||
}
|
||||
}
|
||||
ui->btn_close->setFocusPolicy(Qt::NoFocus);
|
||||
ui->btn_letter->setFocusPolicy(Qt::NoFocus);
|
||||
ui->btn_symbol->setFocusPolicy(Qt::NoFocus);
|
||||
ui->btn_number->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
connect(ui->btn_letter, &QPushButton::clicked, this, [&] {
|
||||
ui->stackedWidget->setCurrentWidget(ui->page_letter);
|
||||
page = 0;
|
||||
switchPage();
|
||||
});
|
||||
connect(ui->btn_symbol, &QPushButton::clicked, this, [&] {
|
||||
ui->stackedWidget->setCurrentWidget(ui->page_letter);
|
||||
page = 1;
|
||||
switchPage();
|
||||
});
|
||||
connect(ui->btn_number, &QPushButton::clicked, this, [&] {
|
||||
ui->stackedWidget->setCurrentWidget(ui->page_number);
|
||||
});
|
||||
connect(ui->btn_close, &QPushButton::clicked,
|
||||
this, &KeyboardWidget::aboutToClose);
|
||||
|
||||
connect(ui->btn_close, &QPushButton::pressed,
|
||||
this, &KeyboardWidget::onButtonPressed);
|
||||
connect(ui->btn_close, &QPushButton::released,
|
||||
this, &KeyboardWidget::onButtonReleased);
|
||||
}
|
||||
|
||||
void KeyboardWidget::setDefaultIcon()
|
||||
{
|
||||
ui->btn_backspace->setIcon(QIcon(":/images/images/backspace.svg"));
|
||||
ui->btn_backspace_num->setIcon(QIcon(":/images/images/backspace.svg"));
|
||||
ui->btn_enter->setIcon(QIcon(":/images/images/enter.svg"));
|
||||
ui->btn_enter_num->setIcon(QIcon(":/images/images/enter.svg"));
|
||||
ui->btn_shift_l->setIcon(QIcon(":/images/images/capslock.svg"));
|
||||
ui->btn_shift_r->setIcon(QIcon(":/images/images/capslock.svg"));
|
||||
ui->btn_close->setIcon(QIcon(":/images/images/close.svg"));
|
||||
//ui->btn_super->setIcon(QIcon(":/images/images/super.svg"));
|
||||
ui->btn_super->setText("Super");
|
||||
ui->btn_up->setIcon(QIcon(":/images/images/up.svg"));
|
||||
ui->btn_down->setIcon(QIcon(":/images/images/down.svg"));
|
||||
ui->btn_left->setIcon(QIcon(":/images/images/left.svg"));
|
||||
ui->btn_right->setIcon(QIcon(":/images/images/right.svg"));
|
||||
}
|
||||
|
||||
QString KeyboardWidget::getKeyName(QPushButton *btn)
|
||||
{
|
||||
QString objName = btn->objectName();
|
||||
int lastUnderline = objName.lastIndexOf('_');
|
||||
int start = strlen("btn_");
|
||||
int keyLength = lastUnderline - start;
|
||||
QString keyName = objName.mid(start, keyLength);
|
||||
return keyName;
|
||||
}
|
||||
|
||||
void KeyboardWidget::changeFuncKeyStyle(QPushButton *btn, bool isPressed)
|
||||
{
|
||||
QString modName = getKeyName(btn);
|
||||
Modifier::MOD mod = Modifier::getModifier(modName);
|
||||
|
||||
if(vKeyboard->hasModifier(mod)) {
|
||||
if(isPressed)
|
||||
btn->setStyleSheet(BUTTON_BG_HL_PRESSED);
|
||||
else
|
||||
btn->setStyleSheet(BUTTON_BG_HL);
|
||||
} else {
|
||||
if(isPressed)
|
||||
btn->setStyleSheet(BUTTON_BG_PRESSED);
|
||||
else
|
||||
btn->setStyleSheet(BUTTON_BG);
|
||||
}
|
||||
}
|
||||
|
||||
void KeyboardWidget::changeShitKeyStyle(QPushButton *btn, bool isPressed)
|
||||
{
|
||||
if(page == 0){
|
||||
if(isShift) {
|
||||
if(capsLock){
|
||||
if(isPressed) {
|
||||
btn->setStyleSheet(BUTTON_BG_HL_PRESSED);
|
||||
btn->setIcon(QIcon(":/images/images/capslock_click.svg"));
|
||||
} else {
|
||||
btn->setStyleSheet(BUTTON_BG_HL);
|
||||
btn->setIcon(QIcon(":/images/images/capslock.svg"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(isPressed)
|
||||
btn->setIcon(QIcon(":/images/images/capslock_hl_click.svg"));
|
||||
else
|
||||
btn->setIcon(QIcon(":/images/images/capslock_hl.svg"));
|
||||
}
|
||||
} else {
|
||||
if(isPressed)
|
||||
btn->setIcon(QIcon(":/images/images/capslock_click.svg"));
|
||||
else
|
||||
btn->setIcon(QIcon(":/images/images/capslock.svg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyboardWidget::changeDirectKeyStyle(QPushButton *btn, bool isPressed)
|
||||
{
|
||||
QString keyName = getKeyName(btn);
|
||||
FuncKey::FUNCKEY key = FuncKey::getKey(keyName);
|
||||
if(key == FuncKey::UNKNOWN)
|
||||
return;
|
||||
|
||||
QString iconName = QString(":/images/images/%1.svg").arg(keyName);
|
||||
QString iconNamePressed = QString(":/images/images/%1_click.svg").arg(keyName);
|
||||
|
||||
if(isPressed)
|
||||
btn->setIcon(QIcon(iconNamePressed));
|
||||
else
|
||||
btn->setIcon(QIcon(iconName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 修改按键样式
|
||||
* @param obj 按键
|
||||
* @param isPressed 按下或者松开
|
||||
*/
|
||||
void KeyboardWidget::changeKeyStyle(QPushButton *btn, bool isPressed)
|
||||
{
|
||||
if(btn == ui->btn_ctrl_l || btn == ui->btn_ctrl_r ||
|
||||
btn == ui->btn_alt_l || btn == ui->btn_alt_r ||
|
||||
btn == ui->btn_super) {
|
||||
changeFuncKeyStyle(btn, isPressed);
|
||||
}
|
||||
|
||||
if(btn == ui->btn_shift_l)
|
||||
changeShitKeyStyle(ui->btn_shift_l, isPressed);
|
||||
if(btn == ui->btn_shift_r)
|
||||
changeShitKeyStyle(ui->btn_shift_r, isPressed);
|
||||
|
||||
changeDirectKeyStyle(btn, isPressed);
|
||||
}
|
||||
|
||||
void KeyboardWidget::onButtonPressed()
|
||||
{
|
||||
QPushButton *btn = static_cast<QPushButton*>(sender());
|
||||
changeKeyStyle(btn, true);
|
||||
}
|
||||
|
||||
void KeyboardWidget::onButtonReleased()
|
||||
{
|
||||
QPushButton *btn = static_cast<QPushButton*>(sender());
|
||||
changeKeyStyle(btn, false);
|
||||
}
|
||||
|
||||
void KeyboardWidget::onButtonClicked()
|
||||
{
|
||||
QObject *obj = sender();
|
||||
if(obj->metaObject()->className() != QString("QPushButton"))
|
||||
return;
|
||||
|
||||
QPushButton *btn = static_cast<QPushButton*>(obj);
|
||||
QString keyName = getKeyName(btn);
|
||||
qDebug() << "keyName: " << keyName;
|
||||
|
||||
Modifier::MOD mod = Modifier::getModifier(keyName);
|
||||
FuncKey::FUNCKEY funcKey = FuncKey::getKey(keyName);
|
||||
|
||||
if(keyName == "shift") {
|
||||
if(page == 0) {
|
||||
isShift = !isShift;
|
||||
if(isShift) { //第一次被按下
|
||||
capsLock = false;
|
||||
shiftLastClicked = QTime::currentTime();
|
||||
ui->btn_shift_l->setIcon(QIcon(":/images/images/capslock_hl.svg"));
|
||||
ui->btn_shift_r->setIcon(QIcon(":/images/images/capslock_hl.svg"));
|
||||
}
|
||||
else {
|
||||
int doubleClickInterval = QApplication::doubleClickInterval();
|
||||
if(shiftLastClicked.msecsTo(QTime::currentTime()) <= doubleClickInterval) {
|
||||
//shift键双击,锁定大写
|
||||
capsLock = true;
|
||||
isShift = true;
|
||||
ui->btn_shift_l->setIcon(QIcon(":/images/images/capslock.svg"));
|
||||
ui->btn_shift_r->setIcon(QIcon(":/images/images/capslock.svg"));
|
||||
ui->btn_shift_l->setStyleSheet("QPushButton{background:#80c342}");
|
||||
ui->btn_shift_r->setStyleSheet("QPushButton{background:#80c342}");
|
||||
} else {
|
||||
ui->btn_shift_l->setIcon(QIcon(":/images/images/capslock.svg"));
|
||||
ui->btn_shift_r->setIcon(QIcon(":/images/images/capslock.svg"));
|
||||
ui->btn_shift_l->setStyleSheet("QPushButton{background:#1e1b18}");
|
||||
ui->btn_shift_r->setStyleSheet("QPushButton{background:#1e1b18}");
|
||||
}
|
||||
}
|
||||
toggleCase();
|
||||
} else {
|
||||
page = page % (SYMBOL_PAGE_COUNT - 1) + 1;
|
||||
switchPage();
|
||||
}
|
||||
} else if(mod != Modifier::UNKNOWN) {
|
||||
if(vKeyboard->hasModifier(mod)) {
|
||||
vKeyboard->removeModifier(mod);
|
||||
btn->setStyleSheet(BUTTON_BG);
|
||||
btn->setStyleSheet(BUTTON_BG);
|
||||
} else {
|
||||
vKeyboard->addModifier(mod);
|
||||
btn->setStyleSheet(BUTTON_BG_HL);
|
||||
btn->setStyleSheet(BUTTON_BG_HL);
|
||||
}
|
||||
} else if(funcKey != FuncKey::UNKNOWN) {
|
||||
Q_EMIT keyPressed(funcKey);
|
||||
} else { //字符键
|
||||
QChar c;
|
||||
QString text = btn->text();
|
||||
qDebug() << "clicked button text: " << text;
|
||||
if(text == "&&")
|
||||
c = '&';
|
||||
else if(text.length() == 1)
|
||||
c = text.at(0);
|
||||
|
||||
Q_EMIT keyPressed(c);
|
||||
|
||||
//如果shift键被单击,按一个键后就恢复为小写
|
||||
if(isShift && !capsLock) {
|
||||
isShift = false;
|
||||
toggleCase();
|
||||
changeShitKeyStyle(ui->btn_shift_l, false);
|
||||
changeShitKeyStyle(ui->btn_shift_r, false);
|
||||
}
|
||||
clearModifier();
|
||||
}
|
||||
}
|
||||
|
||||
void KeyboardWidget::clearModifier()
|
||||
{
|
||||
for(auto mod : vKeyboard->getAllModifier()) {
|
||||
QString modName = Modifier::getModifierName(mod);
|
||||
if(mod == Modifier::SUPER) {
|
||||
QString objName = QString("btn_%1").arg(modName);
|
||||
QPushButton *btn = ui->page_letter->findChild<QPushButton*>(objName);
|
||||
btn->setStyleSheet(BUTTON_BG);
|
||||
} else {
|
||||
QString objName = QString("btn_%1_l").arg(modName);
|
||||
QPushButton *btn = ui->page_letter->findChild<QPushButton*>(objName);
|
||||
btn->setStyleSheet(BUTTON_BG);
|
||||
objName = QString("btn_%1_r").arg(modName);
|
||||
btn = ui->page_letter->findChild<QPushButton*>(objName);
|
||||
btn->setStyleSheet(BUTTON_BG);
|
||||
}
|
||||
}
|
||||
vKeyboard->clearModifier();
|
||||
}
|
||||
|
||||
void KeyboardWidget::toggleCase()
|
||||
{
|
||||
for(int i = 0; i < 26; i++) {
|
||||
QString objName = "btn_" + QString::number(i);
|
||||
QPushButton *btn = findChild<QPushButton*>(objName);
|
||||
QChar ch;
|
||||
if(isShift) { //切换到大写
|
||||
ch = symbols[0][i].toUpper();
|
||||
} else {
|
||||
ch = symbols[0][i];
|
||||
}
|
||||
btn->setText(ch);
|
||||
}
|
||||
}
|
||||
|
||||
void KeyboardWidget::switchPage()
|
||||
{
|
||||
if(page == 0) {
|
||||
ui->btn_shift_l->setText("");
|
||||
ui->btn_shift_r->setText("");
|
||||
ui->btn_shift_l->setIcon(QIcon(":/images/images/capslock.svg"));
|
||||
ui->btn_shift_r->setIcon(QIcon(":/images/images/capslock.svg"));
|
||||
} else {
|
||||
ui->btn_shift_l->setText("");
|
||||
ui->btn_shift_r->setText("");
|
||||
ui->btn_shift_l->setIcon(QIcon(":/images/images/capslock.svg"));
|
||||
ui->btn_shift_r->setIcon(QIcon(":/images/images/capslock.svg"));
|
||||
}
|
||||
|
||||
for(int i = 0; i < SYMBOL_KEY_COUNT; i++) {
|
||||
QString btnObjName = "btn_" + QString::number(i);
|
||||
QPushButton *btn = ui->page_letter->findChild<QPushButton*>(btnObjName);
|
||||
QChar c = symbols[page][i];
|
||||
if(c == '&')
|
||||
btn->setText("&&");
|
||||
else
|
||||
btn->setText(c);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
**/
|
||||
#ifndef KEYBOARDWIDGET_H
|
||||
#define KEYBOARDWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMap>
|
||||
#include <QTime>
|
||||
#include "x11keyboard.h"
|
||||
|
||||
namespace Ui {
|
||||
class KeyboardWidget;
|
||||
}
|
||||
|
||||
class QPushButton;
|
||||
|
||||
class KeyboardWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KeyboardWidget(QWidget *parent = 0);
|
||||
~KeyboardWidget();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
private:
|
||||
void bindSingal();
|
||||
void toggleCase();
|
||||
void switchPage();
|
||||
void setDefaultIcon();
|
||||
void setIconSize();
|
||||
void changeKeyStyle(QPushButton *btn, bool isPressed);
|
||||
void changeFuncKeyStyle(QPushButton *btn, bool isPressed);
|
||||
void changeShitKeyStyle(QPushButton *btn, bool isPressed);
|
||||
void changeDirectKeyStyle(QPushButton *btn, bool isPressed);
|
||||
void clearModifier();
|
||||
QString getKeyName(QPushButton *btn);
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void onButtonClicked();
|
||||
void onButtonPressed();
|
||||
void onButtonReleased();
|
||||
|
||||
Q_SIGNALS:
|
||||
void aboutToClose();
|
||||
void keyPressed(QChar c);
|
||||
void keyPressed(FuncKey::FUNCKEY key);
|
||||
|
||||
private:
|
||||
Ui::KeyboardWidget *ui;
|
||||
bool capsLock; //是否大写锁定
|
||||
bool isShift;
|
||||
QTime shiftLastClicked; //shift键上次被点击的时间
|
||||
int page; //当前是第几页的键盘
|
||||
X11Keyboard *vKeyboard;
|
||||
};
|
||||
|
||||
#endif // KEYBOARDWIDGET_H
|
|
@ -0,0 +1,383 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "letterswidget.h"
|
||||
#include "commondef.h"
|
||||
#include "plasma-shell-manager.h"
|
||||
#include <QDebug>
|
||||
#include <QX11Info>
|
||||
#include <KWayland/Client/keystate.h>
|
||||
|
||||
LettersWidget::LettersWidget(QWidget *parent/* = nullptr*/)
|
||||
: QWidget(parent)
|
||||
{
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);//背景透明
|
||||
initUI();
|
||||
|
||||
if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland") {
|
||||
isWayland = true;
|
||||
}
|
||||
|
||||
if(isWayland){
|
||||
connect(PlasmaShellManager::getInstance(), &PlasmaShellManager::keyStateChanged,
|
||||
this, &LettersWidget::onCapsChanged);
|
||||
}else{
|
||||
settings = new QGSettings("org.ukui.peripherals-keyboard", "", this);
|
||||
connect(settings, &QGSettings::changed,
|
||||
this, &LettersWidget::onCapsChanged);
|
||||
}
|
||||
onCapsChanged();
|
||||
}
|
||||
|
||||
LettersWidget::~LettersWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LettersWidget::initUI()
|
||||
{
|
||||
// line 1
|
||||
QChar chLine1[] = {'q','w','e','r','t','y','u','i','o','p'};
|
||||
for (int n = 0; n < sizeof(chLine1)/sizeof(QChar); n++) {
|
||||
KBButton *letterBtn = new KBButton(this);
|
||||
QString objName = "btn_" + QString::number(chLine1[n].toLatin1());
|
||||
letterBtn->setObjectName(objName);
|
||||
letterBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L1+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*n,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
letterBtn->setCharId(chLine1[n]);
|
||||
letterBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_NORMAL,KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_FONT_COLOR_PRESS);
|
||||
connect(letterBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[letterBtn] = letterBtn->geometry();
|
||||
}
|
||||
// backspace
|
||||
KBButton *backspaceBtn = new KBButton(this);
|
||||
backspaceBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L1+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*10,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
backspaceBtn->setObjectName("btn_backspace");
|
||||
backspaceBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
backspaceBtn->setIcon(QIcon(":/images/images/delet.svg"));
|
||||
connect(backspaceBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[backspaceBtn] = backspaceBtn->geometry();
|
||||
qDebug()<<"backspaceBtn geometry:"<<backspaceBtn->geometry();
|
||||
|
||||
// line 2
|
||||
QChar chLine2[] = {'a','s','d','f','g','h','j','k','l'};
|
||||
for (int n = 0; n < sizeof(chLine2)/sizeof(QChar); n++) {
|
||||
KBButton *letterBtn = new KBButton(this);
|
||||
QString objName = "btn_" + QString::number(chLine2[n].toLatin1());
|
||||
letterBtn->setObjectName(objName);
|
||||
letterBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L2+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*n,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING),
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
letterBtn->setCharId(chLine2[n]);
|
||||
letterBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_NORMAL,KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_FONT_COLOR_PRESS);
|
||||
connect(letterBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[letterBtn] = letterBtn->geometry();
|
||||
}
|
||||
// enter
|
||||
KBButton *enterBtn = new KBButton(this);
|
||||
enterBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L2+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*9,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING),
|
||||
KEYBOARD_FIXED_DEFAULT_ENTERBTN_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
enterBtn->setObjectName("btn_enter");
|
||||
enterBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
enterBtn->setIcon(QIcon(":/images/images/enter.svg"));
|
||||
connect(enterBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[enterBtn] = enterBtn->geometry();
|
||||
|
||||
// line 3
|
||||
QChar chLine3[] = {'z','x','c','v','b','n','m',',','.'};
|
||||
for (int n = 0; n < sizeof(chLine3)/sizeof(QChar); n++) {
|
||||
KBButton *letterBtn = new KBButton(this);
|
||||
QString objName = "btn_" + QString::number(chLine3[n].toLatin1());
|
||||
letterBtn->setObjectName(objName);
|
||||
letterBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L3+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*(n+1),
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*2,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
letterBtn->setCharId(chLine3[n]);
|
||||
letterBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_NORMAL,KEYBOARD_LETTER_COLOR_BORDER_PRESSED,
|
||||
KEYBOARD_FONT_COLOR_PRESS);
|
||||
connect(letterBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[letterBtn] = letterBtn->geometry();
|
||||
}
|
||||
// shift l
|
||||
KBButton *shiftLBtn = new KBButton(this);
|
||||
shiftLBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L3,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*2,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
shiftLBtn->setObjectName("btn_shift_l");
|
||||
shiftLBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,
|
||||
KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
shiftLBtn->setIcon(QIcon(":/images/images/shift.svg"));
|
||||
connect(shiftLBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[shiftLBtn] = shiftLBtn->geometry();
|
||||
// shift r
|
||||
KBButton *shiftRBtn = new KBButton(this);
|
||||
shiftRBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L3+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*10,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*2,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
shiftRBtn->setObjectName("btn_shift_r");
|
||||
shiftRBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,
|
||||
KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
shiftRBtn->setIcon(QIcon(":/images/images/shift.svg"));
|
||||
connect(shiftRBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[shiftRBtn] = shiftRBtn->geometry();
|
||||
|
||||
// line 4
|
||||
KBButton *symbolBtn = new KBButton(this);
|
||||
symbolBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
symbolBtn->setObjectName("btn_symbol");
|
||||
symbolBtn->setText(tr("&&?!"));
|
||||
symbolBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,
|
||||
KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
connect(symbolBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[symbolBtn] = symbolBtn->geometry();
|
||||
|
||||
KBButton *numBtn = new KBButton(this);
|
||||
numBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING),
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
numBtn->setObjectName("btn_num");
|
||||
numBtn->setText(tr("123"));
|
||||
numBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,
|
||||
KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
connect(numBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[numBtn] = numBtn->geometry();
|
||||
|
||||
KBButton *ctrlBtn = new KBButton(this);
|
||||
ctrlBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*2,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
ctrlBtn->setObjectName("btn_ctrl");
|
||||
ctrlBtn->setText(tr("Ctrl"));
|
||||
ctrlBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,
|
||||
KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
connect(ctrlBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[ctrlBtn] = ctrlBtn->geometry();
|
||||
|
||||
KBButton *spaceBtn = new KBButton(this);
|
||||
spaceBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_SPACEBTN_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
spaceBtn->setObjectName("btn_space");
|
||||
spaceBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_PRESSED,
|
||||
KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
spaceBtn->setIcon(QIcon(":/images/images/space.svg"));
|
||||
connect(spaceBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[spaceBtn] = spaceBtn->geometry();
|
||||
|
||||
KBButton *altBtn = new KBButton(this);
|
||||
altBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*8,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
altBtn->setObjectName("btn_alt");
|
||||
altBtn->setText(tr("Alt"));
|
||||
altBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,
|
||||
KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
connect(altBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[altBtn] = altBtn->geometry();
|
||||
|
||||
KBButton *leftBtn = new KBButton(this);
|
||||
leftBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*9,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
leftBtn->setObjectName("btn_left");
|
||||
leftBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,
|
||||
KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
leftBtn->setIcon(QIcon(":/images/images/left.svg"));
|
||||
connect(leftBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[leftBtn] = leftBtn->geometry();
|
||||
|
||||
KBButton *rightBtn = new KBButton(this);
|
||||
rightBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_LETTER_L4+(KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*10,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_LETTER_HEIGHT);
|
||||
rightBtn->setObjectName("btn_right");
|
||||
rightBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,
|
||||
KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
rightBtn->setIcon(QIcon(":/images/images/right.svg"));
|
||||
connect(rightBtn, &KBButton::clicked, this, &LettersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[rightBtn] = rightBtn->geometry();
|
||||
}
|
||||
|
||||
void LettersWidget::adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical/* = false*/, bool floatStatus)
|
||||
{
|
||||
QMap<KBButton*, QRect>::iterator itGeometry = m_mapBtnGeometrys.begin();
|
||||
for (; itGeometry != m_mapBtnGeometrys.end(); itGeometry ++) {
|
||||
KBButton *button = itGeometry.key();
|
||||
if (button) {
|
||||
QRect oldGeometry = itGeometry.value();
|
||||
QRect newGeometry = oldGeometry;
|
||||
if (floatStatus) {
|
||||
newGeometry.setX(oldGeometry.x()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
|
||||
newGeometry.setY(oldGeometry.y()*lfHeightScale);
|
||||
newGeometry.setWidth(oldGeometry.width()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
|
||||
newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
|
||||
} else {
|
||||
newGeometry.setX(oldGeometry.x()*lfWidthScale);
|
||||
newGeometry.setY(oldGeometry.y()*lfHeightScale);
|
||||
newGeometry.setWidth(oldGeometry.width()*lfWidthScale);
|
||||
newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
|
||||
}
|
||||
button->setGeometry(newGeometry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LettersWidget::onBtnClicked(QChar charId)
|
||||
{
|
||||
QObject *obj = sender();
|
||||
KBButton *btn = static_cast<KBButton*>(obj);
|
||||
QString objName = btn->objectName();
|
||||
int lastUnderline = objName.lastIndexOf('_');
|
||||
int start = strlen("btn_");
|
||||
int keyLength = lastUnderline - start;
|
||||
QString keyName = objName.mid(start, keyLength);
|
||||
|
||||
if (charId != QChar::Null && isShift && !capsState) { //第一次按shift,按后取消shift状态
|
||||
isShift = false;
|
||||
changeFuncKeyStyle("shift_l", false);
|
||||
changeFuncKeyStyle("shift_r", false);
|
||||
toggleCase();
|
||||
}
|
||||
|
||||
if (keyName == "num") { //数字页面
|
||||
Q_EMIT specialBtnClicked(PAGE_NUMBER);
|
||||
} else if (keyName == "symbol") { //符号页面
|
||||
Q_EMIT specialBtnClicked(PAGE_CHAR);
|
||||
} else if (keyName == BTN_SHIFT) { //shift
|
||||
if (capsState) {
|
||||
capsState = false;
|
||||
isShift = false;
|
||||
changeFuncKeyStyle("shift_l", false);
|
||||
changeFuncKeyStyle("shift_r", false);
|
||||
Q_EMIT specialBtnClicked(BTN_CAPSLOCK);
|
||||
} else if (isShift) { //shift键锁定
|
||||
capsState = true;
|
||||
isShift = true;
|
||||
changeFuncKeyStyle("shift_l", true);
|
||||
changeFuncKeyStyle("shift_r", true);
|
||||
Q_EMIT specialBtnClicked(BTN_CAPSLOCK);
|
||||
} else {
|
||||
isShift = true;
|
||||
changeFuncKeyStyle("shift_l", true);
|
||||
changeFuncKeyStyle("shift_r", true);
|
||||
}
|
||||
toggleCase();
|
||||
} else if (charId != QChar::Null) { //字符
|
||||
Q_EMIT normalBtnClicked(charId);
|
||||
} else { //ctrl或者alt
|
||||
Q_EMIT specialBtnClicked(keyName);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void LettersWidget::onCapsChanged()
|
||||
{
|
||||
if(isWayland){
|
||||
capsState = PlasmaShellManager::getInstance()->getKeyState(KWayland::Client::Keystate::Key::CapsLock);
|
||||
}else{
|
||||
capsState = settings->get("capslock-state").toBool();
|
||||
}
|
||||
|
||||
isShift = capsState;
|
||||
for (int i = 97; i < 123; i++) { //大小写切换
|
||||
QString objName = QString("btn_%1").arg(QString::number(i));
|
||||
KBButton *btn = findChild<KBButton*>(objName);
|
||||
btn->setCapsStatus(capsState);
|
||||
changeFuncKeyStyle("shift_l", capsState);
|
||||
changeFuncKeyStyle("shift_r", capsState);
|
||||
}
|
||||
}
|
||||
|
||||
void LettersWidget::toggleCase()
|
||||
{
|
||||
for (int i = 97; i < 123; i++) { //大小写切换
|
||||
QString objName = QString("btn_%1").arg(QString::number(i));
|
||||
KBButton *btn = findChild<KBButton*>(objName);
|
||||
btn->setShiftState(isShift);
|
||||
}
|
||||
}
|
||||
|
||||
void LettersWidget::changeFuncKeyStyle(QString obj, bool isLock)
|
||||
{
|
||||
if(obj == BTN_CAPSLOCK)
|
||||
return;
|
||||
QString objName = QString("btn_%1").arg(obj);
|
||||
KBButton *btn = findChild<KBButton*>(objName);
|
||||
if (isLock) {
|
||||
btn->updateStyleSheet(KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS,
|
||||
KBButton::BORDER_RADIUS_ALL,true);
|
||||
if (capsState && obj.contains(BTN_SHIFT)) {
|
||||
btn->setIcon(QIcon(":/images/images/shift_lock.svg"));
|
||||
} else if (obj.contains(BTN_SHIFT)) {
|
||||
btn->setIcon(QIcon(":/images/images/rectangle.svg"));
|
||||
}
|
||||
} else {
|
||||
btn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
if (obj.contains(BTN_SHIFT)) {
|
||||
btn->setIcon(QIcon(":/images/images/shift.svg"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef LETTERSWIDGET_H
|
||||
#define LETTERSWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGSettings/qgsettings.h>
|
||||
#include "kbbutton.h"
|
||||
#include <QMap>
|
||||
|
||||
class LettersWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LettersWidget(QWidget *parent = nullptr);
|
||||
virtual ~LettersWidget();
|
||||
|
||||
void adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical = false, bool floatStatus = false);
|
||||
void changeFuncKeyStyle(QString obj, bool isLock);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onBtnClicked(QChar charId);
|
||||
void onCapsChanged();
|
||||
|
||||
Q_SIGNALS:
|
||||
void clicked(int nKeyId);
|
||||
void specialBtnClicked(QString keyName);
|
||||
void normalBtnClicked(QChar c);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void toggleCase();
|
||||
|
||||
private:
|
||||
QMap<KBButton*, QRect> m_mapBtnGeometrys;
|
||||
|
||||
bool isShift = false;
|
||||
|
||||
QGSettings *settings;
|
||||
bool capsState = false;
|
||||
bool isWayland = false;
|
||||
};
|
||||
|
||||
#endif // LETTERSWIDGET_H
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -12,9 +12,8 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "virtualkeyboard.h"
|
||||
#include <QApplication>
|
||||
|
|
|
@ -0,0 +1,293 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "numberswidget.h"
|
||||
#include "kbbutton.h"
|
||||
#include "commondef.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QScrollArea>
|
||||
#include <QScrollBar>
|
||||
#include <QVBoxLayout>
|
||||
#include <QVariant>
|
||||
#include <QDebug>
|
||||
|
||||
NumbersWidget::NumbersWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);//背景透明
|
||||
initUI();
|
||||
}
|
||||
|
||||
NumbersWidget::~NumbersWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NumbersWidget::initUI()
|
||||
{
|
||||
// all chars
|
||||
m_layoutBtnList = new QVBoxLayout();
|
||||
m_layoutBtnList->setContentsMargins(8,0,0,0);
|
||||
m_layoutBtnList->setSpacing(1);
|
||||
listFrame = new QFrame();
|
||||
listFrame->setObjectName("listFrame");
|
||||
listFrame->setLayout(m_layoutBtnList);
|
||||
listFrame->setStyleSheet("QFrame{border-radius: 8px}");
|
||||
listFrame->setFrameStyle(QFrame::Plain);
|
||||
m_scrollFrame = new QScrollArea(this);
|
||||
m_scrollFrame->setObjectName("scrollFrame");
|
||||
m_scrollFrame->setFocusPolicy(Qt::NoFocus);
|
||||
m_scrollFrame->setContentsMargins(0, 0, 0, 0);
|
||||
m_scrollFrame->setStyleSheet("QScrollArea {background-color: #C0CED3D9; border-radius:8px;}");
|
||||
m_scrollFrame->viewport()->setStyleSheet("background-color:transparent;");
|
||||
m_scrollFrame->verticalScrollBar()->setProperty("drawScrollBarGroove", false);
|
||||
m_scrollFrame->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_scrollFrame->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
m_scrollFrame->setWidgetResizable(true);
|
||||
m_scrollFrame->setWidget(listFrame);
|
||||
m_scrollFrame->setGeometry(KEYBOARD_FIXED_DEFAULT_NUMBER_L1, KEYBOARD_FIXED_DEFAULT_TMARGIN,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH, KEYBOARD_FIXED_DEFAULT_NUMBER_CHARS_HEIGHT);
|
||||
listFrame->setGeometry(KEYBOARD_FIXED_DEFAULT_NUMBER_L1, KEYBOARD_FIXED_DEFAULT_TMARGIN,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH, KEYBOARD_FIXED_DEFAULT_NUMBER_CHARS_HEIGHT);
|
||||
m_mapBtnGeometrys[m_scrollFrame] = m_scrollFrame->geometry();
|
||||
//m_mapBtnGeometrys[listFrame] = listFrame->geometry();
|
||||
QChar chChars[] = {',', '.', '?', '!', '\'', ':', '~', '@', ';', '"',
|
||||
'/', '(', ')', '_', '+', '=', '`', '^', '#', '*',
|
||||
'%', '&', '\\', '[', ']', '<', '>', '{', '}', '|',
|
||||
'$', '-'};
|
||||
for (int n = 0; n < sizeof(chChars)/sizeof(QChar); n++) {
|
||||
KBButton *charBtn = new KBButton(listFrame);
|
||||
charBtn->setCharId(chChars[n]);
|
||||
charBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS,
|
||||
KBButton::BORDER_RADIUS_NONE);
|
||||
charBtn->setObjectName(QString("btn_%1").arg(QString(chChars[n])));
|
||||
connect(charBtn, &KBButton::clicked, this, &NumbersWidget::onBtnClicked);
|
||||
charBtn->setFixedHeight(KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT);
|
||||
m_layoutBtnList->addWidget(charBtn);
|
||||
}
|
||||
// line 1
|
||||
QChar chLine1[] = {'1','2','3'};
|
||||
for (int n = 0; n < sizeof(chLine1)/sizeof(QChar); n++) {
|
||||
KBButton *numberBtn = new KBButton(this);
|
||||
numberBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_NUMBER_L1+(KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*(n+1),
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT);
|
||||
numberBtn->setCharId(chLine1[n]);
|
||||
numberBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_NORMAL,KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_FONT_COLOR_PRESS);
|
||||
connect(numberBtn, &KBButton::clicked, this, &NumbersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[numberBtn] = numberBtn->geometry();
|
||||
}
|
||||
// backspace
|
||||
KBButton *backspaceBtn = new KBButton(this);
|
||||
backspaceBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_NUMBER_L1+(KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*4,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT);
|
||||
backspaceBtn->setObjectName("btn_backspace");
|
||||
backspaceBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
backspaceBtn->setIcon(QIcon(":/images/images/delet.svg"));
|
||||
connect(backspaceBtn, &KBButton::clicked, this, &NumbersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[backspaceBtn] = backspaceBtn->geometry();
|
||||
|
||||
// line 2
|
||||
QChar chLine2[] = {'4','5','6'};
|
||||
for (int n = 0; n < sizeof(chLine2)/sizeof(QChar); n++) {
|
||||
KBButton *numberBtn = new KBButton(this);
|
||||
numberBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_NUMBER_L2+(KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*(n+1),
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*1,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT);
|
||||
numberBtn->setCharId(chLine2[n]);
|
||||
numberBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_NORMAL,KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_FONT_COLOR_PRESS);
|
||||
connect(numberBtn, &KBButton::clicked, this, &NumbersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[numberBtn] = numberBtn->geometry();
|
||||
}
|
||||
// @
|
||||
KBButton *atBtn = new KBButton(this);
|
||||
atBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_NUMBER_L2+(KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*4,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*1,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT);
|
||||
atBtn->setCharId('@');
|
||||
atBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
connect(atBtn, &KBButton::clicked, this, &NumbersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[atBtn] = atBtn->geometry();
|
||||
// line 3
|
||||
QChar chLine3[] = {'7','8','9'};
|
||||
for (int n = 0; n < sizeof(chLine3)/sizeof(QChar); n++) {
|
||||
KBButton *numberBtn = new KBButton(this);
|
||||
numberBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_NUMBER_L3+(KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*(n+1),
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*2,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT);
|
||||
numberBtn->setCharId(chLine3[n]);
|
||||
numberBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_NORMAL,KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_FONT_COLOR_PRESS);
|
||||
connect(numberBtn, &KBButton::clicked, this, &NumbersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[numberBtn] = numberBtn->geometry();
|
||||
}
|
||||
// symbol
|
||||
KBButton *symbolBtn = new KBButton(this);
|
||||
symbolBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_NUMBER_L3+(KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*4,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*2,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT);
|
||||
symbolBtn->setObjectName("btn_symbol");
|
||||
symbolBtn->setText(tr("&&?!"));
|
||||
symbolBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
connect(symbolBtn, &KBButton::clicked, this, &NumbersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[symbolBtn] = symbolBtn->geometry();
|
||||
|
||||
// line 4
|
||||
KBButton *returnBtn = new KBButton(this);
|
||||
returnBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_NUMBER_L4,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT);
|
||||
returnBtn->setObjectName("btn_return");
|
||||
returnBtn->setText(tr("Return"));
|
||||
returnBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
connect(returnBtn, &KBButton::clicked, this, &NumbersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[returnBtn] = returnBtn->geometry();
|
||||
|
||||
// space
|
||||
KBButton *spaceBtn = new KBButton(this);
|
||||
spaceBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_NUMBER_L4+(KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*1,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT);
|
||||
spaceBtn->setObjectName("btn_space");
|
||||
spaceBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
spaceBtn->setIcon(QIcon(":/images/images/space.svg"));
|
||||
connect(spaceBtn, &KBButton::clicked, this, &NumbersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[spaceBtn] = spaceBtn->geometry();
|
||||
|
||||
// .
|
||||
KBButton *dianBtn = new KBButton(this);
|
||||
dianBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_NUMBER_L4+(KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT);
|
||||
dianBtn->setCharId('.');
|
||||
dianBtn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_FONT_COLOR_PRESS);
|
||||
connect(dianBtn, &KBButton::clicked, this, &NumbersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[dianBtn] = dianBtn->geometry();
|
||||
|
||||
// 9
|
||||
KBButton *num0Btn = new KBButton(this);
|
||||
num0Btn->setGeometry(KEYBOARD_FIXED_DEFAULT_NUMBER_L4+(KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*2,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT);
|
||||
num0Btn->setCharId('0');
|
||||
num0Btn->updateStyleSheet(KEYBOARD_LETTER_COLOR_NORMAL,KEYBOARD_LETTER_COLOR_PRESSED,
|
||||
KEYBOARD_LETTER_COLOR_PRESSED,KEYBOARD_LETTER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_LETTER_COLOR_BORDER_PRESSED,KEYBOARD_FONT_COLOR_PRESS);
|
||||
connect(num0Btn, &KBButton::clicked, this, &NumbersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[num0Btn] = num0Btn->geometry();
|
||||
|
||||
// enter
|
||||
KBButton *enterBtn = new KBButton(this);
|
||||
enterBtn->setGeometry(KEYBOARD_FIXED_DEFAULT_NUMBER_L3+(KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH+KEYBOAED_FIXED_DEFAULT_HSPACING)*4,
|
||||
KEYBOARD_FIXED_DEFAULT_TMARGIN+(KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT+KEYBOAED_FIXED_DEFAULT_VSPACING)*3,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_WIDTH,
|
||||
KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT);
|
||||
enterBtn->setObjectName("btn_enter");
|
||||
enterBtn->updateStyleSheet(KEYBOARD_OTHER_COLOR_NORMAL,KEYBOARD_OTHER_COLOR_PRESSED,
|
||||
KEYBOARD_OTHER_COLOR_PRESSED,KEYBOARD_OTHER_COLOR_BORDER_NORMAL,
|
||||
KEYBOARD_OTHER_COLOR_BORDER_PRESSED,KEYBOARD_OTHER_FONT_COLOR_PRESS);
|
||||
enterBtn->setIcon(QIcon(":/images/images/enter.svg"));
|
||||
connect(enterBtn, &KBButton::clicked, this, &NumbersWidget::onBtnClicked);
|
||||
m_mapBtnGeometrys[enterBtn] = enterBtn->geometry();
|
||||
}
|
||||
|
||||
void NumbersWidget::adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical/* = false*/, bool floatStatus)
|
||||
{
|
||||
QMap<QWidget*, QRect>::iterator itGeometry = m_mapBtnGeometrys.begin();
|
||||
for (; itGeometry != m_mapBtnGeometrys.end(); itGeometry ++) {
|
||||
QWidget *widget = itGeometry.key();
|
||||
if (widget) {
|
||||
QRect oldGeometry = itGeometry.value();
|
||||
QRect newGeometry = oldGeometry;
|
||||
if (floatStatus) {
|
||||
newGeometry.setX(oldGeometry.x()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
|
||||
newGeometry.setY(oldGeometry.y()*lfHeightScale);
|
||||
newGeometry.setWidth(oldGeometry.width()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
|
||||
newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
|
||||
} else {
|
||||
newGeometry.setX(oldGeometry.x()*lfWidthScale);
|
||||
newGeometry.setY(oldGeometry.y()*lfHeightScale);
|
||||
newGeometry.setWidth(oldGeometry.width()*lfWidthScale);
|
||||
newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
|
||||
}
|
||||
widget->setGeometry(newGeometry);
|
||||
}
|
||||
}
|
||||
|
||||
QChar chChars[] = {',', '.', '?', '!', '\'', ':', '~', '@', ';', '"',
|
||||
'/', '(', ')', '_', '+', '=', '`', '^', '#', '*',
|
||||
'%', '&', '\\', '[', ']', '<', '>', '{', '}', '|',
|
||||
'$', '-'};
|
||||
for (int n = 0; n < sizeof(chChars)/sizeof(QChar); n++) { //单独更新符号btn的高度
|
||||
QString objName = QString("btn_%1").arg(QString(chChars[n]));
|
||||
KBButton *btn = findChild<KBButton*>(objName);
|
||||
btn->setFixedHeight(KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT *lfHeightScale);
|
||||
}
|
||||
//更新listfarame的高度
|
||||
listFrame->setFixedHeight((KEYBOARD_FIXED_DEFAULT_NUMBER_HEIGHT *lfHeightScale +1) * (m_layoutBtnList->count()));
|
||||
}
|
||||
|
||||
void NumbersWidget::onBtnClicked(QChar charId)
|
||||
{
|
||||
QObject *obj = sender();
|
||||
KBButton *btn = static_cast<KBButton*>(obj);
|
||||
QString objName = btn->objectName();
|
||||
int lastUnderline = objName.lastIndexOf('_');
|
||||
int start = strlen("btn_");
|
||||
int keyLength = lastUnderline - start;
|
||||
QString keyName = objName.mid(start, keyLength);
|
||||
qDebug() << "keyName: " << keyName;
|
||||
if (keyName == BTN_RETURN) {
|
||||
Q_EMIT specialBtnClicked(PAGE_LETTER);
|
||||
} else if (keyName == "symbol") {
|
||||
Q_EMIT specialBtnClicked(PAGE_CHAR);
|
||||
} else if (charId != QChar::Null) {
|
||||
Q_EMIT narmalBtnClicked(charId);
|
||||
} else if (keyName == BTN_BACK) {
|
||||
Q_EMIT specialBtnClicked(BTN_BACK);
|
||||
} else {
|
||||
Q_EMIT specialBtnClicked(keyName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef NUMBERSWIDGET_H
|
||||
#define NUMBERSWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMap>
|
||||
|
||||
class KBButton;
|
||||
class QVBoxLayout;
|
||||
class QScrollArea;
|
||||
class QFrame;
|
||||
class NumbersWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NumbersWidget(QWidget *parent = nullptr);
|
||||
virtual ~NumbersWidget();
|
||||
|
||||
void adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical = false, bool floatStatus = false);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onBtnClicked(QChar charId);
|
||||
|
||||
Q_SIGNALS:
|
||||
void clicked(int nKeyId);
|
||||
void specialBtnClicked(QString keyName);
|
||||
void narmalBtnClicked(QChar charId);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
|
||||
private:
|
||||
QMap<QWidget*, QRect> m_mapBtnGeometrys;
|
||||
QVBoxLayout *m_layoutBtnList = nullptr;
|
||||
QScrollArea *m_scrollFrame = nullptr;
|
||||
QFrame *listFrame = nullptr;
|
||||
};
|
||||
|
||||
#endif // NUMBERSWIDGET_H
|
|
@ -0,0 +1,225 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "qtkeyboard.h"
|
||||
#include <QDebug>
|
||||
#include <QWidget>
|
||||
#include <QKeyEvent>
|
||||
#include <QDir>
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
#include "plasma-shell-manager.h"
|
||||
|
||||
QMap<QChar,int> m_specialSymbolMap = {
|
||||
{' ', Qt::Key_Space},
|
||||
{',', Qt::Key_Comma},
|
||||
{'.', Qt::Key_Period},
|
||||
{'\'', Qt::Key_QuoteLeft},
|
||||
{'@', Qt::Key_At},
|
||||
{'#', Qt::Key_NumberSign},
|
||||
{'$', Qt::Key_Dollar},
|
||||
{'%', Qt::Key_Percent},
|
||||
{'&', Qt::Key_Ampersand},
|
||||
{'*', Qt::Key_Asterisk},
|
||||
{'(', Qt::Key_ParenLeft},
|
||||
{')', Qt::Key_ParenRight},
|
||||
{'-', Qt::Key_Minus},
|
||||
{'+', Qt::Key_Plus},
|
||||
{'!', Qt::Key_Exclam},
|
||||
{'"', Qt::Key_QuoteDbl},
|
||||
{'<', Qt::Key_Less},
|
||||
{'>', Qt::Key_Greater},
|
||||
{':', Qt::Key_Colon},
|
||||
{';', Qt::Key_Semicolon},
|
||||
{'/', Qt::Key_Slash},
|
||||
{'?', Qt::Key_Question},
|
||||
{'=', Qt::Key_Equal},
|
||||
{'.', Qt::Key_Period}, /*XK_kana_middledot*/
|
||||
{'~', Qt::Key_AsciiTilde},
|
||||
{'`', Qt::Key_QuoteLeft},
|
||||
{'|', Qt::Key_Bar},
|
||||
{'^', Qt::Key_AsciiCircum},
|
||||
{'{', Qt::Key_BraceLeft},
|
||||
{'}', Qt::Key_BraceRight},
|
||||
{'[', Qt::Key_BracketLeft},
|
||||
{']', Qt::Key_BracketRight},
|
||||
{'_', Qt::Key_Underscore},
|
||||
{'\\', Qt::Key_Backslash},
|
||||
};
|
||||
|
||||
QMap<FuncKey::FUNCKEY, int> m_funckeyMap = {
|
||||
{FuncKey::SPACE, Qt::Key_Space},
|
||||
{FuncKey::BACKSPACE, Qt::Key_Backspace},
|
||||
{FuncKey::ENTER, Qt::Key_Enter},
|
||||
{FuncKey::HOME, Qt::Key_Home},
|
||||
{FuncKey::END, Qt::Key_End},
|
||||
{FuncKey::PGUP, Qt::Key_PageUp},
|
||||
{FuncKey::PGDN, Qt::Key_PageDown},
|
||||
{FuncKey::INSERT, Qt::Key_Insert},
|
||||
{FuncKey::DELETE, Qt::Key_Delete},
|
||||
{FuncKey::UP, Qt::Key_Up},
|
||||
{FuncKey::DOWN, Qt::Key_Down},
|
||||
{FuncKey::LEFT, Qt::Key_Left},
|
||||
{FuncKey::RIGHT, Qt::Key_Right}
|
||||
};
|
||||
|
||||
QMap<Modifier::MOD, Qt::KeyboardModifier> m_modifierMap = {
|
||||
{Modifier::CTRL, Qt::ControlModifier},
|
||||
{Modifier::ALT, Qt::AltModifier},
|
||||
{Modifier::SUPER, Qt::MetaModifier},
|
||||
{Modifier::SHIFT, Qt::ShiftModifier}
|
||||
};
|
||||
|
||||
QVector<QChar> m_shiftKeyVec = {'~', '!', '@', '#', '$', '%', '^', '&', '*',
|
||||
'(', ')', '_', '+', '{', '}', '|', ':', '"',
|
||||
'>', '?'};
|
||||
|
||||
#define DRM_DIR "/sys/class/leds/"
|
||||
#define CAPSLOCK_STATUS "capslock_state"
|
||||
|
||||
/**
|
||||
* @brief 判断大写键状态
|
||||
* @return true: 大写锁定
|
||||
*/
|
||||
bool QtKeyboard::checkCapsLockState()
|
||||
{
|
||||
QDir ledDir(DRM_DIR);
|
||||
QStringList leds = ledDir.entryList(QDir::Dirs);
|
||||
QString capsFile;
|
||||
|
||||
for(int i = 0;i<leds.count();i++){
|
||||
if(leds.at(i).contains("capslock"))
|
||||
capsFile = leds.at(i);
|
||||
}
|
||||
QFile drmStatusFile(DRM_DIR + capsFile + "/brightness");
|
||||
if(drmStatusFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&drmStatusFile);
|
||||
QString status = in.readLine();
|
||||
|
||||
if(status == "0") {
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QtKeyboard::QtKeyboard(QObject *parent)
|
||||
: FakeKeyboard(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QtKeyboard::~QtKeyboard()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QtKeyboard::addModifier(Modifier::MOD mod)
|
||||
{
|
||||
modList.push_back(mod);
|
||||
}
|
||||
|
||||
void QtKeyboard::removeModifier(Modifier::MOD mod)
|
||||
{
|
||||
modList.removeOne(mod);
|
||||
}
|
||||
|
||||
bool QtKeyboard::hasModifier(Modifier::MOD mod)
|
||||
{
|
||||
return modList.contains(mod);
|
||||
}
|
||||
|
||||
QList<Modifier::MOD> QtKeyboard::getAllModifier()
|
||||
{
|
||||
return modList;
|
||||
}
|
||||
|
||||
void QtKeyboard::clearModifier()
|
||||
{
|
||||
modList.clear();
|
||||
}
|
||||
|
||||
|
||||
void QtKeyboard::onKeyPressed(QChar c)
|
||||
{
|
||||
/*判断大写锁定打开时,转换字母大小写状态,与x11keyboard类逻辑保持一致*/
|
||||
if(checkCapsLockState() && c.isLetter()){
|
||||
if(c.isUpper()){
|
||||
c = c.toLower();
|
||||
}
|
||||
else if(c.isLower()){
|
||||
c = c.toUpper();
|
||||
}
|
||||
}
|
||||
|
||||
if(c>='A' && c<='Z'){
|
||||
sendKey(c.toLatin1(),c);
|
||||
}else if(c>='a' && c<='z'){
|
||||
sendKey(c.toLatin1() - 32,c);
|
||||
}else if(c >= '0' && c<='9'){
|
||||
sendKey(c.toLatin1(),c);
|
||||
}else if(m_specialSymbolMap.contains(c)){
|
||||
sendKey(m_specialSymbolMap[c],c);
|
||||
}else {
|
||||
sendKey(c.toLatin1(),c);
|
||||
}
|
||||
}
|
||||
|
||||
void QtKeyboard::onKeyPressed(FuncKey::FUNCKEY key)
|
||||
{
|
||||
int keysym = m_funckeyMap[key];
|
||||
/*这里的text根据实际按键得到的QEvent中的text内容打印*/
|
||||
if(key == FuncKey::SPACE){
|
||||
sendKey(keysym," ");
|
||||
}else if(key == FuncKey::BACKSPACE){
|
||||
sendKey(keysym,"\b");
|
||||
}else if(key == FuncKey::ENTER){
|
||||
sendKey(keysym,"\r");
|
||||
}else if(key == FuncKey::INSERT){
|
||||
sendKey(keysym,"\u007F");
|
||||
}else if(key == FuncKey::CAPSLOCK){
|
||||
PlasmaShellManager::getInstance()->setKeyPressed(58);
|
||||
}else{
|
||||
sendKey(keysym,"");
|
||||
}
|
||||
}
|
||||
|
||||
void QtKeyboard::sendKey(const unsigned int keysym,const QString text)
|
||||
{
|
||||
Qt::KeyboardModifiers modifier = Qt::NoModifier;
|
||||
for(auto mod : modList){
|
||||
modifier = modifier | m_modifierMap[mod];
|
||||
}
|
||||
|
||||
QWidget *objfous = QApplication::focusWidget();
|
||||
|
||||
if(objfous){
|
||||
QKeyEvent event1(QEvent::KeyPress, keysym
|
||||
, modifier, text
|
||||
, true, 1);
|
||||
QKeyEvent event2(QEvent::KeyRelease, keysym
|
||||
, modifier, text
|
||||
, true, 1);
|
||||
|
||||
QCoreApplication::sendEvent(objfous, &event1);
|
||||
QCoreApplication::sendEvent(objfous, &event2);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef QTKEYBOARD_H
|
||||
#define QTKEYBOARD_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMetaEnum>
|
||||
#include "fakekeyboard.h"
|
||||
|
||||
class QtKeyboard : public FakeKeyboard
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QtKeyboard(QObject *parent = nullptr);
|
||||
~QtKeyboard();
|
||||
void addModifier(Modifier::MOD mod);
|
||||
void removeModifier(Modifier::MOD mod);
|
||||
bool hasModifier(Modifier::MOD mod);
|
||||
QList<Modifier::MOD> getAllModifier();
|
||||
void clearModifier();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onKeyPressed(QChar c);
|
||||
void onKeyPressed(FuncKey::FUNCKEY key);
|
||||
|
||||
private:
|
||||
void sendKey(const unsigned int keyCode,const QString text);
|
||||
bool checkCapsLockState();
|
||||
|
||||
private:
|
||||
QList<Modifier::MOD> modList;
|
||||
};
|
||||
|
||||
#endif // QTKEYBOARD_H
|
|
@ -1,79 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
**/
|
||||
#include "virtualkeyboard.h"
|
||||
#include <QFile>
|
||||
#include <QDesktopWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QApplication>
|
||||
|
||||
VirtualKeyboard::VirtualKeyboard(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
Q_INIT_RESOURCE(keyboard);
|
||||
|
||||
setAutoFillBackground(true);
|
||||
QPalette plt;
|
||||
plt.setBrush(QPalette::Background, Qt::black);
|
||||
setPalette(plt);
|
||||
|
||||
setWindowFlags(Qt::FramelessWindowHint |
|
||||
Qt::WindowStaysOnTopHint |
|
||||
Qt::WindowDoesNotAcceptFocus);
|
||||
|
||||
|
||||
keyboardWidget = new KeyboardWidget(this);
|
||||
QHBoxLayout *hl_keyboard = new QHBoxLayout(this);
|
||||
QSpacerItem *spacer = new QSpacerItem(40, 20);
|
||||
hl_keyboard->addSpacerItem(spacer);
|
||||
hl_keyboard->addWidget(keyboardWidget);
|
||||
QSpacerItem *spacer2 = new QSpacerItem(40, 20);
|
||||
hl_keyboard->addSpacerItem(spacer2);
|
||||
|
||||
QFile qssFile(":/qss/keyboard.qss");
|
||||
qssFile.open(QIODevice::ReadOnly);
|
||||
setStyleSheet(qssFile.readAll());
|
||||
qssFile.close();
|
||||
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
cursorMonitor = new CursorMonitor(this);
|
||||
|
||||
//在多显示器情况下,监视鼠标指针的位置和主显示器变化信号
|
||||
connect(cursorMonitor, &CursorMonitor::cursorPosChanged,
|
||||
this, [&](const QPoint &pos){
|
||||
adjustGeometry(desktop->screenNumber(pos));
|
||||
});
|
||||
|
||||
connect(desktop, &QDesktopWidget::primaryScreenChanged,
|
||||
this, [&]{
|
||||
adjustGeometry(desktop->primaryScreen());
|
||||
});
|
||||
|
||||
connect(keyboardWidget, &KeyboardWidget::aboutToClose,
|
||||
this, &VirtualKeyboard::aboutToClose);
|
||||
|
||||
adjustGeometry(desktop->primaryScreen());
|
||||
}
|
||||
|
||||
void VirtualKeyboard::adjustGeometry(int screen)
|
||||
{
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
QWidget *activateScreen = desktop->screen(screen);
|
||||
setGeometry(0, activateScreen->height() - activateScreen->height() / 3,
|
||||
activateScreen->width(), activateScreen->height() / 3);
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
**/
|
||||
#ifndef VIRTUALKEYBOARD_H
|
||||
#define VIRTUALKEYBOARD_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "keyboardwidget.h"
|
||||
#include "cursormonitor.h"
|
||||
|
||||
class VirtualKeyboard : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VirtualKeyboard(QWidget *parent = 0);
|
||||
|
||||
private:
|
||||
void adjustGeometry(int screen);
|
||||
|
||||
Q_SIGNALS:
|
||||
void aboutToClose();
|
||||
|
||||
private:
|
||||
KeyboardWidget *keyboardWidget;
|
||||
CursorMonitor *cursorMonitor;
|
||||
bool isApplication;
|
||||
};
|
||||
|
||||
|
||||
#endif // VIRTUALKEYBOARD_H
|
|
@ -0,0 +1,310 @@
|
|||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "virtualkeyboardwidget.h"
|
||||
|
||||
#include <QPainterPath>
|
||||
#include <QPainter>
|
||||
#include <QX11Info>
|
||||
#include <QMouseEvent>
|
||||
#include "commondef.h"
|
||||
#include <QDebug>
|
||||
#include <QVBoxLayout>
|
||||
#include "dragwidget.h"
|
||||
#include "kbtitle.h"
|
||||
#include "letterswidget.h"
|
||||
#include "numberswidget.h"
|
||||
#include "charswidget.h"
|
||||
#include "charsmorewidget.h"
|
||||
#include "x11keyboard.h"
|
||||
#include "qtkeyboard.h"
|
||||
|
||||
VirtualKeyboardWidget::VirtualKeyboardWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_lfWidthScale(1.0)
|
||||
, m_lfHeightScale(1.0)
|
||||
, m_isVertical(false)
|
||||
{
|
||||
Q_INIT_RESOURCE(keyboard);
|
||||
setAttribute(Qt::WA_TranslucentBackground);//背景透明
|
||||
//setAutoFillBackground(true);
|
||||
setWindowFlags(Qt::FramelessWindowHint |
|
||||
Qt::WindowStaysOnTopHint |
|
||||
Qt::WindowDoesNotAcceptFocus);
|
||||
|
||||
if(QX11Info::isPlatformX11()){
|
||||
vKeyboard = new X11Keyboard(this);
|
||||
}else{
|
||||
vKeyboard = new QtKeyboard(this);
|
||||
}
|
||||
|
||||
connect(this, SIGNAL(keyPressed(QChar)),
|
||||
vKeyboard, SLOT(onKeyPressed(QChar)));
|
||||
connect(this, SIGNAL(keyPressed(FuncKey::FUNCKEY)),
|
||||
vKeyboard, SLOT(onKeyPressed(FuncKey::FUNCKEY)));
|
||||
initUI();
|
||||
initConnections();
|
||||
}
|
||||
|
||||
VirtualKeyboardWidget::~VirtualKeyboardWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void VirtualKeyboardWidget::initUI()
|
||||
{
|
||||
QVBoxLayout *layoutMain = new QVBoxLayout(this);
|
||||
layoutMain->setContentsMargins(0,0,0,0);
|
||||
layoutMain->setSpacing(0);
|
||||
|
||||
m_dragWidget = new DragWidget();
|
||||
layoutMain->addWidget(m_dragWidget);
|
||||
m_dragWidget->installEventFilter(this);
|
||||
|
||||
m_kbTitle = new KBTitle();
|
||||
layoutMain->addWidget(m_kbTitle);
|
||||
|
||||
m_stackedWidget = new QStackedWidget();
|
||||
|
||||
m_lettersWidget = new LettersWidget();
|
||||
m_stackedWidget->addWidget(m_lettersWidget);
|
||||
|
||||
m_numbersWidget = new NumbersWidget(this);
|
||||
m_stackedWidget->addWidget(m_numbersWidget);
|
||||
|
||||
m_charsWidget = new CharsWidget();
|
||||
m_stackedWidget->addWidget(m_charsWidget);
|
||||
|
||||
m_charsMoreWidget = new CharsMoreWidget();
|
||||
m_stackedWidget->addWidget(m_charsMoreWidget);
|
||||
|
||||
m_stackedWidget->setCurrentIndex(VKB_PAGE_LETTERS);
|
||||
m_nCurPage = VKB_PAGE_CHARSMORE;
|
||||
layoutMain->addWidget(m_stackedWidget);
|
||||
}
|
||||
|
||||
void VirtualKeyboardWidget::initConnections()
|
||||
{
|
||||
connect(m_kbTitle, &KBTitle::btnClicked, this, &VirtualKeyboardWidget::onSpecialBtnClicked);
|
||||
connect(m_lettersWidget, &LettersWidget::specialBtnClicked, this, &VirtualKeyboardWidget::onSpecialBtnClicked);
|
||||
connect(m_lettersWidget, &LettersWidget::normalBtnClicked, this, &VirtualKeyboardWidget::onNormalBtnClicked);
|
||||
connect(m_numbersWidget, &NumbersWidget::specialBtnClicked, this, &VirtualKeyboardWidget::onSpecialBtnClicked);
|
||||
connect(m_numbersWidget, &NumbersWidget::narmalBtnClicked, this, &VirtualKeyboardWidget::onNormalBtnClicked);
|
||||
connect(m_charsWidget, &CharsWidget::specialBtnClicked, this, &VirtualKeyboardWidget::onSpecialBtnClicked);
|
||||
connect(m_charsWidget, &CharsWidget::normalBtnClicked, this, &VirtualKeyboardWidget::onNormalBtnClicked);
|
||||
connect(m_charsMoreWidget, &CharsMoreWidget::specialBtnClicked, this, &VirtualKeyboardWidget::onSpecialBtnClicked);
|
||||
connect(m_charsMoreWidget, &CharsMoreWidget::normalBtnClicked, this, &VirtualKeyboardWidget::onNormalBtnClicked);
|
||||
}
|
||||
|
||||
void VirtualKeyboardWidget::adjustGeometry()
|
||||
{
|
||||
QWidget *parentWidget = qobject_cast<QWidget*>(parent());
|
||||
if (parentWidget) {
|
||||
//qDebug()<< "parent: " << parentWidget <<"Parent gemotry:"<<parentWidget->geometry();
|
||||
double lfWidth = parentWidget->geometry().width();
|
||||
double lfHeight = parentWidget->geometry().height();
|
||||
m_isVertical = lfHeight > lfWidth;
|
||||
m_lfWidthScale = lfWidth/KEYBOARD_PARENT_DEFAULT_WIDTH;
|
||||
if (m_isVertical)
|
||||
m_lfHeightScale = lfHeight / KEYBOARD_PARENT_DEFAULT_WIDTH;
|
||||
else
|
||||
m_lfHeightScale = lfHeight / KEYBOARD_PARENT_DEFAULT_HEIGHT;
|
||||
if (m_isdragState) {
|
||||
lfWidth = m_lfWidthScale * KEYBOARD_DRAGSHOW_FIXED_DEFAULT_WIDTH;
|
||||
lfHeight = m_lfHeightScale * KEYBOARD_DRAGSHOW_FIXED_DEFAULT_HEIGHT;
|
||||
setGeometry(QRect(m_lfWidthScale * (KEYBOARD_PARENT_DEFAULT_WIDTH - KEYBOARD_DRAGSHOW_FIXED_DEFAULT_WIDTH) / 2,
|
||||
parentWidget->geometry().height() - lfHeight,
|
||||
lfWidth, lfHeight));
|
||||
m_dragWidget->show();
|
||||
} else {
|
||||
lfWidth = m_lfWidthScale * KEYBOARD_FIXED_DEFAULT_WIDTH;
|
||||
lfHeight = m_lfHeightScale * KEYBOARD_DRAGHIDE_FIXED_DEFAULT_HEIGHT;
|
||||
m_dragWidget->hide();
|
||||
setGeometry(QRect(0, parentWidget->geometry().height()-lfHeight, lfWidth, lfHeight));
|
||||
}
|
||||
|
||||
//qDebug()<<"Widget geometry:"<<geometry();
|
||||
} else {
|
||||
if (m_isdragState) {
|
||||
setGeometry(QRect(0, 0,
|
||||
KEYBOARD_DRAGSHOW_FIXED_DEFAULT_WIDTH, KEYBOARD_DRAGSHOW_FIXED_DEFAULT_HEIGHT));
|
||||
m_dragWidget->show();
|
||||
} else {
|
||||
setGeometry(QRect(0, 0,
|
||||
KEYBOARD_FIXED_DEFAULT_WIDTH, KEYBOARD_DRAGHIDE_FIXED_DEFAULT_HEIGHT));
|
||||
m_dragWidget->hide();
|
||||
}
|
||||
m_lfWidthScale = 1.0;
|
||||
m_lfHeightScale = 1.0;
|
||||
m_isVertical = false;
|
||||
}
|
||||
if (m_dragWidget) {
|
||||
m_dragWidget->adjustGeometry(m_lfWidthScale, m_lfHeightScale, m_isVertical, m_isdragState);
|
||||
}
|
||||
if (m_kbTitle) {
|
||||
m_kbTitle->adjustGeometry(m_lfWidthScale, m_lfHeightScale, m_isVertical, m_isdragState);
|
||||
}
|
||||
if (m_lettersWidget) {
|
||||
m_lettersWidget->adjustGeometry(m_lfWidthScale, m_lfHeightScale, m_isVertical, m_isdragState);
|
||||
}
|
||||
if (m_numbersWidget) {
|
||||
m_numbersWidget->adjustGeometry(m_lfWidthScale, m_lfHeightScale, m_isVertical, m_isdragState);
|
||||
}
|
||||
if (m_charsWidget) {
|
||||
m_charsWidget->adjustGeometry(m_lfWidthScale, m_lfHeightScale, m_isVertical, m_isdragState);
|
||||
}
|
||||
if (m_charsMoreWidget) {
|
||||
m_charsMoreWidget->adjustGeometry(m_lfWidthScale, m_lfHeightScale, m_isVertical, m_isdragState);
|
||||
}
|
||||
}
|
||||
|
||||
bool VirtualKeyboardWidget::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if(watched != m_dragWidget && !isMove) return QWidget::eventFilter(watched, event);
|
||||
switch(event->type())
|
||||
{
|
||||
case QEvent::MouseButtonPress:
|
||||
onMouseEvents(1);
|
||||
return true;
|
||||
case QEvent::MouseMove:
|
||||
onMouseEvents(2);
|
||||
return true;
|
||||
case QEvent::MouseButtonRelease:
|
||||
onMouseEvents(3);
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QWidget::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void VirtualKeyboardWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
adjustGeometry();
|
||||
}
|
||||
|
||||
void VirtualKeyboardWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainterPath path;
|
||||
QPainter painter(this);
|
||||
painter.setOpacity(1.0);
|
||||
painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
||||
painter.setClipping(true);
|
||||
painter.setPen(Qt::transparent);
|
||||
if (m_isdragState) {
|
||||
path.addRoundedRect(this->rect(), 16, 16);
|
||||
} else {
|
||||
path.addRoundedRect(this->rect(), 0, 0);
|
||||
}
|
||||
path.setFillRule(Qt::WindingFill);
|
||||
painter.setBrush(QColor("#EBEDEF"));
|
||||
painter.setPen(Qt::transparent);
|
||||
painter.drawPath(path);
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
void VirtualKeyboardWidget::onSpecialBtnClicked(QString keyName)
|
||||
{
|
||||
Modifier::MOD mod = Modifier::getModifier(keyName);
|
||||
FuncKey::FUNCKEY funcKey = FuncKey::getKey(keyName);
|
||||
if (mod != Modifier::UNKNOWN) {
|
||||
if(vKeyboard->hasModifier(mod)) {
|
||||
vKeyboard->removeModifier(mod);
|
||||
m_lettersWidget->changeFuncKeyStyle(keyName, false);
|
||||
} else {
|
||||
vKeyboard->addModifier(mod);
|
||||
m_lettersWidget->changeFuncKeyStyle(keyName, true);
|
||||
}
|
||||
if (keyName == BTN_CAPSLOCK) {
|
||||
Q_EMIT keyPressed(FuncKey::CAPSLOCK);
|
||||
clearModifier();
|
||||
}
|
||||
} else if(funcKey != FuncKey::UNKNOWN) {
|
||||
Q_EMIT keyPressed(funcKey);
|
||||
} else if (keyName == PAGE_CHARSMORE) {
|
||||
m_stackedWidget->setCurrentIndex(VKB_PAGE_CHARSMORE);
|
||||
update();
|
||||
} else if (keyName == PAGE_CHAR) {
|
||||
m_stackedWidget->setCurrentIndex(VKB_PAGE_CHARS);
|
||||
update();
|
||||
} else if (keyName == PAGE_NUMBER) {
|
||||
m_stackedWidget->setCurrentIndex(VKB_PAGE_NUMBERS);
|
||||
update();
|
||||
} else if (keyName == PAGE_LETTER) {
|
||||
m_stackedWidget->setCurrentIndex(VKB_PAGE_LETTERS);
|
||||
update();
|
||||
} else if (keyName == BTN_FLOAT) {
|
||||
m_isdragState = !m_isdragState;
|
||||
adjustGeometry();
|
||||
Q_EMIT aboutToFloat();
|
||||
} else if (keyName == BTN_CLOSE) {
|
||||
Q_EMIT aboutToClose();
|
||||
}
|
||||
}
|
||||
|
||||
void VirtualKeyboardWidget::onNormalBtnClicked(QChar c)
|
||||
{
|
||||
Q_EMIT keyPressed(c);
|
||||
clearModifier();
|
||||
}
|
||||
|
||||
void VirtualKeyboardWidget::clearModifier()
|
||||
{
|
||||
for(auto mod : vKeyboard->getAllModifier()) {
|
||||
QString modName = Modifier::getModifierName(mod);
|
||||
m_lettersWidget->changeFuncKeyStyle(modName, false);
|
||||
}
|
||||
vKeyboard->clearModifier();
|
||||
}
|
||||
|
||||
void VirtualKeyboardWidget::onMouseEvents(int type)
|
||||
{
|
||||
switch (type) {
|
||||
case 1:
|
||||
{
|
||||
isMove = true;
|
||||
lastPoint = QCursor::pos();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if(isMove)
|
||||
{
|
||||
QPoint cPoint = QCursor::pos();
|
||||
QPoint p = pos();
|
||||
p.setX(p.x() - lastPoint.x() + cPoint.x());
|
||||
p.setY(p.y() - lastPoint.y() + cPoint.y());
|
||||
lastPoint = cPoint;
|
||||
move(p);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
isMove = false;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool VirtualKeyboardWidget::getFloatStatus()
|
||||
{
|
||||
return m_isdragState;
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef VIRTUALKEYBOARDWIDGET_H
|
||||
#define VIRTUALKEYBOARDWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStackedWidget>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include "fakekeyboard.h"
|
||||
#include "plasma-shell-manager.h"
|
||||
|
||||
class DragWidget;
|
||||
class KBTitle;
|
||||
class LettersWidget;
|
||||
class NumbersWidget;
|
||||
class CharsWidget;
|
||||
class CharsMoreWidget;
|
||||
class VirtualKeyboardWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum {
|
||||
VKB_PAGE_LETTERS,
|
||||
VKB_PAGE_NUMBERS,
|
||||
VKB_PAGE_CHARS,
|
||||
VKB_PAGE_CHARSMORE,
|
||||
};
|
||||
VirtualKeyboardWidget(QWidget *parent = nullptr);
|
||||
virtual ~VirtualKeyboardWidget();
|
||||
bool getFloatStatus();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onNormalBtnClicked(QChar c);
|
||||
void onSpecialBtnClicked(QString keyName);
|
||||
|
||||
Q_SIGNALS:
|
||||
void aboutToClose();
|
||||
void aboutToFloat();
|
||||
void keyPressed(QChar c);
|
||||
void keyPressed(FuncKey::FUNCKEY key);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void initConnections();
|
||||
void adjustGeometry();
|
||||
void onMouseEvents(int type);
|
||||
void clearModifier();
|
||||
|
||||
private:
|
||||
double m_lfWidthScale;
|
||||
double m_lfHeightScale;
|
||||
bool m_isVertical;
|
||||
QStackedWidget *m_stackedWidget = nullptr;
|
||||
LettersWidget *m_lettersWidget = nullptr;
|
||||
NumbersWidget *m_numbersWidget = nullptr;
|
||||
CharsWidget *m_charsWidget = nullptr;
|
||||
CharsMoreWidget *m_charsMoreWidget = nullptr;
|
||||
KBTitle *m_kbTitle = nullptr;
|
||||
DragWidget *m_dragWidget = nullptr;
|
||||
int m_nCurPage;
|
||||
QList<int> m_listPageHis;
|
||||
bool m_isdragState = false;//是否为悬浮状态
|
||||
bool isMove;// 是否可移动
|
||||
QPoint lastPoint;// 拖拽控件时 记录当前控件的位置
|
||||
FakeKeyboard *vKeyboard;
|
||||
};
|
||||
|
||||
#endif // VIRTUALKEYBOARDWIDGET_H
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -12,9 +12,8 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "x11keyboard.h"
|
||||
#include <QDebug>
|
||||
|
@ -22,8 +21,6 @@
|
|||
#include <X11/keysym.h>
|
||||
#include <X11/extensions/XTest.h>
|
||||
|
||||
|
||||
|
||||
struct CharMap {
|
||||
QChar name;
|
||||
KeySym code;
|
||||
|
@ -79,14 +76,15 @@ QMap<FuncKey::FUNCKEY, KeySym> funckeyMap = {
|
|||
{FuncKey::UP, XK_Up},
|
||||
{FuncKey::DOWN, XK_Down},
|
||||
{FuncKey::LEFT, XK_Left},
|
||||
{FuncKey::RIGHT, XK_Right}
|
||||
{FuncKey::RIGHT, XK_Right},
|
||||
{FuncKey::CAPSLOCK, XK_Caps_Lock}
|
||||
};
|
||||
|
||||
QMap<Modifier::MOD, KeySym> modifierMap = {
|
||||
{Modifier::CTRL, XK_Control_L},
|
||||
{Modifier::ALT, XK_Alt_L},
|
||||
{Modifier::SUPER, XK_Super_L},
|
||||
{Modifier::SHIFT, XK_Shift_L}
|
||||
{Modifier::SHIFT, XK_Shift_L},
|
||||
};
|
||||
|
||||
QVector<QChar> shiftKeyVec = {'~', '!', '@', '#', '$', '%', '^', '&', '*',
|
||||
|
@ -123,7 +121,7 @@ unsigned int keyCodeOfChar(QChar c)
|
|||
}
|
||||
|
||||
X11Keyboard::X11Keyboard(QObject *parent)
|
||||
: QObject(parent)
|
||||
: FakeKeyboard(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -168,6 +166,7 @@ void X11Keyboard::onKeyPressed(QChar c)
|
|||
void X11Keyboard::onKeyPressed(FuncKey::FUNCKEY key)
|
||||
{
|
||||
KeyCode keyCode;
|
||||
|
||||
KeySym keysym = funckeyMap[key];
|
||||
|
||||
if(keysym != NoSymbol)
|
||||
|
@ -203,6 +202,9 @@ void X11Keyboard::sendKey(unsigned int keyCode)
|
|||
KeyCode keyCode = XKeysymToKeycode(display, modifierMap[mod]);
|
||||
XTestFakeKeyEvent(display, keyCode, False, 2);
|
||||
}
|
||||
|
||||
//输入结束清除shift状态
|
||||
isShift = false;
|
||||
|
||||
XFlush(display);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -12,85 +12,17 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef X11KEYBOARD_H
|
||||
#define X11KEYBOARD_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMetaEnum>
|
||||
#include "fakekeyboard.h"
|
||||
|
||||
class Modifier : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Modifier(){}
|
||||
|
||||
enum MOD{
|
||||
UNKNOWN = -1,
|
||||
CTRL,
|
||||
SHIFT,
|
||||
ALT,
|
||||
SUPER
|
||||
};
|
||||
Q_ENUM(MOD)
|
||||
|
||||
static QString getModifierName(int mod)
|
||||
{
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<Modifier::MOD>();
|
||||
const char* modName = metaEnum.valueToKey(mod);
|
||||
QString result = QString(modName).toLower();
|
||||
return result;
|
||||
}
|
||||
static MOD getModifier(const QString &modName)
|
||||
{
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<Modifier::MOD>();
|
||||
MOD mod = (MOD)metaEnum.keyToValue(modName.toUpper().toLocal8Bit().data());
|
||||
return mod;
|
||||
}
|
||||
};
|
||||
|
||||
class FuncKey : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FuncKey(){}
|
||||
|
||||
enum FUNCKEY {
|
||||
UNKNOWN = -1,
|
||||
SPACE = 0,
|
||||
BACKSPACE,
|
||||
ENTER,
|
||||
HOME,
|
||||
END,
|
||||
PGUP,
|
||||
PGDN,
|
||||
INSERT,
|
||||
DELETE,
|
||||
UP,
|
||||
DOWN,
|
||||
LEFT,
|
||||
RIGHT
|
||||
};
|
||||
Q_ENUM(FUNCKEY)
|
||||
static QString getKeyName(int key)
|
||||
{
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<FuncKey::FUNCKEY>();
|
||||
const char* keyName = metaEnum.valueToKey(key);
|
||||
QString result = QString(keyName).toLower();
|
||||
return result;
|
||||
}
|
||||
static FUNCKEY getKey(const QString &keyName)
|
||||
{
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<FuncKey::FUNCKEY>();
|
||||
FUNCKEY key = (FUNCKEY)metaEnum.keyToValue(keyName.toUpper().toLocal8Bit().data());
|
||||
return key;
|
||||
}
|
||||
};
|
||||
|
||||
class X11Keyboard : public QObject
|
||||
class X11Keyboard : public FakeKeyboard
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -4,3 +4,4 @@ install(FILES ukui-screensaver.directory DESTINATION /usr/share/desktop-director
|
|||
install(FILES ukui-screensavers.menu DESTINATION /etc/xdg/menus)
|
||||
install(FILES ukui-screensaver-qt DESTINATION /etc/pam.d)
|
||||
install(FILES screensaver-startup.sh DESTINATION /usr/bin)
|
||||
install(FILES ukui-screensaver-dialog.desktop DESTINATION /usr/share/applications)
|
||||
|
|
|
@ -166,7 +166,7 @@
|
|||
<description>Allow the session status message to be displayed when the screen is locked.</description>
|
||||
</key>
|
||||
<key name="background" type="s">
|
||||
<default>'/usr/share/backgrounds/1-warty-final-ubuntukylin.jpg'</default>
|
||||
<default>'/usr/share/backgrounds/1-openkylin.jpg'</default>
|
||||
<summary>the background iamge of lockscreen</summary>
|
||||
<description>Allow the user to set the background iamge of lockscreen.</description>
|
||||
</key>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#!/bin/bash
|
||||
/usr/lib/ukui-screensaver/set4kScale >/dev/null 2>&1
|
||||
ukui-screensaver-dialog --lock-startup & >/dev/null 2>&1
|
||||
/usr/lib/ukui-screensaver/screensaver-focus-helper & >/dev/null 2>&1
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Lockscreen Dialog
|
||||
Name[tr]=Ekran pencere
|
||||
Name[zh_CN]=锁屏窗口程序
|
||||
Name[zh_HK]=鎖屏窗口程式
|
||||
Name[zh_TW]=鎖屏窗口程式
|
||||
Comment[tr]=Ekran kilidini ve kurtarıcı göster
|
||||
Comment[zh_CN]=展示屏幕锁定和保护程序
|
||||
Comment[zh_TW]=展示屏幕鎖定和保護程式
|
||||
Exec=/usr/bin/ukui-screensaver-dialog
|
||||
NoDisplay=true
|
||||
OnlyShowIn=UKUI
|
||||
X-KDE-Wayland-Interfaces=org_kde_plasma_window_management,org_kde_kwin_keystate
|
||||
|
|
@ -17,3 +17,4 @@ X-UKUI-Bugzilla-Product=ukui-screensaver
|
|||
X-UKUI-Bugzilla-Component=general
|
||||
X-UKUI-Bugzilla-Version=1.0.0
|
||||
OnlyShowIn=UKUI
|
||||
X-UKUI-AutoRestart=true
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
ukui-screensaver (4.0.0.0-ok0~0426) yangtze; urgency=medium
|
||||
|
||||
* BUG号: 137546 【RISC-V】【控制面板】无法更改屏幕缩放
|
||||
* 需求号:无
|
||||
* 其他修改说明:无
|
||||
|
||||
-- Yang Min <yangmin@kylinos.cn> Wed, 26 Apr 2023 19:49:20 +0800
|
||||
|
||||
ukui-screensaver (3.22.1.3-ok11~0412) yangtze; urgency=medium
|
||||
|
||||
* BUG号:I5XFFQ 锁屏登入界面无键盘图标,无实体键盘时无法输入
|
||||
|
|
|
@ -25,6 +25,7 @@ Build-Depends: debhelper-compat (= 12),
|
|||
libgsettings-qt-dev,
|
||||
libkf5windowsystem-dev,
|
||||
libmatemixer-dev,
|
||||
libimlib2-dev,
|
||||
libukui-log4qt-dev,
|
||||
libkysdk-sysinfo-dev (>> 1.1.0kylin1),
|
||||
ukui-input-gather (>=1.0.0.2),
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
From: winnerym <yangmin@kylinos.cn>
|
||||
Date: Thu, 8 Dec 2022 14:40:46 +0800
|
||||
Subject: =?utf-8?b?5pu05paw5L+u5pS56K6w5b2V?=
|
||||
|
||||
---
|
||||
src/lockwidget.cpp | 23 -----------------------
|
||||
1 file changed, 23 deletions(-)
|
||||
|
||||
diff --git a/src/lockwidget.cpp b/src/lockwidget.cpp
|
||||
index 1f02d85..cafeb59 100644
|
||||
--- a/src/lockwidget.cpp
|
||||
+++ b/src/lockwidget.cpp
|
||||
@@ -1909,29 +1909,6 @@ QString LockWidget::getBatteryIconName()
|
||||
return QString();
|
||||
}
|
||||
|
||||
-QString LockWidget::getBatteryIconName()
|
||||
-{
|
||||
- if (iface->isValid() && dface->isValid()) {
|
||||
- bool batteryState = false;
|
||||
- QDBusReply<QVariant> reply = batInterface->call("Get", UPOWER_SERVICE, "OnBattery");
|
||||
- if (reply.isValid()) {
|
||||
- batteryState = reply.value().toBool();
|
||||
- }
|
||||
- double percentage = -1.0;
|
||||
- QDBusReply<QVariant> percentage_reply = iface->call("Get", UPOWER_DIVICES_SERVICE, "Percentage");
|
||||
- if (percentage_reply.isValid()) {
|
||||
- percentage = percentage_reply.value().toDouble();
|
||||
- }
|
||||
-
|
||||
- if (true == batteryState) {
|
||||
- return QString("battery-level-%1-symbolic").arg((int)percentage / 10 * 10);
|
||||
- } else {
|
||||
- return QString("battery-level-%1-charging-symbolic").arg((int)percentage / 10 * 10);
|
||||
- }
|
||||
- }
|
||||
- return QString();
|
||||
-}
|
||||
-
|
||||
int LockWidget::getLoginedNum()
|
||||
{
|
||||
if(loginedNum != 0)
|
|
@ -1,145 +0,0 @@
|
|||
From: winnerym <yangmin@kylinos.cn>
|
||||
Date: Fri, 30 Dec 2022 15:30:14 +0800
|
||||
Subject: =?utf-8?b?5pu05paw5L+u5pS56K6w5b2V?=
|
||||
|
||||
---
|
||||
src/displaymanager.cpp | 1 -
|
||||
src/fullbackgroundwidget.cpp | 7 ++++++-
|
||||
src/plasma-shell-manager.cpp | 1 +
|
||||
src/powermanager.cpp | 1 -
|
||||
src/screensaverwidget.cpp | 12 +++++-------
|
||||
src/ukui-screensaver-dialog.cpp | 2 +-
|
||||
6 files changed, 13 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/displaymanager.cpp b/src/displaymanager.cpp
|
||||
index abc9e0b..65e9346 100644
|
||||
--- a/src/displaymanager.cpp
|
||||
+++ b/src/displaymanager.cpp
|
||||
@@ -73,7 +73,6 @@ QString DisplayManager::getDisplayType()
|
||||
|
||||
void DisplayManager::switchToGreeter()
|
||||
{
|
||||
- qDebug()<<"111111111111111111111111111111111111111111111111111111";
|
||||
if(_displayType == "lightdm"){
|
||||
QDBusMessage ret = dmSeatService->call("SwitchToGreeter");
|
||||
handleDBusError(ret);
|
||||
diff --git a/src/fullbackgroundwidget.cpp b/src/fullbackgroundwidget.cpp
|
||||
index b77fdbb..3e4e421 100644
|
||||
--- a/src/fullbackgroundwidget.cpp
|
||||
+++ b/src/fullbackgroundwidget.cpp
|
||||
@@ -849,7 +849,6 @@ void FullBackgroundWidget::showScreensaver(bool isPreview/* = false*/)
|
||||
} else {
|
||||
saverWidget->setGeometry(screen->geometry());
|
||||
}
|
||||
-
|
||||
}
|
||||
setCursor(Qt::BlankCursor);
|
||||
|
||||
@@ -1206,6 +1205,8 @@ void FullBackgroundWidget::onDesktopResized()
|
||||
//repaint();
|
||||
update();
|
||||
#endif
|
||||
+
|
||||
+ PlasmaShellManager::getInstance()->setPos(this->windowHandle(),QPoint(0,0));
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::laterInhibit(bool val)
|
||||
@@ -1345,6 +1346,10 @@ QList<quint64> FullBackgroundWidget::GetSubWndIds()
|
||||
void FullBackgroundWidget::raiseOtherWnd()
|
||||
{
|
||||
//qDebug()<<"raiseOtherWnd----:"<<m_listWndIds.size();
|
||||
+
|
||||
+ if(!QX11Info::isPlatformX11())
|
||||
+ return ;
|
||||
+
|
||||
for (auto wndId : m_listWndIds) {
|
||||
XRaiseWindow(QX11Info::display(), wndId);
|
||||
XFlush(QX11Info::display());
|
||||
diff --git a/src/plasma-shell-manager.cpp b/src/plasma-shell-manager.cpp
|
||||
index 1ad8234..f987e4e 100644
|
||||
--- a/src/plasma-shell-manager.cpp
|
||||
+++ b/src/plasma-shell-manager.cpp
|
||||
@@ -93,6 +93,7 @@ bool PlasmaShellManager::setPos(QWindow *window, const QPoint &pos)
|
||||
return false;
|
||||
|
||||
plasmaShellSurface->setPosition(pos);
|
||||
+
|
||||
return true;
|
||||
}
|
||||
|
||||
diff --git a/src/powermanager.cpp b/src/powermanager.cpp
|
||||
index aadcf02..faf67f8 100644
|
||||
--- a/src/powermanager.cpp
|
||||
+++ b/src/powermanager.cpp
|
||||
@@ -216,7 +216,6 @@ void PowerManager::powerClicked(QListWidgetItem *item)
|
||||
lasttime = QTime::currentTime();
|
||||
|
||||
QString name = itemWidget(item)->objectName();
|
||||
- printf("111111111111111111111111111 name = %s\n",name.toLatin1().data());
|
||||
// if(name == lockWidget->objectName())
|
||||
// lockWidgetClicked();
|
||||
if(switchWidget && name == switchWidget->objectName())
|
||||
diff --git a/src/screensaverwidget.cpp b/src/screensaverwidget.cpp
|
||||
index cfc41cc..36bd944 100644
|
||||
--- a/src/screensaverwidget.cpp
|
||||
+++ b/src/screensaverwidget.cpp
|
||||
@@ -106,7 +106,7 @@ void ScreenSaverWidget::paintEvent(QPaintEvent *event)
|
||||
if(!screensaver->exists())
|
||||
{
|
||||
QPainter painter(this);
|
||||
- painter.fillRect(geometry(), Qt::black);
|
||||
+ painter.fillRect(0,0,this->width(),this->height(), Qt::black);
|
||||
}
|
||||
if(screensaver->mode == SAVER_IMAGE) {
|
||||
switch(screensaver->effect) {
|
||||
@@ -115,7 +115,7 @@ void ScreenSaverWidget::paintEvent(QPaintEvent *event)
|
||||
QPixmap pixmap(screensaver->path);
|
||||
pixmap.scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
QPainter painter(this);
|
||||
- painter.drawPixmap(geometry(), pixmap);
|
||||
+ painter.drawPixmap(0,0,this->width(),this->height(), pixmap);
|
||||
break;
|
||||
}
|
||||
case TRANSITION_FADE_IN_OUT:
|
||||
@@ -124,17 +124,15 @@ void ScreenSaverWidget::paintEvent(QPaintEvent *event)
|
||||
QPixmap pixmap1(screensaver->lastPath);
|
||||
pixmap1.scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
painter.setOpacity(opacity);
|
||||
- painter.drawPixmap(geometry(), pixmap1);
|
||||
+ painter.drawPixmap(0,0,this->width(),this->height(), pixmap1);
|
||||
|
||||
QPixmap pixmap(screensaver->path);
|
||||
pixmap.scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
painter.setOpacity(1 - opacity);
|
||||
- painter.drawPixmap(geometry(), pixmap);
|
||||
+ painter.drawPixmap(0,0,this->width(),this->height(), pixmap);
|
||||
break;
|
||||
}
|
||||
}
|
||||
-
|
||||
-
|
||||
}
|
||||
return QWidget::paintEvent(event);
|
||||
}
|
||||
@@ -174,7 +172,7 @@ void ScreenSaverWidget::embedXScreensaver(const QString &path)
|
||||
void ScreenSaverWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
if(m_screensaver){
|
||||
- m_screensaver->setGeometry(this->geometry());
|
||||
+ m_screensaver->setGeometry(0,0,this->width(),this->height());
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/ukui-screensaver-dialog.cpp b/src/ukui-screensaver-dialog.cpp
|
||||
index e7ed780..2a5c0b7 100644
|
||||
--- a/src/ukui-screensaver-dialog.cpp
|
||||
+++ b/src/ukui-screensaver-dialog.cpp
|
||||
@@ -227,7 +227,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifndef USE_INTEL
|
||||
if (QString(qgetenv("XDG_SESSION_TYPE")) == "wayland")
|
||||
- window->showFullScreen();
|
||||
+ window->show();
|
||||
else
|
||||
window->show();
|
||||
window->activateWindow();
|