6#include "phosphorcontrol_export.h"
16#include <QVariantList>
17#include <QtQml/qqmlregistration.h>
57 QML_UNCREATABLE(
"ApplicationController is constructed in C++.")
102 QString stepHistory(QStringList& from, QStringList& to);
108 bool isUsableHistoryEntry(
const QString&
id)
const;
150 const QString& iconSource = QString(),
bool isCollapsible =
false,
bool hasDividerAfter =
false,
152 const QString& counterpartId = QString());
205 Q_INVOKABLE QVariantList
extensionsFor(
const QString& pageId,
const QString& slot)
const;
206 using ExtensionProvider = std::function<QVariantList(
const QString& pageId,
const QString& slot)>;
323 void onDomainDirtyChanged();
324 void onTrackedDomainDestroyed();
330 void pruneAttachments();
331 void recomputeDirty();
343 void completeApplyIfDone();
344 void completeDiscardIfDone();
350 QList<QPointer<StagingDomain>> m_domains;
351 QString m_currentPageId;
354 quint64 m_navigationSerial = 0;
356 QPointer<QObject> m_navigationHookOwner;
359 QPointer<QObject> m_extensionProviderOwner;
362 QHash<QString, QList<QPointer<StagingDomain>>> m_pageAttachments;
368 QStringList m_backHistory;
369 QStringList m_forwardHistory;
370 bool m_navigatingHistory =
false;
373 static constexpr int MaxHistoryEntries = 64;
375 QString m_pendingAnchor;
376 QString m_pendingAnchorPage;
377 bool m_dirty =
false;
382 bool m_inTransaction =
false;
386 bool m_recomputingDirty =
false;
390 bool m_recomputeDirtyPending =
false;
394 bool m_dirtyNotifyPending =
false;
399 int m_applyPending = 0;
400 QStringList m_applyErrors;
401 bool m_applying =
false;
402 int m_discardPending = 0;
403 QStringList m_discardErrors;
404 bool m_discarding =
false;
417 quint64 m_applyGeneration = 0;
418 quint64 m_discardGeneration = 0;
437 QSet<StagingDomain*> m_applyOutstanding;
438 QSet<StagingDomain*> m_discardOutstanding;
447 QList<QMetaObject::Connection> m_applyConnections;
448 QList<QMetaObject::Connection> m_discardConnections;
453 static constexpr int DefaultAsyncBatchTimeoutMs = 60'000;
454 int m_asyncBatchTimeoutMs = DefaultAsyncBatchTimeoutMs;
std::function< void(const QString &pageId)> NavigationHook
Called with the target page id when setCurrentPageId moves to a known page other than the current one...
Definition ApplicationController.h:181
void applyAllAsync()
Async variant of applyAll — collects each dirty domain's applyResult signal and emits applyAllComplet...
void discardAllAsync()
Symmetric to applyAllAsync; emits discardAllComplete(ok, errors).
int asyncBatchTimeoutMs() const
Async-batch timeout in milliseconds, DefaultAsyncBatchTimeoutMs by default: generous for D-Bus round ...
std::function< QVariantList(const QString &pageId, const QString &slot)> ExtensionProvider
Definition ApplicationController.h:206
void discardingChanged()
Symmetric to applyingChanged for discardAllAsync.
void clearExtensionProvider(const QObject *owner)
Remove the provider if owner installed it.
QString takePendingAnchor(const QString &pageId)
Returns + clears the pending anchor iff it targets pageId; otherwise returns an empty string (consume...
QString titlePathFor(const QString &id) const
The page's title path: every ancestor title root-first, then the page's own title,...
void setCurrentPageId(const QString &id)
void forceResetAsyncState()
Force-reset the async-batch state machine to idle.
QString currentPageId() const
bool isDiscarding() const
True while discardAllAsync is in flight — symmetric with isApplying.
bool bindPage(const QString &id, PageController *controller, const QUrl &qmlSource)
Give the already-registered page id its real controller and QML source (PageRegistry::bindPage,...
~ApplicationController() override
bool canGoBack() const
Browser-style navigation history over currentPageId.
bool setExtensionProvider(QObject *owner, ExtensionProvider provider)
Install provider on behalf of owner.
void historyChanged()
Emitted when canGoBack / canGoForward may have flipped (shared NOTIFY for both properties — they alwa...
void extensionsChanged(const QString &pageId)
The sections added to page pageId changed (notifyExtensionsChanged).
void setPendingAnchor(const QString &pageId, const QString &anchor)
Deep-link reveal latch (generic — every settings app built on this shell gets deep-link-to-anchor for...
QStringList dirtyPageIds() const
Ids of every registered page whose controller, or a domain attached to it (attachDomainToPage),...
void discardAllComplete(bool ok, const QStringList &errors)
Symmetric to applyAllComplete for discardAllAsync.
void clearNavigationHook(const QObject *owner)
Remove the hook if owner installed it. A no-op otherwise.
bool registerDomain(StagingDomain *domain)
Register a headless staging domain (no sidebar entry).
QStringList parentChainFor(const QString &id) const
Walk the parent chain from the registered entry for id to the top level.
void applyingChanged()
Emitted on every applying-state transition (false→true at the start of applyAllAsync,...
ApplicationController(QObject *parent=nullptr)
PageRegistry * registry() const
void applyAllComplete(bool ok, const QStringList &errors)
Emitted exactly once per applyAllAsync invocation, when every dirty domain's applyResult has been rec...
void setAsyncBatchTimeoutMs(int ms)
QString gotoPreviousPage()
Navigate to the previous / next navigable page (one with a qmlSource) in the order the sidebar draws ...
bool setNavigationHook(QObject *owner, NavigationHook hook)
Install hook on behalf of owner.
bool isTrackedDomain(const StagingDomain *domain) const
True iff domain is tracked: a registered page's controller or a registered headless domain.
static QString titlePathSeparator()
The separator between the titles of a page path (U+203A), shared by titlePathFor and SearchController...
void currentPageIdChanged()
void notifyExtensionsChanged(const QString &pageId)
Tell ExtensionSlots on page pageId to read extensionsFor again.
void attachDomainToPage(StagingDomain *domain, const QString &pageId)
Count domain as part of page pageId: dirtyPageIds() lists the page while the domain is dirty,...
bool canGoForward() const
void pendingAnchorChanged()
Emitted when the deep-link pending anchor is set or cleared.
QVariantList extensionsFor(const QString &pageId, const QString &slot) const
The sections other modules add to slot slot of page pageId, for the QML ExtensionSlot.
bool isApplying() const
True while applyAllAsync is in flight (at least one domain's applyResult hasn't landed yet).
void registerPage(PageController *page, const QString &parentId, const QString &title, const QUrl &qmlSource, const QString &iconSource=QString(), bool isCollapsible=false, bool hasDividerAfter=false, PageRegistry::PageVisibility visibility=PageRegistry::PageVisibility::Always, const QString &counterpartId=QString())
Register a page in the sidebar.
Base class for a settings page: a staging domain backed by a QML page that appears in the sidebar.
Definition PageController.h:24
Abstract base for anything that holds staged user changes pending an Apply.
Definition StagingDomain.h:30
Definition ApplicationController.h:21