Mudlet / Mudlet

⚔️ A cross-platform, open source, and super fast MUD client with scripting in Lua
https://mudlet.org
GNU General Public License v2.0
738 stars 268 forks source link

UI changes changing other games #3309

Closed Kebap closed 4 years ago

Kebap commented 4 years ago

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:

  1. Connect to any game. Notice the scroll bars
  2. Connect to Clessidra in another profile window. Notice their individual scrollbars
  3. Switch back to the first profile. It now also shows those scrollbars

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

Leris: setAppStyleSheet([[TConsole QScrollBar:vertical seems to influence other profiles as well. Is that intended behavior though? Githzerai: well, command is tellling it all: set App(mudlet) StyleSheet. so, yes, sets it for whole mudlet not just one profile

SlySven commented 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.

vadi2 commented 4 years ago

:+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.

wiploo commented 4 years ago

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!

vadi2 commented 4 years ago

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.

SlySven commented 4 years ago

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 QObjects 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:

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.

wiploo commented 4 years ago

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

Kebap commented 4 years ago

👍 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!

SlySven commented 4 years ago

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 .