I made a subclass of QMessageBox that disables the send button in exec() and starts a timer that calls a slot to re-enable it after a configurable delay.
I went with 3s for the delay.
This PR attempts to implement this feature request: #785.
I made a subclass of QMessageBox that disables the send button in exec() and starts a timer that calls a slot to re-enable it after a configurable delay.
I went with 3s for the delay.
This PR attempts to implement this feature request: #785.
311 | @@ -311,10 +312,10 @@ void SendCoinsDialog::on_sendButton_clicked() 312 | questionString.append(QString("<span style='font-size:10pt;font-weight:normal;'><br />(=%2)</span>") 313 | .arg(alternativeUnits.join(" " + tr("or") + "<br />"))); 314 | 315 | - QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"), 316 | - questionString.arg(formatted.join("<br />")), 317 | - QMessageBox::Yes | QMessageBox::Cancel, 318 | - QMessageBox::Cancel); 319 | + SendConfirmationDialog confirmationDialog(tr("Confirm send coins"), 320 | + questionString.arg(formatted.join("<br />")), 3000, this);
Maybe use a constant for the timeout (3000)?
Concept ACK 2190e07
839 | +} 840 | + 841 | +int SendConfirmationDialog::exec() 842 | +{ 843 | + button(QMessageBox::Yes)->setEnabled(false); 844 | + QTimer::singleShot(msecDelay, this, SLOT(enableSendButton()));
What happens if you close the QMessageBox before the QTimer fires? I have tested it and it works here... but wondering if it would be better to explicit invalidate the timer in the destructor.
@jonasschnelli, I don't think it's possible to invalidate a singleShot. There's never any timer exposed for me to invalidate. It functions like the static QMessageBox::info/warning/etc functions.
I would expect that Qt planned for the possibility of the connected object disappearing, seeing as it could happen often. A quick google turns up that signals are automatically disconnected: http://stackoverflow.com/questions/10570857/are-signals-in-qt-automatically-disconnected-when-one-of-the-class-is-deleted
Okay. Fair enough. Thanks for the clarification.
Somehow I like this but I could imagine confused users during the 3 second timeout ("why the heck is 'Ok' button disabled?!"). What about displaying the remaining seconds? Overkill?
Anyways: this is great work! Thanks.
Needs squashing (at least remove last merge commit).
displaying the remaining seconds?
Maybe just a clock icon?
Maybe just a clock icon?
Good idea!
@jonasschnelli @MarcoFalke what about a wait cursor? That would be the easiest to implement by far. Only 2 lines.
@Tyler-Hardin Not sure if wait cursors are still make since today (haven't seem them on my OSX system a while ago IIRC). But it would be better then noting.
Agree with @jonasschnelli. Today, changing the mouse icon is not a thing to do anymore. Instead, the spinner/clock icon is displayed in place (inside the button). This makes clear what exactly is blocking the ui.
Concept ACK Visual indication of the "sleep" would be nice.
Squashed.
And I added an animated clock on the yes button.
Nice. Looks good!
853 | + 854 | + animateStage = 0; 855 | + QTimer::singleShot(msecDelay / 4, this, SLOT(animate())); 856 | + QTimer::singleShot(msecDelay / 2, this, SLOT(animate())); 857 | + QTimer::singleShot(3 * msecDelay / 4, this, SLOT(animate())); 858 | + QTimer::singleShot(msecDelay, this, SLOT(enableSendButton()));
nit: use a repetitive Timer with interval msecDelay/4.
Fixed.
Tested ACK 59e23c63a14d275b6b787256b53f782f0911e8a1 We could argue about the icon.
Can you hide the icon at the end of animation? Or what is the UI style for this?
But anyway, looks good 👍
Maybe just steal some MIT spinner from elsewhere? https://github.com/snowwlex/QtWaitingSpinner
Putting such a spinner in a /util dir could make it easier to re-use later?
@MarcoFalke that would look good, but I have no idea where to start in terms of getting that integrated into the build process. @paveljanik I'll change it. I had left it in because the button shrinks when it goes away. No style. (I'm guessing you're hinting that I could prevent the shrink with a well designed style. I don't have any idea where to start with that either.)
Lets not bloat the codebase with a progress indicator (should be provided by Qt/OS IMO). We should try to keep the scope of this PR and add graphical improvements over a different PR (if required).
Firefox used to have a similar feature in a dialog that asked the user to confirm they accepted the installation of a plugin from the internet. The "Install" button text was replaced with a timer that counted down while the button was disabled, making it obvious to the user something was going to happen without the need of any other visual indicator.

I made a subclass of QMessageBox that disables the send button in
exec() and starts a timer that calls a slot to re-enable it after a
configurable delay.
It also has a countdown in the send/yes button while it is disabled
to hint to the user why the send button is disabled (and that it is
actually supposed to be disabled).
@laanwj, done. Changed to have a text countdown.
Works for me, tested (but not deeply code-reviewed) ACK 3902a29
Tested ACK 3902a291abecad4da25d496f0e3e2b45f43a7947
Looks great. Thanks for sticking with this.
Tested post-merge ACK