Skip to main content

A pure QML-based Fluent Design component library with 120fps+ smooth animations

Project description

FluentQML

简体中文 | English

基于 PySide6 + QML 的 Fluent Design 组件库,提供 120fps+ 流畅动画体验。

✨ 特性

  • 纯 QML 渲染:无帧率限制,120fps+ 流畅动画
  • Fluent Design:微软 Fluent Design System 组件
  • Python 集成:PySide6 无缝集成,Python 侧管理业务逻辑
  • 配置系统:JSON 持久化 + 原子写入 + QML Property 桥接
  • 响应式状态:细粒度 Store 状态管理,支持 watch / batch 模式
  • 窗口管理:多种窗口布局 + 懒加载 + 云母效果 + 系统托盘
  • 跨平台:Windows、macOS、Linux

📦 安装

pip install fqml

注:PyPI 包名为 fqml(fluentqml 已被占用),但导入名仍是 fluentqml(from fluentqml import ...)。

开发模式安装:

git clone https://github.com/aki-riko/FluentQML.git
cd FluentQML
pip install -e ".[dev]"

🚀 快速开始

from fluentqml import App, Window, WindowType

app = App()
window = app.create_window(WindowType.BAR)
window.setWindowTitle("我的应用")
window.resize(1200, 800)

# 添加导航页面
window.addPage(HomePage, "Home", "首页")
window.addPage(SettingsPage, "Settings", "设置")

window.show()
app.exec()

🏗️ 架构

fluentqml/
├── FluentQML/              # QML 组件(模块名 FluentQML)
│   ├── controls/           # UI 控件
│   ├── _internal/          # 内部窗口实现
│   └── FluentEnums/        # 枚举与常量
└── python/                 # Python 模块
    ├── config/             # 配置管理系统
    ├── core/               # 核心引擎(主题/日志/图标/阴影)
    ├── window/             # 窗口管理(懒加载/云母/托盘)
    ├── state/              # 响应式状态存储
    ├── providers/          # 功能提供者(SVG/二维码/取色器)
    └── models/             # 数据模型(高性能表格)

📐 窗口类型

类型 枚举值 说明
WindowType.BAR 1 紧凑侧边导航(默认)
WindowType.SPLIT 0 展开式侧边导航
WindowType.FILLED 2 填充式分割窗口
from fluentqml import App, Window, WindowType

app = App()

# 紧凑侧边导航(默认)
window = app.create_window(WindowType.BAR)

# 展开式侧边导航
window = app.create_window(WindowType.SPLIT)

🎨 主题系统

切换主题

from fluentqml import setTheme, Theme

setTheme(Theme.LIGHT)   # 浅色
setTheme(Theme.DARK)    # 深色
setTheme(Theme.AUTO)    # 跟随系统

自定义主题色

from fluentqml import setAccentColor, getAccentColor

setAccentColor("#0078d4")
print(getAccentColor())  # "#0078d4"

QML 中使用

import FluentQML as Fluent

// Primary 按钮(style_primary 自动使用全局主题色)
Fluent.Button {
    text: "确定"
    style: Fluent.Enums.button.style_primary
}

// 访问 ThemeManager 属性
Rectangle {
    color: ThemeManager.accentColor
}

说明:ComboBoxSlider 因与 QtQuick.Controls 原生类型同名,未在顶层 FluentQML 模块导出, 需按子模块目录导入后使用,例如 import "../fluentqml/FluentQML/controls/inputs"

⚙️ 配置系统

配置系统采用五层架构:ValidatorSettingEntrySettingsBaseAppConfigConfigManager

  • JSON 持久化:默认存储于 ~/.fluentqml/app.json
  • 原子写入:先写临时文件再替换,防止断电数据丢失
  • QML 桥接:通过 ConfigManager 单例暴露为 QML Property
from fluentqml.python.config import AppConfig, getConfigManager

# 获取配置值
config = getConfigManager()
print(config.lazyLoading)   # True
print(config.dpiScale)      # 0(跟随系统)

# 修改配置(自动保存到 JSON)
config.setDpiScale(150)

自定义配置项

from typing import ClassVar
from fluentqml.python.config import (
    SettingsBase, SettingEntry, EnumEntry,
    Validator,
)


