瀏覽代碼

Don't hide popup widget if the active window is a tooltip/popup

If the popup widget contains a buttton which opens a Tooltip/Popup widget,
there there is no point in hiding the ctkPopupWidget as it will opens
on top of it.
Julien Finet 13 年之前
父節點
當前提交
b080849078
共有 1 個文件被更改,包括 11 次插入2 次删除
  1. 11 2
      Libs/Widgets/ctkPopupWidget.cpp

+ 11 - 2
Libs/Widgets/ctkPopupWidget.cpp

@@ -472,12 +472,18 @@ void ctkPopupWidgetPrivate::updateVisibility()
   Q_Q(ctkPopupWidget);
   // If the BaseWidget window is active, then there is no reason to cover the
   // popup.
-  if (!this->BaseWidget  || !this->BaseWidget->window()->isActiveWindow())
+  if (!this->BaseWidget  ||
+      (!this->BaseWidget->window()->isActiveWindow() &&
+       !qApp->activeWindow() ||
+       (qApp->activeWindow()->windowType() != Qt::ToolTip &&
+        qApp->activeWindow()->windowType() != Qt::Popup)))
     {
     foreach(QWidget* topLevelWidget, qApp->topLevelWidgets())
       {
       // If there is at least 1 window (active or not) that covers the popup,
       // then we ensure the popup is hidden.
+      // We have no way of knowing which toplevel is over (z-order) which one,
+      // it is an OS specific information.
       // Of course, tooltips and popups don't count as covering windows.
       if (topLevelWidget->isVisible() &&
           !(topLevelWidget->windowState() & Qt::WindowMinimized) &&
@@ -487,7 +493,10 @@ void ctkPopupWidgetPrivate::updateVisibility()
           topLevelWidget->frameGeometry().intersects(q->geometry()))
         {
         //qDebug() << "hide" << q << "because of: " << topLevelWidget
-        //         << " with windowType: " << topLevelWidget->windowType();
+        //         << " with windowType: " << topLevelWidget->windowType()
+        //         << topLevelWidget->isVisible()
+        //         << (this->BaseWidget ? this->BaseWidget->window() : 0)
+        //         << topLevelWidget->frameGeometry();
         this->temporarilyHiddenOn();
         return;
         }