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

[ui polish] Reply pane styling #580

Merged
merged 10 commits into from
Oct 25, 2019

Conversation

deeplow
Copy link
Contributor

@deeplow deeplow commented Oct 22, 2019

Do not merge. Waiting on discussion in #580 (comment)

Description

  • Converts rich text into plaintext (reply box was accepting rich text input)
  • add styling according to mockup

Fixes #539 and partially #572

Before:
before

After:
reply-2

Objective: (mockup)
mockup

Test Plan

  1. copy rich text
  2. paste it into reply box

Checklist

If these changes modify code paths involving cryptography, the opening of files in VMs or network (via the RPC service) traffic, Qubes testing in the staging environment is required. For fine tuning of the graphical user interface, testing in any environment in Qubes is required. Please check as applicable:

  • I have tested these changes in the appropriate Qubes environment
  • I do not have an appropriate Qubes OS workstation set up (the reviewer will need to test these changes)
  • These changes should not need testing in Qubes

Comments

Considerations for future PRs:

  • keyboard shortcuts (ctrl+return) in discussion if should be implemented: [ui polish] Reply pane styling/behavior #572
  • add rich text input (or alternative) only for placeholder "Compose a reply to Source Name"
  • think about the scrollbar (should it go away?)
  • Shouldn't the text scale with the content? (it might be hard to have 20% of the screen with an empty reply box when the journalist is reading messages) Discussion: [ui polish] Reply pane styling/behavior #572

@deeplow
Copy link
Contributor Author

deeplow commented Oct 22, 2019

Actually it might not be as simple as this because if we want to to the placehoder like compose a reply to Surreal Yo-Yo, it might require rich text but somehow get disabled.

I will investigate this.

@deeplow deeplow changed the title close #539 make reply box only accept plaintext [WIP] close #539 make reply box only accept plaintext Oct 22, 2019
- 'send.png' (airplane) icon was swapped for an svg version from
the mockup
- plane was repositioned according to the mockup
@deeplow deeplow force-pushed the 539-reply-rich-text branch from 6dd0244 to 62cff38 Compare October 22, 2019 18:08
@deeplow deeplow changed the title [WIP] close #539 make reply box only accept plaintext [ui polish] Reply pane styling Oct 22, 2019
@deeplow
Copy link
Contributor Author

deeplow commented Oct 22, 2019

I will investigate this.

It was decided that this may go on another PR

@deeplow
Copy link
Contributor Author

deeplow commented Oct 22, 2019

The client is crashing in offline mode. I'll check that later

@deeplow deeplow force-pushed the 539-reply-rich-text branch from 62cff38 to 4e33e39 Compare October 23, 2019 06:04
@deeplow
Copy link
Contributor Author

deeplow commented Oct 23, 2019

The client is crashing in offline mode.

this has now been fixed and some styling to the offline mode was added as well as a placeholder for online mode with the temporary text "Compose a reply to Bold Sourcename"

Some discussion on the offline mode styling is still happening in #572 (comment)

support for rich text is disabled for security purposes, which
means we will have to find another way to have the source name in
bold while at the same time preventing the user from inputing rich
text
@deeplow deeplow force-pushed the 539-reply-rich-text branch from 22c1691 to a3c6870 Compare October 23, 2019 06:40
@deeplow
Copy link
Contributor Author

deeplow commented Oct 23, 2019

I've hidden the vertical scrollbar in the reply box even when the box is bigger than its size.
@ninavizz let me know if this is something we want:

Before:

scroll-before

After:

scroll

@deeplow
Copy link
Contributor Author

deeplow commented Oct 23, 2019

I'll fix the linting problem that is making the test fail on CI

@ninavizz
Copy link
Member

Yes, thank you!! The little purple airplane should be a few pixels lower, though; it's lowest points should be flush with the baseline of the last line of text. Thank you, Deeplow!

@deeplow
Copy link
Contributor Author

deeplow commented Oct 24, 2019

The little purple airplane should be a few pixels lower, though; it's lowest points should be flush with the baseline of the last line of text

Like this? (the image below is the mockup)
spec

The only problem now is that it crops the last line in half.

Also, @ninavizz I would also like some feedback on the airplane in offline mode. Quoting from the issue

I didn't see any mockups for the offline mode, so I just did what I thought made sense.

