mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-04-03 15:51:58 -04:00
DRYer
This commit is contained in:
parent
98094724e8
commit
8987b77f2b
@ -122,6 +122,9 @@ class Input(QWidget):
|
||||
b.clicked.connect(self.send_requested)
|
||||
l.addWidget(b, alignment=Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
def setFocus(self, reason) -> None:
|
||||
self.text_input.setFocus(reason)
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self.text_input.value
|
||||
@ -161,6 +164,9 @@ class ChatWidget(QWidget):
|
||||
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||
self.line_spacing = self.browser.fontMetrics().lineSpacing()
|
||||
|
||||
def setFocus(self, reason) -> None:
|
||||
self.input.setFocus(reason)
|
||||
|
||||
def wrap_content_in_padding_table(self, html: str, background_color: str = '') -> str:
|
||||
style = f'style="background-color: {background_color}"' if background_color else ''
|
||||
return f'''<table width="100%" {style} cellpadding="2"><tr><td>{html}</td></tr></table>'''
|
||||
|
||||
@ -259,7 +259,7 @@ class LLMBookDialog(Dialog):
|
||||
self.llm.close_requested.connect(self.accept)
|
||||
l.addWidget(llm)
|
||||
self.bb.setVisible(False)
|
||||
self.llm.result_display.input.text_input.setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
self.llm.result_display.input.setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
|
||||
def sizeHint(self):
|
||||
return QSize(600, 750)
|
||||
|
||||
@ -240,6 +240,9 @@ class ConverseWidget(QWidget):
|
||||
self.show_initial_message()
|
||||
self.update_cost()
|
||||
|
||||
def setFocus(self, reason) -> None:
|
||||
self.result_display.input.setFocus(reason)
|
||||
|
||||
def language_instruction(self):
|
||||
lang = ui_language_as_english()
|
||||
return f'If you can speak in {lang}, then respond in {lang}.'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user