diff --git a/CHANGELOG.md b/CHANGELOG.md index c73b8b0..aed6635 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [Unreleased] +## [v0.7.5] ## Added @@ -6,8 +6,13 @@ 2. Add a jump / navigate to date floating window triggered with: - a shortcut: Ctrl+Shift+F. - a toobar button +3. Add context menu to chat view for copying message text. +## Changed + +1. Set single step scrolling for smoother scrolling. + --- ## [v0.7.0] diff --git a/README.md b/README.md index 4c9c1ad..88d7552 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ pip install git+https://github.com/shsiddhant/memory.text.git ### Filter and Search +- [x] Copy message text - [ ] Search messages - [ ] Filter by participants - [ ] Sort/filter by timestamps diff --git a/src/memorytext/views/chat_view.py b/src/memorytext/views/chat_view.py index 636d9d3..baea4c8 100644 --- a/src/memorytext/views/chat_view.py +++ b/src/memorytext/views/chat_view.py @@ -1,8 +1,8 @@ from __future__ import annotations from typing import TYPE_CHECKING -from PySide6.QtWidgets import QListView +from PySide6.QtWidgets import QApplication, QListView, QMenu from PySide6.QtCore import Qt -from PySide6.QtGui import QFont +from PySide6.QtGui import QAction, QFont, QIcon from memorytext.models.message_list import MessageList from memorytext.services import message_service @@ -13,6 +13,9 @@ import datetime +COPY_ICON = QIcon.fromTheme("edit-copy") + + class ChatView(QListView): def __init__(self): super().__init__() @@ -27,6 +30,10 @@ def __init__(self): self.setItemDelegate(self.delegate) self.setWordWrap(True) self.setUniformItemSizes(False) + self.setMouseTracking(True) + self.setAttribute(Qt.WidgetAttribute.WA_Hover) + self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) + self.customContextMenuRequested.connect(self.show_context_menu) self.setFocusPolicy(Qt.NoFocus) # pyright: ignore[reportAttributeAccessIssue] def set_messages( @@ -49,3 +56,15 @@ def jump_to_date(self, date: datetime.date): if target_index: self.scrollTo(target_index, self.ScrollHint.PositionAtTop) self.setCurrentIndex(target_index) + + def show_context_menu(self, position): + index = self.indexAt(position) + if index.isValid(): + menu = QMenu(self) + copy_action = QAction(COPY_ICON, "Copy Message", self) + menu.addAction(copy_action) + action = menu.exec(self.viewport().mapToGlobal(position)) + if action == copy_action: + QApplication.clipboard().setText( + index.data(Qt.ItemDataRole.DisplayRole) + ) diff --git a/src/memorytext/windows/main_window.py b/src/memorytext/windows/main_window.py index 42291e4..ad8f43a 100644 --- a/src/memorytext/windows/main_window.py +++ b/src/memorytext/windows/main_window.py @@ -58,6 +58,7 @@ def __init__(self): # Messages self.chat_area = ChatView() + self.chat_area.verticalScrollBar().setSingleStep(5) # Smoother Scrolling main_layout.addLayout(sidebar_layout, stretch=1) main_layout.addWidget(self.chat_area, stretch=2) self.sidebar.clicked.connect(self.load_messages)