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

Add workaround for broken tab order of dialog buttons

At least with the KdeLayout the Close button is excluded from the
forward tab order (but not from the backward tab order), so that the
Close button cannot be selected by pressing Tab repeatedly.

The buttons are displayed in the order "Copy to Clipboard", "Save to
Disk...", "Close", but nextInFocusChain() of the Save button returns the
AuditLogViewer instead of the Close button. The complete picture is
as follows:
- focusProxy() of the button box is the Copy button (okay)
- nextInFocusChain() of the Copy button is the Save button (okay)
- nextInFocusChain() of the Save button is the AuditLogViewer (not okay)
- nextInFocusChain() of the Close button is the Copy button (not okay)
Seems to be a bug in Qt.

Creating the Close button after the custom buttons works around the
problem and fixes the tab order (at least for KdeLayout).

GnuPG-bug-id: 5535
parent d31ade75
SPDX-FileCopyrightText: 2015-2021 Laurent Montel <>
SPDX-License-Identifier: LGPL-2.0-or-later
SPDX-FileCopyrightText: 2015-2021 Laurent Montel <>
SPDX-FileCopyrightText: 2021 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <>
SPDX-License-Identifier: LGPL-2.0-or-later
#include "auditlogviewer.h"
......@@ -22,6 +24,9 @@
#include <QPushButton>
#include <QVBoxLayout>
#include <QStyle>
#include <QDebug>
using namespace Kleo::Private;
AuditLogViewer::AuditLogViewer(const QString &log, QWidget *parent)
......@@ -34,20 +39,25 @@ AuditLogViewer::AuditLogViewer(const QString &log, QWidget *parent)
setWindowTitle(i18nc("@title:window", "View GnuPG Audit Log"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
QDialogButtonBox *buttonBox = new QDialogButtonBox{};
auto copyClipBtn = new QPushButton;
copyClipBtn->setText(i18n("&Copy to Clipboard"));
buttonBox->addButton(copyClipBtn, QDialogButtonBox::ActionRole);
connect(copyClipBtn, &QPushButton::clicked, this, &AuditLogViewer::slotCopyClip);
auto saveAsBtn = new QPushButton;
saveAsBtn->setText(i18n("&Save to Disk..."));
buttonBox->addButton(saveAsBtn, QDialogButtonBox::ActionRole);
connect(saveAsBtn, &QPushButton::clicked, this, &AuditLogViewer::slotSaveAs);
......@@ -55,6 +65,12 @@ AuditLogViewer::AuditLogViewer(const QString &log, QWidget *parent)
// qDebug() << "buttonBox->style()->styleHint(QStyle::SH_DialogButtonLayout, ...):" << buttonBox->style()->styleHint(QStyle::SH_DialogButtonLayout, nullptr, buttonBox);
// qDebug() << __func__ << "buttonBox->focusProxy():" << buttonBox->focusProxy();
// qDebug() << __func__ << "copyClipBtn->nextInFocusChain():" << copyClipBtn->nextInFocusChain();
// qDebug() << __func__ << "saveAsBtn->nextInFocusChain():" << saveAsBtn->nextInFocusChain();
// qDebug() << __func__ << "closeBtn->nextInFocusChain():" << buttonBox->button(QDialogButtonBox::Close)->nextInFocusChain();
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
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