Possible New User: Question About Menus/Icons

Do you have a question you want to ask an existing QCAD user about QCAD and what you can do with it? Do you want to know if a particular feature exists? This is the place to ask.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

CVH
Premier Member
Posts: 3480
Joined: Wed Sep 27, 2017 4:17 pm

Re: Possible New User: Question About Menus/Icons

Post by CVH » Fri Nov 17, 2023 7:18 am

Hi, John
John Hyslop wrote:
Fri Nov 17, 2023 6:54 am
The two buttons are "Make All White Layers Black" & Make All Black Layers White"
These methods are from the Misc section and have no associated icon.

The (Pro) scripts are named:
LayerBlackToWhite.js
LayerWhiteToBlack.js

Following Andrew's notes you then need to include under the Themes folder an 'icons' folder with:
LayerBlackToWhite.svg
LayerWhiteToBlack.svg

Unsure if this works because the initialization of these scripts don't call for an icon.
Let us know. :wink:

I think that for the QCAD Dark Theme you also need to include:
LayerBlackToWhite-inverse.svg
LayerWhiteToBlack-inverse.svg
-> With an identical look of course :lol: :P :wink:

Related Topic: https://www.qcad.org/rsforum/viewtopic. ... 41&p=37075

Regards,
CVH
Last edited by CVH on Fri Nov 17, 2023 8:41 am, edited 2 times in total.

John Hyslop
Premier Member
Posts: 474
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Possible New User: Question About Menus/Icons

Post by John Hyslop » Fri Nov 17, 2023 7:44 am

Hi CVH

Thanks for the reply, it didn't work though :(
Also I'm not using a dark theme so I didn't saveas the other name..
I'll upload the svg's if yourself or anyone else could try..

Thanks
John Hyslop
LayerWhiteToBlack.svg
(851 Bytes) Downloaded 277 times
LayerBlackToWhite.svg
(851 Bytes) Downloaded 271 times
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

CVH
Premier Member
Posts: 3480
Joined: Wed Sep 27, 2017 4:17 pm

Re: Possible New User: Question About Menus/Icons

Post by CVH » Fri Nov 17, 2023 8:06 am

John Hyslop wrote:
Fri Nov 17, 2023 7:44 am
Thanks for the reply, it didn't work though
I'll upload the svg's if yourself or anyone else could try..
One of the problems I am facing is that there is no 'Default' Theme listed under themes ....

Another is that there is no icon associated initially .... Remark that these are snippets from proprietary code
Not that there are big secrets in there ... Kinda common practice for addons :wink:

Code: Select all

LayerWhiteToBlack.init = function(basePath) {
    var action = new RGuiAction(qsTr("Make all White Layers Black"), RMainWindowQt.getMainWindow());
    action.setRequiresDocument(true);
    action.setScriptFile(basePath + "/LayerWhiteToBlack.js");
    action.setGroupSortOrder(78100);
    action.setSortOrder(200);
    action.setWidgetNames(["MiscLayerMenu", "MiscLayerToolBar", "MiscLayerToolsPanel"]);
};

Code: Select all

LayerBlackToWhite.init = function(basePath) {
    var action = new RGuiAction(qsTr("Make all Black Layers White"), RMainWindowQt.getMainWindow());
    action.setRequiresDocument(true);
    action.setScriptFile(basePath + "/LayerBlackToWhite.js");
    action.setGroupSortOrder(78100);
    action.setSortOrder(300);
    action.setWidgetNames(["MiscLayerMenu", "MiscLayerToolBar", "MiscLayerToolsPanel"]);
};
Missing in both: action.setIcon(basePath + "/abcxyz.svg"); with the appropriate svg filename.
And then there is probably nothing to supersede ...

Regards,
CVH
Last edited by CVH on Fri Nov 17, 2023 8:20 am, edited 2 times in total.

John Hyslop
Premier Member
Posts: 474
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Possible New User: Question About Menus/Icons

Post by John Hyslop » Fri Nov 17, 2023 8:15 am

OK

Thanks for confirming.. :)

Cheers
John Hyslop
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

CVH
Premier Member
Posts: 3480
Joined: Wed Sep 27, 2017 4:17 pm

Re: Possible New User: Question About Menus/Icons

Post by CVH » Fri Nov 17, 2023 9:12 am

John,
I was able to force at least one of your icons with a little script using the Script Shell :wink:
The other is basically a textual swap or simply iterate further until both are found and updated.

Code: Select all

var actions = RGuiAction.getActions();
for (var c=0; c<actions.length; ++c) {
    var a = actions[c];
    var className = a.getScriptClass();
    if (className.startsWith("LayerBlackToWhite")) {
        a.setIcon("C:/Program Files/QCAD/themes/Default/icons/LayerBlackToWhite.svg");
        break;
    }
}
Confirming what I wrote earlier:
CVH wrote:
Tue Nov 14, 2023 8:24 am
Maybe it is possible to alter all parameters for all RGuiAction's.
First hurdle would be a list of things. :|
In this way they only last for the current session of course. :(

Regards,
CVH

Post Reply

Return to “Pre-sales Questions”