!68 添加平板模式的切换,以及虚拟键盘自测问题修复

Merge pull request !68 from liudunfa/openkylin/nile
This commit is contained in:
杨敏 2024-02-20 02:32:44 +00:00 committed by Gitee
commit ebb335e00f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
23 changed files with 522 additions and 48 deletions

View File

@ -77,6 +77,7 @@ set(EXTRA_LIBS
-lrt
-lpthread
-llibnm-icon-kylin
-lukuiinputgatherclient
)
#qt5_wrap_ui(dialog_SRC
@ -162,6 +163,8 @@ set(backend_SRC
dbusifs/freedesktophelper.cpp
dbusifs/giodbus.cpp
dbusifs/kglobalaccelhelper.cpp
dbusifs/machinemodel.cpp
dbusifs/libinputswitchevent.cpp
userinfo.cpp
agreementinfo.cpp
common/global_utils.cpp
@ -182,6 +185,7 @@ target_link_libraries(ukui-screensaver-backend
ukui-log4qt
-ldl
-lcrypto
-lukuiinputgatherclient
)
set(command_SRC

View File

@ -108,6 +108,8 @@ typedef enum _LOCK_CMD_ID_e
LOCK_CMD_ID_BIOAUTH_AUTHSTATE_CHANGED,
LOCK_CMD_ID_BIOAUTH_FRAME_DATA,
LOCK_CMD_ID_BIOAUTH_COMPLETE,
LOCK_CMD_ID_TABLET_MODE_CHANGED = 700,
LOCK_CMD_ID_TABLET_MODE,
LOCK_CMD_ID_COUNT
}LOCK_CMD_ID;
@ -175,8 +177,8 @@ typedef enum _LOCK_CMD_ID_e
#define GSETTINGS_SCHEMA_MEDIAKEY_SCHEMA "org.ukui.SettingsDaemon.plugins.media-keys"
#define KEY_AREA_SCREENSHOT "areaScreenshot"
#define KEY_AREA_SCREENSHOT2 "areaScreenshot2"
#define KEY_SCREEN_SHOT "screenShot"
#define KEY_SCREEN_SHOT2 "screenShot2"
#define KEY_SCREEN_SHOT "screenshot"
#define KEY_SCREEN_SHOT2 "screenshot2"
#define KEY_WINDOW_SCREENSHOT "windowScreenshot"
#define WORKING_DIRECTORY "/usr/share/ukui-screensaver"

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) 2023 KylinSoft 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 "libinputswitchevent.h"
typedef std::function<void(Event*)> sendEvent;
LibinputSwitchEvent::LibinputSwitchEvent(QObject *parent)
: QObject(parent)
, m_machineModel(MachineModel::getMachineModelInstance())
{
m_machineType = m_machineModel->getTheMachineType();
sendEvent se = std::bind(&LibinputSwitchEvent::dealEvent, this, std::placeholders::_1);
m_inputGatherClient = new UKUIInputGatherClient();
m_inputGatherClient->setEventCallBack(se);
m_inputGatherClient->startToReceiveEvent();
}
LibinputSwitchEvent::~LibinputSwitchEvent()
{
// delete m_inputGatherClient;
}
bool LibinputSwitchEvent::geInitDevicesStatus()
{
//其他处理
if (m_machineType == QStringLiteral("SLATE")) {
return true;
}else if (m_machineType == "LAPTOP" ) {//永久附加键盘笔记本
//return true;
}else if (m_machineType == "ALLINONE") {//台式
return false;
}else {
//0 非平板
//1 平板
//-1 不支持
// int status = m_inputGatherClient->libinputTabletSwitchState();
// qInfo() << __FILE__ << __LINE__<< "当前设备的状态:" << status;
// if(status == 1)
// return true;
// else
return false;
}
}
void LibinputSwitchEvent::dealEvent(Event* e)
{
switch (e->type) {
case LIBINPUT_EVENT_SWITCH_TOGGLE:
qInfo() << __FILE__ << __LINE__ << "=LIBINPUT_EVENT_SWITCH_TOGGLE=";
if(e->event.switchEventDate.switchType == LIBINPUT_SWITCH_TABLET_MODE) {
qInfo() << __FILE__ << __LINE__ << "switch type" << e->event.switchEventDate.switchType;
qInfo() << __FILE__ << __LINE__ << "switch status" << e->event.switchEventDate.switchState;
if(e->event.switchEventDate.switchState == 1) {
Q_EMIT tabletModeStatusChanged(1);
}else {
Q_EMIT tabletModeStatusChanged(0);
}
}
break;
default:
break;
}
}

