Reset the hide timer if a new inline Message is displayed
ClosedPublic

Authored by davidre on May 22 2019, 7:56 PM.

Details

Summary

Previously the KMessageWidget was unconditionally hidden after 10 seconds after it became visible. Even if during
this timeframe a new message was shown. This correctly stops/resets the timer if another message should be
displayed while the widget is shown.

Test Plan
  • Click on "Copy to Clipboard"
  • Wait 5 seconds
  • Click on "Save"
  • The widget hides after 10 seconds instead of previously 5

Diff Detail

Repository
R166 Spectacle
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
davidre created this revision.May 22 2019, 7:56 PM
Restricted Application added a project: Spectacle. · View Herald TranscriptMay 22 2019, 7:56 PM
davidre requested review of this revision.May 22 2019, 7:56 PM
broulik added inline comments.
src/Gui/KSMainWindow.cpp
372

Just calling start() restarts the QTimer, no need to call stop() first

Buf if we want display a persistent inlinemessage (MessageDuration::Persistent) we don't want to unconditionally restart it.

You call start() only from inside the check, so you can just remove your stop() call above?

You call start() only from inside the check, so you can just remove your stop() call above?

But that would have the same issue I'm trying to solve? There are two cases

  1. messageDuration == AutoHide: The widget should hide itself after 10 seconds => Start the Timer or reset it. For this is the call to start()
  2. messageDuration == Persistent: The widget should stay visible. If the widget is currently visible with a timer running we have to stop it. That is why I call stop()

Ah, right, sorry, got confused there. Alright, but you can remove the isActive() check I guess :)

davidre updated this revision to Diff 58535.May 23 2019, 8:36 AM
  • Remove check for isActive
ngraham accepted this revision.May 24 2019, 4:35 AM
ngraham added a subscriber: ngraham.

Works great, code looks good now. Looks like this one you can land yourself now!

This revision is now accepted and ready to land.May 24 2019, 4:35 AM
This revision was automatically updated to reflect the committed changes.