class MyAppConfig(SettingsBase):
    auto_save: ClassVar[SettingEntry] = SettingEntry(
        group="Editor", name="AutoSave",
        default=True, validator=Validator.boolean(),
    )
    font_size: ClassVar[EnumEntry] = EnumEntry(
        group="Editor", name="FontSize",
        default=14,
        validator=Validator.choice([12, 14, 16, 18, 20, 24]),
    )

📊 状态管理

Store 提供响应式状态存储,支持细粒度 watch 和批量更新:

from fluentqml import Store

class AppStore(Store):
    def __init__(self):
        super().__init__("app")
        self.define("user", None)
        self.define("count", 0)

store = AppStore()

# 监听变化
store.watch("count", lambda new, old: print(f"{old}{new}"))

# 设置值
store.set("count", 1)     # 输出: 0 → 1

# 批量更新(合并通知)
with store.batch():
    store.set("count", 10)
    store.set("user", "Alice")
# 退出 with 时统一通知

# 字典语法
store["count"] = 20
print(store["count"])      # 20

🔔 系统托盘

from fluentqml import SystemTrayIcon, Icon

tray = SystemTrayIcon(icon="AppIcon.png", toolTip="我的应用")
tray.addAction(text="显示", icon="Visibility", triggered=window.show)
tray.addSeparator()
tray.addAction(text="退出", icon="Power", triggered=app.quit)
tray.show()

🧩 UI 组件

控件

Button · Card · CheckBox · ToggleSwitch · LineEdit · ComboBox · Slider · ProgressBar · SpinBox · TableView · ListView · TreeView

导航

NavigationBar · NavigationView · Pivot · Breadcrumb · Windows

特效

Shadow · ShadowedRectangle · ColorOverlay · GaussianBlur

完整组件清单见各 controls/ 子目录的 qmldirComboBoxSlider 等与 QtQuick 原生同名的组件需经子模块目录导入。

🧪 测试

python -m pytest tests/ -v

📄 License

FluentQML is licensed under the MIT License.

Copyright © 2026 aki-riko.

🙏 Credits

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fqml-0.2.3.tar.gz (1.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fqml-0.2.3-cp39-abi3-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.9+Windows x86-64

fqml-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

fqml-0.2.3-cp39-abi3-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file fqml-0.2.3.tar.gz.

File metadata

  • Download URL: fqml-0.2.3.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fqml-0.2.3.tar.gz
Algorithm Hash digest
SHA256 ef7e65d0160dd98c874a5008c68325ccea4c54c451cc8101f882dd3a41a27842
MD5 601b9b76234d77bfb577d3fec6945bad
BLAKE2b-256 21101ca9b9989181a1b31341f04933c05f6ef05aec6df8ee9300abd25f0dabb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for fqml-0.2.3.tar.gz:

Publisher: release.yml on aki-riko/FluentQML

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fqml-0.2.3-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: fqml-0.2.3-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.1 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fqml-0.2.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0aeee653b412ebd1524ba6572be41bbe20e9558d1881de60bdbce6427ff86ee9
MD5 a57946e41762305b0b4b97e69b66c266
BLAKE2b-256 5fbc262ef0fcc3af1ba0b0a80c5062a7c29bf4fac979b4fe17e7a2b0f01f2257

See more details on using hashes here.

Provenance

The following attestation bundles were made for fqml-0.2.3-cp39-abi3-win_amd64.whl:

Publisher: release.yml on aki-riko/FluentQML

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fqml-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fqml-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 008ca14a77443872e9d9c5496503043f26b67c91246aa179209d8c8de60b1e51
MD5 e69515789500ea5b00b326e6d6c9fadf
BLAKE2b-256 d43bf38e84083ee5d61ef82d67b20c6733a8ff5b4cf8b2584fed7916d6058b71

See more details on using hashes here.

Provenance

The following attestation bundles were made for fqml-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on aki-riko/FluentQML

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fqml-0.2.3-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fqml-0.2.3-cp39-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 4.2 MB
  • Tags: CPython 3.9+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fqml-0.2.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b71aed76c2c9b477921f53db0b0f053b35f6e733e4e659720a19dbc15267a930
MD5 5127bd3509e5a7ea31018561762e14cf
BLAKE2b-256 a07857ac53ead2d1f8697efcec8f511ede5b0b14aeb37c8974bdf67f6cc1ede5

See more details on using hashes here.

Provenance

The following attestation bundles were made for fqml-0.2.3-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on aki-riko/FluentQML

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page