OllamaInterface/OllamaWidget.py

changeset 68
ca2e671f894e
parent 67
3c2bcbf7eeaf
equal deleted inserted replaced
67:3c2bcbf7eeaf 68:ca2e671f894e
10 import contextlib 10 import contextlib
11 import json 11 import json
12 import os 12 import os
13 import shutil 13 import shutil
14 14
15 from PyQt6.QtCore import QProcess, QProcessEnvironment, Qt, QTimer, QUrl, pyqtSlot 15 from PyQt6.QtCore import (
16 QEvent,
17 QProcess,
18 QProcessEnvironment,
19 Qt,
20 QTimer,
21 QUrl,
22 pyqtSlot,
23 )
16 from PyQt6.QtGui import QDesktopServices 24 from PyQt6.QtGui import QDesktopServices
17 from PyQt6.QtWidgets import ( 25 from PyQt6.QtWidgets import (
18 QDialog, 26 QDialog,
19 QInputDialog, 27 QInputDialog,
20 QLineEdit, 28 QLineEdit,
59 @param parent reference to the parent widget (defaults to None) 67 @param parent reference to the parent widget (defaults to None)
60 @type QWidget (optional) 68 @type QWidget (optional)
61 """ 69 """
62 super().__init__(parent) 70 super().__init__(parent)
63 self.setupUi(self) 71 self.setupUi(self)
72
73 self.messageEdit.installEventFilter(self)
64 74
65 self.__plugin = plugin 75 self.__plugin = plugin
66 self.__client = OllamaClient(plugin, self) 76 self.__client = OllamaClient(plugin, self)
67 77
68 if fromEric: 78 if fromEric:
1152 """ 1162 """
1153 if self.__pullProgressDialog is not None and self.__pulling: 1163 if self.__pullProgressDialog is not None and self.__pulling:
1154 self.__pullProgressDialog.setFinished(True) 1164 self.__pullProgressDialog.setFinished(True)
1155 self.__pulling = False 1165 self.__pulling = False
1156 self.__client.list() 1166 self.__client.list()
1167
1168 def eventFilter(self, obj, evt):
1169 """
1170 Public method to process some events for the message edit.
1171
1172 @param obj reference to the object the event was meant for
1173 @type QObject
1174 @param evt reference to the event object
1175 @type QEvent
1176 @return flag to indicate that the event was handled
1177 @rtype bool
1178 """
1179 if (
1180 obj is self.messageEdit
1181 and evt.type() == QEvent.Type.KeyPress
1182 and evt.key() in (Qt.Key.Key_Return, Qt.Key.Key_Enter)
1183 and evt.modifiers() == Qt.KeyboardModifier.ControlModifier
1184 ):
1185 # Ctrl-Enter or Ctrl-Return => commit
1186 self.sendButton.animateClick()
1187 return True
1188 else:
1189 # standard event processing
1190 return super().eventFilter(obj, evt)

eric ide

mercurial