From 16c8c62213d4e7e478f2503201437b6d8d3ba487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Gonz=C3=A1les=20D=C3=ADaz?= Date: Sun, 15 Nov 2026 18:07:32 -0500 Subject: [PATCH 1/2] Make Backend::showItem invokable from QML Clicking a file in the column showing the selected folder's contents called showItem from QML, which failed with "Property 'showItem' of object Backend is not a function". The test calls it through the meta-object system, as QML does. Co-Authored-By: Claude Sonnet 5.5 --- src/backend.h | 2 +- tests/folio_tests.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/backend.h b/src/backend.h index 464d5023..b8e077af 100644 --- a/src/backend.h +++ b/src/backend.h @@ -106,7 +106,7 @@ class Backend : public QObject { // Called for org.freedesktop.FileManager1: open a folder, or open the // folder holding a file and select it. void showFolder(const QString &path); - void showItem(const QString &path); + Q_INVOKABLE void showItem(const QString &path); static QString expandTyped(const QString &text, const QString &home, const QString ¤t); static QString complete(const QString &text, const QString &home, const QString ¤t); diff --git a/tests/folio_tests.cpp b/tests/folio_tests.cpp index 42458bd1..aa9cb179 100644 --- a/tests/folio_tests.cpp +++ b/tests/folio_tests.cpp @@ -3320,6 +3320,18 @@ private slots: QCOMPARE(backend.takeSelection(), QString("report.pdf")); } + void backendShowItemIsCallableFromQml() + { + // QML reaches the backend through the meta-object system, so a call + // from C++ proves nothing about it. + QTemporaryDir home; + write(home.filePath("report.pdf"), "x"); + Backend backend(home.path()); + QVERIFY(QMetaObject::invokeMethod(&backend, "showItem", Q_ARG(QString, home.filePath("report.pdf")))); + QCOMPARE(backend.path(), home.path()); + QCOMPARE(backend.takeSelection(), QString("report.pdf")); + } + void backendReadsDetailsOffTheUiThread() { // A picture's size and a text's opening lines are read in the From 371e5f13458ae1914216e310e73ec4603a6584c7 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 16 Nov 2026 10:42:03 +0100 Subject: [PATCH 2/2] Call showItem through the meta-object system in its existing test The existing test called showItem from C++, which never needed Q_INVOKABLE. Calling it the way QML does makes that one test cover both what showItem does and that QML can reach it, so the second test is dropped. Co-Authored-By: Claude Opus 5.5 --- tests/folio_tests.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tests/folio_tests.cpp b/tests/folio_tests.cpp index aa9cb179..4d2cad08 100644 --- a/tests/folio_tests.cpp +++ b/tests/folio_tests.cpp @@ -3315,18 +3315,7 @@ private slots: QTemporaryDir home; write(home.filePath("report.pdf"), "x"); Backend backend(home.path()); - backend.showItem(home.filePath("report.pdf")); - QCOMPARE(backend.path(), home.path()); - QCOMPARE(backend.takeSelection(), QString("report.pdf")); - } - - void backendShowItemIsCallableFromQml() - { - // QML reaches the backend through the meta-object system, so a call - // from C++ proves nothing about it. - QTemporaryDir home; - write(home.filePath("report.pdf"), "x"); - Backend backend(home.path()); + // As QML calls it, through the meta-object system. QVERIFY(QMetaObject::invokeMethod(&backend, "showItem", Q_ARG(QString, home.filePath("report.pdf")))); QCOMPARE(backend.path(), home.path()); QCOMPARE(backend.takeSelection(), QString("report.pdf"));