12 #include "DropIndicatorOverlayInterface_p.h"
15 #include "DropArea_p.h"
16 #include "DockRegistry_p.h"
20 DropIndicatorOverlayInterface::DropIndicatorOverlayInterface(DropArea *dropArea)
21 : QWidgetAdapter(dropArea)
22 , m_dropArea(dropArea)
25 setObjectName(QStringLiteral(
"DropIndicatorOverlayInterface"));
27 connect(DockRegistry::self(), &DockRegistry::dropIndicatorsInhibitedChanged,
this,
28 [
this](
bool inhibited) {
36 void DropIndicatorOverlayInterface::setWindowBeingDragged(
bool is)
38 if (is == m_draggedWindowIsHovering)
41 m_draggedWindowIsHovering = is;
43 setGeometry(m_dropArea->QWidgetAdapter::rect());
46 setHoveredFrame(
nullptr);
53 QRect DropIndicatorOverlayInterface::hoveredFrameRect()
const
55 return m_hoveredFrameRect;
58 void DropIndicatorOverlayInterface::setHoveredFrame(Frame *frame)
60 if (frame == m_hoveredFrame)
64 disconnect(m_hoveredFrame, &
QObject::destroyed,
this, &DropIndicatorOverlayInterface::onFrameDestroyed);
66 m_hoveredFrame = frame;
68 connect(frame, &
QObject::destroyed,
this, &DropIndicatorOverlayInterface::onFrameDestroyed);
69 setHoveredFrameRect(m_hoveredFrame->QWidgetAdapter::geometry());
71 setHoveredFrameRect(
QRect());
75 Q_EMIT hoveredFrameChanged(m_hoveredFrame);
76 onHoveredFrameChanged(m_hoveredFrame);
79 bool DropIndicatorOverlayInterface::isHovered()
const
81 return m_draggedWindowIsHovering;
84 DropIndicatorOverlayInterface::DropLocation DropIndicatorOverlayInterface::currentDropLocation()
const
86 return m_currentDropLocation;
89 KDDockWidgets::Location DropIndicatorOverlayInterface::multisplitterLocationFor(DropIndicatorOverlayInterface::DropLocation dropLoc)
92 case KDDockWidgets::DropIndicatorOverlayInterface::DropLocation_None:
94 case KDDockWidgets::DropIndicatorOverlayInterface::DropLocation_Left:
95 case KDDockWidgets::DropIndicatorOverlayInterface::DropLocation_OutterLeft:
97 case KDDockWidgets::DropIndicatorOverlayInterface::DropLocation_OutterTop:
98 case KDDockWidgets::DropIndicatorOverlayInterface::DropLocation_Top:
100 case KDDockWidgets::DropIndicatorOverlayInterface::DropLocation_OutterRight:
101 case KDDockWidgets::DropIndicatorOverlayInterface::DropLocation_Right:
103 case KDDockWidgets::DropIndicatorOverlayInterface::DropLocation_OutterBottom:
104 case KDDockWidgets::DropIndicatorOverlayInterface::DropLocation_Bottom:
106 case KDDockWidgets::DropIndicatorOverlayInterface::DropLocation_Center:
113 void DropIndicatorOverlayInterface::onFrameDestroyed()
115 setHoveredFrame(
nullptr);
118 void DropIndicatorOverlayInterface::onHoveredFrameChanged(Frame *)
122 void DropIndicatorOverlayInterface::setCurrentDropLocation(DropIndicatorOverlayInterface::DropLocation location)
124 if (m_currentDropLocation != location) {
125 m_currentDropLocation = location;
126 Q_EMIT currentDropLocationChanged();
130 DropIndicatorOverlayInterface::DropLocation DropIndicatorOverlayInterface::hover(
QPoint globalPos)
132 return hover_impl(globalPos);
135 void DropIndicatorOverlayInterface::setHoveredFrameRect(
QRect rect)
137 if (m_hoveredFrameRect != rect) {
138 m_hoveredFrameRect = rect;
139 Q_EMIT hoveredFrameRectChanged();
143 void DropIndicatorOverlayInterface::removeHover()
145 setWindowBeingDragged(
false);
146 setCurrentDropLocation(DropIndicatorOverlayInterface::DropLocation_None);