OllamaInterface/OllamaHistoryWidget.py

changeset 21
22245a10b118
parent 10
734921ab2b89
child 44
ef9a85b8768a
equal deleted inserted replaced
20:8cb7bfe07e15 21:22245a10b118
6 """ 6 """
7 Module implementing a widget showing a chat title and store a chat contents. 7 Module implementing a widget showing a chat title and store a chat contents.
8 """ 8 """
9 9
10 import json 10 import json
11 import os
11 import uuid 12 import uuid
12 13
13 from PyQt6.QtCore import pyqtSignal, pyqtSlot 14 from PyQt6.QtCore import pyqtSignal, pyqtSlot
14 from PyQt6.QtWidgets import QInputDialog, QLineEdit, QWidget 15 from PyQt6.QtWidgets import QInputDialog, QLineEdit, QWidget
15 16
16 from eric7.EricGui import EricPixmapCache 17 from eric7.EricGui import EricPixmapCache
18 from eric7.EricWidgets.EricApplication import ericApp
17 19
18 from .Ui_OllamaHistoryWidget import Ui_OllamaHistoryWidget 20 from .Ui_OllamaHistoryWidget import Ui_OllamaHistoryWidget
19 21
20 22
21 class OllamaHistoryWidget(QWidget, Ui_OllamaHistoryWidget): 23 class OllamaHistoryWidget(QWidget, Ui_OllamaHistoryWidget):
24 26
25 @signal deleteChatHistory(id:str) emitted to indicate, that this chat history 27 @signal deleteChatHistory(id:str) emitted to indicate, that this chat history
26 should be deleted 28 should be deleted
27 @signal newChatWithHistory(id:str) emitted to indicate, that a new chat using 29 @signal newChatWithHistory(id:str) emitted to indicate, that a new chat using
28 the saved history should be started 30 the saved history should be started
31 @signal viewChatHistory(id:str) emitted to indicate, that this chat history
32 should be shown in a separate window
29 @signal dataChanged(id:str) emitted to indicate a change of the chat history data 33 @signal dataChanged(id:str) emitted to indicate a change of the chat history data
30 """ 34 """
31 35
32 deleteChatHistory = pyqtSignal(str) 36 deleteChatHistory = pyqtSignal(str)
33 newChatWithHistory = pyqtSignal(str) 37 newChatWithHistory = pyqtSignal(str)
38 viewChatHistory = pyqtSignal(str)
34 dataChanged = pyqtSignal(str) 39 dataChanged = pyqtSignal(str)
35 40
36 def __init__(self, title, model, jsonStr=None, parent=None): 41 def __init__(self, title, model, jsonStr=None, parent=None):
37 """ 42 """
38 Constructor 43 Constructor
48 @type QWidget (optional) 53 @type QWidget (optional)
49 """ 54 """
50 super().__init__(parent) 55 super().__init__(parent)
51 self.setupUi(self) 56 self.setupUi(self)
52 57
58 iconSuffix = "-dark" if ericApp().usesDarkPalette() else "-light"
59
53 self.newChatButton.setIcon(EricPixmapCache.getIcon("plus")) 60 self.newChatButton.setIcon(EricPixmapCache.getIcon("plus"))
54 self.editButton.setIcon(EricPixmapCache.getIcon("editRename")) 61 self.editButton.setIcon(EricPixmapCache.getIcon("editRename"))
62 self.viewButton.setIcon(
63 EricPixmapCache.getIcon(
64 os.path.join("OllamaInterface", "icons", "view{0}".format(iconSuffix))
65 )
66 )
55 self.deleteButton.setIcon(EricPixmapCache.getIcon("trash")) 67 self.deleteButton.setIcon(EricPixmapCache.getIcon("trash"))
56 68
57 if jsonStr is None: 69 if jsonStr is None:
58 self.__title = title 70 self.__title = title
59 self.__model = model 71 self.__model = model
130 ) 142 )
131 if ok and bool(title): 143 if ok and bool(title):
132 self.__title = title 144 self.__title = title
133 self.titleEdit.setText(title) 145 self.titleEdit.setText(title)
134 self.dataChanged.emit(self.__id) 146 self.dataChanged.emit(self.__id)
147
148 @pyqtSlot()
149 def on_viewButton_clicked(self):
150 """
151 Private slot to view the current chat history in a separate window..
152 """
153 self.viewChatHistory.emit(self.__id)
135 154
136 def loadFromJson(self, jsonStr): 155 def loadFromJson(self, jsonStr):
137 """ 156 """
138 Public method to load the chat history data from a JSON string. 157 Public method to load the chat history data from a JSON string.
139 158

eric ide

mercurial