@@ -61,6 +61,7 @@ CAddressCompleter::CAddressCompleter(CHistoryDatabase *db, QWidget *parent)
6161 , m_maxVisibleItems(8 )
6262 , m_isCompleterVisible(false )
6363 , m_pDatabase(db)
64+ , m_bIsWayland(false )
6465{
6566 m_szEnter = tr (" Enter '@' show commands" ) + " ; "
6667 + tr (" Enter a website URL or search content ......" );
@@ -77,6 +78,13 @@ CAddressCompleter::CAddressCompleter(CHistoryDatabase *db, QWidget *parent)
7778 m_szLineEditToolTipShow = m_szEnter + " \n\n " + m_szListWidgetToolTip;
7879 setToolTip (m_szListWidgetToolTip);
7980
81+ #if defined(Q_OS_LINUX)
82+ if (-1 == QGuiApplication::platformName ().indexOf (QRegularExpression (" wayland.*" )))
83+ m_bIsWayland = false ;
84+ else
85+ m_bIsWayland = true ;
86+ #endif
87+
8088 setupUI ();
8189
8290 // 设置搜索延迟定时器(300ms防抖动)
@@ -103,7 +111,12 @@ CAddressCompleter::~CAddressCompleter()
103111
104112void CAddressCompleter::setupUI ()
105113{
106- setWindowFlags (Qt::Tool /* Qt::ToolTip*/ | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
114+ Qt::WindowFlags flags;
115+ flags = Qt::FramelessWindowHint | Qt::CustomizeWindowHint;
116+ if (!m_bIsWayland) {
117+ flags |= Qt::Tool;
118+ }
119+ setWindowFlags (flags);
107120 setAttribute (Qt::WA_TranslucentBackground);
108121
109122 QVBoxLayout *mainLayout = new QVBoxLayout (this );
@@ -508,11 +521,15 @@ void CAddressCompleter::showCompleter()
508521 m_pShowAnimation->setEndValue (endRect);
509522 m_pShowAnimation->setEasingCurve (QEasingCurve::OutCubic);
510523 connect (m_pShowAnimation, &QPropertyAnimation::finished,
511- this , &CAddressCompleter::show);
524+ this , [this ]() {
525+ show ();
526+ raise ();
527+ });
512528 m_pShowAnimation->start ();
513529 } else {
514530 setGeometry (endRect);
515531 show ();
532+ raise ();
516533 }
517534}
518535
@@ -576,6 +593,15 @@ void CAddressCompleter::updateCompleterPosition()
576593 }
577594 }
578595
596+ if (m_bIsWayland) {
597+ QWidget* pWin = qobject_cast<QWidget*>(parent ());
598+ if (pWin) {
599+ globalPos = pWin->mapFromGlobal (globalPos);
600+ } else {
601+ qCritical (log) << " Current platform plugin is wayland. the parent must be setted." ;
602+ }
603+ }
604+
579605 // 设置位置和大小
580606 setGeometry (globalPos.x (), globalPos.y (), width, 0 );
581607}
0 commit comments