Abstract away a call to qApp->activePopupWidget()
It's now generic and doesn't depend on QApplication. Removes an ifdef.
This commit is contained in:
@@ -31,3 +31,8 @@ Platform *Platform::instance()
|
||||
{
|
||||
return s_platform;
|
||||
}
|
||||
|
||||
bool Platform::hasActivePopup() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@ public:
|
||||
/// @brief Returns the platform singleton
|
||||
static Platform *instance();
|
||||
|
||||
/// @brief Returns whether a popup is open
|
||||
/// Usually not needed to override. Investigate further in case side bars aren't auto hidding
|
||||
virtual bool hasActivePopup() const;
|
||||
|
||||
protected:
|
||||
Platform();
|
||||
};
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "WindowBeingDragged_p.h"
|
||||
#include "multisplitter/Item_p.h"
|
||||
|
||||
#include "Platform.h"
|
||||
#include "controllers/FloatingWindow.h"
|
||||
#include "controllers/SideBar.h"
|
||||
#include "controllers/DockWidget.h"
|
||||
@@ -51,11 +52,6 @@ DockRegistry::DockRegistry(QObject *parent)
|
||||
{
|
||||
qApp->installEventFilter(this);
|
||||
|
||||
#ifndef KDDOCKWIDGETS_QTWIDGETS
|
||||
KDDockWidgets::registerQmlTypes();
|
||||
QQuickWindow::setDefaultAlphaBuffer(true);
|
||||
#endif
|
||||
|
||||
connect(qApp, &QGuiApplication::focusObjectChanged,
|
||||
this, &DockRegistry::onFocusObjectChanged);
|
||||
|
||||
@@ -742,11 +738,9 @@ bool DockRegistry::onDockWidgetPressed(DockWidgetBase *dw, QMouseEvent *ev)
|
||||
// Here we implement "auto-hide". If there's a overlayed dock widget, we hide it if some other
|
||||
// dock widget is clicked.
|
||||
|
||||
#ifdef KDDOCKWIDGETS_QTWIDGETS
|
||||
// Don't be sending mouse events around if a popup is open, they are sensitive
|
||||
if (qApp->activePopupWidget())
|
||||
if (Platform::instance()->hasActivePopup())
|
||||
return false;
|
||||
#endif
|
||||
|
||||
Controllers::MainWindow *mainWindow = dw->mainWindow();
|
||||
if (!mainWindow) // Only docked widgets are interesting
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "KDDockWidgets.h"
|
||||
#include "qtwidgets/DebugWindow_p.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
static KDDockWidgets::Platform_qtwidgets s_platformQtWidgets;
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
@@ -35,3 +37,8 @@ const char *Platform_qtwidgets::name() const
|
||||
{
|
||||
return "qtwidgets";
|
||||
}
|
||||
|
||||
bool Platform_qtwidgets::hasActivePopup() const
|
||||
{
|
||||
return qApp->activePopupWidget() != nullptr;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
Platform_qtwidgets();
|
||||
~Platform_qtwidgets() override;
|
||||
const char *name() const override;
|
||||
bool hasActivePopup() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user