77#include " controlwidget.h"
88#include " logowidget.h"
99#include " mfa_widget.h"
10- #include " modules_loader.h"
1110#include " popupwindow.h"
1211#include " sessionbasemodel.h"
1312#include " sfa_widget.h"
@@ -34,27 +33,12 @@ DCORE_USE_NAMESPACE
3433
3534LockContent::LockContent (QWidget *parent)
3635 : SessionBaseWindow(parent)
37- , m_model(nullptr )
38- , m_controlWidget(nullptr )
39- , m_centerTopWidget(nullptr )
40- , m_virtualKB(nullptr )
4136 , m_wmInter(new com::deepin::wm(" com.deepin.wm" , " /com/deepin/wm" , QDBusConnection::sessionBus(), this))
42- , m_sfaWidget(nullptr )
43- , m_mfaWidget(nullptr )
44- , m_authWidget(nullptr )
45- , m_fmaWidget(nullptr )
46- , m_userListWidget(nullptr )
4737 , m_localServer(new QLocalServer(this ))
4838 , m_currentModeStatus(SessionBaseModel::ModeStatus::NoStatus)
49- , m_initialized(false )
50- , m_isUserSwitchVisible(false )
51- , m_popWin(nullptr )
52- , m_isPANGUCpu(false )
53- , m_MPRISEnable(false )
5439 , m_showMediaWidget(DConfigHelper::instance()->getConfig(SHOW_MEDIA_WIDGET, false ).toBool())
55- , m_hasResetPasswordDialog(false )
5640{
57-
41+ installEventFilter ( this );
5842}
5943
6044LockContent* LockContent::instance ()
@@ -143,7 +127,7 @@ void LockContent::initUI()
143127 m_logoWidget->setAccessibleName (" LogoWidget" );
144128 setLeftBottomWidget (m_logoWidget);
145129
146- m_controlWidget = new ControlWidget (m_model);
130+ m_controlWidget = new ControlWidget (m_model, this );
147131 m_controlWidget->setAccessibleName (" ControlWidget" );
148132 setRightBottomWidget (m_controlWidget);
149133
@@ -176,6 +160,7 @@ void LockContent::initConnections()
176160 });
177161 connect (m_controlWidget, &ControlWidget::requestSwitchVirtualKB, this , &LockContent::toggleVirtualKB);
178162 connect (m_controlWidget, &ControlWidget::requestShowModule, this , &LockContent::showModule);
163+ connect (m_controlWidget, &ControlWidget::requestShowTrayModule, this , &LockContent::showTrayPopup);
179164
180165 // 刷新背景单独与onStatusChanged信号连接,避免在showEvent事件时调用onStatusChanged而重复刷新背景,减少刷新次数
181166 connect (m_model, &SessionBaseModel::onStatusChanged, this , &LockContent::onStatusChanged);
@@ -212,12 +197,6 @@ void LockContent::initConnections()
212197
213198 connect (m_wmInter, &com::deepin::wm::WorkspaceSwitched, this , &LockContent::currentWorkspaceChanged);
214199 connect (m_localServer, &QLocalServer::newConnection, this , &LockContent::onNewConnection);
215- connect (m_controlWidget, &ControlWidget::notifyKeyboardLayoutHidden, this , [this ]{
216- if (!m_model->isUseWayland () && isVisible () && window ()->windowHandle ()) {
217- qCDebug (DDE_SHELL) << " Grab keyboard after keyboard layout hidden" ;
218- window ()->windowHandle ()->setKeyboardGrabEnabled (true );
219- }
220- });
221200
222201 connect (m_model, &SessionBaseModel::showUserList, this , &LockContent::showUserList);
223202 connect (m_model, &SessionBaseModel::showLockScreen, this , &LockContent::showLockScreen);
@@ -697,38 +676,7 @@ void LockContent::showModule(const QString &name, const bool callShowForce)
697676 qCWarning (DDE_SHELL) << " TrayButton or plugin`s content is null" ;
698677 return ;
699678 }
700-
701- if (!m_popWin) {
702- m_popWin = new PopupWindow (this );
703- connect (m_model, &SessionBaseModel::visibleChanged, this , [this ] (const bool visible) {
704- if (!visible) {
705- m_popWin->hide ();
706- }
707- });
708- connect (m_popWin, &PopupWindow::visibleChanged, this , [this ] (bool visible) {
709- m_controlWidget->setCanShowMenu (!visible);
710- });
711- connect (qobject_cast<FloatingButton*>(m_currentTray), &FloatingButton::buttonHide, m_popWin, &PopupWindow::hide);
712- connect (this , &LockContent::parentChanged, this , [this ] {
713- if (m_popWin && m_popWin->isVisible ()) {
714- const QPoint &point = mapFromGlobal (m_currentTray->mapToGlobal (QPoint (m_currentTray->size ().width () / 2 , 0 )));
715- m_popWin->show (point);
716- }
717- });
718- }
719-
720- // 隐藏后需要removeEventFilter,后期优化
721- for (auto child : this ->findChildren <QWidget*>()) {
722- child->removeEventFilter (this );
723- child->installEventFilter (this );
724- }
725-
726- if (!m_popWin->getContent () || m_popWin->getContent () != plugin->content ())
727- m_popWin->setContent (plugin->content ());
728- const QPoint &point = mapFromGlobal (m_currentTray->mapToGlobal (QPoint (m_currentTray->size ().width () / 2 , 0 )));
729- // 插件图标不显示,窗口不显示
730- if (m_currentTray->isVisible ())
731- callShowForce ? m_popWin->show (point) : m_popWin->toggle (point);
679+ showTrayPopup (m_currentTray, plugin->content ());
732680 break ;
733681 }
734682 default :
@@ -748,7 +696,6 @@ bool LockContent::eventFilter(QObject *watched, QEvent *e)
748696 if ((watched == m_currentTray || isChild) && e->type () == QEvent::Enter) {
749697 Q_EMIT qobject_cast<FloatingButton*>(m_currentTray)->requestHideTips ();
750698 } else if (watched != m_currentTray && !isChild && e->type () == QEvent::MouseButtonRelease) {
751- QMouseEvent *ev = static_cast <QMouseEvent *>(e);
752699 if (!m_popWin->geometry ().contains (this ->mapFromGlobal (QCursor::pos ()))) {
753700 m_popWin->hide ();
754701 }
@@ -932,6 +879,62 @@ void LockContent::refreshLayout(SessionBaseModel::ModeStatus status)
932879 setBottomFrameVisible (status != SessionBaseModel::ModeStatus::ShutDownMode);
933880}
934881
882+ void LockContent::showTrayPopup (QWidget *trayWidget, QWidget *contentWidget, const bool callShowForce)
883+ {
884+ if (!trayWidget || !contentWidget) {
885+ return ;
886+ }
887+
888+ if (!m_popWin) {
889+ m_popWin = new PopupWindow (this );
890+ connect (m_model, &SessionBaseModel::visibleChanged, this , [this ] (const bool visible) {
891+ if (!visible) {
892+ m_popWin->hide ();
893+ }
894+ });
895+ connect (m_popWin, &PopupWindow::visibleChanged, this , [this ] (bool visible) {
896+ m_controlWidget->setCanShowMenu (!visible);
897+ // BUG-134087, tray popup窗口隐藏后,锁屏界面需要重新抓取键盘
898+ if (!visible && !m_model->isUseWayland () && isVisible () && window ()->windowHandle ()) {
899+ qCDebug (DDE_SHELL) << " Grab keyboard after keyboard layout hidden" ;
900+ window ()->windowHandle ()->setKeyboardGrabEnabled (true );
901+ }
902+ });
903+
904+ connect (this , &LockContent::parentChanged, this , [this ] {
905+ if (m_popWin && m_popWin->isVisible ()) {
906+ const QPoint &point = mapFromGlobal (m_currentTray->mapToGlobal (QPoint (m_currentTray->size ().width () / 2 , 0 )));
907+ m_popWin->show (point);
908+ }
909+ });
910+
911+ // for BUG-256133
912+ connect (m_model, &SessionBaseModel::onStatusChanged, this , [this ] (SessionBaseModel::ModeStatus status) {
913+ if (status != SessionBaseModel::ModeStatus::PasswordMode) {
914+ m_popWin->hide ();
915+ }
916+ });
917+ }
918+
919+ m_currentTray = trayWidget;
920+
921+ // 隐藏后需要removeEventFilter,后期优化
922+ for (auto child : this ->findChildren <QWidget*>()) {
923+ child->removeEventFilter (this );
924+ child->installEventFilter (this );
925+ }
926+
927+ if (!m_popWin->getContent () || m_popWin->getContent () != contentWidget)
928+ m_popWin->setContent (contentWidget);
929+
930+ const QPoint point = mapFromGlobal (m_currentTray->mapToGlobal (QPoint (m_currentTray->size ().width () / 2 , 0 )));
931+ // 插件图标不显示,窗口不显示
932+ if (m_currentTray->isVisible ()) {
933+ m_popWin->move (point.x (), point.y ());
934+ callShowForce ? m_popWin->show (point) : m_popWin->toggle (point);
935+ }
936+ }
937+
935938void LockContent::keyPressEvent (QKeyEvent *event)
936939{
937940 switch (event->key ()) {
0 commit comments