presentation/QuickMailMenu.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | #include <QObject> | ||
| 3 | #include <QVariantList> | ||
| 4 | |||
| 5 | #include <functional> | ||
| 6 | |||
| 7 | // Native context menu of a mail row (Sprint 95 S95.4.2, pattern of | ||
| 8 | // QuickTaskMenu). QML composes the entries from command availability and | ||
| 9 | // the clicked mail; this class only renders them as a QMenu and reports the | ||
| 10 | // pick. Entry: {id, label, icon?, enabled?, shortcut?, checkable?, checked?, | ||
| 11 | // count?, children?, command?, color?} or {separator: true}; `color` draws a swatch as the icon; `children` makes a submenu and a | ||
| 12 | // `count` ≥ 0 shows in the right column. The header's "☰" menu (F95-10) | ||
| 13 | // uses a second instance, the search tab's menus (Sprint 101) a third. Returns false without a | ||
| 14 | // QApplication (tests on QGuiApplication), so QML opens its fallback menu. | ||
| 15 | class QuickMailMenu final : public QObject { | ||
| 16 | Q_OBJECT | ||
| 17 | public: | ||
| 18 | using QObject::QObject; | ||
| 19 | // `above`: the menu's bottom edge at (x, y) — menus of a footer open upwards (F108-04). | ||
| 20 | Q_INVOKABLE bool show(const QVariantList &entries, QObject *window, qreal x, qreal y, | ||
| 21 | const QString &name = QStringLiteral("nativeMailMenu"), bool above = false); | ||
| 22 | // Sprint 105 S105.8.2: an entry's `command` shows the key that runs that | ||
| 23 | // command here (the router's effective key, in portable text); `shortcut` | ||
| 24 | // stays for keys without a command. Set once by the host. | ||
| 25 | using KeyResolver = std::function<QString(const QString &command)>; | ||
| 26 | 3180 | void setKeyResolver(KeyResolver resolver) { m_keyResolver = std::move(resolver); } | |
| 27 | signals: | ||
| 28 | void triggered(const QString &id); | ||
| 29 | // F100-03/F100-09: the same pick with the menu's name, so one instance | ||
| 30 | // serves every PNativeMenu (each listens for its own name). | ||
| 31 | void chosen(const QString &name, const QString &id); | ||
| 32 | |||
| 33 | private: | ||
| 34 | KeyResolver m_keyResolver; | ||
| 35 | }; | ||
| 36 |