From c40cedf5250514cdf0d4a82aac71158df2750c12 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 3 Aug 2026 14:29:06 +0200 Subject: fix: keep the shortcut reference inside the screen Fourteen actions in one table made a dialog taller than the display, which pushed its own title bar off the top. The rows are split into two columns of seven, with the closing note spanning both. QMessageBox is replaced by a plain QDialog. The message box wraps its text at a narrow fixed width, which broke every description into a column of single words and was most of the height: 719x1084 before, 1426x366 after. --- src/mainwindow.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index be80d8a..eaf98b8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -20,6 +20,8 @@ #include #include +#include +#include #include #include #include @@ -362,24 +364,55 @@ void MainWindow::showShortcutReference() if (!action) continue; const QString sequence = action->shortcut().toString(QKeySequence::NativeText); - rows.append(QStringLiteral("%1%2" + rows.append(QStringLiteral("%1  " + "%2  " "%3") .arg(sequence.isEmpty() ? tr("(unbound)") : sequence.toHtmlEscaped(), m_actionDescriptions.value(name).toHtmlEscaped(), name.toHtmlEscaped())); } - QMessageBox box(this); - box.setWindowTitle(tr("Keyboard shortcuts")); - box.setTextFormat(Qt::RichText); - box.setText(tr("

Keyboard shortcuts

" - "" - "" - "%1
KeyDoesAction name
" - "

Rebind any of these in the [keys] section of " - "qtmaildir.conf, using the action name.

") - .arg(rows.join(QString()))); - box.exec(); + // Two columns rather than one. Fourteen actions in a single table made a + // dialog taller than the screen, which cut off its own title bar. + const int half = (rows.size() + 1) / 2; + const QString header = + tr("KeyDoes" + "Action name"); + const QString left = header + rows.mid(0, half).join(QString()); + const QString right = header + rows.mid(half).join(QString()); + + // A QDialog rather than QMessageBox: the message box wraps its text at a + // narrow default width, which turned every description into a column of + // single words and made the dialog taller than the screen. + QDialog dialog(this); + dialog.setWindowTitle(tr("Keyboard shortcuts")); + + auto *label = new QLabel(&dialog); + label->setTextFormat(Qt::RichText); + label->setText(tr("" + "" + "" + "" + "
%1
%2
") + .arg(left, right)); + + auto *note = new QLabel( + tr("Rebind any of these in the [keys] section of " + "qtmaildir.conf, using the action name."), + &dialog); + note->setTextFormat(Qt::RichText); + note->setWordWrap(true); + + auto *buttons = new QDialogButtonBox(QDialogButtonBox::Ok, &dialog); + connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept); + + auto *layout = new QVBoxLayout(&dialog); + layout->addWidget(label); + layout->addWidget(note); + layout->addStretch(); + layout->addWidget(buttons); + + dialog.exec(); } void MainWindow::showAbout() -- cgit v1.2.3