FreeCAD 0.19 ignores active container color setting

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

FreeCAD 0.19 ignores active container color setting

Post by adrianinsaval »

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18024 (Git)
Build type: Release
Branch: master
Hash: 9cc8f6eb666b0a0ae2dc256f7bc0beb8c987710c
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Spanish/Paraguay (es_PY)
Freecad ignores the active container setting as shown in attached screenshot, making it really ugly and hard to see with some stylesheets (in this case, Darker-blue). I have confirmed the same behavior exist with the AppImage in Manjaro.

After some digging and after taking a quick look at https://github.com/FreeCAD/FreeCAD/comm ... 1a53b3fe6b I believe

Code: Select all

void DocumentItem::slotHighlightObject (const Gui::ViewProviderDocumentObject& obj, const Gui::HighlightMode& high, bool set)
{
    FOREACH_ITEM(item,obj)
        QFont f = item->font(0);
        switch (high) {
        case Gui::Bold: f.setBold(set);             break;
        case Gui::Italic: f.setItalic(set);         break;
        case Gui::Underlined: f.setUnderline(set);  break;
        case Gui::Overlined: f.setOverline(set);    break;
        case Gui::Blue:
            if (set)
                item->setBackgroundColor(0,QColor(200,200,255));
            else
                item->setData(0, Qt::BackgroundColorRole,QVariant());
            break;
        case Gui::LightBlue:
            if (set) {
                ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/TreeView");
                unsigned long col = hGrp->GetUnsigned("TreeActiveColor",3873898495);
                item->setBackgroundColor(0,QColor((col >> 24) & 0xff,(col >> 16) & 0xff,(col >> 8) & 0xff));
            }
            else
                item->setData(0, Qt::BackgroundColorRole,QVariant());
            break;
        default:
            break;
        }

        item->setFont(0,f);
    END_FOREACH_ITEM
}
in src/Gui/Tree.cpp should not have different behaviors for Gui::Blue and Gui::LightBlue but always use the user's preference. I must clarify that I have very little knowledge of C++ and FreeCAD's source code so don't take my word for it.
Attachments
Captura de pantalla (10).png
Captura de pantalla (10).png (176.14 KiB) Viewed 1414 times
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: FreeCAD 0.19 ignores active container color setting

Post by adrianinsaval »

adrianinsaval wrote: Tue Sep 03, 2019 1:26 amAfter some digging and after taking a quick look at https://github.com/FreeCAD/FreeCAD/comm ... 1a53b3fe6b I believe

Code: Select all

void DocumentItem::slotHighlightObject (const Gui::ViewProviderDocumentObject& obj, const Gui::HighlightMode& high, bool set)
{
    FOREACH_ITEM(item,obj)
        QFont f = item->font(0);
        switch (high) {
        case Gui::Bold: f.setBold(set);             break;
        case Gui::Italic: f.setItalic(set);         break;
        case Gui::Underlined: f.setUnderline(set);  break;
        case Gui::Overlined: f.setOverline(set);    break;
        case Gui::Blue:
            if (set)
                item->setBackgroundColor(0,QColor(200,200,255));
            else
                item->setData(0, Qt::BackgroundColorRole,QVariant());
            break;
        case Gui::LightBlue:
            if (set) {
                ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/TreeView");
                unsigned long col = hGrp->GetUnsigned("TreeActiveColor",3873898495);
                item->setBackgroundColor(0,QColor((col >> 24) & 0xff,(col >> 16) & 0xff,(col >> 8) & 0xff));
            }
            else
                item->setData(0, Qt::BackgroundColorRole,QVariant());
            break;
        default:
            break;
        }

        item->setFont(0,f);
    END_FOREACH_ITEM
}
in src/Gui/Tree.cpp should not have different behaviors for Gui::Blue and Gui::LightBlue but always use the user's preference. I must clarify that I have very little knowledge of C++ and FreeCAD's source code so don't take my word for it.
Nevermind, turns out I was looking at the file from that commit, the current one is quite different
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: FreeCAD 0.19 ignores active container color setting

Post by adrianinsaval »

I think one of the commits here is supposed to fix this, can you confirm @realthunder?
realthunder wrote: Mon Sep 02, 2019 3:01 am ping
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: FreeCAD 0.19 ignores active container color setting

Post by realthunder »

adrianinsaval wrote: Thu Sep 05, 2019 2:05 am I think one of the commits here is supposed to fix this, can you confirm @realthunder?
realthunder wrote: Mon Sep 02, 2019 3:01 am ping
Yes, it is.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
Petrikas
Posts: 122
Joined: Sat Dec 05, 2020 8:05 pm

Re: FreeCAD 0.19 ignores active container color setting

Post by Petrikas »

realthunder wrote: Thu Sep 05, 2019 2:49 am
Is Active Container accessible from the QSS stylesheet? I can't seem to be able to describe it.
Should be something along the lines of

QTreeView::item
I sometimes make FreeCAD Tutorials | VertUI | MidnightUI
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: FreeCAD 0.19 ignores active container color setting

Post by realthunder »

Petrikas wrote: Fri Jan 14, 2022 5:12 pm
realthunder wrote: Thu Sep 05, 2019 2:49 am
Is Active Container accessible from the QSS stylesheet? I can't seem to be able to describe it.
Should be something along the lines of

QTreeView::item
No. It is configurable through parameter BaseApp/Preferences/TreeView/TreeActiveColor (unsigned type). The font can be configured through parameters TreeActiveBold/Italic/Underline/Overlined (all boolean types). You may also want to change TreeEditColor, the background color for the editing object.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
Petrikas
Posts: 122
Joined: Sat Dec 05, 2020 8:05 pm

Re: FreeCAD 0.19 ignores active container color setting

Post by Petrikas »

realthunder wrote: Mon Jan 17, 2022 4:20 am
Petrikas wrote: Fri Jan 14, 2022 5:12 pm
realthunder wrote: Thu Sep 05, 2019 2:49 am
Is Active Container accessible from the QSS stylesheet? I can't seem to be able to describe it.
Should be something along the lines of

QTreeView::item
No. It is configurable through parameter BaseApp/Preferences/TreeView/TreeActiveColor (unsigned type). The font can be configured through parameters TreeActiveBold/Italic/Underline/Overlined (all boolean types). You may also want to change TreeEditColor, the background color for the editing object.
Thanks for the reply.
The issue arises when I try something fancy with the tree, like adding borders or rounding corners.
Doesn't matter, just checking. Thanks again!
I sometimes make FreeCAD Tutorials | VertUI | MidnightUI
Post Reply