diff --git a/cmake/FindYTMusicAPI.cmake b/cmake/FindYTMusicAPI.cmake index 6be5006..c8653f7 100644 --- a/cmake/FindYTMusicAPI.cmake +++ b/cmake/FindYTMusicAPI.cmake @@ -4,7 +4,7 @@ find_package(Python3 REQUIRED COMPONENTS Interpreter) -execute_process(COMMAND ${Python3_EXECUTABLE} -c "import ytmusicapi; print(ytmusicapi.version('ytmusicapi'))" RESULT_VARIABLE YTMUSICAPI_CHECK_RESULT OUTPUT_VARIABLE YTMusicAPI_VERSION) +execute_process(COMMAND ${Python3_EXECUTABLE} -c "import ytmusicapi; print(ytmusicapi.__version__)" RESULT_VARIABLE YTMUSICAPI_CHECK_RESULT OUTPUT_VARIABLE YTMusicAPI_VERSION) string(STRIP ${YTMusicAPI_VERSION} YTMusicAPI_VERSION) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 89881e4..ea8dd9b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,6 +55,8 @@ target_link_libraries(audiotube asyncdatabase ) -target_compile_definitions(audiotube PRIVATE -DQT_NO_KEYWORDS -DQT_NO_URL_CAST_FROM_STRING) +target_compile_definitions(audiotube PRIVATE + -DAUDIOTUBE_VERSION_STRING="${RELEASE_SERVICE_VERSION}" + -DQT_NO_KEYWORDS -DQT_NO_URL_CAST_FROM_STRING) install(TARGETS audiotube ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/src/asyncytmusic.cpp b/src/asyncytmusic.cpp index 3a49ff6..ab966a0 100644 --- a/src/asyncytmusic.cpp +++ b/src/asyncytmusic.cpp @@ -148,6 +148,13 @@ QFuture AsyncYTMusic::fetchLyrics(const QString &browseId) }); } +QFuture AsyncYTMusic::version() +{ + return invokeAndCatchOnThread([this]() { + return QString::fromStdString(m_ytm->get_version()); + }); +} + YTMusicThread &YTMusicThread::instance() { static YTMusicThread thread; diff --git a/src/asyncytmusic.h b/src/asyncytmusic.h index eca4986..7beb88e 100644 --- a/src/asyncytmusic.h +++ b/src/asyncytmusic.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -123,6 +124,8 @@ public: QFuture fetchLyrics(const QString &browseId); + QFuture version(); + Q_SIGNAL void errorOccurred(const QString &error); protected: diff --git a/src/contents/ui/AboutAudiotube.qml b/src/contents/ui/AboutAudiotube.qml new file mode 100644 index 0000000..44dd2ee --- /dev/null +++ b/src/contents/ui/AboutAudiotube.qml @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: 2022 Mathis Brüchert +// +// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL + +import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm + +import QtQuick 2.15 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.15 as Controls +import org.kde.kirigami 2.20 as Kirigami +import org.kde.ytmusic 1.0 + +MobileForm.AboutPage { + aboutData: About + + showAboutKDE: false +} diff --git a/src/contents/ui/Sidebar.qml b/src/contents/ui/Sidebar.qml index 7385301..d9875b9 100644 --- a/src/contents/ui/Sidebar.qml +++ b/src/contents/ui/Sidebar.qml @@ -150,26 +150,28 @@ Rectangle { "title": i18n("Played Songs"), "objectName": "history" })} - } - -// Kirigami.NavigationTabButton { -// Layout.fillWidth: true -// width: column.width - column.Layout.leftMargin - column.Layout.rightMargin -// implicitHeight: 50 -// display: Controls.AbstractButton.TextBesideIcon -// text: i18n("Charts") -// icon.name: "office-chart-line-forecast" - -// } } } - Kirigami.Separator { Layout.fillWidth: true Layout.rightMargin: Kirigami.Units.smallSpacing Layout.leftMargin: Kirigami.Units.smallSpacing } + Kirigami.NavigationTabButton { + id: aboutButton + Layout.fillWidth: true + width: column.width - column.Layout.leftMargin - column.Layout.rightMargin + implicitHeight: 50 + display: Controls.AbstractButton.TextBesideIcon + text: collapsed? "" : i18n("About") + checkable: false + icon.name: "help-about-symbolic" + + onClicked: { + pageStack.pushDialogLayer("qrc:/AboutAudiotube.qml") + } + } Kirigami.NavigationTabButton { id: collapseButton diff --git a/src/main.cpp b/src/main.cpp index c3d0795..ee0d9c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,7 +38,25 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) KLocalizedString::setApplicationDomain("audiotube"); - KAboutData::setApplicationData(KAboutData(QStringLiteral("audiotube"), QStringLiteral("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; @@ -51,6 +69,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) qmlRegisterUncreatableType(URI, 1, 0, "PlaybackHistoryModel",""); qmlRegisterType(URI, 1, 0, "SortFilterModel"); qmlRegisterType(URI, 1, 0, "Blur"); + qmlRegisterSingletonType(URI, 1, 0, "About", [](QQmlEngine *engine, QJSEngine *) -> QJSValue { + return engine->toScriptValue(KAboutData::applicationData()); + }); qmlRegisterSingletonType(URI, 1, 0, "UserPlaylistModel", [](QQmlEngine *, QJSEngine *) { return new UserPlaylistModel(); diff --git a/src/playerutils.h b/src/playerutils.h index 25f333c..6849a8d 100644 --- a/src/playerutils.h +++ b/src/playerutils.h @@ -11,6 +11,7 @@ class PlayerUtils : public QObject { Q_OBJECT + public: explicit PlayerUtils(QObject *parent = nullptr); diff --git a/src/resources.qrc b/src/resources.qrc index f7d6a8f..49b7920 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -28,5 +28,6 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted contents/ui/SearchWithDropdown.qml resources/favourites_placeholder.svg resources/played_placeholder.svg + contents/ui/AboutAudiotube.qml diff --git a/src/ytmusic.cpp b/src/ytmusic.cpp index b8b69b2..78d6e13 100644 --- a/src/ytmusic.cpp +++ b/src/ytmusic.cpp @@ -35,18 +35,18 @@ struct UNEXPORT YTMusicPrivate { py::object get_ytmusic() { if (ytmusic.is_none()) { - const auto module = py::module::import("ytmusicapi"); - ytmusic = module.attr("YTMusic")(auth, user, requests_session, proxies, language); + ytmusicapi_module = py::module::import("ytmusicapi"); + ytmusic = ytmusicapi_module.attr("YTMusic")(auth, user, requests_session, proxies, language); // Some of the called python code randomly fails if the encoding is not utf8 setenv("LC_ALL", "en_US.utf8", true); - auto oldVersion = module.attr("__dict__").contains("_version"); + auto oldVersion = ytmusicapi_module.attr("__dict__").contains("_version"); if (oldVersion) { std::cerr << "Running with outdated and untested version of ytmusicapi." << std::endl; std::cerr << "The currently tested and supported version is " << TESTED_YTMUSICAPI_VERSION << std::endl; } else { - const auto version = module.attr("__version__").cast(); + const auto version = ytmusicapi_module.attr("__version__").cast(); if (version != TESTED_YTMUSICAPI_VERSION) { std::cerr << "Running with untested version of ytmusicapi " << version << "." << std::endl; std::cerr << "The currently tested and supported version is " << TESTED_YTMUSICAPI_VERSION << std::endl; @@ -66,6 +66,9 @@ struct UNEXPORT YTMusicPrivate { return ytdl; } +public: + py::module ytmusicapi_module; + private: py::object ytmusic = py::none(); py::object ytdl = py::none(); @@ -507,3 +510,9 @@ Lyrics YTMusic::get_lyrics(const std::string &browse_id) const lyrics["lyrics"].cast() }; } + +std::string YTMusic::get_version() const +{ + d->get_ytmusic(); + return d->ytmusicapi_module.attr("__version__").cast(); +} diff --git a/src/ytmusic.h b/src/ytmusic.h index ba7c24c..7611215 100644 --- a/src/ytmusic.h +++ b/src/ytmusic.h @@ -319,6 +319,8 @@ public: Lyrics get_lyrics(const std::string &browse_id) const; + std::string get_version() const; + // TODO wrap more methods private: