Add DockRegistry::frameInMDIResize()
Only emitted in a MDI layout. Emitted when one dockwidget is being resized
This commit is contained in:
@@ -16,12 +16,13 @@
|
|||||||
#include "FloatingWindow_p.h"
|
#include "FloatingWindow_p.h"
|
||||||
#include "LayoutWidget_p.h"
|
#include "LayoutWidget_p.h"
|
||||||
#include "Logging_p.h"
|
#include "Logging_p.h"
|
||||||
|
#include "MainWindowMDI.h"
|
||||||
#include "Position_p.h"
|
#include "Position_p.h"
|
||||||
#include "QWidgetAdapter.h"
|
#include "QWidgetAdapter.h"
|
||||||
#include "SideBar_p.h"
|
#include "SideBar_p.h"
|
||||||
#include "Utils_p.h"
|
#include "Utils_p.h"
|
||||||
|
#include "WidgetResizeHandler_p.h"
|
||||||
#include "WindowBeingDragged_p.h"
|
#include "WindowBeingDragged_p.h"
|
||||||
#include "MainWindowMDI.h"
|
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -225,6 +226,25 @@ SideBar *DockRegistry::sideBarForDockWidget(const DockWidgetBase *dw) const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Frame *DockRegistry::frameInMDIResize() const
|
||||||
|
{
|
||||||
|
for (auto mw : m_mainWindows) {
|
||||||
|
if (!mw->isMDI())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
LayoutWidget *layout = mw->layoutWidget();
|
||||||
|
const QList<Frame *> frames = layout->frames();
|
||||||
|
for (Frame *frame : frames) {
|
||||||
|
if (WidgetResizeHandler *wrh = frame->resizeHandler()) {
|
||||||
|
if (wrh->isResizing())
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
MainWindowBase::List DockRegistry::mainWindowsWithAffinity(const QStringList &affinities) const
|
MainWindowBase::List DockRegistry::mainWindowsWithAffinity(const QStringList &affinities) const
|
||||||
{
|
{
|
||||||
MainWindowBase::List result;
|
MainWindowBase::List result;
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ struct WindowBeingDragged;
|
|||||||
class DOCKS_EXPORT DockRegistry : public QObject
|
class DOCKS_EXPORT DockRegistry : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(
|
||||||
|
KDDockWidgets::Frame *frameInMDIResize READ frameInMDIResize NOTIFY frameInMDIResizeChanged)
|
||||||
public:
|
public:
|
||||||
static DockRegistry *self();
|
static DockRegistry *self();
|
||||||
~DockRegistry();
|
~DockRegistry();
|
||||||
@@ -210,10 +212,16 @@ public:
|
|||||||
///@brief Overload that returns the SideBar itself
|
///@brief Overload that returns the SideBar itself
|
||||||
SideBar *sideBarForDockWidget(const DockWidgetBase *) const;
|
SideBar *sideBarForDockWidget(const DockWidgetBase *) const;
|
||||||
|
|
||||||
|
///@brief Returns the Frame which is being resized in a MDI layout. nullptr if none
|
||||||
|
Frame *frameInMDIResize() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/// @brief emitted when a main window or a floating window change screen
|
/// @brief emitted when a main window or a floating window change screen
|
||||||
void windowChangedScreen(QWindow *);
|
void windowChangedScreen(QWindow *);
|
||||||
|
|
||||||
|
/// @brief emitted when the MDI frame that's being resized changed
|
||||||
|
void frameInMDIResizeChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -792,3 +792,8 @@ int Frame::userType() const
|
|||||||
{
|
{
|
||||||
return m_userType;
|
return m_userType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WidgetResizeHandler *Frame::resizeHandler() const
|
||||||
|
{
|
||||||
|
return m_resizeHandler;
|
||||||
|
}
|
||||||
|
|||||||
@@ -266,6 +266,9 @@ public:
|
|||||||
/// @brief See DockWidgetBase::userType()
|
/// @brief See DockWidgetBase::userType()
|
||||||
int userType() const;
|
int userType() const;
|
||||||
|
|
||||||
|
/// @brief Returns the resize handler. Used mostly in MDI mode.
|
||||||
|
WidgetResizeHandler *resizeHandler() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void currentDockWidgetChanged(KDDockWidgets::DockWidgetBase *);
|
void currentDockWidgetChanged(KDDockWidgets::DockWidgetBase *);
|
||||||
void numDockWidgetsChanged();
|
void numDockWidgetsChanged();
|
||||||
|
|||||||
@@ -66,6 +66,11 @@ bool WidgetResizeHandler::isMDI() const
|
|||||||
return frame && frame->isMDI();
|
return frame && frame->isMDI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WidgetResizeHandler::isResizing() const
|
||||||
|
{
|
||||||
|
return m_resizingInProgress;
|
||||||
|
}
|
||||||
|
|
||||||
int WidgetResizeHandler::widgetResizeHandlerMargin()
|
int WidgetResizeHandler::widgetResizeHandlerMargin()
|
||||||
{
|
{
|
||||||
return 4; // pixels
|
return 4; // pixels
|
||||||
@@ -127,6 +132,8 @@ bool WidgetResizeHandler::eventFilter(QObject *o, QEvent *e)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_resizingInProgress = true;
|
m_resizingInProgress = true;
|
||||||
|
if (isMDI())
|
||||||
|
Q_EMIT DockRegistry::self()->frameInMDIResizeChanged();
|
||||||
mNewPosition = Qt5Qt6Compat::eventGlobalPos(mouseEvent);
|
mNewPosition = Qt5Qt6Compat::eventGlobalPos(mouseEvent);
|
||||||
mCursorPos = cursorPos;
|
mCursorPos = cursorPos;
|
||||||
|
|
||||||
@@ -134,6 +141,8 @@ bool WidgetResizeHandler::eventFilter(QObject *o, QEvent *e)
|
|||||||
}
|
}
|
||||||
case QEvent::MouseButtonRelease: {
|
case QEvent::MouseButtonRelease: {
|
||||||
m_resizingInProgress = false;
|
m_resizingInProgress = false;
|
||||||
|
if (isMDI())
|
||||||
|
Q_EMIT DockRegistry::self()->frameInMDIResizeChanged();
|
||||||
updateCursor(CursorPosition_Undefined);
|
updateCursor(CursorPosition_Undefined);
|
||||||
auto mouseEvent = static_cast<QMouseEvent *>(e);
|
auto mouseEvent = static_cast<QMouseEvent *>(e);
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ public:
|
|||||||
|
|
||||||
bool isMDI() const;
|
bool isMDI() const;
|
||||||
|
|
||||||
|
bool isResizing() const;
|
||||||
|
|
||||||
static int widgetResizeHandlerMargin();
|
static int widgetResizeHandlerMargin();
|
||||||
|
|
||||||
static void setupWindow(QWindow *window);
|
static void setupWindow(QWindow *window);
|
||||||
|
|||||||
Reference in New Issue
Block a user