mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-05 23:41:44 +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 <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
@@ -27,7 +28,6 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QSet>
|
||||
#include <QStandardPaths>
|
||||
|
||||
namespace bonsaiviewer::modules::connectors {
|
||||
|
||||
@@ -78,20 +78,15 @@ bool parseManifest(const QString& folder, ConnectorManifest& out) {
|
||||
|
||||
} // namespace
|
||||
|
||||
QString userConnectorsDir() {
|
||||
// GenericDataLocation maps to the platform's per-user data root:
|
||||
// Linux -> ~/.local/share
|
||||
// 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");
|
||||
QString bundledConnectorsDir() {
|
||||
// Connectors ship alongside the executable in a "connectors" subdirectory.
|
||||
return QDir(QCoreApplication::applicationDirPath()).filePath("connectors");
|
||||
}
|
||||
|
||||
std::vector<ConnectorManifest> discoverConnectors() {
|
||||
std::vector<ConnectorManifest> result;
|
||||
QSet<QString> seen_ids;
|
||||
QDir dir(userConnectorsDir());
|
||||
QDir dir(bundledConnectorsDir());
|
||||
if (!dir.exists()) return result;
|
||||
const QFileInfoList entries = dir.entryInfoList(
|
||||
QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
||||
|
||||
@@ -35,15 +35,16 @@ struct ConnectorManifest {
|
||||
// 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
|
||||
// are skipped with a qWarning. Returned in discovery order so first-wins
|
||||
// is observable to callers.
|
||||
std::vector<ConnectorManifest> discoverConnectors();
|
||||
|
||||
// Per-user connectors directory (platform-specific). Exposed for tests and
|
||||
// for "open user connectors dir" affordances.
|
||||
QString userConnectorsDir();
|
||||
// Connectors directory bundled next to the executable
|
||||
// (<applicationDirPath>/connectors). Exposed for tests and for
|
||||
// "open connectors dir" affordances.
|
||||
QString bundledConnectorsDir();
|
||||
|
||||
} // namespace bonsaiviewer::modules::connectors
|
||||
|
||||
|
||||
Reference in New Issue
Block a user