// SPDX-FileCopyrightText: 2021 Jonah Brüchert // // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL #include #include #include #include #include #include #include #include #include #include #include #include #include "clipboard.h" #include "searchmodel.h" #include "albummodel.h" #include "videoinfoextractor.h" #include "artistmodel.h" #include "userplaylistmodel.h" #include "errorhandler.h" #include "playlistmodel.h" #include "playerutils.h" #include "library.h" #include "thumbnailsource.h" #include "blur.h" #include "localplaylistmodel.h" #include "localplaylistsmodel.h" #include "asyncdatabase.h" constexpr auto URI = "org.kde.ytmusic"; Q_DECL_EXPORT int main(int argc, char *argv[]) { // set default style and icon theme QIcon::setFallbackThemeName(QStringLiteral("breeze")); if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE") && QQuickStyle::name().isEmpty()) { QQuickStyle::setStyle(QStringLiteral("org.kde.desktop")); } QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); QCoreApplication::setOrganizationName(QStringLiteral("KDE")); QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org")); QCoreApplication::setApplicationName(QStringLiteral("audiotube")); KLocalizedString::setApplicationDomain("audiotube"); KAboutData about(QStringLiteral("audiotube"), i18n("AudioTube"), QStringLiteral(AUDIOTUBE_VERSION_STRING), i18n("YouTube Music Player"), KAboutLicense::GPL_V3, i18n("© 2021-2023 Jonah Brüchert, 2021-2023 KDE Community")); about.addAuthor(i18n("Jonah Brüchert"), i18n("Maintainer"), QStringLiteral("jbb@kaidan.im")); about.addAuthor(i18n("Mathis Brüchert"), i18n("Designer"), QStringLiteral("mbb@kaidan.im")); about.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails")); about.setOrganizationDomain("kde.org"); about.setBugAddress("https://bugs.kde.org/describecomponents.cgi?product=audiotube"); auto future = YTMusicThread::instance()->version(); connectFuture(future, &app, [&about](const auto &version) { about.addComponent(QStringLiteral("ytmusicapi"), i18n("Unofficial API for YouTube Music"), version); KAboutData::setApplicationData(about); }); QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("org.kde.audiotube"))); KCrash::initialize(); QQmlApplicationEngine engine; MprisPlugin(&engine).registerTypes("org.nemomobile.qtmpris"); qmlRegisterType(URI, 1, 0, "SearchModel"); qmlRegisterType(URI, 1, 0, "AlbumModel"); qmlRegisterType(URI, 1, 0, "VideoInfoExtractor"); qmlRegisterType(URI, 1, 0, "ArtistModel"); qmlRegisterType(URI, 1, 0, "PlaylistModel"); qmlRegisterUncreatableType(URI, 1, 0, "PlaybackHistoryModel",""); qmlRegisterType(URI, 1, 0, "SortFilterModel"); qmlRegisterType(URI, 1, 0, "Blur"); qmlRegisterType(URI, 1, 0, "LocalPlaylistModel"); qmlRegisterType(URI, 1, 0, "LocalPlaylistsModel"); qmlRegisterSingletonType(URI, 1, 0, "About", [](QQmlEngine *engine, QJSEngine *) -> QJSValue { return engine->toScriptValue(KAboutData::applicationData()); }); qmlRegisterSingletonType(URI, 1, 0, "UserPlaylistModel", [](QQmlEngine *, QJSEngine *) { return new UserPlaylistModel(); }); qmlRegisterSingletonType(URI, 1, 0, "ErrorHandler", [](QQmlEngine *, QJSEngine *) { return new ErrorHandler(); }); qmlRegisterSingletonType(URI, 1, 0, "PlayerUtils", [](QQmlEngine *, QJSEngine *) { return new PlayerUtils(); }); qmlRegisterSingletonType(URI, 1, 0, "Clipboard", [](QQmlEngine *, QJSEngine *) { return new Clipboard(); }); qmlRegisterSingletonInstance(URI, 1, 0, "Library", &Library::instance()); qmlRegisterType(URI, 1, 0, "ThumbnailSource"); qmlRegisterAnonymousType(URI, 1); qmlRegisterAnonymousType(URI, 1); engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); engine.load(QUrl(QStringLiteral("qrc:///main.qml"))); if (engine.rootObjects().isEmpty()) { return -1; } return app.exec(); }