The current version looks like this: (over in #580)

offline

@ninavizz I think we should also add a disabled-looking airplane. What do you think? (it the last iterations of the code there were none). With the plane disabled it would look like:

plane-disabled

I already have the code for that which I can merge into #580, in case that's the way to go.

@deeplow deeplow changed the title [ui polish] Reply pane styling [wip] [ui polish] Reply pane styling Oct 24, 2019
@deeplow
Copy link
Contributor Author

deeplow commented Oct 24, 2019

I'll be trying to add the source name in the reply box

Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deeplow the disabled-looking airplane looks great to me, we can discuss after standup to see if others are in agreement, but I think you should add that in.

also, the button looks giant now, but it does match the mockups so i don't think my opinion should hold up this pr. i'll bring it up to see what others think now that they can see it in the client application.

One change I think you should make in this PR is using the actual journalist_designation name instead of %bold_source_name% as a placeholder. If you'd rather create a separate PR for retrieving the name, then I recommend changing Compose a reply to %bold_source_name% to just Compose a reply.

Also, currently when clicking inside the textbox the Compose a reply text does not go away as I expected. Instead it goes away when you start typing, but I think it's distracting having the text in front of the cursor as you're thinking about what to type. It would be great if you could update this behavior as part of this PR as well.

@deeplow deeplow force-pushed the 539-reply-rich-text branch from df5f6d7 to 3de6439 Compare October 25, 2019 18:33
@deeplow
Copy link
Contributor Author

deeplow commented Oct 25, 2019

@creviera could you check if the test I did looks sane?

I had to make select a source from the sources list. Otherwise, I think it would be always true since I'd be creating a source and using that for a ReplyBoxWidget and testing the placeholder.

@deeplow
Copy link
Contributor Author

deeplow commented Oct 25, 2019

Also, currently when clicking inside the textbox the Compose a reply text does not go away as I expected. Instead it goes away when you start typing, but I think it's distracting having the text in front of the cursor as you're thinking about what to type. It would be great if you could update this behavior as part of this PR as well.

@creviera regarding this, It's intended Qt behavior and there doesn't seem to be a default way to disable that. We might have to find another way, but let's do that in another PR, I think.

From the docs (https://doc.qt.io/qt-5/qtextedit.html#placeholderText-prop)

placeholderText : QString

This property holds the editor placeholder text

Setting this property makes the editor display a grayed-out placeholder text as long as the document() is empty.

@sssoleileraaa sssoleileraaa self-requested a review October 25, 2019 19:23
@sssoleileraaa
Copy link
Contributor

@creviera could you check if the test I did looks sane?

I had to make select a source from the sources list. Otherwise, I think it would be always true since I'd be creating a source and using that for a ReplyBoxWidget and testing the placeholder.

I think your test looks good, although to improve code clarity, you could change A->B:

A:

    sl = SourceList()
    sl.setup(controller)
    ...
    source_1 = factory.Source()
    source_2 = factory.Source()
    sl.update([source_1, source_2])
    source_1_item = sl.item(0)
    source_2_item = sl.item(1)
    ...
    sl.setCurrentItem(source_2_item)
    selected_source = sl.itemWidget(sl.currentItem()).source
    rb = ReplyBoxWidget(selected_source, controller)
    assert rb.text_edit.placeholderText().find(source_2.journalist_designation) != -1

B:

    source = factory.Source()
    rb = ReplyBoxWidget(source, controller)
    assert rb.text_edit.placeholderText().find(source.journalist_designation) != -1

Because all you're really testing is that the journalist_designation used in the placeholder text matches the journalist_designation of the ReplyBoxWidget source.

The rest of your test is better done at the SourceConversationWrapper level. That's where we do things like making sure the ReplyBoxWidget is initialized with the currently selected source whenever selection changes in the SourceList etc.

Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, looks like qt's placeholderText is not what we want here then. I agree that it makes sense to come up with a solution in a follow-up pr, especially if that solution is to add a QLabel to the ReplyBoxWidget that hides on a focus event and allows rich-text formatting for the source name -- solves two issues in one!

@sssoleileraaa sssoleileraaa merged commit 9b84f62 into freedomofpress:master Oct 25, 2019
@eloquence eloquence changed the title [wip] [ui polish] Reply pane styling [ui polish] Reply pane styling Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reply box accepts rich text input
3 participants