aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorNaoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>2024-09-28 03:41:20 +0900
committerNaoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>2024-09-29 13:19:34 +0900
commitb4202d3d5aca7842314edbf010e2e8605a6a9e24 (patch)
tree542146f5e7bcc613fd019ead16c57c94ea65f83f /main.cpp
parent0404436ada9d6bb695ba1da5b5a2bb68538c2b66 (diff)
Rework momplay to migrate to Qt6
QtMultimedia has big change from Qt5 to Q6. Existing momiplay is difficult to migrate to Qt6. New momiplay is made from Qt Media Player Example. As a result, it get video player capability. Bug-AGL: SPEC-5162 Change-Id: Ib754f914fc9d5534721f0d29df689ac11034025a Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp65
1 files changed, 7 insertions, 58 deletions
diff --git a/main.cpp b/main.cpp
index afc4a46..69aab44 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,71 +1,20 @@
-/*
- * Copyright (C) 2016 The Qt Company Ltd.
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+// Copyright (C) 2021 The Qt Company Ltd.
+// Copyright (C) 2024 Automotive Grade Linux
+// SPDX-License-Identifier: GPL-3.0+
-#include <QtCore/QDebug>
-#include <QtCore/QDir>
-#include <QtCore/QStandardPaths>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
-#include <QQmlContext>
-#include <QtQml/qqml.h>
-#include <QtQuickControls2/QQuickStyle>
-
-
-#include "playlistwithmetadata.h"
-
-QVariantList readMusicFile(const QString &path)
-{
- QVariantList ret;
- QDir dir(path);
- for (const auto &entry : dir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name)) {
- QFileInfo fileInfo(dir.absoluteFilePath(entry));
- if (fileInfo.isDir()) {
- ret.append(readMusicFile(fileInfo.absoluteFilePath()));
- } else if (fileInfo.isFile()) {
- ret.append(QUrl::fromLocalFile(fileInfo.absoluteFilePath()));
- }
- }
- return ret;
-}
-
int main(int argc, char *argv[])
{
- QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
-
QGuiApplication app(argc, argv);
- qmlRegisterType<PlaylistWithMetadata>("MediaPlayer", 1, 0, "PlaylistWithMetadata");
+ QCoreApplication::setApplicationName("MomiPlayer");
- QVariantList mediaFiles;
- for (const auto &music : QStandardPaths::standardLocations(QStandardPaths::MusicLocation)) {
- mediaFiles.append(readMusicFile(music));
- }
QQmlApplicationEngine engine;
- QQmlContext *context = engine.rootContext();
- context->setContextProperty("mediaFiles", mediaFiles);
- const QUrl url(QStringLiteral("qrc:/momiplay.qml"));
- QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
- &app, [url](QObject *obj, const QUrl &objUrl) {
- if (!obj && url == objUrl)
- QCoreApplication::exit(-1);
- }, Qt::QueuedConnection);
- engine.load(url);
+ QObject::connect(&engine, &QQmlApplicationEngine::quit, &app, &QGuiApplication::quit);
+
+ engine.loadFromModule("MediaPlayerModule", "Main");
return app.exec();
}