tests: Make DropArea::hover() return the chosen drop location
Just for tests.
This commit is contained in:
@@ -73,7 +73,7 @@ private:
|
||||
DropLocation m_currentDropLocation = DropLocation_None;
|
||||
|
||||
protected:
|
||||
virtual void hover_impl(QPoint globalPos) = 0;
|
||||
virtual DropIndicatorOverlayInterface::DropLocation hover_impl(QPoint globalPos) = 0;
|
||||
virtual void onHoveredFrameChanged(Frame *);
|
||||
virtual void updateVisibility() {};
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ ClassicIndicators::~ClassicIndicators()
|
||||
delete m_indicatorWindow;
|
||||
}
|
||||
|
||||
void ClassicIndicators::hover_impl(QPoint globalPos)
|
||||
DropIndicatorOverlayInterface::DropLocation ClassicIndicators::hover_impl(QPoint globalPos)
|
||||
{
|
||||
m_indicatorWindow->hover(globalPos);
|
||||
return m_indicatorWindow->hover(globalPos);
|
||||
}
|
||||
|
||||
QPoint ClassicIndicators::posForIndicator(DropIndicatorOverlayInterface::DropLocation loc) const
|
||||
|
||||
@@ -207,12 +207,20 @@ QPoint IndicatorWindow::posForIndicator(DropIndicatorOverlayInterface::DropLocat
|
||||
return indicator->mapToGlobal(indicator->rect().center());
|
||||
}
|
||||
|
||||
void IndicatorWindow::hover(QPoint globalPos)
|
||||
DropIndicatorOverlayInterface::DropLocation IndicatorWindow::hover(QPoint globalPos)
|
||||
{
|
||||
DropIndicatorOverlayInterface::DropLocation loc = DropIndicatorOverlayInterface::DropLocation_None;
|
||||
|
||||
for (Indicator *indicator : qAsConst(m_indicators)) {
|
||||
if (indicator->isVisible())
|
||||
indicator->setHovered(indicator->rect().contains(indicator->mapFromGlobal(globalPos)));
|
||||
if (indicator->isVisible()) {
|
||||
const bool hovered = indicator->rect().contains(indicator->mapFromGlobal(globalPos));
|
||||
indicator->setHovered(hovered);
|
||||
if (hovered)
|
||||
loc = indicator->m_dropLocation;
|
||||
}
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
void IndicatorWindow::updatePositions()
|
||||
@@ -262,14 +270,13 @@ IndicatorWindow::IndicatorWindow(KDDockWidgets::ClassicIndicators *classicIndica
|
||||
setSource(QUrl(QStringLiteral("qrc:/kddockwidgets/private/quick/qml/ClassicIndicatorsOverlay.qml")));
|
||||
}
|
||||
|
||||
void IndicatorWindow::hover(QPoint pt)
|
||||
DropIndicatorOverlayInterface::DropLocation IndicatorWindow::hover(QPoint pt)
|
||||
{
|
||||
QQuickItem *item = indicatorForPos(pt);
|
||||
if (item) {
|
||||
classicIndicators()->setDropLocation(locationForIndicator(item));
|
||||
} else {
|
||||
classicIndicators()->setDropLocation(DropIndicatorOverlayInterface::DropLocation_None);
|
||||
}
|
||||
const DropIndicatorOverlayInterface::DropLocation loc = item ? locationForIndicator(item)
|
||||
: DropIndicatorOverlayInterface::DropLocation_None;
|
||||
classicIndicators()->setDropLocation(loc);
|
||||
return loc;
|
||||
}
|
||||
|
||||
QQuickItem *IndicatorWindow::indicatorForPos(QPoint pt) const
|
||||
|
||||
@@ -30,7 +30,7 @@ class IndicatorWindow : public QWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IndicatorWindow(ClassicIndicators *classicIndicators);
|
||||
void hover(QPoint globalPos);
|
||||
DropIndicatorOverlayInterface::DropLocation hover(QPoint globalPos);
|
||||
void updatePositions();
|
||||
QPoint posForIndicator(DropIndicatorOverlayInterface::DropLocation) const;
|
||||
private:
|
||||
@@ -91,7 +91,7 @@ class IndicatorWindow : public QQuickView
|
||||
Q_PROPERTY(KDDockWidgets::ClassicIndicators* classicIndicators READ classicIndicators CONSTANT)
|
||||
public:
|
||||
explicit IndicatorWindow(ClassicIndicators *);
|
||||
void hover(QPoint);
|
||||
DropIndicatorOverlayInterface::DropLocation hover(QPoint);
|
||||
void updatePositions();
|
||||
QPoint posForIndicator(DropIndicatorOverlayInterface::DropLocation) const;
|
||||
Q_INVOKABLE QString iconName(int loc, bool active) const;
|
||||
|
||||
@@ -29,7 +29,7 @@ class DOCKS_EXPORT ClassicIndicators : public DropIndicatorOverlayInterface
|
||||
public:
|
||||
explicit ClassicIndicators(DropArea *dropArea);
|
||||
~ClassicIndicators() override;
|
||||
void hover_impl(QPoint globalPos) override;
|
||||
DropLocation hover_impl(QPoint globalPos) override;
|
||||
QPoint posForIndicator(DropLocation) const override;
|
||||
|
||||
bool innerIndicatorsVisible() const;
|
||||
|
||||
@@ -27,7 +27,7 @@ class DOCKS_EXPORT NullIndicators : public DropIndicatorOverlayInterface
|
||||
public:
|
||||
using DropIndicatorOverlayInterface::DropIndicatorOverlayInterface;
|
||||
~NullIndicators() override;
|
||||
void hover_impl(QPoint) override {};
|
||||
DropIndicatorOverlayInterface::DropLocation hover_impl(QPoint) override { return {}; };
|
||||
|
||||
DropLocation dropLocationForPos(QPoint) const { return {}; }
|
||||
|
||||
|
||||
@@ -38,11 +38,13 @@ SegmentedIndicators::~SegmentedIndicators()
|
||||
{
|
||||
}
|
||||
|
||||
void SegmentedIndicators::hover_impl(QPoint pt)
|
||||
DropIndicatorOverlayInterface::DropLocation SegmentedIndicators::hover_impl(QPoint pt)
|
||||
{
|
||||
m_hoveredPt = mapFromGlobal(pt);
|
||||
updateSegments();
|
||||
setCurrentDropLocation(dropLocationForPos(m_hoveredPt));
|
||||
|
||||
return currentDropLocation();
|
||||
}
|
||||
|
||||
DropIndicatorOverlayInterface::DropLocation SegmentedIndicators::dropLocationForPos(QPoint pos) const
|
||||
|
||||
@@ -25,7 +25,7 @@ class DOCKS_EXPORT SegmentedIndicators : public DropIndicatorOverlayInterface
|
||||
public:
|
||||
explicit SegmentedIndicators(DropArea *dropArea);
|
||||
~SegmentedIndicators() override;
|
||||
void hover_impl(QPoint globalPos) override;
|
||||
DropIndicatorOverlayInterface::DropLocation hover_impl(QPoint globalPos) override;
|
||||
|
||||
DropLocation dropLocationForPos(QPoint pos) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user