Skip to content

Commit

Permalink
more stuff working ..more stuff working ....
Browse files Browse the repository at this point in the history
Signed-off-by: Conrad Hübler <Conrad.Huebler@gmx.net>
  • Loading branch information
conradhuebler committed Dec 29, 2024
1 parent e066880 commit 5c0c47a
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 119 deletions.
21 changes: 13 additions & 8 deletions qml/components/TidalApi.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ Item {
signal albumAdded(int id, string title, string artist, string image, int duration)
signal artistAdded(int id, string name, string image)

//signal cacheTrack(int id, string title, string album, string artist, string image, int duration)
signal cacheAlbum(int id, string title, string artist, string image, int duration)
signal cacheArtist(int id, string name, string image)

signal playlistSearchAdded(int id, string name, string image, int duration, string uid)
signal personalPlaylistAdded(string id, string title, string image, int num_tracks, string description, int duration)
signal playlistAdded(string id, string title, string image, int num_tracks, string description, int duration)
Expand All @@ -40,7 +36,11 @@ Item {
signal playurl(string url)
signal currentPlayback(var trackinfo)
signal cacheTrack(var track_info)
signal cacheAlbum(var album_info)
signal cacheArtist(var artist_info)

signal playlistTrackAdded(var track_info)
signal albumTrackAdded(var track_info)

// Properties für die Suche
property string artistsResults
Expand Down Expand Up @@ -110,11 +110,11 @@ Item {
tidalApi.cacheTrack(track_info)
})

setHandler('cacheArtist', function(id, name, image) {
tidalApi.cacheArtist(id, name, image)
setHandler('cacheArtist', function(artist_info) {
tidalApi.cacheArtist(artist_info)
})
setHandler('cacheAlbum', function(id, title, artist, image, duration) {
tidalApi.cacheAlbum(id, title, artist, image, duration)
setHandler('cacheAlbum', function(album_info) {
tidalApi.cacheAlbum(album_info)
})


Expand Down Expand Up @@ -222,6 +222,10 @@ Item {
root.playlistTrackAdded(track_info)
})

setHandler('albumTrackAdded', function(track_info) {
root.albumTrackAdded(track_info)
})

importModule('tidal', function() {
console.log("Tidal module imported successfully")
})
Expand Down Expand Up @@ -332,6 +336,7 @@ Item {

// Album Funktionen
function getAlbumTracks(id) {
console.log("Get album tracks", id)
pythonTidal.call("tidal.Tidaler.getAlbumTracks", [id])
}

Expand Down
27 changes: 26 additions & 1 deletion qml/components/TidalCache.qml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,36 @@ id: root
artist: track_info.artist,
image: track_info.image,
duration: track_info.duration,
albumid: track_info.albumid,
timestamp: Date.now(),
fromSearch: true // Optional: markiert Einträge aus der Suche
})
}

onCacheArtist: {
//artist_info
saveArtistToCache({
id: artist_info.id,
name: artist_info.name,
bio: artist_info.bio,
image: artist_info.image,
timestamp: Date.now(),
fromSearch: true // Optional: markiert Einträge aus der Suche
})
}

onCacheAlbum: {
//album_info
saveAlbumToCache({
id: album_info.id,
title: album_info.title,
artist: album_info.artist,
image: album_info.image,
duration: album_info.duration,
timestamp: Date.now(),
fromSearch: true // Optional: markiert Einträge aus der Suche
})
}
onTrackAdded: {
// id, title, album, artist, image, duration
saveTrackToCache({
Expand Down Expand Up @@ -125,7 +150,7 @@ id: root
function addSearchTrack(id) {
if (!searchResults.tracks.includes(id)) {
searchResults.tracks.push(id)
}
}d, title, artist, image, duration
}

function addSearchAlbum(id) {
Expand Down
124 changes: 54 additions & 70 deletions qml/pages/AlbumPage.qml
Original file line number Diff line number Diff line change
@@ -1,116 +1,100 @@
// AlbumPage.qml
import QtQuick 2.0
import Sailfish.Silica 1.0
import QtMultimedia 5.6
import Sailfish.Media 1.0

import "widgets"


Page {
property int track_id

id: albumPage
property int albumId: -1
property var albumData: null

// The effective value will be restricted by ApplicationWindow.allowedOrientations
allowedOrientations: Orientation.All

// To enable PullDownMenu, place our content in a SilicaFlickable
SilicaFlickable {
width: parent.width
id: flickable
anchors {
fill: parent
bottomMargin: minPlayerPanel.margin
}

contentHeight: column.height

PullDownMenu {
MenuItem {
text: qsTr("Show Playlist")
onClicked:
{
onClicked: pageStack.push(Qt.resolvedUrl("PlaylistPage.qml"))
}
}

MenuItem {
text: minPlayerPanel.open ? "Hide player" : "Show player"
onClicked: minPlayerPanel.open = !minPlayerPanel.open
anchors.horizontalCenter: parent.horizontalCenter
}
}


Column {
id: infoCoulumn
id: column
width: parent.width
spacing: Theme.paddingMedium

PageHeader {
id: header
title: qsTr("Album Info")
title: albumData ? albumData.title : qsTr("Album Info")
}
spacing: 10 // Abstand zwischen den Elementen in der Column
width: parent.width // Die Column nimmt die volle Breite des Eltern-Elements (Item) ein

Image {
id: coverImage
anchors {
top: header.bottom
horizontalCenter: albumPage.isPortrait ? parent.horizontalCenter : undefined
}
width: parent.width * 0.8
height: width
anchors.horizontalCenter: parent.horizontalCenter
fillMode: Image.PreserveAspectFit
source: albumData ? albumData.image : ""

sourceSize.width: {
var maxImageWidth = Screen.width
var leftMargin = Theme.horizontalPageMargin
var rightMargin = albumPage.isPortrait ? Theme.horizontalPageMargin : 0
return (maxImageWidth - leftMargin - rightMargin)*3/2
Rectangle {
color: Theme.rgba(Theme.highlightBackgroundColor, 0.1)
anchors.fill: parent
visible: coverImage.status !== Image.Ready
}

fillMode: Image.PreserveAspectFit
}
Label
{

Label {
id: artistName
anchors {
top : coverImage.bottom
}
width: parent.width
horizontalAlignment: Text.AlignHCenter
text: albumData ? albumData.artist : ""
truncationMode: TruncationMode.Fade
color: Theme.highlightColor
font.pixelSize: Theme.fontSizeLarge
}
}
TrackList {
id: aLtrackList
type: 2
anchors {
top: infoCoulumn.bottom// Anker oben an den unteren Rand der Column
topMargin: 600 // Abstand zwischen der Column und dem ListView
left: parent.left // Anker links am linken Rand des Eltern-Elements (Page)
right: parent.right // Anker rechts am rechten Rand des Eltern-Elements (Page)
leftMargin: Theme.horizontalPageMargin
rightMargin: Theme.horizontalPageMargin
bottom: parent.bottom// Anker unten am unteren Rand des Eltern-Elements (Page)
}
}


Connections {
target: tidalApi
Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
text: albumData ? Format.formatDuration(albumData.duration, Format.DurationLong) : ""
color: Theme.secondaryHighlightColor
font.pixelSize: Theme.fontSizeMedium
}

onAlbumChanged:
{
// artistName.text =artist
header.title = title + " - " + artist
coverImage.source = image
Item {
width: parent.width
height: Theme.paddingLarge
}

onTrackAdded:
{
aLtrackList.type = 2
aLtrackList.addTrack(title, artist, album, id, duration)
TrackList {
id: trackList
width: parent.width
height: albumPage.height - y - (minPlayerPanel.open ? minPlayerPanel.height : 0)
type: "album"
albumId: albumPage.albumId
}
}

VerticalScrollDecorator {}
}

onTrackChanged:
{
for(var i = 1; i < aLtrackList.listModel.count; ++i)
if(aLtrackList.listModel.get(i).name === title)
{
aLtrackList.scrollTo(i);
}
Component.onCompleted: {
if (albumId > 0) {
albumData = cacheManager.getAlbum(albumId)
if (!albumData) {
console.log("Album nicht im Cache gefunden:", albumId)
}
}
}
}
}
8 changes: 4 additions & 4 deletions qml/pages/FirstPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ Page {
}
}

/*MenuItem {
text: qsTr("Playlist")
MenuItem {
text: qsTr("Clear Playlist")
onClicked: {
pageStack.push(Qt.resolvedUrl("TrackList.qml"))
playlistManager.clearPlayList()
}
}*/
}

MenuItem {
text: minPlayerPanel.open ? "Hide player" : "Show player"
Expand Down
3 changes: 2 additions & 1 deletion qml/pages/Search.qml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ Item {
id: track.id,
type: typeTrack,
image: track.image,
duration: track.duration
duration: track.duration,
albumid : track.albumid
}
}

Expand Down
Loading

0 comments on commit 5c0c47a

Please sign in to comment.