chore: allow dragging focus overlay

This commit is contained in:
talksik
2026-02-01 13:47:41 -08:00
parent 9e68c554f4
commit ca3478f51e
3 changed files with 114 additions and 34 deletions
+28 -1
View File
@@ -2,10 +2,12 @@
#include "ui_focusoverlay.h"
#include <QScreen>
#include <QGuiApplication>
#include <QMouseEvent>
FocusOverlay::FocusOverlay(QWidget *parent)
: QWidget(parent),
ui(new Ui::FocusOverlay)
ui(new Ui::FocusOverlay),
m_dragging(false)
{
ui->setupUi(this);
@@ -71,3 +73,28 @@ void FocusOverlay::positionAtBottomCenter()
move(x, y);
}
void FocusOverlay::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
m_dragging = true;
m_dragStartPosition = event->globalPosition().toPoint() - frameGeometry().topLeft();
event->accept();
}
}
void FocusOverlay::mouseMoveEvent(QMouseEvent *event)
{
if (m_dragging && (event->buttons() & Qt::LeftButton)) {
move(event->globalPosition().toPoint() - m_dragStartPosition);
event->accept();
}
}
void FocusOverlay::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
m_dragging = false;
event->accept();
}
}