[Issue] Multiline Textfield with Dark Themes

A forum for research and development of the user interface of FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
balrobs
Posts: 449
Joined: Fri Apr 24, 2020 8:58 pm

[Issue] Multiline Textfield with Dark Themes

Post by balrobs »

Recently I noticed an issue with the multiline-textfield while using the ExtremeProDark Theme. So I investigated on other three Dark Themes (Dracula, ProDarkThemePack and Behave-Dark Colors) and discovered that:
  • all of them show an inconsistency between singleline and multiline textfields
  • the multiline textfield is only readable with the Behave-Dark Colors Theme
Behave-Dark Colors Theme:
Behave-Dark Colors.png
Behave-Dark Colors.png (56.34 KiB) Viewed 2310 times
Dracula Theme:
Dracula.png
Dracula.png (55.01 KiB) Viewed 2310 times
ExtremeProDark Theme:
ExtremeProDark.png
ExtremeProDark.png (54.37 KiB) Viewed 2310 times
ProDarkThemePack Theme:
ProDarkThemePack.png
ProDarkThemePack.png (55.79 KiB) Viewed 2310 times
Edit: Forgot my system info:

Code: Select all

OS: Ubuntu Core 20 (ubuntu:GNOME/ubuntu)
Word size of FreeCAD: 64-bit
Version: 0.21.29856 (Git) Snap 177
Build type: Release
Branch: master
Hash: a6fbd74caeed6c9f55041ee82ec227c12bc11900
Python 3.8.10, Qt 5.15.3, Coin 4.0.0, Vtk 7.1.1, OCC 7.6.2
Locale: English/United States (en_US)
Installed mods: 
  * BIM 2021.12.0
  * Behave-Dark-Colors 0.1.1
  * ProDarkThemePreferencePack 1.0.0
  * FEM_FrontISTR 0.1.0
  * ExtremeProDark 1.0.3
  * Dracula 0.0.2
User avatar
MisterMaker
Posts: 739
Joined: Mon Sep 21, 2020 7:41 am

Re: [Issue] Multiline Textfield with Dark Themes

Post by MisterMaker »

I have seen this issue in the python console and I fixed it too there, not sure if it's the same style and I forgot too publish the fix.... I'll have a look at it tomorrow.
balrobs
Posts: 449
Joined: Fri Apr 24, 2020 8:58 pm

Re: [Issue] Multiline Textfield with Dark Themes

Post by balrobs »

Thanks @Mistermaker for picking up the issue and for your wonderfull work.
Greetings
User avatar
MisterMaker
Posts: 739
Joined: Mon Sep 21, 2020 7:41 am

Re: [Issue] Multiline Textfield with Dark Themes

Post by MisterMaker »

This doesn't seem to be themed anywhere. It's just default color everywhere.
I think it has to do with qlineedit cursor position. But can't find any examples on how to put this in a theme.
Maybe @wandererfan knows how it is enabled then we probably can give it a name?
https://doc.qt.io/qt-6/qlineedit.html#c ... ition-prop
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Issue] Multiline Textfield with Dark Themes

Post by wandererfan »

MisterMaker wrote: Tue Aug 02, 2022 8:22 am Maybe @wandererfan knows how it is enabled then we probably can give it a name?
The annotation text is an App::PropertyStringList, so the PropertyEditor needs to be tweaked. Either PropertyStringListItem in PropertyItem.cpp, or maybe Gui:LabelEditor in Widgets.cpp.

The template fields are updated by TechDraw/Gui/DlgTemplateField.cpp/DlgTemplateField.ui.

I don't know much about stylesheets, so I'm not sure why one respects the stylesheet and the other doesn't.
User avatar
MisterMaker
Posts: 739
Joined: Mon Sep 21, 2020 7:41 am

Re: [Issue] Multiline Textfield with Dark Themes

Post by MisterMaker »

@wandererfan Thanks for the help, I digged around and still don't understand why this multi-line box that skips the stylesheet, also don't understand why/how it has line numbers and why the cursor line is marked.
At least I know what is called: "leInput"!

Code: Select all

        leInput = new QLineEdit(TechDrawGui__dlgTemplateField);
        leInput->setObjectName(QString::fromUtf8("leInput"));
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Issue] Multiline Textfield with Dark Themes

Post by wandererfan »

MisterMaker wrote: Tue Aug 02, 2022 8:10 pm At least I know what is called: "leInput"!
leInput -> leProcessing -> leOutput? :D

I think you're looking for these classes in Gui/Widgets.cpp:
class GuiExport PropertyListEditor : public QPlainTextEdit
class GuiExport LabelEditor : public QWidget
class LineNumberArea : public QWidget

The yellow colour is hard coded here:

Code: Select all

void PropertyListEditor::highlightCurrentLine()
{
    QList<QTextEdit::ExtraSelection> extraSelections;
    if (!isReadOnly()) {
        QTextEdit::ExtraSelection selection;

        QColor lineColor = QColor(Qt::yellow).lighter(160); //<<<<<<<<<<

        selection.format.setBackground(lineColor);
        selection.format.setProperty(QTextFormat::FullWidthSelection, true);
        selection.cursor = textCursor();
        selection.cursor.clearSelection();
        extraSelections.append(selection);
    }

    setExtraSelections(extraSelections);
}
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Issue] Multiline Textfield with Dark Themes

Post by wandererfan »

This change:

Code: Select all

        //        QColor lineColor = QColor(Qt::yellow).lighter(160);
        QPalette palette = QGuiApplication::palette();
        QColor lineColor = palette.color(QPalette::Highlight);
        selection.format.setBackground(lineColor);
        QColor textColor = palette.color(QPalette::HighlightedText);
        selection.format.setForeground(textColor);
gets you this:
propertyList_behave.png
propertyList_behave.png (7.03 KiB) Viewed 1869 times
"no stylesheet" and the couple of stylesheets I tried looked good, but I didn't try them all.
balrobs
Posts: 449
Joined: Fri Apr 24, 2020 8:58 pm

Re: [Issue] Multiline Textfield with Dark Themes

Post by balrobs »

Wow, this is why I love FreeCad. A few days and issues get solved :D
Post Reply