Skip to content

Commit f69e022

Browse files
committed
Bugfix #2
1 parent bb4e61c commit f69e022

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

pyqt_openai/chat_widget/center/commandSuggestionWidget.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
from PySide6.QtCore import Signal
12
from PySide6.QtWidgets import QListWidget, QWidget, QVBoxLayout, QLabel
23

34
from pyqt_openai.lang.translations import LangClass
45

56

67
class CommandSuggestionWidget(QWidget):
8+
toggleCommandSuggestion = Signal(bool)
9+
710
def __init__(self, parent=None):
811
super().__init__(parent)
912
self.__initUi()
@@ -29,3 +32,9 @@ def onCountChanged(self):
2932
scrollbarHeight = self.__commandList.verticalScrollBar().sizeHint().height()
3033
totalHeight = contentHeight + itemHeight
3134
self.setMaximumHeight(totalHeight + scrollbarHeight)
35+
36+
def showEvent(self, event):
37+
self.toggleCommandSuggestion.emit(True)
38+
39+
def hideEvent(self, event):
40+
self.toggleCommandSuggestion.emit(False)

pyqt_openai/chat_widget/center/prompt.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ def __initUi(self):
8787

8888
# Create the command suggestion list
8989
self.__suggestionWidget = CommandSuggestionWidget()
90+
self.__suggestionWidget.toggleCommandSuggestion.connect(
91+
self.__setCommandSuggestionEnabled
92+
)
9093
self.__suggestion_list = self.__suggestionWidget.getCommandList()
9194

9295
self.__uploadedImageFileWidget = UploadedImageFileWidget()
@@ -247,6 +250,13 @@ def __getEveryPromptCommands(self, get_name_only=False):
247250
return [obj["name"] for obj in self.__p_grp]
248251
return self.__p_grp
249252

253+
def __setCommandSuggestionEnabled(self, f):
254+
for w in self.__textEditGroup.getGroup().values():
255+
if isinstance(w, JSONEditor):
256+
pass
257+
else:
258+
w.setCommandSuggestionEnabled(f)
259+
250260
def __updateSuggestions(self):
251261
w = self.__textEditGroup.getCurrentTextEdit()
252262
if w and self.__commandEnabled:
@@ -257,7 +267,6 @@ def __updateSuggestions(self):
257267
input_text_chunk = input_text_chunk[-1]
258268
starts_with_f = input_text_chunk.startswith("/")
259269
self.__suggestionWidget.setVisible(starts_with_f)
260-
w.setCommandSuggestionEnabled(starts_with_f)
261270
if starts_with_f:
262271
command_word = input_text_chunk[1:]
263272
# Set every prompt commands first
@@ -339,7 +348,6 @@ def __showEnding(self, f):
339348

340349
def __supportPromptCommand(self, f):
341350
self.__commandEnabled = f
342-
self.__textEditGroup.setCommandEnabled(f)
343351

344352
def __readingFiles(self):
345353
filenames = QFileDialog.getOpenFileNames(

pyqt_openai/chat_widget/center/textEditPromptGroup.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ def getCurrentTextEdit(self):
9595
if w.hasFocus():
9696
return w
9797

98-
def setCommandEnabled(self, f: bool):
99-
for w in self.__textGroup.values():
100-
if isinstance(w, TextEditPrompt):
101-
w.setCommandSuggestionEnabled(f)
102-
10398
def adjustHeight(self) -> int:
10499
"""
105100
Adjust overall height of text edit group based on their contents and return adjusted height

0 commit comments

Comments
 (0)