diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/app.pro | 2 | ||||
-rw-r--r-- | app/main.cpp | 55 |
2 files changed, 50 insertions, 7 deletions
diff --git a/app/app.pro b/app/app.pro index eeb139c..0083bfc 100644 --- a/app/app.pro +++ b/app/app.pro @@ -1,5 +1,5 @@ TARGET = videoplayer -QT = quick aglextras multimedia +QT = quick websockets multimedia SOURCES = main.cpp diff --git a/app/main.cpp b/app/main.cpp index 7fdff20..11b1230 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -13,14 +13,57 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include <QtAGLExtras/AGLApplication> #include <QtQml/QQmlApplicationEngine> +#include <QtGui/QGuiApplication> +#include <QDebug> +#include <QUrlQuery> +#include <QCommandLineParser> +#include <QtQml/QQmlContext> + int main(int argc, char *argv[]) { - AGLApplication app(argc, argv); - app.setApplicationName("VideoPlayer"); - app.setupApplicationRole("Video"); - app.load(QUrl(QStringLiteral("qrc:/VideoPlayer.qml"))); - return app.exec(); + + setenv("QT_QPA_PLATFORM", "wayland", 1); + int port; + QString token; + + QCommandLineParser parser; + QGuiApplication app(argc, argv); + + parser.addPositionalArgument("port", + app.translate("main", "port for binding")); + parser.addPositionalArgument("secret", + app.translate("main", "secret for binding")); + + parser.addHelpOption(); + parser.addVersionOption(); + parser.process(app); + QStringList positionalArguments = parser.positionalArguments(); + + if (positionalArguments.length() == 2) { + port = positionalArguments.takeFirst().toInt(); + token = positionalArguments.takeFirst(); + qInfo() << "setting port:" << port << ", token:" << token; + } else { + qInfo() << "Need to specify port and token"; + exit(EXIT_FAILURE); + } + + QUrl bindingAddress; + bindingAddress.setScheme(QStringLiteral("ws")); + bindingAddress.setHost(QStringLiteral("localhost")); + bindingAddress.setPort(port); + bindingAddress.setPath(QStringLiteral("/api")); + + QUrlQuery query; + query.addQueryItem(QStringLiteral("token"), token); + bindingAddress.setQuery(query); + + QQmlApplicationEngine engine; + engine.rootContext()->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress); + engine.load(QUrl(QStringLiteral("qrc:/VideoPlayer.qml"))); + + return app.exec(); + } |