Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions settings/qt6-app/qml/pages/PageModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,18 @@ Item {
spacing: 12

Repeater {
id: statTiles
model: [
{ label: "Latency", value: Engine.latencyP50 + " ms" },
{ label: "RAM", value: Engine.ramGb.toFixed(1) + " GB" },
{ label: "CPU", value: Engine.cpuPct + "%" },
]
].concat(Engine.gpuAvailable ? [
{ label: "VRAM", value: Engine.vramGb.toFixed(1) + " GB" },
{ label: "GPU", value: Engine.gpuPct + "%" },
] : [])
delegate: Rectangle {
required property var modelData
width: (parent.width - 24) / 3; height: 52
width: (parent.width - 12 * (statTiles.count - 1)) / statTiles.count; height: 52
radius: 7
color: Theme.ink03; border.width: 1; border.color: Theme.ink06

Expand Down
32 changes: 23 additions & 9 deletions settings/qt6-app/qml/pages/PagePersonalisation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ Item {
width: parent.width
spacing: 12

// Accept rate and time saved come from the engine's in-memory
// counters (metrics.json), which reset when fcitx5 restarts —
// hence "this session" and no per-day bars for those two.
Repeater {
model: [
{ label: "Words learned", value: CorpusStats.words.toLocaleString(), bars: [20, 30, 25, 40, 38, 50, CorpusStats.words > 0 ? 100 : 0] },
{ label: "Accept rate · 7d", value: "0%", bars: [0, 0, 0, 0, 0, 0, 0] },
{ label: "Time saved · 7d", value: "0 s", bars: [0, 0, 0, 0, 0, 0, 0] },
{ label: "Words learned", value: CorpusStats.words.toLocaleString(), bars: CorpusStats.wordsPerDay },
{ label: "Accept rate · this session", value: Math.round(Engine.acceptRate * 100) + "%", bars: [] },
{ label: "Time saved · this session", value: root.formatDuration(Engine.secondsSaved), bars: [] },
]
delegate: Rectangle {
required property var modelData
Expand Down Expand Up @@ -63,6 +66,7 @@ Item {
}
Item { width: 6 }
XBars {
opacity: modelData.bars.length > 0 ? 1 : 0 // keep the slot so labels stay aligned
values: modelData.bars
width: 56; height: 24
anchors.verticalCenter: parent.verticalCenter
Expand Down Expand Up @@ -307,6 +311,15 @@ Item {
}
}

// Time saved is an estimate: accepted characters at an assumed typing
// speed (EngineProbe::kCharsPerSecond).
function formatDuration(secs) {
const s = Math.round(secs)
if (s < 60) return s + " s"
if (s < 3600) return Math.round(s / 60) + " min"
return (s / 3600).toFixed(1) + " h"
}

function exportProfile() {
const src = Qt.resolvedUrl("file://" + Qt.platform.os) // placeholder
// In a real app: QFileDialog exposed via invokable; for now show toast
Expand All @@ -325,13 +338,14 @@ Item {

Rectangle {
anchors.centerIn: parent
width: 320; height: 160
width: 320; height: confirmCol.implicitHeight + 40
radius: Theme.radius.card
color: Qt.rgba(0.08, 0.06, 0.13, 0.97)
border.color: Theme.ink12; border.width: 1

Column {
anchors { fill: parent; margins: 20 }
id: confirmCol
anchors { left: parent.left; right: parent.right; top: parent.top; margins: 20 }
spacing: 16

Text {
Expand All @@ -342,7 +356,7 @@ Item {
}
Text {
width: parent.width
text: "This removes all learned text. A backup is saved automatically."
text: "This permanently deletes everything XType learned from your typing. The engine stops using it within 5 minutes."
font.family: Theme.sansFamily; font.pixelSize: 12
color: Theme.ink65; wrapMode: Text.WordWrap
renderType: Text.NativeRendering
Expand All @@ -355,9 +369,9 @@ Item {
variant: "primary"
onClicked: {
resetConfirm.visible = false
// xtype-corpus wipe --yes is destructive — run and refresh stats
Qt.openUrlExternally("xtype-corpus://wipe") // no-op placeholder
CorpusStats.refresh()
const removed = CorpusStats.wipe()
StyleProfile.refresh()
wipeText.text = removed < 0 ? "Could not delete some corpus files" : "Corpus wiped"
wipeToast.show()
}
}
Expand Down
110 changes: 58 additions & 52 deletions settings/qt6-app/qml/primitives/XSidebar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -139,58 +139,28 @@ Item {
}
}

// CPU row
Row {
width: parent.width
spacing: 8
Text {
text: "CPU"
font.family: Theme.sansFamily; font.pixelSize: 10
font.capitalization: Font.AllUppercase
color: Theme.ink45; font.weight: Font.DemiBold
renderType: Text.NativeRendering
anchors.verticalCenter: parent.verticalCenter
}
XMiniBar {
value: Engine.cpuPct / 100.0
anchors.verticalCenter: parent.verticalCenter
width: parent.width - cpuLabel.implicitWidth - 38
}
Text {
id: cpuLabel
text: Engine.cpuPct + "%"
font.family: Theme.monoFamily; font.pixelSize: 11
color: Theme.ink80
renderType: Text.NativeRendering
anchors.verticalCenter: parent.verticalCenter
}
// Resource rows. GPU/VRAM only appear on machines with an NVIDIA GPU.
StatRow {
caption: "CPU"
fraction: Engine.cpuPct / 100.0
valueText: Engine.cpuPct + "%"
}

// RAM row
Row {
width: parent.width
spacing: 8
Text {
text: "RAM"
font.family: Theme.sansFamily; font.pixelSize: 10
font.capitalization: Font.AllUppercase
color: Theme.ink45; font.weight: Font.DemiBold
renderType: Text.NativeRendering
anchors.verticalCenter: parent.verticalCenter
}
XMiniBar {
value: Math.min(1.0, Engine.ramGb / 4.0)
anchors.verticalCenter: parent.verticalCenter
width: parent.width - ramLabel.implicitWidth - 38
}
Text {
id: ramLabel
text: Engine.ramGb.toFixed(1) + " GB"
font.family: Theme.monoFamily; font.pixelSize: 11
color: Theme.ink80
renderType: Text.NativeRendering
anchors.verticalCenter: parent.verticalCenter
}
StatRow {
caption: "RAM"
fraction: Math.min(1.0, Engine.ramGb / 4.0)
valueText: Engine.ramGb.toFixed(1) + " GB"
}
StatRow {
visible: Engine.gpuAvailable
caption: "GPU"
fraction: Engine.gpuPct / 100.0
valueText: Engine.gpuPct + "%"
}
StatRow {
visible: Engine.gpuAvailable
caption: "VRAM"
fraction: Engine.vramTotalGb > 0 ? Math.min(1.0, Engine.vramGb / Engine.vramTotalGb) : 0
valueText: Engine.vramGb.toFixed(1) + " GB"
}

// Engine line
Expand All @@ -207,7 +177,43 @@ Item {
}
}

// ── Inline component ───────────────────────────────────────────────────
// ── Inline components ──────────────────────────────────────────────────
// Caption and value columns have fixed widths so the bars line up.
TextMetrics { id: captionMetrics; font.family: Theme.sansFamily; font.pixelSize: 10; font.weight: Font.DemiBold; text: "VRAM" }
TextMetrics { id: valueMetrics; font.family: Theme.monoFamily; font.pixelSize: 11; text: "00.0 GB" }

component StatRow: Row {
id: statRow
property string caption: ""
property real fraction: 0.0 // 0.0 – 1.0
property string valueText: ""
width: parent ? parent.width : 0
spacing: 8
Text {
width: captionMetrics.advanceWidth
text: statRow.caption
font.family: Theme.sansFamily; font.pixelSize: 10
font.capitalization: Font.AllUppercase
color: Theme.ink45; font.weight: Font.DemiBold
renderType: Text.NativeRendering
anchors.verticalCenter: parent.verticalCenter
}
XMiniBar {
value: statRow.fraction
anchors.verticalCenter: parent.verticalCenter
width: statRow.width - captionMetrics.advanceWidth - valueMetrics.advanceWidth - 2 * statRow.spacing
}
Text {
width: valueMetrics.advanceWidth
horizontalAlignment: Text.AlignRight
text: statRow.valueText
font.family: Theme.monoFamily; font.pixelSize: 11
color: Theme.ink80
renderType: Text.NativeRendering
anchors.verticalCenter: parent.verticalCenter
}
}

component NavItem: Item {
id: navRoot
property string navId: ""
Expand Down
Loading