7
7
#include " controlwidget.h"
8
8
#include " logowidget.h"
9
9
#include " mfa_widget.h"
10
- #include " modules_loader.h"
11
10
#include " popupwindow.h"
12
11
#include " sessionbasemodel.h"
13
12
#include " sfa_widget.h"
@@ -34,25 +33,10 @@ DCORE_USE_NAMESPACE
34
33
35
34
LockContent::LockContent (QWidget *parent)
36
35
: SessionBaseWindow(parent)
37
- , m_model(nullptr )
38
- , m_controlWidget(nullptr )
39
- , m_centerTopWidget(nullptr )
40
- , m_virtualKB(nullptr )
41
36
, 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 )
47
37
, m_localServer(new QLocalServer(this ))
48
38
, 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 )
54
39
, m_showMediaWidget(DConfigHelper::instance()->getConfig(SHOW_MEDIA_WIDGET, false ).toBool())
55
- , m_hasResetPasswordDialog(false )
56
40
{
57
41
58
42
}
@@ -143,7 +127,7 @@ void LockContent::initUI()
143
127
m_logoWidget->setAccessibleName (" LogoWidget" );
144
128
setLeftBottomWidget (m_logoWidget);
145
129
146
- m_controlWidget = new ControlWidget (m_model);
130
+ m_controlWidget = new ControlWidget (m_model, this );
147
131
m_controlWidget->setAccessibleName (" ControlWidget" );
148
132
setRightBottomWidget (m_controlWidget);
149
133
@@ -176,6 +160,7 @@ void LockContent::initConnections()
176
160
});
177
161
connect (m_controlWidget, &ControlWidget::requestSwitchVirtualKB, this , &LockContent::toggleVirtualKB);
178
162
connect (m_controlWidget, &ControlWidget::requestShowModule, this , &LockContent::showModule);
163
+ connect (m_controlWidget, &ControlWidget::requestShowTrayModule, this , &LockContent::showTrayPopup);
179
164
180
165
// 刷新背景单独与onStatusChanged信号连接,避免在showEvent事件时调用onStatusChanged而重复刷新背景,减少刷新次数
181
166
connect (m_model, &SessionBaseModel::onStatusChanged, this , &LockContent::onStatusChanged);
@@ -212,12 +197,6 @@ void LockContent::initConnections()
212
197
213
198
connect (m_wmInter, &com::deepin::wm::WorkspaceSwitched, this , &LockContent::currentWorkspaceChanged);
214
199
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
- });
221
200
222
201
connect (m_model, &SessionBaseModel::showUserList, this , &LockContent::showUserList);
223
202
connect (m_model, &SessionBaseModel::showLockScreen, this , &LockContent::showLockScreen);
@@ -697,38 +676,7 @@ void LockContent::showModule(const QString &name, const bool callShowForce)
697
676
qCWarning (DDE_SHELL) << " TrayButton or plugin`s content is null" ;
698
677
return ;
699
678
}
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 ());
732
680
break ;
733
681
}
734
682
default :
@@ -748,7 +696,6 @@ bool LockContent::eventFilter(QObject *watched, QEvent *e)
748
696
if ((watched == m_currentTray || isChild) && e->type () == QEvent::Enter) {
749
697
Q_EMIT qobject_cast<FloatingButton*>(m_currentTray)->requestHideTips ();
750
698
} else if (watched != m_currentTray && !isChild && e->type () == QEvent::MouseButtonRelease) {
751
- QMouseEvent *ev = static_cast <QMouseEvent *>(e);
752
699
if (!m_popWin->geometry ().contains (this ->mapFromGlobal (QCursor::pos ()))) {
753
700
m_popWin->hide ();
754
701
}
@@ -932,6 +879,62 @@ void LockContent::refreshLayout(SessionBaseModel::ModeStatus status)
932
879
setBottomFrameVisible (status != SessionBaseModel::ModeStatus::ShutDownMode);
933
880
}
934
881
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
+
935
938
void LockContent::keyPressEvent (QKeyEvent *event)
936
939
{
937
940
switch (event->key ()) {
0 commit comments