Gui: Add functionality to enable/disable block shape cursor in text editor and console

This commit is contained in:
marioalexis
2022-01-26 00:07:47 -03:00
committed by wwmayer
parent 4b2e707018
commit ec167207bf
6 changed files with 88 additions and 16 deletions

View File

@@ -488,14 +488,15 @@ void PythonConsole::OnChange( Base::Subject<const char*> &rCaller,const char* sR
{
Q_UNUSED(rCaller);
ParameterGrp::handle hPrefGrp = getWindowParameter();
ParameterGrp::handle hPrefGen = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("General");
bool pythonWordWrap = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("General")->GetBool("PythonWordWrap", true);
if (pythonWordWrap) {
this->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
} else {
this->setWordWrapMode(QTextOption::NoWrap);
if (strcmp(sReason, "PythonWordWrap") == 0) {
bool pythonWordWrap = hPrefGen->GetBool("PythonWordWrap", true);
if (pythonWordWrap)
setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
else
setWordWrapMode(QTextOption::NoWrap);
}
if (strcmp(sReason, "FontSize") == 0 || strcmp(sReason, "Font") == 0) {
@@ -511,7 +512,8 @@ void PythonConsole::OnChange( Base::Subject<const char*> &rCaller,const char* sR
#else
setTabStopDistance(width);
#endif
} else {
}
else {
QMap<QString, QColor>::ConstIterator it = d->colormap.find(QString::fromLatin1(sReason));
if (it != d->colormap.end()) {
QColor color = it.value();
@@ -523,6 +525,16 @@ void PythonConsole::OnChange( Base::Subject<const char*> &rCaller,const char* sR
pythonSyntax->setColor(QString::fromLatin1(sReason), color);
}
}
if (strcmp(sReason, "PythonBlockCursor") == 0 ||
strcmp(sReason, "FontSize") == 0 ||
strcmp(sReason, "Font") == 0) {
bool block = hPrefGen->GetBool("PythonBlockCursor", false);
if (block)
setCursorWidth(QFontMetrics(font()).averageCharWidth());
else
setCursorWidth(1);
}
}
/**