View File

@ -0,0 +1,47 @@
/*
* 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 LIBINPUTSWITCHEVENT_H
#define LIBINPUTSWITCHEVENT_H
#include <QObject>
#include <QDebug>
#include <ukui/event.h>
#include <ukui/ukuiinputgatherclient.h>
#include "machinemodel.h"
//头文件以及顺序不可改,不可删
class LibinputSwitchEvent : public QObject
{
Q_OBJECT
public:
explicit LibinputSwitchEvent(QObject *parent = nullptr);
~LibinputSwitchEvent();
UKUIInputGatherClient * m_inputGatherClient = nullptr;
bool geInitDevicesStatus();
signals:
void tabletModeStatusChanged(int tabletmode);
private:
void dealEvent(Event* e);
private:
QString m_machineType;
std::shared_ptr<MachineModel> m_machineModel = nullptr;
};
#endif // LIBINPUTSWITCHEVENT_H

View File

@ -0,0 +1,112 @@
/*
* Copyright (C) 2023 KylinSoft 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 "machinemodel.h"
#include <QSettings>
#include <QProcess>
#include <QDebug>
std::shared_ptr<MachineModel> MachineModel::m_machineModel = nullptr;
std::mutex MachineModel::m_mutex;
MachineModel::MachineModel(QObject *parent) : QObject(parent)
{
initMachineType();
}
QString MachineModel::getTheMachineType()
{
return m_machineType;
}
std::shared_ptr<MachineModel> MachineModel::getMachineModelInstance()
{
if(m_machineModel == nullptr)
{
std::unique_lock<std::mutex> lock(m_mutex);
if(m_machineModel == nullptr)
{
m_machineModel = std::shared_ptr<MachineModel>(new MachineModel);
}
}
return m_machineModel;
}
void MachineModel::initMachineType()
{
QSettings setting(":/assets/data/conf.ini", QSettings::IniFormat);
setting.beginGroup("MachineType");//节点开始
QString type = getSysVendor() + getProductFamily();
qInfo() << __FILE__ << __LINE__ << type;
if (setting.contains(type)) {
m_machineType = setting.value(type).toString();
} else {
m_machineType = QString();
}
qInfo() << __FILE__ << __LINE__ << m_machineType;
setting.endGroup();//节点结束
}
const QString MachineModel::getSysVendor() const
{
QProcess process;
QStringList options;
options << "-c";
options << "cat /sys/class/dmi/id/sys_vendor";
process.start("/bin/bash", options);
process.waitForFinished();
QString result = process.readAllStandardOutput();
QStringList list = result.split("\n");
result = list.at(0);
qInfo() << __FILE__ << __LINE__ << "获取设备厂商为:" << result;
return result;
}
const QString MachineModel::getProductName() const
{
QProcess process;
QStringList options;
options << "-c";
options << "cat /sys/class/dmi/id/product_name";
process.start("/bin/bash", options);
process.waitForFinished();
QString result = process.readAllStandardOutput();
QStringList list = result.split("\n");
result = list.at(0);
qInfo() << __FILE__ << __LINE__ << "获取产品名为:" << result;
return result;
}
const QString MachineModel::getProductFamily() const
{
QProcess process;
QStringList options;
options << "-c";
options << "cat /sys/class/dmi/id/product_family";
process.start("/bin/bash", options);
process.waitForFinished();
QString result = process.readAllStandardOutput();
QStringList list = result.split("\n");
result = list.at(0);
qInfo() << __FILE__ << __LINE__ << "获取设备Family为" << result;
return result;
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (C) 2023 KylinSoft 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 MACHINEMODEL_H
#define MACHINEMODEL_H
#include <QObject>
#include <mutex>
#include <memory>
class MachineModel : public QObject
{
Q_OBJECT
public:
QString getTheMachineType();
static std::shared_ptr<MachineModel> getMachineModelInstance();
private:
MachineModel(QObject *parent = nullptr);
MachineModel(const MachineModel &);
const MachineModel &operator =(const MachineModel &) = delete;
private:
void initMachineType();
const QString getSysVendor() const;
const QString getProductName() const;
const QString getProductFamily() const;
QString m_machineType;
static std::shared_ptr<MachineModel> m_machineModel;
static std::mutex m_mutex;
signals:
};
#endif // MACHINEMODEL_H

View File

@ -51,7 +51,7 @@ bool UsdHelper::usdExternalDoAction(int actionType)
init();
QDBusPendingCall result = usdInterface->asyncCall("externalDoAction", actionType, "screensaver");
if (result.reply().type() == QDBusMessage::ErrorMessage) {
qWarning() << "setDefaultDevice error!!!!!!!!!!!!!!";
qWarning() << "usdExternalDoAction error!!!!!!!!!!!!!!";
return false;
}
return true;

View File

@ -41,6 +41,7 @@
#include "rsac.h"
#include "kglobalaccelhelper.h"
#include "personalizeddata.h"
#include "libinputswitchevent.h"
#define CONFIG_FILE "/usr/share/ukui-greeter/ukui-greeter.conf"
@ -68,6 +69,7 @@ void DbusUpperInterface::initData()
m_sessionHelper = new SessionHelper(this);
m_sessionWatcher = new SessionWatcher(m_gsettingsHelper, this);
m_kglobalHelper = new KglobalAccelHelper(this);
m_libinputSwitchEvent = new LibinputSwitchEvent(this);
m_config->initShareConfig();
m_config->setShareConfigValue("timeType", m_gsettingsHelper->GetUkccPluginsConf(KEY_HOUR_SYSTEM).toInt());
@ -134,6 +136,9 @@ void DbusUpperInterface::initConnections()
connect(m_sessionWatcher, &SessionWatcher::sessionIdleExit, this, &DbusUpperInterface::onSessionIdleExit);
}
connect(&m_procLockDialog, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(onLockDialogProcExit(int,QProcess::ExitStatus)));
if (m_libinputSwitchEvent) {
connect(m_libinputSwitchEvent, &LibinputSwitchEvent::tabletModeStatusChanged, this, &DbusUpperInterface::onTabletModeChanged);
}
}
void DbusUpperInterface::onNameLost(const QString &serviceName)
@ -566,6 +571,10 @@ QString DbusUpperInterface::GetInformation(QString strJson)
retObj["CmdId"] = cmdId;
retObj["Content"] = getPublicEncrypt();
break;
case LOCK_CMD_ID_TABLET_MODE:
retObj["CmdId"] = cmdId;
retObj["Content"] = getCurTabletMode();
break;
default:
qInfo()<<"不支持的CmdId";
retObj["Ret"] = -2;
@ -923,6 +932,15 @@ int DbusUpperInterface::SetCurrentUser(const QJsonObject &objInfo)
return nRet;
}
bool DbusUpperInterface::getCurTabletMode()
{
bool tabletMode = false;
if (m_libinputSwitchEvent) {
tabletMode = m_libinputSwitchEvent->geInitDevicesStatus();
}
return tabletMode;
}
int DbusUpperInterface::switchToUser(const QJsonObject &objInfo)
{
int nRet = -1;
@ -1987,6 +2005,14 @@ void DbusUpperInterface::onBioAuthCompleted(int nUid, bool isSuccess, int nError
SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson()));
}
void DbusUpperInterface::onTabletModeChanged(bool tabletMode)
{
QJsonObject retObj;
retObj["CmdId"] = LOCK_CMD_ID_TABLET_MODE_CHANGED;
retObj["mode"] = tabletMode;
SendUpdateInfoSig(QString(QJsonDocument(retObj).toJson()));
}
void DbusUpperInterface::BioGetAvailableDevices(QJsonObject &reqObj, QJsonObject &retObj)
{
QVariant varUserId = reqObj.value("UserId");

View File

@ -42,6 +42,7 @@ class SessionHelper;
class SessionWatcher;
class BioAuthenticate;
class KglobalAccelHelper;
class LibinputSwitchEvent;
/**
* @brief dbus服务接口实现类
*
@ -203,6 +204,8 @@ public Q_SLOTS:
void onBioAuthFrameData(QString strData);
void onBioAuthCompleted(int nUid, bool isSuccess, int nError, int nMaxFailedTime, int nFailedTime);
// 平板模式切换
void onTabletModeChanged(bool tabletMode);
private Q_SLOTS:
void onLockDialogProcExit(int exitCode, QProcess::ExitStatus exitStatus);
@ -351,6 +354,7 @@ private:
int BioStopAuth(const QJsonObject &objInfo);
bool getCurTabletMode();
private:
/**
* @brief
@ -394,7 +398,7 @@ private:
RSAC rsac;
QByteArray pubKey,priKey;
KglobalAccelHelper *m_kglobalHelper = nullptr;
LibinputSwitchEvent *m_libinputSwitchEvent = nullptr;
};
#endif // DBUSUPPERINTERFACE_H

View File

@ -17,6 +17,7 @@
**/
#include "gsettingshelper.h"
#include <QVariant>
#include <QDebug>
#include "definetypes.h"
GSettingsHelper::GSettingsHelper(QObject *parent)
@ -275,11 +276,14 @@ bool GSettingsHelper::initUsdMediaKeys()
}
if (keys.contains(KEY_AREA_SCREENSHOT2)) {
m_areaScreenShot2 = m_gsUsdMediaKeys->get(KEY_AREA_SCREENSHOT2).toString();
} else if (keys.contains(KEY_SCREEN_SHOT)) {
}
if (keys.contains(KEY_SCREEN_SHOT)) {
m_screenShot = m_gsUsdMediaKeys->get(KEY_SCREEN_SHOT).toString();
} else if (keys.contains(KEY_SCREEN_SHOT2)) {
}
if (keys.contains(KEY_SCREEN_SHOT2)) {
m_screenShot2 = m_gsUsdMediaKeys->get(KEY_SCREEN_SHOT2).toString();
} else if (keys.contains(KEY_WINDOW_SCREENSHOT)) {
}
if (keys.contains(KEY_WINDOW_SCREENSHOT)) {
m_windowScreenshot = m_gsUsdMediaKeys->get(KEY_WINDOW_SCREENSHOT).toString();
}
}

View File

@ -310,6 +310,43 @@ bool BackendDbusHelper::getIsBattery()
return isBattery;
}
bool BackendDbusHelper::getCurTabletMode()
{
bool tabletMode = false;
QJsonObject jsonCmd;
jsonCmd["CmdId"] = LOCK_CMD_ID_TABLET_MODE;
QDBusPendingReply<QString> reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson()));
reply.waitForFinished();
if (reply.isError()) {
qWarning() << "getCurTabletMode error: " << reply.error().message();
} else {
QString strResponse = reply.value();
QJsonParseError jsonParseError;
const QJsonDocument jsonDoc = QJsonDocument::fromJson(strResponse.toUtf8(), &jsonParseError);
if (jsonParseError.error != QJsonParseError::NoError) {
qInfo()<<"getCurTabletMode Parse json failed!!";
} else {
QJsonObject objRes = jsonDoc.object();
if (objRes.isEmpty()) {
qInfo()<<"getCurTabletMode Json is null!!";
} else {
if (objRes.contains("CmdId") && objRes.contains("Ret")) {
int nCmdId = objRes.value("CmdId").toInt(-1);
int nRet = objRes.value("Ret").toInt(-1);
if (nCmdId != LOCK_CMD_ID_TABLET_MODE || nRet != 0) {
qInfo()<<"getCurTabletMode Failed!!";
} else {
tabletMode = objRes.value("Content").toBool();
}
} else {
qInfo()<<"getCurTabletMode Json is invalid!!";
}
}
}
}
return tabletMode;
}
bool BackendDbusHelper::setCurrentSession(QString strSession)
{
QJsonObject jsonCmd;
@ -572,6 +609,11 @@ void BackendDbusHelper::ParseBioAuthCompleted(const QJsonObject &objRes)
Q_EMIT bioAuthCompleted(nUid, isSuccess, nError, nMaxFailedTime, nFailedTime);
}
void BackendDbusHelper::ParseTabletModeChanged(const QJsonObject &objRes)
{
Q_EMIT tabletModeChanged(objRes.value("mode").toBool());
}
QList<DeviceInfo> BackendDbusHelper::bioGetAvailableDevices(int nUid)
{
QList<DeviceInfo> listDevInfo;
@ -1101,6 +1143,11 @@ void BackendDbusHelper::onUpdateInformation(const QString &strJson)
ParseBioAuthCompleted(objRes);
}
break;
case LOCK_CMD_ID_TABLET_MODE_CHANGED:
{
ParseTabletModeChanged(objRes);
}
break;
default:
break;
}
@ -1374,7 +1421,7 @@ bool BackendDbusHelper::usdExternalDoAction(int actionType)
jsonCmd["Content"] = actionType;
QDBusPendingReply<int> reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson()));
if (reply.isError()) {
qWarning() << "setCurrentUser error: " << reply.error().message();
qWarning() << "usdExternalDoAction error: " << reply.error().message();
return false;
}
return true;

