添加平板模式下点击密码框自动弹出虚拟键盘功能

This commit is contained in:
liudun 2024-02-19 14:22:27 +08:00
parent 7f36e1e3a4
commit 426108bda7
2 changed files with 32 additions and 38 deletions

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();
}
}
@ -333,7 +302,7 @@ void LockWidget::initConnections()
connect(authDialog, &AuthDialog::customRequestAccount,
this, &LockWidget::onCustomRequestAccount);
connect(authDialog, &AuthDialog::lineEditClicked,this, [=]{
onShowVirtualKeyboard(m_isTabletMode);
onLineEditClicked();
});
}
connect(LanguageSetting::instance(this), &LanguageSetting::languageChanged, this, &LockWidget::onLanguageChanged);
@ -870,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){

View File

@ -121,6 +121,7 @@ private Q_SLOTS:
void onShowPowerListWidget();
void onShowVirtualKeyboard();
void onShowVirtualKeyboard(bool tabletMode);
void onLineEditClicked();
void onNetWorkResetLocation();
void onSetVirkeyboardPos();