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

Make the tool tip pop-ups in the Certify dialog accessible

At least on Linux, we need to post an ObjectShow event for the tool tip,
so that orca reads out the tool tip. Qt explicitly omits posting this
event because "Tooltips are read aloud twice in MS narrator".

Moreover, we change the time the tool tip will be displayed from
30 seconds to 24 hours.

GnuPG-bug-id: 6044
parent dd178447
......@@ -170,7 +170,12 @@ include_directories(
if (WIN32)
# On Windows, we need to use stuff deprecated since Qt 5.11, e.g. from QDesktopWidget
ecm_set_disabled_deprecation_versions(QT 5.10.0 KF 5.95.0)
else ()
ecm_set_disabled_deprecation_versions(QT 5.14.0 KF 5.95.0)
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces -Wno-parentheses -Wno-ignored-qualifiers")
......@@ -11,6 +11,8 @@
#include "certifywidget.h"
#include <utils/accessibility.h>
#include "kleopatra_debug.h"
#include <KLocalizedString>
......@@ -242,8 +244,8 @@ auto createInfoButton(const QString &text, QWidget *parent)
QObject::connect(infoBtn, &QPushButton::clicked, infoBtn, [infoBtn, text] () {
QToolTip::showText(infoBtn->mapToGlobal(QPoint()) + QPoint(infoBtn->width(), 0),
text, infoBtn, QRect(), 30000);
const auto pos = infoBtn->mapToGlobal(QPoint()) + QPoint(infoBtn->width(), 0);
showToolTip(pos, text, infoBtn);
return infoBtn;
......@@ -13,11 +13,17 @@
#include <KLocalizedString>
#ifdef Q_OS_WIN32
#include <QApplication>
#include <QDesktopWidget>
#include <QLabel>
#include <QObject>
#include <QTextDocument>
#include <QToolTip>
#include <algorithm>
#include <chrono>
#include "kleopatra_debug.h"
......@@ -78,6 +84,45 @@ void Kleo::selectLabelText(QLabel *label)
static void notifyAccessibilityClientsAboutToolTip(const QPoint &pos, QWidget *parent)
#ifdef Q_OS_WIN32
// On Windows, the tool tip's parent widget is a desktop screen widget (see implementation of QToolTip::showText)
const auto desktop = QApplication::desktop();
const int screenNumber = desktop->isVirtualDesktop() ? desktop->screenNumber(pos) : desktop->screenNumber(parent);
parent = desktop->screen(screenNumber);
if (!parent) {
if (auto toolTipLabel = parent->findChild<QLabel *>(QStringLiteral("qtooltip_label"))) {
// Qt explicitly does not notify accessibility clients about the tool tip being shown because
// "Tooltips are read aloud twice in MS narrator."
// The problem is that they are not read out by orca (on Linux) if the notification is omitted.
// Therefore, we take care of notifying the accessibility clients.
QAccessibleEvent event(toolTipLabel, QAccessible::ObjectShow);
void Kleo::showToolTip(const QPoint &pos, const QString &text, QWidget *w)
using namespace std::chrono_literals;
static const std::chrono::milliseconds timeout = 24h;
QToolTip::showText(pos, text, w, {}, timeout.count());
notifyAccessibilityClientsAboutToolTip(pos, w);
......@@ -28,6 +28,14 @@ namespace Kleo
void selectLabelText(QLabel *label);
* Shows \p text as a tool tip, with the global position \p pos as the point of interest.
* Additionally to QToolTip::showText, it takes care of notifying accessibility clients
* about the tool tip.
* \sa QToolTip::showText
void showToolTip(const QPoint &pos, const QString &text, QWidget *w);
* Simple helper that sets the focus policy of the associated labels
* to \c Qt::StrongFocus if an assistive tool is active.
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