View File

@ -125,6 +125,8 @@ public:
QStringList getShutdownLockcheck();
bool getCurTabletMode();
public Q_SLOTS:
/**
* @brief dbus服务信息更新处理
@ -361,6 +363,8 @@ Q_SIGNALS: // SIGNALS
void bioAuthFrameData(QString strData);
void bioAuthCompleted(int nUid, bool isSuccess, int nError, int nMaxFailedTime, int nFailedTime);
void tabletModeChanged(bool tabletMode);
private:
/**
* @brief
@ -421,6 +425,8 @@ private:
void ParseBioAuthStateChanged(const QJsonObject &objRes);
void ParseBioAuthFrameData(const QJsonObject &objRes);
void ParseBioAuthCompleted(const QJsonObject &objRes);
void ParseTabletModeChanged(const QJsonObject &objRes);
};
#endif // BACKENDDBUSHELPER_H

View File

@ -403,6 +403,11 @@ void LockDialogModel::onUsdMediaKeysChanged(const QString &key, const QString &v
Q_EMIT usdMediaKeysChanged(key, value);
}
void LockDialogModel::onTabletModeChanged(bool tabletMode)
{
Q_EMIT tabletModeChanged(tabletMode);
}
void LockDialogModel::updateCapslockState(bool capslockState)
{
m_capslockState = capslockState;
@ -522,3 +527,8 @@ void LockDialogModel::updateLoggedInUsersCount()
}
}
}
void LockDialogModel::updateTabletMode(bool tabletMode)
{
m_tabletMode = tabletMode;
}

View File

@ -102,6 +102,8 @@ public:
void updateShutdownLockcheck(QStringList shutdownLockcheck);
void updateLoggedInUsersCount();
void updateTabletMode(bool tabletMode);
/**
* @brief
*
@ -194,6 +196,8 @@ public:
inline bool getLockEnabled() {return m_lockEnabled; }
inline bool getTabletMode() { return m_tabletMode; }
public Q_SLOTS:
/**
* @brief
@ -234,6 +238,8 @@ public Q_SLOTS:
void onThemeStyleConfChanged(const QString &key, QVariant value);
void onTabletModeChanged(bool tabletMode);
Q_SIGNALS:
/**
* @brief
@ -358,6 +364,8 @@ Q_SIGNALS:
QString getPublicEncrypt();
bool sendPassword(const QString username,QByteArray password);
void tabletModeChanged(bool tabletMode);
private:
QString getXScreensaverPath(const QString &theme);
private:
@ -397,6 +405,8 @@ private:
int m_lockTimeout = 10;
bool m_lockEnabled = true;
double m_curFontSize;
bool m_tabletMode = false;
};
#endif // LOCKDIALOGMODEL_H

View File

@ -73,6 +73,8 @@ void LockDialogPerformer::initConnections()
connect(m_bdHelper, SIGNAL(bioAuthCompleted(int, bool, int, int, int)), m_modelLockDialog, SIGNAL(bioAuthCompleted(int, bool, int, int, int)));
connect(m_bdHelper, &BackendDbusHelper::usdMediaKeysConfChanged, m_modelLockDialog, &LockDialogModel::onUsdMediaKeysChanged);
connect(m_bdHelper, &BackendDbusHelper::tabletModeChanged, m_modelLockDialog, &LockDialogModel::onTabletModeChanged);
///通过信号直接调用槽
connect(m_modelLockDialog, &LockDialogModel::setCurrentUser, m_bdHelper, &BackendDbusHelper::setCurrentUser);
connect(m_modelLockDialog, &LockDialogModel::switchToUser, m_bdHelper, &BackendDbusHelper::switchToUser);
@ -147,5 +149,6 @@ void LockDialogPerformer::initData()
m_modelLockDialog->updateLockTimeout(m_bdHelper->getLockScreenConf(KEY_LOCK_TIMEOUT).toInt());
m_modelLockDialog->updateLockEnabled(m_bdHelper->getLockScreenConf(KEY_LOCK_ENABLED).toBool());
m_modelLockDialog->updateSystemFontSize(m_bdHelper->getThemeStyleConf(KEY_SYSTEM_FONT_SIZE).toDouble());
m_modelLockDialog->updateTabletMode(m_bdHelper->getCurTabletMode());
}

View File

@ -299,6 +299,9 @@ void AuthDialog::initEditWidget()
//m_passwordEdit->setPrompt("password");
editLayout->addWidget(m_passwordEdit);
editWidgetLayout->addLayout(editLayout);
connect(m_passwordEdit, &IconEdit::clickedPassword, this, [=]{
Q_EMIT lineEditClicked();
});
m_messageButton = new QPushButton(m_editWidget);
m_messageButton->setObjectName(QStringLiteral("messageButton"));
@ -328,6 +331,9 @@ void AuthDialog::initUkeyPasswordWidget()
m_ukeyPasswordEdit->setPrompt(tr(""));
editLayout->addWidget(m_ukeyPasswordEdit);
ukeyWidgetLayout->addLayout(editLayout);
connect(m_ukeyPasswordEdit, &IconEdit::clicked, this, [=]{
Q_EMIT lineEditClicked();
});
m_ukeyMessageLabel = new KLabel(m_ukeyPasswdWidget);
m_ukeyMessageLabel->setText("");
m_ukeyMessageLabel->setAlignment(Qt::AlignHCenter);

View File

@ -130,6 +130,8 @@ Q_SIGNALS:
*/
void customRequestAccount(QString account);
void lineEditClicked();
protected:
bool eventFilter(QObject *obj, QEvent *event);
void resizeEvent(QResizeEvent *event);

