From 6d0336f2231479951120c1128f9f95255612bd52 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Mon, 16 Dec 2019 19:05:52 +0100 Subject: CheckableMessageBox: Forbid focus for text and pixmap That allows changing between the buttons with the cursor Left and Right keys, without loosing focus from one of the buttons. Before, that was impossible without intermediate tab key pressing. E.g. when pressing Ctrl+W to close the git commit editor, the focus was outside the buttons. To select one of them, Tab had to be pressed first, but after some Key Right presses, the focus got away from the buttons again and the game had to be repeated. That behavior was different from QMessageBox, where one of the buttons always has focus. Change-Id: I9b12f794e8ba4aef1a68aaf249ba6dd6789cae4d Reviewed-by: Eike Ziller --- src/libs/utils/checkablemessagebox.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/utils/checkablemessagebox.cpp b/src/libs/utils/checkablemessagebox.cpp index 3ec411cfb3..ccf773cb99 100644 --- a/src/libs/utils/checkablemessagebox.cpp +++ b/src/libs/utils/checkablemessagebox.cpp @@ -62,6 +62,7 @@ public: sizePolicy.setHeightForWidth(pixmapLabel->sizePolicy().hasHeightForWidth()); pixmapLabel->setSizePolicy(sizePolicy); pixmapLabel->setVisible(false); + pixmapLabel->setFocusPolicy(Qt::NoFocus); auto pixmapSpacer = new QSpacerItem(0, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); @@ -71,6 +72,7 @@ public: messageLabel->setWordWrap(true); messageLabel->setOpenExternalLinks(true); messageLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse); + messageLabel->setFocusPolicy(Qt::NoFocus); auto checkBoxRightSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum); -- cgit v1.2.3