Added WidgetResizeHandler::setAllowedResizeSides()
This commit is contained in:
@@ -51,6 +51,11 @@ WidgetResizeHandler::~WidgetResizeHandler()
|
||||
{
|
||||
}
|
||||
|
||||
void WidgetResizeHandler::setAllowedResizeSides(CursorPositions sides)
|
||||
{
|
||||
mAllowedResizeSides = sides;
|
||||
}
|
||||
|
||||
bool WidgetResizeHandler::eventFilter(QObject *o, QEvent *e)
|
||||
{
|
||||
if (s_disableAllHandlers)
|
||||
@@ -367,6 +372,9 @@ void WidgetResizeHandler::updateCursor(CursorPosition m)
|
||||
case CursorPosition_Undefined:
|
||||
restoreMouseCursor();
|
||||
break;
|
||||
case CursorPosition_All:
|
||||
// Doesn't happen
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,5 +416,8 @@ WidgetResizeHandler::CursorPosition WidgetResizeHandler::cursorPosition(QPoint g
|
||||
else if (qAbs(y - (mTarget->height() - margin)) <= margin)
|
||||
result |= CursorPosition_Bottom;
|
||||
|
||||
// Filter out sides we don't allow
|
||||
result = result & mAllowedResizeSides;
|
||||
|
||||
return static_cast<CursorPosition>(result);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,10 @@ public:
|
||||
CursorPosition_TopLeft = CursorPosition_Top | CursorPosition_Left,
|
||||
CursorPosition_TopRight = CursorPosition_Top | CursorPosition_Right,
|
||||
CursorPosition_BottomRight = CursorPosition_Bottom | CursorPosition_Right,
|
||||
CursorPosition_BottomLeft = CursorPosition_Bottom | CursorPosition_Left
|
||||
CursorPosition_BottomLeft = CursorPosition_Bottom | CursorPosition_Left,
|
||||
CursorPosition_All = CursorPosition_Left | CursorPosition_Right | CursorPosition_Top | CursorPosition_Bottom
|
||||
};
|
||||
Q_DECLARE_FLAGS(CursorPositions, CursorPosition)
|
||||
|
||||
/**
|
||||
* @brief CTOR
|
||||
@@ -50,6 +52,14 @@ public:
|
||||
explicit WidgetResizeHandler(bool filterIsGlobal, QWidgetOrQuick *target);
|
||||
~WidgetResizeHandler() override;
|
||||
|
||||
/**
|
||||
* @brief Sets the sides the user is allowed to resize with mouse.
|
||||
*
|
||||
* By default the user can resize all 4 sides.
|
||||
* However, when a dock widget is overlayed (popuped), only one side can be resized.
|
||||
*/
|
||||
void setAllowedResizeSides(CursorPositions);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
static bool handleWindowsNativeEvent(FloatingWindow *w, const QByteArray &eventType, void *message, Qt5Qt6Compat::qintptr *result);
|
||||
#endif
|
||||
@@ -69,6 +79,7 @@ private:
|
||||
QPoint mNewPosition;
|
||||
bool mResizeWidget = false;
|
||||
const bool mFilterIsGlobal;
|
||||
CursorPositions mAllowedResizeSides = CursorPosition_All;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user