View File

@ -107,8 +107,8 @@ bool IconEdit::eventFilter(QObject *obj, QEvent *event)
return true;
}
}
if (event->type() == 2) {
if (event->type() == QEvent::MouseButtonPress) {
Q_EMIT clickedPassword();
}
if(event->type() == 23)
{

View File

@ -61,7 +61,7 @@ private:
Q_SIGNALS:
void clicked(const QString &);
void focusOut();
void clickedPassword(bool clicked);
void clickedPassword();
public Q_SLOTS:
void clicked_cb();
void onCapsChanged(bool state);

View File

@ -89,44 +89,13 @@ bool LockWidget::eventFilter(QObject *obj, QEvent *event)
}
} else if (event->type() == QEvent::MouseButtonPress) {
/// TODO
if(m_userListWidget && m_userListWidget->isVisible()){
if (obj != m_userListWidget) {
onShowUserListWidget();
}
}
if(m_powerListWidget && m_powerListWidget->isVisible()){
if (obj != m_powerListWidget) {
onShowPowerListWidget();
}
}
//这段代码没看懂,但是如果注释掉的话,点击网络窗口,网络窗口会隐藏
if(m_networkWidget && m_networkWidget == obj){
if((m_networkWidget && m_networkWidget == obj) ||
(m_userListWidget && m_userListWidget == obj) ||
(m_sessionListWidget && m_sessionListWidget == obj) ||
(m_virtualKeyboardWidget && m_virtualKeyboardWidget == obj)) {
return true;
}
if(m_networkWidget && m_networkWidget->isVisible()){
if (m_networkWidget != obj){
onShowNetworkWidget();
}
}
if(m_virtualKeyboardWidget && m_virtualKeyboardWidget->isVisible()){
if (m_virtualKeyboardWidget != obj){
onShowVirtualKeyboard();
}
}
if(m_sessionListWidget && m_sessionListWidget->isVisible()){
if (m_sessionListWidget != obj){
onShowSessionListWidget();
}
}
if(batteryWidget && batteryWidget->isVisible()){
if (batteryWidget != obj){
onShowBatteryWidget();
}
} else if (buttonListWidget && obj != buttonListWidget) {
exitSubWidget();
}
}
@ -292,6 +261,7 @@ void LockWidget::keyReleaseEvent(QKeyEvent *e)
} else if (keySequence == listFromString(m_windowScreenshot)) {
Q_EMIT m_modelLockDialog->usdExternalDoAction(WINDOW_SCREENSHOT_KEY);
}
QWidget::keyReleaseEvent(e);
}
void LockWidget::initUI()
@ -324,12 +294,16 @@ void LockWidget::initConnections()
connect(m_modelLockDialog, &LockDialogModel::currentUserChanged, this, &LockWidget::onCurUserChanged);
connect(m_modelLockDialog, &LockDialogModel::currentSessionChanged, this, &LockWidget::onSessionChanged);
connect(m_modelLockDialog, &LockDialogModel::sessionActiveChanged, this, &LockWidget::onSessionActiveChanged);
connect(m_modelLockDialog, &LockDialogModel::tabletModeChanged, this, &LockWidget::onTabletModeChanged);
if (authDialog) {
connect(authDialog, SIGNAL(authSucceed(QString)), this, SIGNAL(authSucceed(QString)));
connect(authDialog, &AuthDialog::userChangedByManual,
this, &LockWidget::onUserChangedByManual);
connect(authDialog, &AuthDialog::customRequestAccount,
this, &LockWidget::onCustomRequestAccount);
connect(authDialog, &AuthDialog::lineEditClicked,this, [=]{
onLineEditClicked();
});
}
connect(LanguageSetting::instance(this), &LanguageSetting::languageChanged, this, &LockWidget::onLanguageChanged);
}
@ -505,6 +479,7 @@ void LockWidget::initButtonWidget()
connect(m_virKbButton, &StatusButton::clicked, this, [this]() {
onShowVirtualKeyboard();
});
onShowVirtualKeyboard(m_modelLockDialog->getTabletMode());
if (m_powerListWidget->count() > 1 ) {
m_powerManagerButton = new StatusButton(this, BOTBUTTON);
@ -840,6 +815,9 @@ void LockWidget::onShowNetworkWidget()
if (!m_networkWidget) {
m_networkWidget = new MyNetworkWidget(this);
m_networkWidget->installEventFilter(this);
connect(m_networkWidget, &MyNetworkWidget::showVirtualKeyboard, this, [=]{
onShowVirtualKeyboard(m_isTabletMode);
});
}
m_networkWidget->loadNetPlugin();
m_networkWidget->setGeometry(this->width() - m_networkWidget->width() - RIGHT_MARGIN*scale,
@ -861,6 +839,30 @@ void LockWidget::onShowNetworkWidget()
}
}
void LockWidget::onLineEditClicked()
{
if(!m_virtualKeyboardWidget){
m_virtualKeyboardWidget = new VirtualKeyboardWidget(this);
m_virtualKeyboardWidget->installEventFilter(this);
m_virtualKeyboardWidget->hide();
connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToClose,
this, &LockWidget::onHideVirkeyboard);
connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToFloat,
this, &LockWidget::onNetWorkResetLocation);
}
if (m_isTabletMode) {
if (batteryWidget && batteryWidget->isVisible())
batteryWidget->hide();
if (m_sessionListWidget && m_sessionListWidget->isVisible())
m_sessionListWidget->hide();
if (m_userListWidget && m_userListWidget->isVisible())
m_userListWidget->hide();
m_virtualKeyboardWidget->show();
authDialog->setFocus();
}
}
void LockWidget::onShowVirtualKeyboard()
{
if(!m_virtualKeyboardWidget){
@ -898,6 +900,44 @@ void LockWidget::onShowVirtualKeyboard()
m_virKbButton->setClickedStatus(NORMAL);
}
void LockWidget::onShowVirtualKeyboard(bool tabletMode)
{
m_isTabletMode = tabletMode;
if(!m_virtualKeyboardWidget){
m_virtualKeyboardWidget = new VirtualKeyboardWidget(this);
m_virtualKeyboardWidget->installEventFilter(this);
m_virtualKeyboardWidget->hide();
connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToClose,
this, &LockWidget::onHideVirkeyboard);
connect(m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToFloat,
this, &LockWidget::onNetWorkResetLocation);
}
if (tabletMode) {
if (batteryWidget && batteryWidget->isVisible())
batteryWidget->hide();
if (m_sessionListWidget && m_sessionListWidget->isVisible())
m_sessionListWidget->hide();
if (m_userListWidget && m_userListWidget->isVisible())
m_userListWidget->hide();
m_virtualKeyboardWidget->show();
authDialog->setFocus();
} else {
m_virtualKeyboardWidget->hide();
}
if(!m_virtualKeyboardWidget->isHidden()){
if(m_networkWidget && m_networkWidget->isVisible() && !m_virtualKeyboardWidget->getFloatStatus()) {
m_networkWidget->move(this->width() - m_networkWidget->width() - 20,
this->height() - m_networkWidget->height() - m_virtualKeyboardWidget->height());
m_networkWidget->raise();
} else {
}
m_virtualKeyboardWidget->raise();
}
m_virKbButton->setClickedStatus(NORMAL);
}
void LockWidget::onShowPowerListWidget()
{
if (m_powerListWidget->isHidden()) {
@ -1065,6 +1105,11 @@ void LockWidget::onSessionActiveChanged(bool isActive)
}
}
void LockWidget::onTabletModeChanged(bool tabletMode)
{
onShowVirtualKeyboard(tabletMode);
}
void LockWidget::SwitchToUser(QString strUserName)
{
if(m_modelLockDialog) {

View File

@ -120,6 +120,8 @@ private Q_SLOTS:
void onShowNetworkWidget();
void onShowPowerListWidget();
void onShowVirtualKeyboard();
void onShowVirtualKeyboard(bool tabletMode);
void onLineEditClicked();
void onNetWorkResetLocation();
void onSetVirkeyboardPos();
@ -146,6 +148,8 @@ private Q_SLOTS:
void onLanguageChanged(bool isCompleted);
void onTabletModeChanged(bool tabletMode);
Q_SIGNALS:
void authSucceed(QString strUserName);
@ -216,6 +220,8 @@ private:
bool drawBackgroundIsStarted = false;
QFuture<void> m_futureDrawBg;
QList<QPair<QRect,QRect>> m_screenRectList;
bool m_isTabletMode = false;
};
#endif // LOCKWIDGET_H

View File

@ -104,6 +104,8 @@ void MyNetworkWidget::loadNetPlugin()
tabWidget->addTab(widget,"");
//connect(plugin, SIGNAL(updatePluginHidden(bool)), this, SLOT(onUpdatePluginHidden(bool)));
// 平板模式输入状态下自动调出虚拟键盘
connect(wlanInterface, SIGNAL(needShowVirtualKeyboard()), this, SLOT(onNetInPutStatus()));
} else {
qDebug() << "Load Failed: " << wlanloader.errorString() << "\n";
return;
@ -223,6 +225,11 @@ void MyNetworkWidget::sendNetPluginVisible(bool visible)
*/
}
void MyNetworkWidget::onNetInPutStatus()
{
Q_EMIT showVirtualKeyboard();
}
void MyNetworkWidget::showEvent(QShowEvent *event)
{
sendNetPluginVisible(true);

View File

@ -40,6 +40,7 @@ private Q_SLOTS:
*/
void onNetTabWidgetChanged(int index);
void onUpdatePluginHidden();
void onNetInPutStatus();
void showEvent(QShowEvent *event) ;
void hideEvent(QHideEvent *event) ;
void paintEvent(QPaintEvent *p1);
@ -47,6 +48,10 @@ private Q_SLOTS:
private:
void sendNetPluginVisible(bool visible);
Q_SIGNALS:
void showVirtualKeyboard();
private:
QPluginLoader netloader;
QPluginLoader wlanloader;