From 8b823261ef667780f100a7e49b6a4c6b3af1ed65 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 18 Nov 2026 15:39:07 +0100 Subject: [PATCH 1/2] Draw file names as plain text A file named like markup, such as "bold.txt", drew as rich text, bold and without its tag, because the labels that show names took Text's AutoText default, which guesses from the text whether it's markup. Every label that shows a file, folder, drive or app name, and the lines that quote one (the notice, a dialog's title, a rename's problem, the search field's hint and a search that found nothing), now draws plain text. Co-Authored-By: GM Co-Authored-By: Claude Opus 5.5 --- src/FileRow.qml | 1 + src/FileTile.qml | 5 +++-- src/FolderGrid.qml | 1 + src/FolderList.qml | 1 + src/FolderPane.qml | 1 + src/FolioDialog.qml | 1 + src/FolioMenuItem.qml | 1 + src/FormatDialog.qml | 2 ++ src/MediaPreview.qml | 1 + src/PathBar.qml | 2 ++ src/PlainButton.qml | 1 + src/PreviewPane.qml | 4 +++- src/PreviewWindow.qml | 1 + src/RenameDialog.qml | 1 + src/Sidebar.qml | 1 + tests/folio_tests.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++ 16 files changed, 68 insertions(+), 3 deletions(-) diff --git a/src/FileRow.qml b/src/FileRow.qml index 26031f46..4afa06fa 100644 --- a/src/FileRow.qml +++ b/src/FileRow.qml @@ -151,6 +151,7 @@ Item { Layout.minimumWidth: 120 horizontalAlignment: Text.AlignLeft text: row.name + textFormat: Text.PlainText color: row.current ? theme.accent : theme.foreground elide: Text.ElideMiddle } diff --git a/src/FileTile.qml b/src/FileTile.qml index 4be99d2d..2713009e 100644 --- a/src/FileTile.qml +++ b/src/FileTile.qml @@ -74,6 +74,7 @@ Item { anchors.horizontalCenter: parent.horizontalCenter width: parent.width - 28 text: tile.name + textFormat: Text.PlainText color: tile.current ? theme.accent : theme.foreground size: 12 horizontalAlignment: Text.AlignHCenter @@ -324,7 +325,7 @@ Item { width: badge.implicitWidth + 8 height: badge.implicitHeight + 2 color: tile.kindColor - FolioText { id: badge; anchors.centerIn: parent; text: tile.extension.slice(0, 4); size: 9; font.bold: true; color: theme.background } + FolioText { id: badge; anchors.centerIn: parent; text: tile.extension.slice(0, 4); textFormat: Text.PlainText; size: 9; font.bold: true; color: theme.background } } } } @@ -355,7 +356,7 @@ Item { } } } - FolioText { anchors.right: parent.right; anchors.bottom: parent.bottom; anchors.margins: 5; text: tile.extension; size: 9; color: theme.secondaryForeground } + FolioText { anchors.right: parent.right; anchors.bottom: parent.bottom; anchors.margins: 5; text: tile.extension; textFormat: Text.PlainText; size: 9; color: theme.secondaryForeground } } } diff --git a/src/FolderGrid.qml b/src/FolderGrid.qml index e64bc139..6c0591ef 100644 --- a/src/FolderGrid.qml +++ b/src/FolderGrid.qml @@ -112,6 +112,7 @@ GridView { text: searching ? qsTr("Searching…") : backend.folder.query ? qsTr("Nothing matches “%1”").arg(backend.folder.query) : plugins.views[backend.path] ? plugins.views[backend.path].empty : qsTr("This folder is empty") + textFormat: Text.PlainText color: theme.secondaryForeground } } diff --git a/src/FolderList.qml b/src/FolderList.qml index 518cd483..f8917bb0 100644 --- a/src/FolderList.qml +++ b/src/FolderList.qml @@ -96,6 +96,7 @@ FileListView { text: searching ? qsTr("Searching…") : backend.folder.query ? qsTr("Nothing matches “%1”").arg(backend.folder.query) : plugins.views[backend.path] ? plugins.views[backend.path].empty : qsTr("This folder is empty") + textFormat: Text.PlainText color: theme.secondaryForeground } } diff --git a/src/FolderPane.qml b/src/FolderPane.qml index aef2751c..87eb7173 100644 --- a/src/FolderPane.qml +++ b/src/FolderPane.qml @@ -407,6 +407,7 @@ FocusScope { id: bannerText Layout.fillWidth: true text: backend.message || backend.folder.error || (slowWork.shown ? slowWork.working : "") || backend.notice + textFormat: Text.PlainText color: theme.brightForeground elide: Text.ElideRight } diff --git a/src/FolioDialog.qml b/src/FolioDialog.qml index 04338d2e..6422f374 100644 --- a/src/FolioDialog.qml +++ b/src/FolioDialog.qml @@ -60,6 +60,7 @@ FocusScope { FolioText { Layout.fillWidth: true text: dialog.title + textFormat: Text.PlainText wrapMode: Text.Wrap color: theme.brightForeground size: 16 diff --git a/src/FolioMenuItem.qml b/src/FolioMenuItem.qml index c48870d3..16ad2871 100644 --- a/src/FolioMenuItem.qml +++ b/src/FolioMenuItem.qml @@ -46,6 +46,7 @@ MenuItem { anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter text: entry.text + textFormat: Text.PlainText color: !entry.enabled ? theme.secondaryForeground : entry.highlighted ? theme.brightForeground : theme.foreground } FolioText { diff --git a/src/FormatDialog.qml b/src/FormatDialog.qml index a8f545cf..a21a361a 100644 --- a/src/FormatDialog.qml +++ b/src/FormatDialog.qml @@ -54,12 +54,14 @@ FolioDialog { Layout.fillWidth: true visible: !!dialog.drive && dialog.drive.label.length > 0 text: dialog.drive ? dialog.drive.label : "" + textFormat: Text.PlainText color: theme.brightForeground elide: Text.ElideRight } FolioText { Layout.fillWidth: true text: dialog.drive ? dialog.drive.title : "" + textFormat: Text.PlainText color: dialog.drive && dialog.drive.label.length > 0 ? theme.secondaryForeground : theme.brightForeground elide: Text.ElideRight } diff --git a/src/MediaPreview.qml b/src/MediaPreview.qml index 07ace3cc..8ba72db4 100644 --- a/src/MediaPreview.qml +++ b/src/MediaPreview.qml @@ -78,6 +78,7 @@ Item { FolioText { Layout.alignment: Qt.AlignHCenter text: player.metaData.stringValue(MediaMetaData.Title) || previewer.item.name || "" + textFormat: Text.PlainText color: theme.brightForeground size: 16 font.weight: Font.DemiBold diff --git a/src/PathBar.qml b/src/PathBar.qml index 0b446a8a..d17dad5c 100644 --- a/src/PathBar.qml +++ b/src/PathBar.qml @@ -136,6 +136,7 @@ Rectangle { anchors.rightMargin: 12 anchors.verticalCenter: parent.verticalCenter text: backend.path.startsWith("plugin:") ? qsTr("Search %1").arg(here) : qsTr("Search %1 and below").arg(here) + textFormat: Text.PlainText color: theme.secondaryForeground size: 12 } @@ -195,6 +196,7 @@ Rectangle { } FolioText { text: crumb.modelData.name + textFormat: Text.PlainText color: crumb.last ? theme.brightForeground : crumbMouse.containsMouse ? theme.foreground : theme.secondaryForeground size: 14 font.weight: crumb.last ? Font.DemiBold : Font.Normal diff --git a/src/PlainButton.qml b/src/PlainButton.qml index 8327860d..83586d3c 100644 --- a/src/PlainButton.qml +++ b/src/PlainButton.qml @@ -46,6 +46,7 @@ AbstractButton { contentItem: FolioText { id: label text: button.text + textFormat: Text.PlainText color: button.destructive ? theme.background : button.primary ? theme.accentForeground : theme.foreground font.weight: button.filled ? Font.DemiBold : Font.Normal horizontalAlignment: Text.AlignHCenter diff --git a/src/PreviewPane.qml b/src/PreviewPane.qml index 5cc8a970..3f3770c5 100644 --- a/src/PreviewPane.qml +++ b/src/PreviewPane.qml @@ -195,6 +195,7 @@ Rectangle { Layout.fillWidth: true horizontalAlignment: Text.AlignLeft text: pane.item.name || "" + textFormat: Text.PlainText color: theme.brightForeground size: 15 font.weight: Font.DemiBold @@ -229,6 +230,7 @@ Rectangle { Layout.fillWidth: true horizontalAlignment: Text.AlignRight text: pane.trashed ? pane.homeless(pane.origin.replace(/\/[^\/]*$/, "") || "/") : "" + textFormat: Text.PlainText color: theme.foreground size: 12 elide: Text.ElideMiddle @@ -371,7 +373,7 @@ Rectangle { } contentItem: RowLayout { // A long app name ends in … rather than running past the button. - FolioText { Layout.leftMargin: 14; Layout.fillWidth: true; text: openButton.text; elide: Text.ElideRight; color: theme.accentForeground; font.weight: Font.DemiBold } + FolioText { Layout.leftMargin: 14; Layout.fillWidth: true; text: openButton.text; textFormat: Text.PlainText; elide: Text.ElideRight; color: theme.accentForeground; font.weight: Font.DemiBold } FolioText { Layout.rightMargin: 14; text: "⏎"; color: theme.accentForeground } } } diff --git a/src/PreviewWindow.qml b/src/PreviewWindow.qml index 2b710086..decebd22 100644 --- a/src/PreviewWindow.qml +++ b/src/PreviewWindow.qml @@ -98,6 +98,7 @@ ApplicationWindow { Layout.fillWidth: true horizontalAlignment: Text.AlignLeft text: win.item.name || "" + textFormat: Text.PlainText color: theme.brightForeground size: 15 font.weight: Font.DemiBold diff --git a/src/RenameDialog.qml b/src/RenameDialog.qml index 234d02fa..e38f400e 100644 --- a/src/RenameDialog.qml +++ b/src/RenameDialog.qml @@ -49,6 +49,7 @@ FolioDialog { horizontalAlignment: Text.AlignLeft visible: dialog.problem.length > 0 text: dialog.problem + textFormat: Text.PlainText color: theme.red wrapMode: Text.Wrap } diff --git a/src/Sidebar.qml b/src/Sidebar.qml index 67500c7a..e5f10f50 100644 --- a/src/Sidebar.qml +++ b/src/Sidebar.qml @@ -247,6 +247,7 @@ Rectangle { Layout.fillWidth: true horizontalAlignment: Text.AlignLeft text: row.text + textFormat: Text.PlainText elide: Text.ElideRight color: row.active ? theme.brightForeground : theme.foreground } diff --git a/tests/folio_tests.cpp b/tests/folio_tests.cpp index 6a0aeeb4..31f0d2c9 100644 --- a/tests/folio_tests.cpp +++ b/tests/folio_tests.cpp @@ -678,6 +678,53 @@ private slots: QTRY_COMPARE(orders(), expected); } + // A name that looks like markup is drawn as written, in the list and + // the grid alike, not as rich text that's bold and without its tags. + void namesDrawAsPlainText() + { + QTemporaryDir home; + const QString name = "bold.txt"; + write(home.filePath(name), "x"); + Backend backend(home.path()); + backend.navigate(home.path()); + Theme theme(home.filePath("theme")); + FileOps fileOps; + Translator translator(home.filePath("language"), home.path()); + Thumbnails thumbnails(home.filePath("cache"), {home.filePath("none")}); + qmlRegisterType("Folio", 1, 0, "FolderModel"); + QQmlEngine engine; + engine.rootContext()->setContextProperty("backend", &backend); + engine.rootContext()->setContextProperty("theme", &theme); + engine.rootContext()->setContextProperty("fileOps", &fileOps); + engine.rootContext()->setContextProperty("translator", &translator); + engine.rootContext()->setContextProperty("plugins", QVariantMap{{"views", QVariantMap{}}}); + engine.addImageProvider("thumb", new ThumbnailProvider(&thumbnails)); + QTRY_COMPARE(backend.folder()->rowCount(), 1); + for (const QString &view : {"FolderList", "FolderGrid"}) { + QQmlComponent component(&engine); + component.setData(QString(R"( + import QtQuick + Window { + width: 900; height: 480; visible: true + %1 { anchors.fill: parent } + } + )").arg(view).toUtf8(), QUrl::fromLocalFile(sourceFolder() + "/PlainNamesTest.qml")); + std::unique_ptr root(component.create()); + QVERIFY2(root, qPrintable(component.errorString())); + QList labels; + std::function walk = [&](QQuickItem *item) { + if (item->property("text").toString() == name && item->property("textFormat").isValid()) + labels << item; + for (auto *child : item->childItems()) + walk(child); + }; + QTRY_VERIFY2((labels.clear(), walk(qobject_cast(root.get())->contentItem()), !labels.isEmpty()), + qPrintable(view)); + for (QQuickItem *label : labels) + QCOMPARE(label->property("textFormat").toInt(), int(Qt::PlainText)); + } + } + // A place picked in the sidebar is the first column shown, with the // folders above it scrolled out of sight to the left; going up shows // them again. From c1819701f88ded5b54a1d82a29b5f2d213e40c91 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 18 Nov 2026 15:50:44 +0100 Subject: [PATCH 2/2] Draw the preview window's extension as plain text too A file with no preview shows its extension under a plain glyph, and that label still took AutoText: a file named "x.ty" showed a bold "TY" without its tag. It now draws plain text, as the grid's badges do. Co-Authored-By: Claude Opus 5.5 --- src/PreviewWindow.qml | 1 + tests/folio_tests.cpp | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/PreviewWindow.qml b/src/PreviewWindow.qml index decebd22..9d35bba9 100644 --- a/src/PreviewWindow.qml +++ b/src/PreviewWindow.qml @@ -397,6 +397,7 @@ ApplicationWindow { FolioText { Layout.alignment: Qt.AlignHCenter text: win.item.extension || "" + textFormat: Text.PlainText color: theme.accent font.weight: Font.DemiBold } diff --git a/tests/folio_tests.cpp b/tests/folio_tests.cpp index 31f0d2c9..ad3050e3 100644 --- a/tests/folio_tests.cpp +++ b/tests/folio_tests.cpp @@ -6913,6 +6913,41 @@ private slots: QCOMPARE(previewer.item().value("mime").toString(), QString("application/zip")); } + // A file with no preview is named, and its extension shown, as written, + // however much they look like markup. + void previewWindowDrawsNamesAsPlainText() + { + QTemporaryDir dir; + write(dir.filePath("x.ty"), QByteArray("abc\0def", 7)); + Theme theme(dir.filePath("theme")); + Translator translator(dir.filePath("language"), dir.path()); + Thumbnails thumbnails(dir.filePath("cache"), {dir.filePath("none")}); + Previewer previewer; + previewer.start(dir.filePath("x.ty"), false, "name"); + QQmlApplicationEngine engine; + engine.addImageProvider("thumb", new ThumbnailProvider(&thumbnails)); + engine.rootContext()->setContextProperty("translator", &translator); + engine.rootContext()->setContextProperty("theme", &theme); + engine.rootContext()->setContextProperty("previewer", &previewer); + engine.load(QUrl("qrc:/PreviewWindow.qml")); + QVERIFY(!engine.rootObjects().isEmpty()); + auto *window = qobject_cast(engine.rootObjects().first()); + QTRY_COMPARE(previewer.viewer(), QString("other")); + const auto formatOf = [&](const QString &text) { + int format = -1; + std::function walk = [&](QQuickItem *item) { + if (item->property("text").toString() == text && item->property("textFormat").isValid()) + format = item->property("textFormat").toInt(); + for (auto *child : item->childItems()) + walk(child); + }; + walk(window->contentItem()); + return format; + }; + QTRY_COMPARE(formatOf("x.ty"), int(Qt::PlainText)); + QTRY_COMPARE(formatOf("TY"), int(Qt::PlainText)); + } + void previewerShowsOnlyWhatLaysOutQuickly() { // The preview lays out all it's given on its UI thread, about a