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
1 change: 1 addition & 0 deletions src/FileRow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions src/FileTile.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
}
}
}
Expand Down Expand Up @@ -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 }
}
}

Expand Down
1 change: 1 addition & 0 deletions src/FolderGrid.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
1 change: 1 addition & 0 deletions src/FolderList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
1 change: 1 addition & 0 deletions src/FolderPane.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/FolioDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ FocusScope {
FolioText {
Layout.fillWidth: true
text: dialog.title
textFormat: Text.PlainText
wrapMode: Text.Wrap
color: theme.brightForeground
size: 16
Expand Down
1 change: 1 addition & 0 deletions src/FolioMenuItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/FormatDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/MediaPreview.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/PathBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/PlainButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/PreviewPane.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/PreviewWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ ApplicationWindow {
Layout.fillWidth: true
horizontalAlignment: Text.AlignLeft
text: win.item.name || ""
textFormat: Text.PlainText
Comment thread
dhh marked this conversation as resolved.
Resolved
color: theme.brightForeground
size: 15
font.weight: Font.DemiBold
Expand Down Expand Up @@ -396,6 +397,7 @@ ApplicationWindow {
FolioText {
Layout.alignment: Qt.AlignHCenter
text: win.item.extension || ""
textFormat: Text.PlainText
color: theme.accent
font.weight: Font.DemiBold
}
Expand Down
1 change: 1 addition & 0 deletions src/RenameDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/Sidebar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
82 changes: 82 additions & 0 deletions tests/folio_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<b>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<FolderModel>("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<QObject> root(component.create());
QVERIFY2(root, qPrintable(component.errorString()));
QList<QQuickItem *> labels;
std::function<void(QQuickItem *)> 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<QQuickWindow *>(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.
Expand Down Expand Up @@ -6866,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.<b>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.<b>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<QQuickWindow *>(engine.rootObjects().first());
QTRY_COMPARE(previewer.viewer(), QString("other"));
const auto formatOf = [&](const QString &text) {
int format = -1;
std::function<void(QQuickItem *)> 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.<b>ty"), int(Qt::PlainText));
QTRY_COMPARE(formatOf("<B>TY"), int(Qt::PlainText));
}

void previewerShowsOnlyWhatLaysOutQuickly()
{
// The preview lays out all it's given on its UI thread, about a
Expand Down
Loading