Skip to content

Commit

Permalink
Make window movable
Browse files Browse the repository at this point in the history
  • Loading branch information
vietanhdev committed Dec 13, 2024
1 parent 32e0ca8 commit e88e94d
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions llama_assistant/llama_assistant_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
QVBoxLayout,
QMessageBox,
QSystemTrayIcon,
QRubberBand,
)
from PyQt5.QtCore import Qt, QPoint, QTimer, QSize, QRect
from PyQt5.QtCore import Qt, QTimer, QRect
from PyQt5.QtGui import (
QPixmap,
QPainter,
QDragEnterEvent,
QDropEvent,
QBitmap,
QTextCursor,
QFont,
QMouseEvent,
)

from llama_assistant import config
Expand Down Expand Up @@ -64,6 +63,24 @@ def __init__(self):
self.gen_mark_down = True
self.has_ocr_context = False

# Add drag-drop move support
self.setWindowFlags(Qt.FramelessWindowHint)
self.oldPos = None

def mousePressEvent(self, event: QMouseEvent):
if event.button() == Qt.LeftButton:
self.oldPos = event.globalPos()

def mouseMoveEvent(self, event: QMouseEvent):
if self.oldPos is not None:
delta = event.globalPos() - self.oldPos
self.move(self.x() + delta.x(), self.y() + delta.y())
self.oldPos = event.globalPos()

def mouseReleaseEvent(self, event: QMouseEvent):
if event.button() == Qt.LeftButton:
self.oldPos = None

def capture_screenshot(self):
self.hide()
self.screen_capture_widget.show()
Expand Down

0 comments on commit e88e94d

Please sign in to comment.