Closed Kebap closed 4 years ago
That is a fundament limit to setting the Application stylesheet - it is by definition global in scope and there is no way around THAT. It might be possible to focus the effect by making it more specific - added a name qualifier to the TConsole
in that styling code (see: https://doc.qt.io/qt-5/stylesheet-examples.html#style-sheet-usage) so that it only applies to the TConsole for that profile - need to see whether the object name gets set for that TConsole
instance - yes, most of them do and for the main profile console it is give the name of the profile:
void mudlet::addConsoleForNewHost(Host* pH)
{
if (mConsoleMap.contains(pH)) {
return;
}
pH->mLogStatus = mAutolog;
auto pConsole = new TConsole(pH, TConsole::MainConsole);
if (!pConsole) {
return;
}
pH->mpConsole = pConsole;
pConsole->setWindowTitle(pH->getName());
pConsole->setObjectName(pH->getName());
mConsoleMap[pH] = pConsole;
therefore it is possible to limit the scope of the above (for a profile called "Clessidra") with a:
setAppStyleSheet([[TConsole#Clessidra QScrollBar:vertical
So I do not think this is anything that can be fixed from Mudlet - rather the producers of packages that style things like this need to be a bit more selective about what they are styling.
:+1: would be great if we could do this automatically from Mudlet - does @SlySven's suggestion work, @Kebap ?
This is also something we talked about in https://github.com/Mudlet/Mudlet/issues/2393#issuecomment-470434939.
Hey, this is Clessidra package developer speaking :-P
I think we can close #2393 and maybe someone can update docs about that to avoid the same problem.
Thanks Slyven to find the fix for us!
So the fix works well as-is, @wiploo?
In that case we could add a setProfileStyleSheet()
that basically does setAppStyleSheet([[TConsole#Clessidra <stylesheet here>]])
... :) and it'll be more discoverable and easier to use rather than a documented workaround.
Note that that specifically targets the main console - if it is needed for other ones either those superimposed on the main one or those that are separate floating/dockable ones then the styling will need to be applied to those as well. In the future we may want to provide a means to apply a Qt dynamic-property (with (bool) QObject::setProperty(const char *name, const QVariant &value)
) to various types of QObject
s so that they can be targetted like this as a group - one thing we could do is:
pConsole->setWindowTitle(pH->getName());
pConsole->setObjectName(pH->getName());
+ pConsole->setProperty("profileName", pH->getName());
and repeat that for other items that we create for each profile so that a package can create profile specific styling, e.g. for the example situation:
setAppStyleSheet([[TConsole[profileName="]] .. getProfileName() .. [["] QScrollBar:vertical
We do need to:
getAppStyleSheet()
Lua function - so that each profile can, with care, arrange to supplement rather than replace any existing style sheetsetAppStyleSheet(...)
to actually be stored by the Mudlet application separately and then concatenated with those of any other profiles - and in the future with Mudlet's own {which I intimated at in the comment for #2470 but haven't gotten around to finishing (which will restore an appropriate text colour scheme to the trigger items depending on whether the user checks/clears a dark/light desktop theme checkbox option)}this will help to get around the current problem that will result from two profiles BOTH trying to set application stylesheets - at present only the last one will get to be used.
Mhhh, what is the best workaround?
setAppStyleSheet([[TConsole[profileName="]] .. getProfileName() .. [["] QScrollBar:vertical
or
setAppStyleSheet([[TConsole#]] .. getProfileName() .. [[ QScrollBar:vertical
Now I use the second one, but your are the boss :-D
👍 would be great if we could do this automatically from Mudlet - does @SlySven's suggestion work, @Kebap ?
Yes, Clessidra already fixed this in their package. <3 Thanks for the quick turn-around!
The second one is already in place - but I am just put in a PR that does the first (with ProfileName
rather than profileName
) in #3373 .
Brief summary of issue / Description of requested feature:
Connecting to Clessidra changes lots of UI. Some even for other profiles (multi-profile)
Steps to reproduce the issue / Reasons for adding feature:
Error output / Expected result of feature
Any game UI should stay in that profile only, and not influence other games' UI
Extra information, such as Mudlet version, operating system and ideas for how to solve / implement:
Mudlet 4.4