diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-24 11:13:04 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-24 11:13:04 +0200 |
| commit | 2703d4c42710418b0f15a41fa896824e2e1a6170 (patch) | |
| tree | c7f463a92c4f56b7f6a1e02def9bc2d53c4894c0 /src/messageview.cpp | |
| parent | dd6f35b8f35f231ebf1511daef3dd707eaa9839d (diff) | |
| download | qtmaildir-2703d4c42710418b0f15a41fa896824e2e1a6170.tar.gz qtmaildir-2703d4c42710418b0f15a41fa896824e2e1a6170.zip | |
feat(ui): give the message pane its own action bar
Items 139, 140 and 141, built together because the seam between them is
wasted work: 140 needs a container and 141 is that container.
The main toolbar had grown to mix two scopes. Sync, Archive, Delete, Mark
all read and Undo act on the list or the selection; Compose, Reply and
Forward are about one message. With everything in one row the distinction
was invisible, and Forward was on no toolbar at all, reachable only from the
Message menu, which is item 139.
Compose, Reply and Forward now sit on a bar above the message pane, and
LEAVE the main toolbar rather than gaining a second home: that is what makes
the toolbar's remaining contents mean one thing. Toggle HTML joins them at
the right end, separated by an expanding spacer, since changing how a
message is displayed is a different scope from acting on it. That layout was
the open design question item 141 recorded, and it was settled with the user
rather than guessed.
The actions are MainWindow's own QAction objects shown a second time, never
copies: a duplicate would carry its own enablement and drift from the menu
entry updateComposeActions() keeps in step. MessageView::setBarActions() is
the seam, so the pane still knows nothing about the window's action map.
Two things worth recording:
QToolBar has no addStretch(), so the separation is an expanding spacer
widget. A test asserting only on action ORDER passes with that spacer
deleted, measured, so it asserts on the spacer's size policy instead.
noTwoActionsShareAnIcon looked up the toolbar with an unnamed
findChild<QToolBar*>(). There are two toolbars now, so it is pinned to
main_toolbar: pointed at the pane's bar it would have asserted that a
thread action is absent from a bar that never holds any, and passed while
the rule it exists for went unchecked.
Diffstat (limited to 'src/messageview.cpp')
| -rw-r--r-- | src/messageview.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/messageview.cpp b/src/messageview.cpp index 22df6ce..c8395f1 100644 --- a/src/messageview.cpp +++ b/src/messageview.cpp @@ -37,6 +37,9 @@ #include <QTimer> #include <QTreeWidget> #include <QVBoxLayout> +#include <QStyle> +#include <QSizePolicy> +#include <QToolBar> #include <QWheelEvent> #include <QWebEnginePage> #include <QWebEngineProfile> @@ -456,7 +459,20 @@ MessageView::MessageView(QWidget *parent) menu.exec(globalPos); }); + // The pane's own action bar (items 139 to 141). Empty until MainWindow + // fills it: the actions belong to the window, and MessageView deliberately + // knows nothing about the action map. + m_messageBar = new QToolBar(this); + m_messageBar->setObjectName(QStringLiteral("message_toolbar")); + // The desktop's own button style, for the reason the main toolbar records: + // a hardcoded setToolButtonStyle() overrides the user's "Icon only". + m_messageBar->setToolButtonStyle(static_cast<Qt::ToolButtonStyle>( + style()->styleHint(QStyle::SH_ToolButtonStyle, nullptr, m_messageBar))); + m_messageBar->setMovable(false); + m_messageBar->hide(); + auto *layout = new QVBoxLayout(this); + layout->addWidget(m_messageBar); layout->addLayout(headerRow); layout->addWidget(m_blockedBar); layout->addWidget(m_receiveOnlyRibbon); @@ -566,6 +582,33 @@ void MessageView::applyNoticeBarStyles() } } +void MessageView::setBarActions(const QList<QAction *> &messageActions, + const QList<QAction *> &viewControls) +{ + m_messageBar->clear(); + + for (QAction *action : messageActions) { + if (action) + m_messageBar->addAction(action); + } + + // The stretch is what separates the two scopes, so the view controls end + // up at the right edge. A QToolBar has no addStretch(), so it takes an + // expanding spacer widget. + if (!viewControls.isEmpty()) { + auto *spacer = new QWidget(m_messageBar); + spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + m_messageBar->addWidget(spacer); + + for (QAction *action : viewControls) { + if (action) + m_messageBar->addAction(action); + } + } + + m_messageBar->setVisible(!m_messageBar->actions().isEmpty()); +} + void MessageView::clear() { m_items.clear(); |
