Commit 06184481 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Close tool tip instead of dialog if Escape is pressed

By default, QDialog rejects the dialog if Escape is pressed. If one of
the "Explain" tool tips of the CertifyWidget are shown, then pressing
Escape should just close the explicitly shown tool tip instead of
canceling the dialog. For simplicity, we hide any currently visible
tool tip on Escape.

GnuPG-bug-id: 6046
parent 88414297
......@@ -27,7 +27,9 @@
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <QKeyEvent>
#include <QPushButton>
#include <QToolTip>
#include <gpg-error.h>
......@@ -159,3 +161,14 @@ void CertifyCertificateDialog::accept()
QDialog::accept();
}
void CertifyCertificateDialog::keyPressEvent(QKeyEvent *e)
{
// if Escape is pressed while a tool tip is shown, then close the tool tip but not the dialog
if (e->matches(QKeySequence::Cancel) && QToolTip::isVisible()) {
QToolTip::hideText();
return;
}
QDialog::keyPressEvent(e);
}
......@@ -54,6 +54,9 @@ public:
public Q_SLOTS:
void accept() override;
protected:
void keyPressEvent(QKeyEvent *) override;
private:
CertifyWidget *mCertWidget;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment