Tue, 10 Dec 2024 15:48:48 +0100
Updated copyright for 2025.
# -*- coding: utf-8 -*- # Copyright (c) 2024 - 2025 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing a dialog to edit parameters of a chat history. """ from PyQt6.QtCore import pyqtSlot from PyQt6.QtWidgets import QDialog, QDialogButtonBox from .Ui_OllamaHistoryEditDialog import Ui_OllamaHistoryEditDialog class OllamaHistoryEditDialog(QDialog, Ui_OllamaHistoryEditDialog): """ Class implementing a dialog to edit parameters of a chat history. """ def __init__(self, title, model, selectableModels, parent=None): """ Constructor @param title title of the chat @type str @param model current model used by the chat @type str @param selectableModels list of available models @type list of str @param parent reference to the parent widget (defaults to None) @type QWidget (optional) """ super().__init__(parent) self.setupUi(self) self.modelComboBox.addItems(selectableModels) self.chatTitleEdit.setText(title) self.modelComboBox.setCurrentText(model) msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) @pyqtSlot(str) def on_chatTitleEdit_textChanged(self, title): """ Private slot to handle a change of the chat title. @param title entered title text @type str """ self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( bool(title) ) def getData(self): """ Public method to retrieve the entered chat parameters. @return tuple containing the entered chat title and the selected model name @rtype tuple of (str, str) """ return ( self.chatTitleEdit.text(), self.modelComboBox.currentText(), )