diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-19 11:34:58 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-19 11:34:58 +0200 |
| commit | e187db1b84fadaf67bb8bee91460fbaea6ce8efb (patch) | |
| tree | c28d3b866f9289afab83254619970f25d32643f4 /src/messageview.h | |
| parent | 41d0b94dcd2b4208e5d3e7483c88ce9b664ce565 (diff) | |
| download | qtmaildir-e187db1b84fadaf67bb8bee91460fbaea6ce8efb.tar.gz qtmaildir-e187db1b84fadaf67bb8bee91460fbaea6ce8efb.zip | |
feat(pane): move the copy confirmation into the message pane
The user's preference after seeing item 115 ship: a small transient in the
bottom right of the pane with a checkmark, rather than a status bar message at
the far end of the window. A copy happens in the pane, so the confirmation
belongs there.
Three properties are load-bearing and each has a mutation that fails. The toast
is a hand-placed CHILD rather than a layout item, because it floats over the
message instead of taking a strip away from it: nothing reflows when it appears
and the text just copied does not jump. That is why resizeEvent() is overridden,
since a hand-placed child does not follow its parent. It is autoFillBackground
and painted from the theme's ToolTipBase/ToolTipText, so it stays readable over
a rendered message and follows the desktop theme the way the document already
does. And its timer is restarted rather than started, so a second copy gets its
own full reading time instead of inheriting what is left of the first.
The resize test was wrong on its first draft and passed against the mutation it
exists to catch. It grew the pane, which moves the right and bottom edges away,
so a toast left at its old position still satisfied "inside the pane"; measured
green with the reposition deleted. It shrinks now, where a stale position lands
outside the new rect, which is also what the user would see.
No new strings: the four messages are unchanged, only where they appear.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/messageview.h')
| -rw-r--r-- | src/messageview.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/messageview.h b/src/messageview.h index 0b18769..09fc905 100644 --- a/src/messageview.h +++ b/src/messageview.h @@ -20,6 +20,7 @@ #include <QList> #include <QUrl> +#include <QTimer> #include <QWidget> #include "htmlbuilder.h" @@ -97,6 +98,10 @@ public: /// The body zoom factor. Chromium's own range is roughly 0.25 to 5.0; /// these are tighter, since a pane at either extreme is unusable and the /// only visible way back is a menu entry the user cannot read. + /// How long the copy confirmation stays up. Long enough to read four + /// words, short enough that it is gone before it becomes furniture. + static constexpr int kToastMs = 2000; + static constexpr qreal kMinZoom = 0.5; static constexpr qreal kMaxZoom = 3.0; static constexpr qreal kDefaultZoom = 1.0; @@ -257,6 +262,9 @@ protected: /// until the next selection. void changeEvent(QEvent *event) override; + /// Keeps the hand-placed toast anchored to the bottom right. + void resizeEvent(QResizeEvent *event) override; + private: void render(); void updateHeader(); @@ -304,6 +312,30 @@ private: /// different wording or a different pair of operations. void addSearchEntries(QMenu *menu, const QList<SearchOffer> &offers); + /// The copy confirmation, floating over the web view in the pane's bottom + /// right rather than in the window's status bar. + /// + /// A CHILD placed by hand, never a layout item: it must sit on top of the + /// message rather than take a strip away from it, so nothing reflows when + /// it appears and the text the user just copied does not jump. That is + /// also why positionToast() exists and why resizeEvent() is overridden; + /// a hand-placed child does not follow its parent the way a laid-out one + /// does. + QLabel *m_copyToast = nullptr; + QTimer *m_copyToastTimer = nullptr; + + /// Paints the toast in the theme's tooltip colours. + /// + /// Re-applied on a PaletteChange, so it follows the desktop theme the way + /// the rendered document already does. + void applyToastPalette(); + + /// Shows the toast with `text` and restarts its countdown. + void showCopyToast(const QString &text); + + /// Puts the toast in the pane's bottom right, inside the margins. + void positionToast(); + QList<ThreadRenderItem> m_items; bool m_preferHtml = true; |
