mirror of
https://github.com/KDE/audiotube.git
synced 2025-12-24 00:18:04 -05:00
Add about page
This commit is contained in:
committed by
Jonah Brüchert
parent
bda1811200
commit
d97ae991dc
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
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)
|
string(STRIP ${YTMusicAPI_VERSION} YTMusicAPI_VERSION)
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ target_link_libraries(audiotube
|
|||||||
asyncdatabase
|
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})
|
install(TARGETS audiotube ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||||
|
|||||||
@@ -148,6 +148,13 @@ QFuture<Lyrics> AsyncYTMusic::fetchLyrics(const QString &browseId)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QFuture<QString> AsyncYTMusic::version()
|
||||||
|
{
|
||||||
|
return invokeAndCatchOnThread([this]() {
|
||||||
|
return QString::fromStdString(m_ytm->get_version());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
YTMusicThread &YTMusicThread::instance()
|
YTMusicThread &YTMusicThread::instance()
|
||||||
{
|
{
|
||||||
static YTMusicThread thread;
|
static YTMusicThread thread;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <ytmusic.h>
|
#include <ytmusic.h>
|
||||||
@@ -123,6 +124,8 @@ public:
|
|||||||
|
|
||||||
QFuture<Lyrics> fetchLyrics(const QString &browseId);
|
QFuture<Lyrics> fetchLyrics(const QString &browseId);
|
||||||
|
|
||||||
|
QFuture<QString> version();
|
||||||
|
|
||||||
Q_SIGNAL void errorOccurred(const QString &error);
|
Q_SIGNAL void errorOccurred(const QString &error);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
17
src/contents/ui/AboutAudiotube.qml
Normal file
17
src/contents/ui/AboutAudiotube.qml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2022 Mathis Brüchert <mbb@kaidan.im>
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
}
|
||||||
@@ -150,26 +150,28 @@ Rectangle {
|
|||||||
"title": i18n("Played Songs"),
|
"title": i18n("Played Songs"),
|
||||||
"objectName": "history"
|
"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 {
|
Kirigami.Separator {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.rightMargin: Kirigami.Units.smallSpacing
|
Layout.rightMargin: Kirigami.Units.smallSpacing
|
||||||
Layout.leftMargin: 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 {
|
Kirigami.NavigationTabButton {
|
||||||
id: collapseButton
|
id: collapseButton
|
||||||
|
|||||||
23
src/main.cpp
23
src/main.cpp
@@ -38,7 +38,25 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
|||||||
|
|
||||||
KLocalizedString::setApplicationDomain("audiotube");
|
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();
|
KCrash::initialize();
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
@@ -51,6 +69,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
|||||||
qmlRegisterUncreatableType<PlaybackHistoryModel>(URI, 1, 0, "PlaybackHistoryModel","");
|
qmlRegisterUncreatableType<PlaybackHistoryModel>(URI, 1, 0, "PlaybackHistoryModel","");
|
||||||
qmlRegisterType<QSortFilterProxyModel>(URI, 1, 0, "SortFilterModel");
|
qmlRegisterType<QSortFilterProxyModel>(URI, 1, 0, "SortFilterModel");
|
||||||
qmlRegisterType<Blur>(URI, 1, 0, "Blur");
|
qmlRegisterType<Blur>(URI, 1, 0, "Blur");
|
||||||
|
qmlRegisterSingletonType(URI, 1, 0, "About", [](QQmlEngine *engine, QJSEngine *) -> QJSValue {
|
||||||
|
return engine->toScriptValue(KAboutData::applicationData());
|
||||||
|
});
|
||||||
|
|
||||||
qmlRegisterSingletonType<UserPlaylistModel>(URI, 1, 0, "UserPlaylistModel", [](QQmlEngine *, QJSEngine *) {
|
qmlRegisterSingletonType<UserPlaylistModel>(URI, 1, 0, "UserPlaylistModel", [](QQmlEngine *, QJSEngine *) {
|
||||||
return new UserPlaylistModel();
|
return new UserPlaylistModel();
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
class PlayerUtils : public QObject
|
class PlayerUtils : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PlayerUtils(QObject *parent = nullptr);
|
explicit PlayerUtils(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
|||||||
@@ -28,5 +28,6 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted
|
|||||||
<file alias="SearchWithDropdown.qml">contents/ui/SearchWithDropdown.qml</file>
|
<file alias="SearchWithDropdown.qml">contents/ui/SearchWithDropdown.qml</file>
|
||||||
<file>resources/favourites_placeholder.svg</file>
|
<file>resources/favourites_placeholder.svg</file>
|
||||||
<file>resources/played_placeholder.svg</file>
|
<file>resources/played_placeholder.svg</file>
|
||||||
|
<file alias="AboutAudiotube.qml">contents/ui/AboutAudiotube.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -35,18 +35,18 @@ struct UNEXPORT YTMusicPrivate {
|
|||||||
|
|
||||||
py::object get_ytmusic() {
|
py::object get_ytmusic() {
|
||||||
if (ytmusic.is_none()) {
|
if (ytmusic.is_none()) {
|
||||||
const auto module = py::module::import("ytmusicapi");
|
ytmusicapi_module = py::module::import("ytmusicapi");
|
||||||
ytmusic = module.attr("YTMusic")(auth, user, requests_session, proxies, language);
|
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
|
// Some of the called python code randomly fails if the encoding is not utf8
|
||||||
setenv("LC_ALL", "en_US.utf8", true);
|
setenv("LC_ALL", "en_US.utf8", true);
|
||||||
|
|
||||||
auto oldVersion = module.attr("__dict__").contains("_version");
|
auto oldVersion = ytmusicapi_module.attr("__dict__").contains("_version");
|
||||||
if (oldVersion) {
|
if (oldVersion) {
|
||||||
std::cerr << "Running with outdated and untested version of ytmusicapi." << std::endl;
|
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;
|
std::cerr << "The currently tested and supported version is " << TESTED_YTMUSICAPI_VERSION << std::endl;
|
||||||
} else {
|
} else {
|
||||||
const auto version = module.attr("__version__").cast<std::string>();
|
const auto version = ytmusicapi_module.attr("__version__").cast<std::string>();
|
||||||
if (version != TESTED_YTMUSICAPI_VERSION) {
|
if (version != TESTED_YTMUSICAPI_VERSION) {
|
||||||
std::cerr << "Running with untested version of ytmusicapi " << version << "." << std::endl;
|
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;
|
std::cerr << "The currently tested and supported version is " << TESTED_YTMUSICAPI_VERSION << std::endl;
|
||||||
@@ -66,6 +66,9 @@ struct UNEXPORT YTMusicPrivate {
|
|||||||
return ytdl;
|
return ytdl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
py::module ytmusicapi_module;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
py::object ytmusic = py::none();
|
py::object ytmusic = py::none();
|
||||||
py::object ytdl = 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>()
|
lyrics["lyrics"].cast<std::string>()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string YTMusic::get_version() const
|
||||||
|
{
|
||||||
|
d->get_ytmusic();
|
||||||
|
return d->ytmusicapi_module.attr("__version__").cast<std::string>();
|
||||||
|
}
|
||||||
|
|||||||
@@ -319,6 +319,8 @@ public:
|
|||||||
|
|
||||||
Lyrics get_lyrics(const std::string &browse_id) const;
|
Lyrics get_lyrics(const std::string &browse_id) const;
|
||||||
|
|
||||||
|
std::string get_version() const;
|
||||||
|
|
||||||
// TODO wrap more methods
|
// TODO wrap more methods
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user