summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-24 11:54:41 +0200
committerDanilo M. <danix@danix.xyz>2026-08-24 11:54:41 +0200
commit02a795abe731da908928cd08a799ad79002ff421 (patch)
tree8e1d8cdd37973b378775b0977b38b320149fbadb
parenta4e8c837a07014be3863a40f371d02a492b7efb7 (diff)
downloadqtmaildir-02a795abe731da908928cd08a799ad79002ff421.tar.gz
qtmaildir-02a795abe731da908928cd08a799ad79002ff421.zip
fix(compose): make the Send button a square that reads as one item
An Expanding vertical size policy stretched the button to the full height of the header form beside it, while the icon and the label kept their natural sizes. The result was a tall rectangle with the icon anchored near the top, the label near the bottom, and a gap between them: two marks rather than one control. Fixed size, derived from the icon so the square still fits its contents if toolbar_icon_size changes, and aligned vertically centre against the headers so the whole button is centred rather than its contents. The icon grows to the configured size plus 8, since at this scale it is the button's subject and the word underneath is the caption. Nothing in the layout or the actions could see this, which is why the test now asserts the vertical policy and that width equals height. Both fail against the previous code.
-rw-r--r--src/composewindow.cpp18
-rw-r--r--tests/test_mainwindow.cpp15
2 files changed, 31 insertions, 2 deletions
diff --git a/src/composewindow.cpp b/src/composewindow.cpp
index ccf606e..6193e1c 100644
--- a/src/composewindow.cpp
+++ b/src/composewindow.cpp
@@ -312,11 +312,25 @@ void ComposeWindow::buildUi()
// Icon above text, at the user's choice: a big target, with the word
// removing any doubt about what it does.
+ //
+ // A SQUARE of a fixed size, and vertically centred against the header
+ // block. Expanding was wrong in a way that only shows on screen: it
+ // stretched the button to the full height of the form beside it while the
+ // icon and the label kept their natural sizes, so the two sat apart with a
+ // gap between them inside a tall rectangle. Fixed removes the stretch, and
+ // the alignment centres the whole button rather than its contents.
m_sendButton = new QToolButton(central);
m_sendButton->setObjectName(QStringLiteral("sendButton"));
m_sendButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
- m_sendButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
- headerRow->addWidget(m_sendButton, 0);
+ const int sendIconSize = qMax(24, m_config.toolbarIconSize() + 8);
+ m_sendButton->setIconSize(QSize(sendIconSize, sendIconSize));
+ // Derived from the icon rather than hardcoded, so the square still fits
+ // its contents if toolbar_icon_size changes. The extra covers the label
+ // under the icon and the style's own margins.
+ const int sendSide = sendIconSize + 34;
+ m_sendButton->setFixedSize(sendSide, sendSide);
+ m_sendButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ headerRow->addWidget(m_sendButton, 0, Qt::AlignVCenter);
layout->addLayout(headerRow);
diff --git a/tests/test_mainwindow.cpp b/tests/test_mainwindow.cpp
index 35f7093..4c33302 100644
--- a/tests/test_mainwindow.cpp
+++ b/tests/test_mainwindow.cpp
@@ -12267,6 +12267,21 @@ void TestMainWindow::theComposerSplitsItsToolbarByScope()
QVERIFY2(sendButton->defaultAction() == send,
"the Send button does not carry the send action itself");
+ // A SQUARE, and not a widget that stretches. An Expanding vertical policy
+ // grew it to the full height of the header form beside it while the icon
+ // and label kept their natural sizes, leaving the two marooned at either
+ // end of a tall rectangle with a gap between them. Nothing in the layout
+ // or the actions could see that, which is why it is asserted here.
+ QCOMPARE(sendButton->sizePolicy().verticalPolicy(), QSizePolicy::Fixed);
+ QCOMPARE(sendButton->width(), sendButton->height());
+
+ // And the icon is the larger half of the button, not a small mark with
+ // the label doing the work.
+ QVERIFY2(sendButton->iconSize().width() >= 24,
+ qPrintable(QStringLiteral("the Send icon is %1px, too small to "
+ "read as the button's subject")
+ .arg(sendButton->iconSize().width())));
+
// Item 143: the formatting buttons carry icons, and keep their words as
// the tooltip so nothing becomes unnameable in an icon-only row.
for (const QString &name : { QStringLiteral("format_bold"),