diff --git a/src/capture/captureareaselector.cpp b/src/capture/captureareaselector.cpp index fa59629..cfd5920 100644 --- a/src/capture/captureareaselector.cpp +++ b/src/capture/captureareaselector.cpp @@ -31,7 +31,6 @@ CaptureAreaSelector::CaptureAreaSelector(Capturer &capturer, { setWindowFlags(Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint); - setCursor(Qt::CrossCursor); setMouseTracking(true); setAttribute(Qt::WA_OpaquePaintEvent); @@ -96,6 +95,29 @@ void CaptureAreaSelector::cancel() capturer_.canceled(); } +void CaptureAreaSelector::updateCursorShape(const QPoint &pos) +{ + const auto set = [this](Qt::CursorShape shape) { + const auto current = cursor().shape(); + if (current != shape) + setCursor(shape); + }; + + if (areas_.empty()) { + set(Qt::CrossCursor); + return; + } + + for (const auto &area : areas_) { + if (area->rect().contains(pos)) { + set(Qt::CursorShape::PointingHandCursor); + return; + } + } + + set(Qt::CrossCursor); +} + void CaptureAreaSelector::setScreenRects(const std::vector &screens) { auto helpRect = fontMetrics().boundingRect({}, 0, help_); @@ -203,6 +225,7 @@ void CaptureAreaSelector::showEvent(QShowEvent * /*event*/) startSelectPos_ = currentSelectPos_ = QPoint(); areas_.erase(std::remove_if(areas_.begin(), areas_.end(), notLocked), areas_.end()); + updateCursorShape(QCursor::pos()); } void CaptureAreaSelector::hideEvent(QHideEvent * /*event*/) @@ -256,6 +279,8 @@ void CaptureAreaSelector::mousePressEvent(QMouseEvent *event) void CaptureAreaSelector::mouseMoveEvent(QMouseEvent *event) { + updateCursorShape(QCursor::pos()); + if (startSelectPos_.isNull()) { if (updateCurrentHelpRects()) update(); diff --git a/src/capture/captureareaselector.h b/src/capture/captureareaselector.h index c3fb38d..1d5e428 100644 --- a/src/capture/captureareaselector.h +++ b/src/capture/captureareaselector.h @@ -38,6 +38,7 @@ private: void capture(CaptureArea &area, uint generation); void captureAll(); void cancel(); + void updateCursorShape(const QPoint &pos); bool updateCurrentHelpRects(); void drawHelpRects(QPainter &painter, const HelpRect &rect) const;