mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 06:00:51 +00:00
Bundle connectors next to the Bonsai Viewer executable
Connector discovery scanned a per-user data directory (QStandardPaths::GenericDataLocation -> ~/.local/share/IfcOpenShell/ BonsaiViewer/connectors and the macOS/Windows equivalents). Connectors are now meant to ship with the application, so there is no reason to look outside the install tree. Replace userConnectorsDir() with bundledConnectorsDir(), which returns QCoreApplication::applicationDirPath() + "/connectors". discoverConnectors() scans only that path; its first-wins / malformed-manifest handling is unchanged. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "Discovery.h"
|
#include "Discovery.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@@ -27,7 +28,6 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QStandardPaths>
|
|
||||||
|
|
||||||
namespace bonsaiviewer::modules::connectors {
|
namespace bonsaiviewer::modules::connectors {
|
||||||
|
|
||||||
@@ -78,20 +78,15 @@ bool parseManifest(const QString& folder, ConnectorManifest& out) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
QString userConnectorsDir() {
|
QString bundledConnectorsDir() {
|
||||||
// GenericDataLocation maps to the platform's per-user data root:
|
// Connectors ship alongside the executable in a "connectors" subdirectory.
|
||||||
// Linux -> ~/.local/share
|
return QDir(QCoreApplication::applicationDirPath()).filePath("connectors");
|
||||||
// macOS -> ~/Library/Application Support
|
|
||||||
// Win -> %APPDATA% (Roaming)
|
|
||||||
// matching the Bonsai Viewer connector protocol docs.
|
|
||||||
const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
|
||||||
return QDir(base).filePath("IfcOpenShell/BonsaiViewer/connectors");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ConnectorManifest> discoverConnectors() {
|
std::vector<ConnectorManifest> discoverConnectors() {
|
||||||
std::vector<ConnectorManifest> result;
|
std::vector<ConnectorManifest> result;
|
||||||
QSet<QString> seen_ids;
|
QSet<QString> seen_ids;
|
||||||
QDir dir(userConnectorsDir());
|
QDir dir(bundledConnectorsDir());
|
||||||
if (!dir.exists()) return result;
|
if (!dir.exists()) return result;
|
||||||
const QFileInfoList entries = dir.entryInfoList(
|
const QFileInfoList entries = dir.entryInfoList(
|
||||||
QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
||||||
|
|||||||
@@ -35,15 +35,16 @@ struct ConnectorManifest {
|
|||||||
// otherwise a bare name for PATH lookup at launch
|
// otherwise a bare name for PATH lookup at launch
|
||||||
};
|
};
|
||||||
|
|
||||||
// Scans the per-user connectors directory per the connector protocol docs.
|
// Scans the connectors directory bundled alongside the executable.
|
||||||
// First match wins for any given id; duplicates and malformed manifests
|
// First match wins for any given id; duplicates and malformed manifests
|
||||||
// are skipped with a qWarning. Returned in discovery order so first-wins
|
// are skipped with a qWarning. Returned in discovery order so first-wins
|
||||||
// is observable to callers.
|
// is observable to callers.
|
||||||
std::vector<ConnectorManifest> discoverConnectors();
|
std::vector<ConnectorManifest> discoverConnectors();
|
||||||
|
|
||||||
// Per-user connectors directory (platform-specific). Exposed for tests and
|
// Connectors directory bundled next to the executable
|
||||||
// for "open user connectors dir" affordances.
|
// (<applicationDirPath>/connectors). Exposed for tests and for
|
||||||
QString userConnectorsDir();
|
// "open connectors dir" affordances.
|
||||||
|
QString bundledConnectorsDir();
|
||||||
|
|
||||||
} // namespace bonsaiviewer::modules::connectors
|
} // namespace bonsaiviewer::modules::connectors
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user