12 #include "ClassicIndicators_p.h"
15 #include "ClassicIndicatorsWindow_p.h"
17 #include "private/DropArea_p.h"
18 #include "private/DragController_p.h"
19 #include "private/Frame_p.h"
20 #include "private/Logging_p.h"
21 #include "private/DockRegistry_p.h"
22 #include "private/Utils_p.h"
28 auto window =
new IndicatorWindow(classicIndicators);
29 window->setObjectName(QStringLiteral(
"_docks_IndicatorWindow_Overlay"));
34 ClassicIndicators::ClassicIndicators(DropArea *dropArea)
35 : DropIndicatorOverlayInterface(dropArea)
36 , m_rubberBand(
Config::self().frameworkWidgetFactory()->createRubberBand(rubberBandIsTopLevel() ? nullptr : dropArea))
39 if (rubberBandIsTopLevel())
40 m_rubberBand->setWindowOpacity(0.5);
43 ClassicIndicators::~ClassicIndicators()
45 delete m_indicatorWindow;
48 DropIndicatorOverlayInterface::DropLocation ClassicIndicators::hover_impl(
QPoint globalPos)
50 return m_indicatorWindow->hover(globalPos);
53 QPoint ClassicIndicators::posForIndicator(DropIndicatorOverlayInterface::DropLocation loc)
const
55 return m_indicatorWindow->posForIndicator(loc);
58 bool ClassicIndicators::innerIndicatorsVisible()
const
60 return m_innerIndicatorsVisible;
63 bool ClassicIndicators::outterIndicatorsVisible()
const
65 return m_outterIndicatorsVisible;
68 bool ClassicIndicators::tabIndicatorVisible()
const
70 return m_tabIndicatorVisible;
73 bool ClassicIndicators::onResize(
QSize)
75 m_indicatorWindow->resize(window()->size());
79 void ClassicIndicators::updateVisibility()
82 m_indicatorWindow->updatePositions();
83 m_indicatorWindow->setVisible(
true);
84 updateWindowPosition();
85 updateIndicatorsVisibility(
true);
88 m_rubberBand->setVisible(
false);
89 m_indicatorWindow->setVisible(
false);
90 updateIndicatorsVisibility(
false);
94 void ClassicIndicators::updateIndicatorsVisibility(
bool visible)
96 const bool isTheOnlyFrame = m_hoveredFrame && m_hoveredFrame->isTheOnlyFrame();
98 m_innerIndicatorsVisible = visible && m_hoveredFrame;
100 WindowBeingDragged *windowBeingDragged = DragController::instance()->windowBeingDragged();
104 m_outterIndicatorsVisible = visible && (!isTheOnlyFrame || DockRegistry::self()->isProbablyObscured(m_hoveredFrame->window()->windowHandle(), windowBeingDragged));
108 auto tabbingAllowedFunc = Config::self().tabbingAllowedFunc();
109 m_tabIndicatorVisible = m_innerIndicatorsVisible && windowBeingDragged && DockRegistry::self()->affinitiesMatch(m_hoveredFrame->affinities(), windowBeingDragged->affinities()) && m_hoveredFrame->isDockable();
110 if (m_tabIndicatorVisible && tabbingAllowedFunc) {
113 m_tabIndicatorVisible = tabbingAllowedFunc(source, target);
116 Q_EMIT innerIndicatorsVisibleChanged();
117 Q_EMIT outterIndicatorsVisibleChanged();
118 Q_EMIT tabIndicatorVisibleChanged();
121 void ClassicIndicators::raiseIndicators()
123 m_indicatorWindow->raise();
129 case DropIndicatorOverlayInterface::DropLocation_Left:
131 case DropIndicatorOverlayInterface::DropLocation_Top:
133 case DropIndicatorOverlayInterface::DropLocation_Right:
135 case DropIndicatorOverlayInterface::DropLocation_Bottom:
137 case DropIndicatorOverlayInterface::DropLocation_OutterLeft:
139 case DropIndicatorOverlayInterface::DropLocation_OutterTop:
141 case DropIndicatorOverlayInterface::DropLocation_OutterRight:
143 case DropIndicatorOverlayInterface::DropLocation_OutterBottom:
150 void ClassicIndicators::setDropLocation(ClassicIndicators::DropLocation location)
152 setCurrentDropLocation(location);
154 if (location == DropLocation_None) {
155 m_rubberBand->setVisible(
false);
159 if (location == DropLocation_Center) {
160 m_rubberBand->setGeometry(geometryForRubberband(m_hoveredFrame ? m_hoveredFrame->QWidgetAdapter::geometry() : rect()));
161 m_rubberBand->setVisible(
true);
162 if (rubberBandIsTopLevel()) {
163 m_rubberBand->raise();
171 Frame *relativeToFrame =
nullptr;
174 case DropLocation_Left:
175 case DropLocation_Top:
176 case DropLocation_Right:
177 case DropLocation_Bottom:
178 if (!m_hoveredFrame) {
179 qWarning() <<
"ClassicIndicators::setCurrentDropLocation: frame is null. location=" << location
180 <<
"; isHovered=" << isHovered()
181 <<
"; dropArea->widgets=" << m_dropArea->items();
185 relativeToFrame = m_hoveredFrame;
187 case DropLocation_OutterLeft:
188 case DropLocation_OutterTop:
189 case DropLocation_OutterRight:
190 case DropLocation_OutterBottom:
196 auto windowBeingDragged = DragController::instance()->windowBeingDragged();
198 QRect rect = m_dropArea->rectForDrop(windowBeingDragged, multisplitterLocation,
199 m_dropArea->itemForFrame(relativeToFrame));
201 m_rubberBand->setGeometry(geometryForRubberband(rect));
202 m_rubberBand->setVisible(
true);
203 if (rubberBandIsTopLevel()) {
204 m_rubberBand->raise();
209 void ClassicIndicators::updateWindowPosition()
211 QRect rect = this->rect();
212 if (KDDockWidgets::isWindow(m_indicatorWindow)) {
217 m_indicatorWindow->setGeometry(rect);
220 bool ClassicIndicators::rubberBandIsTopLevel()
const
222 return Config::self().internalFlags() & Config::InternalFlag_TopLevelIndicatorRubberBand;
225 QRect ClassicIndicators::geometryForRubberband(
QRect localRect)
const
227 if (!rubberBandIsTopLevel())
231 QPoint topLeftGlobal = m_dropArea->QWidgetAdapter::mapToGlobal(topLeftLocal);