OllamaInterface/OllamaHistoryWidget.py

changeset 21
22245a10b118
parent 10
734921ab2b89
child 44
ef9a85b8768a
--- a/OllamaInterface/OllamaHistoryWidget.py	Fri Aug 30 12:04:28 2024 +0200
+++ b/OllamaInterface/OllamaHistoryWidget.py	Fri Aug 30 15:22:47 2024 +0200
@@ -8,12 +8,14 @@
 """
 
 import json
+import os
 import uuid
 
 from PyQt6.QtCore import pyqtSignal, pyqtSlot
 from PyQt6.QtWidgets import QInputDialog, QLineEdit, QWidget
 
 from eric7.EricGui import EricPixmapCache
+from eric7.EricWidgets.EricApplication import ericApp
 
 from .Ui_OllamaHistoryWidget import Ui_OllamaHistoryWidget
 
@@ -26,11 +28,14 @@
         should be deleted
     @signal newChatWithHistory(id:str) emitted to indicate, that a new chat using
         the saved history should be started
+    @signal viewChatHistory(id:str) emitted to indicate, that this chat history
+        should be shown in a separate window
     @signal dataChanged(id:str) emitted to indicate a change of the chat history data
     """
 
     deleteChatHistory = pyqtSignal(str)
     newChatWithHistory = pyqtSignal(str)
+    viewChatHistory = pyqtSignal(str)
     dataChanged = pyqtSignal(str)
 
     def __init__(self, title, model, jsonStr=None, parent=None):
@@ -50,8 +55,15 @@
         super().__init__(parent)
         self.setupUi(self)
 
+        iconSuffix = "-dark" if ericApp().usesDarkPalette() else "-light"
+
         self.newChatButton.setIcon(EricPixmapCache.getIcon("plus"))
         self.editButton.setIcon(EricPixmapCache.getIcon("editRename"))
+        self.viewButton.setIcon(
+            EricPixmapCache.getIcon(
+                os.path.join("OllamaInterface", "icons", "view{0}".format(iconSuffix))
+            )
+        )
         self.deleteButton.setIcon(EricPixmapCache.getIcon("trash"))
 
         if jsonStr is None:
@@ -133,6 +145,13 @@
             self.titleEdit.setText(title)
             self.dataChanged.emit(self.__id)
 
+    @pyqtSlot()
+    def on_viewButton_clicked(self):
+        """
+        Private slot to view the current chat history in a separate window..
+        """
+        self.viewChatHistory.emit(self.__id)
+
     def loadFromJson(self, jsonStr):
         """
         Public method to load the chat history data from a JSON string.

eric ide

mercurial