Ruler widget name
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
- petevick
- Premier Member
- Posts: 392
- Joined: Tue May 19, 2020 9:34 am
- Location: North Norfolk coast UK
Ruler widget name
I'd like to add the ability to change the colours for the ruler in Qcad with my theme apps, but I can't find the name of the ruler widget. Searching Github I came across RRuler and RRulerQt, neither of which work, I've also tried QRuler, but again no go. If anyone knows what the name is, or even if it's possible to change the ruler colours, I'd be grateful.
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Qcad Pro 3.29.6
Linux Mint 21.2 Cinnamon, Qcad Pro 3.29.6
Re: Ruler widget name
Pete,
Looked into that.
I think it is more then just one setting for one ruler, remember that there are up to 4 viewports with each 2 rulers (or not by preferences).
See Application or Drawing Preferences .. Layout .. Viewports
I did a search too but I perform a textual search with Notepad++ in a full local copy of all the files on GitHub.
In DefaultNavigation.js I discover that it retrieves HorizontalRuler & VerticalRuler of the presented widget (Probably a viewport).
And that it updates these depending a mouseMoveEvent or for scrolling/panning/zooming with simulateMouseMoveEvent
It resurface in ViewportWidget.js where a viewport widget is created.
The default widget layout is sourced from ViewportWidgetQt.ui
The HorizontalRuler & VerticalRuler of this ui file are nothing but empty space.
All this is very complex, there are several events to listen to, values and tick marks need to be spaced in any user format, on any kind of display.
In fact, it is the essence of how we navigate in a drawing document, what part of the geometry is shown, scrollbars, grid and so on.
It must be clear that this is repainted on almost everything we do in the QCAD GUI.
I then suspect this is handled in C++.
Searched further and I don't think you can really solve this:
Both rulers of ViewportWidgetQt.ui are of the RRulerQt class ...
RRulerQt.cpp >> RRulerQt::getFont()
The font to draw labels in is always sourced from RSettings (=Preferences).
RRulerQt.cpp >> RRulerQt::paintTick(int pos, bool major, const QString& label)
Line 126 and further: https://github.com/qcad/qcad/blob/1c5e3 ... t.cpp#L126
This paints a single tick mark in the ruler bar and adds some text if provided:
It seems that the colors are hard-coded depending the GUI background e.g.:
painter->setPen(darkGuiBackground==1 ? Qt::white : Qt::black);
A black and then a white mark for the dark theme and reversed on all others.
The second painter then actually draws the label text ifso, and this is not a text or a label field at all.
Regards,
CVH
Looked into that.
I think it is more then just one setting for one ruler, remember that there are up to 4 viewports with each 2 rulers (or not by preferences).
See Application or Drawing Preferences .. Layout .. Viewports
I did a search too but I perform a textual search with Notepad++ in a full local copy of all the files on GitHub.
In DefaultNavigation.js I discover that it retrieves HorizontalRuler & VerticalRuler of the presented widget (Probably a viewport).
And that it updates these depending a mouseMoveEvent or for scrolling/panning/zooming with simulateMouseMoveEvent
It resurface in ViewportWidget.js where a viewport widget is created.
The default widget layout is sourced from ViewportWidgetQt.ui
The HorizontalRuler & VerticalRuler of this ui file are nothing but empty space.
All this is very complex, there are several events to listen to, values and tick marks need to be spaced in any user format, on any kind of display.
In fact, it is the essence of how we navigate in a drawing document, what part of the geometry is shown, scrollbars, grid and so on.
It must be clear that this is repainted on almost everything we do in the QCAD GUI.
I then suspect this is handled in C++.
Searched further and I don't think you can really solve this:
Both rulers of ViewportWidgetQt.ui are of the RRulerQt class ...
RRulerQt.cpp >> RRulerQt::getFont()
The font to draw labels in is always sourced from RSettings (=Preferences).
RRulerQt.cpp >> RRulerQt::paintTick(int pos, bool major, const QString& label)
Line 126 and further: https://github.com/qcad/qcad/blob/1c5e3 ... t.cpp#L126
This paints a single tick mark in the ruler bar and adds some text if provided:
It seems that the colors are hard-coded depending the GUI background e.g.:
painter->setPen(darkGuiBackground==1 ? Qt::white : Qt::black);
A black and then a white mark for the dark theme and reversed on all others.
The second painter then actually draws the label text ifso, and this is not a text or a label field at all.
Regards,
CVH
- petevick
- Premier Member
- Posts: 392
- Joined: Tue May 19, 2020 9:34 am
- Location: North Norfolk coast UK
Re: Ruler widget name
That's the conclusion I came to as well
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Qcad Pro 3.29.6
Linux Mint 21.2 Cinnamon, Qcad Pro 3.29.6