diff --git a/src/qt/oboy.cpp b/src/qt/oboy.cpp index a72ef90..54d7cb2 100644 --- a/src/qt/oboy.cpp +++ b/src/qt/oboy.cpp @@ -1,7 +1,8 @@ #include "oboy.h" -#include #include +#include +#include #include #include @@ -15,7 +16,8 @@ OBoy::OBoy(QObject *parent) : QObject(parent) { const QStringList args = QCoreApplication::arguments(); if (args.size() > 1) { - load(args.at(1)); + const QUrl path = QUrl::fromLocalFile(args.at(1)); + load(path); } } @@ -60,8 +62,7 @@ QString OBoy::version() const return QString(str); } -bool OBoy::load(const QString &path) -{ +bool OBoy::load(const QUrl &path) { CAMLparam0(); CAMLlocal1(ocaml_path) ; @@ -71,9 +72,8 @@ bool OBoy::load(const QString &path) return false; } - QString truncated(path); - truncated.remove(0, 7); // remove file:// - QByteArray ba = truncated.toLocal8Bit(); + const QString local_path = path.toLocalFile(); + const QByteArray ba = local_path.toLocal8Bit(); ocaml_path = caml_copy_string_of_os(ba.data()); diff --git a/src/qt/oboy.h b/src/qt/oboy.h index 9474248..432d243 100644 --- a/src/qt/oboy.h +++ b/src/qt/oboy.h @@ -16,7 +16,7 @@ public: QString name() const; QString version() const; bool loaded() const; - Q_INVOKABLE bool load(const QString &path); + Q_INVOKABLE bool load(const QUrl &path); QImage backgroundMap(int index) const; signals: