Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shrinking size of window can cause sources in the source list to disappear #331

Closed
sssoleileraaa opened this issue Apr 25, 2019 · 8 comments · Fixed by #354, #620 or #696
Closed

shrinking size of window can cause sources in the source list to disappear #331

sssoleileraaa opened this issue Apr 25, 2019 · 8 comments · Fixed by #354, #620 or #696

Comments

@sssoleileraaa
Copy link
Contributor

When resizing the client window a bunch I noticed that sometimes the sourcelist wouldn't fully repaint a source item. I need to investigate this further to create a follow-up STR.

@heartsucker
Copy link
Contributor

This bug is present for me too.

@sssoleileraaa
Copy link
Contributor Author

sssoleileraaa commented Apr 28, 2019

I found the problem, but not a great solution. It might be an upstream issue...

To remove Qt's list view item decoration, which shows a border and background color for the first item in the list (before it's been selected), you can use the following CSS:

    QListView {
        show-decoration-selected: 0;
    }

This removes the unwanted behavior of always showing the first item in the list as decorated.

When I change that back to 1 instead of 0, the issue goes away. But now we're stuck with the decoration before the item is selected, so no conversation is displayed, but it looks like there should be. It make the application appear broken. I've tried getting around this by setting border: none; for items in the list, but the first item still appears with a border and background color.

For example, I've tried this, but the first item still shows unwanted decoration:

    QListWidget {
        show-decoration-selected: 1;
        selection-color: #fff;
        selection-background-color: #fff;
    }
    QListView::item {
        border: none;
    }
    QListView::item:selected {
        border: none;
        color: #f00;
    }
    QListView::item:selected:active {
        border: none;
        background: #0f0;
    }
    QListView::item:hover {
        border: none;
        background: #00f;
    }

The only way it seems to get rid of the first item decoration is to do this, which causes the repainting bug (this really seems like a Qt upstream issue):

   QListWidget {
        show-decoration-selected: 0;
   }

Proposal

I'm running out different things to try, so I think the work-around for now should be to remove the show-decoration-selected code so that it defaults back to 1 and to try to match this QListView decoration with our own selection background color and border so it looks consistent. I also think it would make more sense to the user if we show the first conversation since it'll look like the first item in the list is selected.

References

@sssoleileraaa
Copy link
Contributor Author

sssoleileraaa commented Aug 2, 2019

This bug is now back because I forgot that adding show-decoration-selected: 0; causes it to happen for us. We definitely don't want to use the default QListWidget selection decoration, so we need to come up with some kind of workaround or solve the core issue (maybe by finding the issue in the Qt codebase or discovering that this is caused by something we are doing around repainting widgets or CSS).

@sssoleileraaa
Copy link
Contributor Author

STR:

  1. Start the client
  2. Double click on the title bar to resize the client window

Expected: all sources in the list remain
Actual: source at the bottom of the list disappears

If this doesn't happen to you the first time you try, close the client and try again. Also make sure when you are trying to solve this bug and making code changes that you test a few times to make sure it's acutally gone.

@deeplow
Copy link
Contributor

deeplow commented Nov 13, 2019

I'm running out different things to try, so I think the work-around for now should be to remove the show-decoration-selected code so that it defaults back to 1 and to try to match this QListView decoration with our own selection background color and border so it looks consistent. I also think it would make more sense to the user if we show the first conversation since it'll look like the first item in the list is selected.

I may have found a solution but it's kind of like a hack. The odd-looking default style always shows up when show-decoration-selected is 1 so the previous solutions changed it to 0. In my solution, I do all the background styling in the border (which would be no problem since in the design there seems to be no use for the border). So I set a ridiculous amount of border size (500px) and voila - the default style disappears.

    QListView {
        border: none;
        show-decoration-selected: 1;
        border-right: 3 px solid #f3f5f9;
    }
    QListView::item:selected {
        border: 500 px solid qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #f8fefe, stop: 0.74 #f1eef7, stop: 1 #eef0f7);
    }

hack

@deeplow
Copy link
Contributor

deeplow commented Nov 13, 2019

I may have found a solution but it's kind of like a hack.

This change has some side-effects that I don't know exactly what they mean.
The following image shows what it looked like before.

sd-before

Notice the tiny shadow there. I don't know what the purpose for that was, but with this change that disappeared.

@sssoleileraaa
Copy link
Contributor Author

I'll apply your change and test so I can see the side effects better. Seems like a clever workaround to this strange Qt behavior, but I want to make sure we can still display preview text (on a feature branch) with a 500px mega border.

@sssoleileraaa sssoleileraaa changed the title Strange repainting behavior of sourcelist items shrinking size of window can cause sources in the source list to disappear Nov 13, 2019
@sssoleileraaa
Copy link
Contributor Author

hey @deeplow your change looks good to me, and it still works with preview text
Screenshot from 2019-11-13 13-34-42

deeplow added a commit to deeplow/securedrop-client that referenced this issue Nov 13, 2019
…list

workaround: do styling on border instead of in the background and
make border very large so that the default style is shrinked until
it no longer exists.

See freedomofpress#331
for discussion
sssoleileraaa pushed a commit that referenced this issue Nov 13, 2019
workaround: do styling on border instead of in the background and
make border very large so that the default style is shrinked until
it no longer exists.

See #331
for discussion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment