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);
839+}
840+
841+int SendConfirmationDialog::exec()
842+{
843+ button(QMessageBox::Yes)->setEnabled(false);
844+ QTimer::singleShot(msecDelay, this, SLOT(enableSendButton()));
@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
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.
displaying the remaining seconds?
Maybe just a clock icon?
Maybe just a clock icon?
Good idea!
Squashed.
And I added an animated clock on the yes button.
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()));
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?
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).
Looks great. Thanks for sticking with this.
Tested post-merge ACK