Gui: Remove code duplication in PythonConsole class

This commit is contained in:
wmayer
2024-12-25 19:19:23 +01:00
committed by Yorik van Havre
parent 446b6e6d41
commit 71f8793310
4 changed files with 25 additions and 55 deletions

View File

@@ -87,6 +87,25 @@ PythonEditor::~PythonEditor()
delete d;
}
void PythonEditor::OnChange(Base::Subject<const char*> &rCaller, const char* sReason)
{
const auto & rGrp = static_cast<ParameterGrp &>(rCaller);
if (strcmp(sReason, "EnableBlockCursor") == 0 ||
strcmp(sReason, "FontSize") == 0 ||
strcmp(sReason, "Font") == 0) {
bool block = rGrp.GetBool("EnableBlockCursor", false);
if (block) {
setCursorWidth(QFontMetrics(font()).averageCharWidth());
}
else {
setCursorWidth(1);
}
}
TextEditor::OnChange(rCaller, sReason);
}
void PythonEditor::setFileName(const QString& fn)
{
d->filename = fn;