Target Spreadsheet Aliased Cell Color through .qss? (FreeCAD 0.20.1)

A forum for research and development of the user interface of FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Axeia
Posts: 19
Joined: Sun Oct 02, 2022 9:42 pm
Location: United Kingdom
Contact:

Target Spreadsheet Aliased Cell Color through .qss? (FreeCAD 0.20.1)

Post by Axeia »

Hello,

I'm working on a Dark Theme as all the included dark themes weren't quite dark enough for my tastes and many had weird little glitches.
My theme is based on the by default included Dark-Contrast one, I am running into a problem with aliased spreadsheet cells. By default these have a yellow background color, as I have set my spreadsheet cells to have a white foreground (font) color this gives me white on yellow which is unreadable.
Image
If I set a background-color on all spreadsheet cells the yellow color gets overwritten but then aliased cells don't stand out.
ImageDoomed if I do, doomed if I don't. Is there a way to target an aliased cell specifically? Does it have a special attribute that can be targeted?

I have tracked down the line of code in FreeCADthat sets the yellow color if no background color is set over here:
https://github.com/FreeCAD/FreeCAD/blob ... el.cpp#L56

Code: Select all

aliasBgColor = QColor(Base::Tools::fromStdString(hGrp->GetASCII("AliasedCellBackgroundColor", "#feff9e")));
Which seems to mean if the cell has a background color, use that, if not make it yellow.

I have no experience with Qt/C++ so I'm not quite sure what good this does me other than figuring out that aliased cells have a tooltip and perhaps elements with a tooltip can be selected through QSS somehow. Unless I'm overlooking it there doesn't seem to be anything set on the cell that would be equal to the CSS equivalent of a class.

Can anyone that's more knowledgeable about Qt/C++ help me out here? Can I target aliased cells in qss somehow? Should I submit a feature request on github for it to be added if not?

[edit]
I tried (to no avail)

Code: Select all

QTableView::item[tooltip], QTableView::item[toolTip], QTableView::item[Tooltip]{
    background: black;
}
Last edited by Axeia on Tue Oct 04, 2022 2:51 pm, edited 1 time in total.
User avatar
onekk
Veteran
Posts: 6149
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Target Spreadsheet Aliased Cell Color through .qss?

Post by onekk »

Hello, maybe it is something similar to this problem:

https://forum.freecadweb.org/viewtopic.php?f=34&t=50744

Probably a less verbose title will make clear that you can't find a way to change a color.

As from the post linked seems that something has been changed, and your post is not telling what FC version you are targeting it is hard to tell if using latest dev version (if changes are already packaged for OS you are using) it will solve this problem.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Target Spreadsheet Aliased Cell Color through .qss?

Post by Kunda1 »

An aside, @Axeia can you share the location of your repo. I'd like to add you to https://github.com/FreeCAD/FreeCAD-addons/issues/201 if you don't mind?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
MisterMaker
Posts: 740
Joined: Mon Sep 21, 2020 7:41 am

Re: Target Spreadsheet Aliased Cell Color through .qss?

Post by MisterMaker »

It's btw weird that below text has the correct white color if you don't use the setting.
Image
But it also changes when you add the setting, feels like that text has some parameters that spreadsheet text should have.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Target Spreadsheet Aliased Cell Color through .qss?

Post by adrianinsaval »

it's using the same widget type as the spreadsheet probably.
User avatar
MisterMaker
Posts: 740
Joined: Mon Sep 21, 2020 7:41 am

Re: Target Spreadsheet Aliased Cell Color through .qss?

Post by MisterMaker »

I tried this:

Code: Select all

QTableView {
  qproperty-AliasedCellBackgroundColor: #f700ff;
  qproperty-aliasBgColor: #f700ff;
}
And some versions of that code, but non worked. Not sure why it doesn't work.
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Target Spreadsheet Aliased Cell Color through .qss?

Post by chennes »

The aliased cell background color is set in User.cfg, not in the QSS file, unfortunately. It sounds like a good adjustment to me, to make that a QProperty that can then be set via QSS, however.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
MisterMaker
Posts: 740
Joined: Mon Sep 21, 2020 7:41 am

Re: Target Spreadsheet Aliased Cell Color through .qss?

Post by MisterMaker »

chennes wrote: Mon Oct 03, 2022 6:47 pm The aliased cell background color is set in User.cfg, not in the QSS file, unfortunately. It sounds like a good adjustment to me, to make that a QProperty that can then be set via QSS, however.
I thought it would be possible to set it true the preference pack settings but I also get no results.
I added this:

Code: Select all

          <FCParamGroup Name="Spreadsheet">
            <FCUInt Name="aliasBgColor" Value="2105376255"/>
            <FCUInt Name="textFgColor" Value="2105376255"/>
            <FCUInt Name="positiveFgColor" Value="2105376255"/>
            <FCUInt Name="negativeFgColor" Value="4294967295"/>
          </FCParamGroup>
These settings are also not in the user.cfg.
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Target Spreadsheet Aliased Cell Color through .qss?

Post by chennes »

You need to set "AliasedCellBackgroundColor".
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Axeia
Posts: 19
Joined: Sun Oct 02, 2022 9:42 pm
Location: United Kingdom
Contact:

Re: Target Spreadsheet Aliased Cell Color through .qss?

Post by Axeia »

onekk wrote: Mon Oct 03, 2022 7:55 am Hello, maybe it is something similar to this problem:

https://forum.freecadweb.org/viewtopic.php?f=34&t=50744

Probably a less verbose title will make clear that you can't find a way to change a color.

As from the post linked seems that something has been changed, and your post is not telling what FC version you are targeting it is hard to tell if using latest dev version (if changes are already packaged for OS you are using) it will solve this problem.

Regards

Carlo D.
Ah I ran into that post a bit earlier in my theme creating journey as that was indeed another thing that was a bit hard to style, but the DarkPro stylesheet actually manages to target that one so I copied the code from there for my own theme (I actually created a git pull request that fixes all the 'Darker' stylesheets fixing that one).

I should have indeed mentioned my FreeCad version, I'm on 0.20.1 (Revision 29410) and I'm using Windows 10.
I'll append it to the title but I'll leave the rest of it it as it is. It's succinct but should get the point across in this part of the forum :)

---

If changes are made to the FreeCAD code I'd be in support of simply adding a class named "alias" or "aliased" so themes can simply target it as

Code: Select all

QTableView::item.aliased{
    background-color: teal;
}
It's a lot easier to read than the the whole "qproperty-AliasedCellBackgroundColor" syntax. It also makes it easier for people (like me) that have a CSS rather than a Qt Style Sheets background to understand what's going on.
Post Reply