|
@@ -22,6 +22,7 @@
|
|
|
#include <QApplication>
|
|
|
#include <QDebug>
|
|
|
#include <QDesktopWidget>
|
|
|
+#include <QDialog>
|
|
|
#include <QDir>
|
|
|
#include <QEvent>
|
|
|
#include <QLabel>
|
|
@@ -108,27 +109,20 @@ bool ctkPopupWidgetPrivate::eventFilter(QObject* obj, QEvent* event)
|
|
|
QRect desiredGeometry = this->desiredOpenGeometry(newBaseGeometry);
|
|
|
q->move(desiredGeometry.topLeft());
|
|
|
}
|
|
|
- else if (widget->isWindow() &&
|
|
|
- widget->windowType() != Qt::ToolTip &&
|
|
|
- widget->windowType() != Qt::Popup)
|
|
|
+ else if (this->isHidingCandidate(widget))
|
|
|
{
|
|
|
QTimer::singleShot(0, this, SLOT(updateVisibility()));
|
|
|
}
|
|
|
}
|
|
|
else if (event->type() == QEvent::Resize)
|
|
|
{
|
|
|
- if (widget->isWindow() &&
|
|
|
- widget != this->BaseWidget->window() &&
|
|
|
- widget->windowType() != Qt::ToolTip &&
|
|
|
- widget->windowType() != Qt::Popup)
|
|
|
+ if (this->isHidingCandidate(widget))
|
|
|
{
|
|
|
QTimer::singleShot(0, this, SLOT(updateVisibility()));
|
|
|
}
|
|
|
}
|
|
|
else if (event->type() == QEvent::WindowStateChange &&
|
|
|
- widget != this->BaseWidget->window() &&
|
|
|
- widget->windowType() != Qt::ToolTip &&
|
|
|
- widget->windowType() != Qt::Popup)
|
|
|
+ this->isHidingCandidate(widget))
|
|
|
{
|
|
|
QTimer::singleShot(0, this, SLOT(updateVisibility()));
|
|
|
}
|
|
@@ -158,6 +152,25 @@ void ctkPopupWidgetPrivate::onApplicationDeactivate()
|
|
|
}
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
+bool ctkPopupWidgetPrivate::isHidingCandidate(QWidget* widget)const
|
|
|
+{
|
|
|
+ bool canWindowsHidePopup = false;
|
|
|
+#if defined Q_OS_MAC
|
|
|
+ canWindowsHidePopup = true;
|
|
|
+#endif
|
|
|
+ bool isWindow = widget->isWindow();
|
|
|
+ QDialog* dialog = qobject_cast<QDialog*>(widget);
|
|
|
+ bool isModal = dialog ? dialog->isModal() : false;
|
|
|
+ bool isBasePopupWidget = qobject_cast<ctkBasePopupWidget*>(widget);
|
|
|
+ bool isToolTip = widget->windowType() == Qt::ToolTip;
|
|
|
+ bool isPopup = widget->windowType() == Qt::Popup;
|
|
|
+ bool isSelf = (widget == (this->BaseWidget ? this->BaseWidget->window() : 0));
|
|
|
+
|
|
|
+ return canWindowsHidePopup && isWindow && !isModal && !isBasePopupWidget &&
|
|
|
+ !isToolTip && !isPopup && !isSelf;
|
|
|
+}
|
|
|
+
|
|
|
+// -------------------------------------------------------------------------
|
|
|
void ctkPopupWidgetPrivate::updateVisibility()
|
|
|
{
|
|
|
Q_Q(ctkPopupWidget);
|
|
@@ -168,8 +181,8 @@ void ctkPopupWidgetPrivate::updateVisibility()
|
|
|
(!this->BaseWidget->window()->isActiveWindow() &&
|
|
|
// and no other active window
|
|
|
(!qApp->activeWindow() ||
|
|
|
- // or the active window is a popup/tooltip
|
|
|
- (qApp->activeWindow()->windowType() != Qt::ToolTip &&
|
|
|
+ // or the active window is a popup
|
|
|
+ (!qobject_cast<ctkBasePopupWidget*>(qApp->activeWindow()) && //->windowType() != PopupWindowType &&
|
|
|
qApp->activeWindow()->windowType() != Qt::Popup))))
|
|
|
{
|
|
|
foreach(QWidget* topLevelWidget, qApp->topLevelWidgets())
|
|
@@ -181,9 +194,7 @@ void ctkPopupWidgetPrivate::updateVisibility()
|
|
|
// Of course, tooltips and popups don't count as covering windows.
|
|
|
if (topLevelWidget->isVisible() &&
|
|
|
!(topLevelWidget->windowState() & Qt::WindowMinimized) &&
|
|
|
- topLevelWidget->windowType() != Qt::ToolTip &&
|
|
|
- topLevelWidget->windowType() != Qt::Popup &&
|
|
|
- topLevelWidget != (this->BaseWidget ? this->BaseWidget->window() : 0) &&
|
|
|
+ this->isHidingCandidate(topLevelWidget) &&
|
|
|
topLevelWidget->frameGeometry().intersects(q->geometry()))
|
|
|
{
|
|
|
//qDebug() << "hide" << q << "because of: " << topLevelWidget
|
|
@@ -226,7 +237,6 @@ void ctkPopupWidgetPrivate::temporarilyHiddenOn()
|
|
|
void ctkPopupWidgetPrivate::temporarilyHiddenOff()
|
|
|
{
|
|
|
Q_Q(ctkPopupWidget);
|
|
|
-
|
|
|
int forcedClosed = this->property("forcedClosed").toInt();
|
|
|
if (forcedClosed > 0)
|
|
|
{
|