Fluent-Qt

API 參考

FluentElement

為基於 QWidget 的元件提供共用的 Fluent 設計 token 與佈景主題回呼。

fluent::FluentElement

列舉

enum Theme

解析設計 token 時使用的全域視覺佈景主題。

  • Light = 0
  • Dark = 1
  • HighContrast = 2

方法

static void setTheme(Theme theme)

更新全域主題,並通知使用中的 FluentElement 執行個體。

static void setThemeDeferred(Theme theme)

排程以可見元素優先的批次主題重新整理,避免阻斷目前的互動。

static Theme currentTheme()

傳回目前生效的全域主題。

static bool themeUsesDarkAppearance(Theme theme)

傳回主題是否使用深色底的視窗框架與材質 token。

static void refreshTheme()

在設計 token 變更後重新廣播目前佈景主題以觸發重繪。

static int themeGeneration()

每次主題變更時遞增的單調計數器,用於過期檢查。

Theme effectiveTheme() const

解析此元素所使用的佈景主題,並遵循繼承的 QWidget 覆寫。

bool effectiveThemeUsesDarkAppearance() const

傳回此元素的實際主題是否使用深色底 chrome。

bool setThemeOverrides(const QJsonObject& overrides)

取代此元素的稀疏色彩、圓角與字型 token 覆寫。

QJsonObject themeOverrides() const

傳回此元素的覆寫設定。

void clearThemeOverrides()

將全部 token 欄位還原為全域主題預設值。

const Colors& themeColorsRef() const

對目前使用中色組的不複製存取(適用於繪製熱路徑)。

Material::AcrylicToken themeAcrylic() const

材質、高度層級與自適應版面配置 token。

QColor themeBackdrop(bool active) const

指定啟用狀態下的視窗 chrome 背景色。

virtual void onThemeUpdated()

在全域主題變更後呼叫。

型別與別名

struct Colors

傳回給元件使用的設計 token 快照。

受保護成員

建構函式

解構函式

欄位

FluentElementPrivate* d_ptr

保留用於 1.x 原始碼相容性。

fluent::FluentElement::Colors

傳回給元件使用的設計 token 快照。

欄位

QColor textOnAccent

強調色背景上的文字(白/黑)。

QColor textAccentPrimary

一般背景上的強調色文字。

QColor bgLayerOverlay

半透明視窗的分層內容遮罩。

fluent::FluentElement::FontStyle

欄位

QString styleName

精確靜態字型,例如 "Regular" 或 "Semibold"。

int lineHeight

絕對行高,Figma 實測值。

方法

fluent::FluentElement::Radius

欄位

int none

直角。

int control

頁面內控制項。

int overlay

浮層容器(Dialog、ToolTip、Flyout)。

fluent::FluentElement::Spacing

欄位

controlHeight

標準控制項高度。

fluent::FluentElement::Animation

欄位