Commit 270ca957 authored by Camilo Higuita's avatar Camilo Higuita

more work on mobile/touchVSdesktop/mouse interactions, and work on color moods tags

parent a6da910c
......@@ -180,6 +180,12 @@ int Babe::trackRate(const QString &path)
return this->con->getTrackStars(path);
}
bool Babe::moodTrack(const QString &path, const QString &color)
{
qDebug()<<path<<color;
return this->con->artTrack(path, color);
}
void Babe::notify(const QString &title, const QString &body)
{
......
......@@ -45,6 +45,9 @@ public:
Q_INVOKABLE bool babeTrack(const QString &path, const bool &value);
Q_INVOKABLE bool rateTrack(const QString &path, const int &value);
Q_INVOKABLE int trackRate(const QString &path);
Q_INVOKABLE bool moodTrack(const QString &path, const QString &color);
Q_INVOKABLE void notify(const QString &title, const QString &body);
Q_INVOKABLE void notifySong(const QString &url);
......
......@@ -63,8 +63,9 @@ ApplicationWindow
{
target: player
onPos: mainPlaylist.progressBar.value = pos
onTiming: mainPlaylist.progressTime.text = time
onDurationChanged: mainPlaylist.durationTime.text = time
onFinished: Player.nextTrack()
}
Connections
......
#include "player.h"
#include <QMediaMetaData>
#include "../utils/bae.h"
Player::Player(QObject *parent) : QObject(parent)
{
this->player = new QMediaPlayer(this);
connect(player, &QMediaPlayer::durationChanged, this, [&](qint64 dur) {
qDebug()<<"DUARTION READY<<"<<dur;
auto duration = BAE::transformTime(dur/1000);
qDebug()<<duration;
emit this->durationChanged(duration);
});
this->player->setVolume(100);
this->updater = new QTimer(this);
connect(this->updater, &QTimer::timeout, this, &Player::update);
}
void Player::source(const QString &url)
......@@ -21,7 +32,7 @@ void Player::play()
if(sourceurl.isEmpty()) return;
if(!updater->isActive())
this->updater->start(100);
this->updater->start(1000);
this->player->play();
}
......@@ -54,9 +65,18 @@ bool Player::isPaused()
return !(this->player->state() == QMediaPlayer::PlayingState);
}
QString Player::transformTime(const int &pos)
{
auto time = BAE::transformTime(pos);
return time;
}
void Player::update()
{
emit this->pos(static_cast<int>(static_cast<double>(this->player->position())/this->player->duration()*1000));
emit this->timing(BAE::transformTime(player->position()/1000));
if(this->player->state() == QMediaPlayer::StoppedState)
emit this->finished();
}
......@@ -18,6 +18,7 @@ public:
Q_INVOKABLE void seek(const int &pos);
Q_INVOKABLE int duration();
Q_INVOKABLE bool isPaused();
Q_INVOKABLE QString transformTime(const int &pos);
private:
QMediaPlayer *player;
......@@ -29,6 +30,8 @@ private:
signals:
void pos(int pos);
void finished();
void timing(QString time);
void durationChanged(QString time);
public slots:
};
......
......@@ -76,8 +76,8 @@ uint TagInfo::getYear() const
int TagInfo::getDuration() const
{
return 0;
/*file.audioProperties()->lengthInSeconds();*/
return file.audioProperties()->length();
}
QString TagInfo::getComment() const
......
......@@ -7,7 +7,6 @@ function playTrack(track)
player.source(root.mainPlaylist.currentTrack.url);
player.play()
root.title = root.mainPlaylist.currentTrack.title + " - " +root.mainPlaylist.currentTrack.artist
var artwork = root.mainPlaylist.currentTrack.artwork
root.mainPlaylist.currentArtwork = artwork ? artwork : bae.loadCover(root.mainPlaylist.currentTrack.url)
......@@ -103,13 +102,16 @@ function quickPlay(track)
function appendTrack(track)
{
var empty = root.mainPlaylist.list.count
root.mainPlaylist.list.model.append(track)
if(empty === 0 && root.mainPlaylist.list.count>0)
if(track)
{
root.mainPlaylist.list.currentIndex = 0
playTrack(root.mainPlaylist.list.model.get(0))
var empty = root.mainPlaylist.list.count
root.mainPlaylist.list.model.append(track)
if(empty === 0 && root.mainPlaylist.list.count>0)
{
root.mainPlaylist.list.currentIndex = 0
playTrack(root.mainPlaylist.list.model.get(0))
}
}
}
......
......@@ -217,7 +217,7 @@ namespace BAE
tStr = time.toString(format);
}
return tStr.isEmpty()?"00:00":tStr;
return tStr.isEmpty() ? "00:00" : tStr;
}
inline QString getNameFromLocation(const QString &str)
......
......@@ -11,6 +11,10 @@ ListView
property bool trackNumberVisible
property bool quickBtnsVisible : true
property bool quickPlayVisible : true
property bool trackDuration
property bool trackRating
property alias holder : holder
signal rowClicked(int index)
signal rowPressed(int index)
......@@ -32,8 +36,6 @@ ListView
snapMode: ListView.SnapToItem
function clearTable()
{
listModel.clear()
......@@ -90,6 +92,10 @@ ListView
number : trackNumberVisible ? true : false
quickBtns : quickBtnsVisible
quickPlay: quickPlayVisible
trackDurationVisible : list.trackDuration
trackRatingVisible : list.trackRating
Connections
{
target: delegate
......@@ -102,13 +108,21 @@ ListView
onClicked:
{
currentIndex = index
list.rowClicked(index)
if(bae.isMobile())
list.rowClicked(index)
}
onDoubleClicked:
{
if(!bae.isMobile())
list.rowClicked(index)
}
onPlay: list.quickPlayTrack(index)
onMenuClicked:
{
currentRow = index
currentIndex = index
contextMenu.rate = bae.trackRate(list.model.get(currentRow).url)
if(bae.isMobile()) contextMenu.open()
else
......
......@@ -14,8 +14,21 @@ ItemDelegate
property bool number : false
property bool quickBtns : false
property bool quickPlay : true
property bool trackDurationVisible : false
property bool trackRatingVisible: false
property string trackMood : art
property alias trackRating : trackRating
checkable: true
background: Rectangle
{
color: Qt.lighter(trackMood, 1.5) || "transparent"
opacity: 0.4
}
MouseArea
{
anchors.fill: parent
......@@ -39,7 +52,6 @@ ItemDelegate
rows:2
columns:4
ToolButton
{
id: playBtn
......@@ -63,6 +75,8 @@ ItemDelegate
Layout.rowSpan: 2
Layout.alignment: Qt.AlignCenter
verticalAlignment: Qt.AlignVCenter
text: track
font.bold: true
......@@ -81,7 +95,7 @@ ItemDelegate
Layout.fillHeight: true
Layout.row: 1
Layout.column: 3
verticalAlignment: Qt.AlignVCenter
text: title
font.bold: true
elide: Text.ElideRight
......@@ -99,7 +113,7 @@ ItemDelegate
Layout.fillHeight: true
Layout.row: 2
Layout.column: 3
verticalAlignment: Qt.AlignVCenter
text: artist + " | " + album
font.bold: false
elide: Text.ElideRight
......@@ -108,13 +122,47 @@ ItemDelegate
}
Row
Label
{
id: trackDuration
visible: trackDurationVisible
Layout.fillWidth: true
Layout.fillHeight: true
Layout.row: 1
Layout.column: 4
horizontalAlignment: Qt.AlignRight
verticalAlignment: Qt.AlignVCenter
text: player.transformTime(duration)
font.bold: false
elide: Text.ElideRight
font.pointSize: 8
color: textColor
}
Label
{
id: trackRating
visible: trackRatingVisible
Layout.fillWidth: true
Layout.fillHeight: true
Layout.row: 2
Layout.column: 4
horizontalAlignment: Qt.AlignRight
verticalAlignment: Qt.AlignVCenter
text: stars
font.bold: false
elide: Text.ElideRight
font.pointSize: 8
color: textColor
}
Row
{
Layout.column: 5
Layout.row: 1
Layout.rowSpan: 2
Layout.alignment: Qt.AlignRight
visible: quickBtns || menuBtn.visible
visible: quickBtns || menuBtn.visible
ToolButton
{
......@@ -127,4 +175,31 @@ ItemDelegate
}
function setStars(stars)
{
switch (parseInt(stars))
{
case 0:
return " ";
case 1:
return "\xe2\x98\x86 ";
case 2:
return "\xe2\x98\x86 \xe2\x98\x86 ";
case 3:
return "\xe2\x98\x86 \xe2\x98\x86 \xe2\x98\x86 ";
case 4:
return "\xe2\x98\x86 \xe2\x98\x86 \xe2\x98\x86 \xe2\x98\x86 ";
case 5:
return "\xe2\x98\x86 \xe2\x98\x86 \xe2\x98\x86 \xe2\x98\x86 \xe2\x98\x86 ";
default: return "error";
}
}
}
......@@ -11,7 +11,7 @@ Menu
id: rootMenu
x: parent.width / 2 - width / 2
y: parent.height / 2 - height / 2
modal: bae.isMobile()
modal: true
focus: true
......@@ -22,9 +22,6 @@ Menu
property int assetsize : menuItemHeight/2
property int menuItemHeight : bae.isMobile() ? 48 : 32;
signal rated(int value)
enter: Transition {
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
......@@ -33,7 +30,26 @@ Menu
function rateIt(rank)
{
rate = rank
bae.rateTrack(list.model.get(currentRow).url, rate)
if(bae.rateTrack(list.model.get(currentRow).url, rate))
{
list.currentItem.trackRating.text = rate
list.model.get(currentRow).stars = rate
}
if(!bae.isMobile())
dismiss()
else close()
}
function moodIt(color)
{
if(bae.moodTrack(list.model.get(currentRow).url, color))
{
list.currentItem.trackMood = color
list.model.get(currentRow).art = color
}
if(!bae.isMobile())
dismiss()
else close()
}
......@@ -41,7 +57,7 @@ Menu
{
implicitWidth: 200
implicitHeight: 40
color: bae.backgroundColor()
color: bae.altColor()
border.color: bae.midColor()
border.width: 1
radius: 4
......@@ -74,7 +90,7 @@ Menu
{
height: menuItemHeight
txt: "Queue"
onTriggered: list.queueTrack(currentRow)
onTriggered: list.queueTrack(currentIndex)
}
TableMenuItem
......@@ -187,9 +203,6 @@ Menu
onClicked: rateIt(5)
}
}
}
......@@ -219,7 +232,7 @@ Menu
border.width: 1
}
onClicked: {}
onClicked: moodIt(bae.moodColor(0))
}
ToolButton
{
......@@ -238,7 +251,7 @@ Menu
border.width: 1
}
onClicked: {}
onClicked: moodIt(bae.moodColor(1))
}
ToolButton
{
......@@ -257,7 +270,7 @@ Menu
border.width: 1
}
onClicked: {}
onClicked: moodIt(bae.moodColor(2))
}
ToolButton
{
......@@ -276,7 +289,7 @@ Menu
border.width: 1
}
onClicked: {}
onClicked: moodIt(bae.moodColor(3))
}
ToolButton
......@@ -296,12 +309,8 @@ Menu
border.width: 1
}
onClicked: {}
onClicked: moodIt(bae.moodColor(4))
}
}
}
}
......@@ -25,6 +25,10 @@ Item
property alias playIcon : playIcon
property alias babeBtnIcon: babeBtnIcon
property alias infoView : infoView
property alias durationTime : durationTime
property alias progressTime : progressTime
signal coverDoubleClicked(var tracks)
signal coverPressed(var tracks)
// Component.onCompleted:
......@@ -129,7 +133,7 @@ Item
Layout.column: 1
Layout.fillWidth: true
height: 48
// anchors.top: cover.bottom
// anchors.top: cover.bottom
visible: list.count > 0
Rectangle
......@@ -168,11 +172,11 @@ Item
drag.axis: Drag.YAxis
drag.minimumY: 0
drag.maximumY: columnWidth
// onClicked:
// {
// if(!bae.isMobile())
// cover.visible = !cover.visible
// }
// onClicked:
// {
// if(!bae.isMobile())
// cover.visible = !cover.visible
// }
onMouseYChanged:
......@@ -299,6 +303,8 @@ Item
Layout.fillWidth: true
height: 48
anchors.top: playbackControls.bottom
visible: list.count > 0
Rectangle
{
anchors.fill: parent
......@@ -306,49 +312,92 @@ Item
opacity: 0.8
z: -999
}
Slider
GridLayout
{
id: progressBar
width: parent.width
height: parent.height
from: 0
to: 1000
value: 0
visible: list.count>0
spacing: 0
anchors.fill: parent
columns:3
rows:2
onMoved: player.seek(player.duration() / 1000 * value);
Label
{
id: progressTime
Layout.row: 1
Layout.column: 1
Layout.fillWidth:true
Layout.alignment: Qt.AlignCenter
horizontalAlignment: Qt.AlignHCenter
text: "00:00"
color: bae.foregroundColor()
font.pointSize: 8
}
background: Rectangle
Label
{
x: progressBar.leftPadding
y: progressBar.topPadding + progressBar.availableHeight / 2 - height / 2
implicitWidth: 200
implicitHeight: 2
width: progressBar.availableWidth
height: implicitHeight
id: durationTime
Layout.row: 1
Layout.column: 3
Layout.fillWidth:true
Layout.alignment: Qt.AlignCenter
horizontalAlignment: Qt.AlignHCenter
text: "00:00"
color: bae.foregroundColor()
font.pointSize: 8
}
Rectangle
Slider
{
id: progressBar
Layout.row: 2
Layout.column: 1
Layout.columnSpan: 3
Layout.fillWidth:true
Layout.fillHeight: true
from: 0
to: 1000
value: 0
spacing: 0
onMoved: player.seek(player.duration() / 1000 * value);
background: Rectangle
{
width: progressBar.visualPosition * parent.width
height: parent.height
x: progressBar.leftPadding
y: progressBar.topPadding + progressBar.availableHeight / 2 - height / 2
implicitWidth: 200
implicitHeight: 2
width: progressBar.availableWidth
height: implicitHeight
color: bae.foregroundColor()
Rectangle
{
width: progressBar.visualPosition * parent.width
height: parent.height
color: bae.babeColor()
}
}
handle: Rectangle
{
x: progressBar.leftPadding + progressBar.visualPosition * (progressBar.availableWidth - width)
y: progressBar.topPadding + progressBar.availableHeight / 2 - height / 2
implicitWidth: 16
implicitHeight: 16
radius: 13
color: bae.babeColor()
}
}
handle: Rectangle
{
x: progressBar.leftPadding + progressBar.visualPosition * (progressBar.availableWidth - width)
y: progressBar.topPadding + progressBar.availableHeight / 2 - height / 2
implicitWidth: 16
implicitHeight: 16
radius: 13
color: bae.babeColor()
}
}
}
......@@ -360,7 +409,7 @@ Item
Layout.fillWidth: true
Layout.fillHeight: true
anchors.top: slideBar.bottom
// anchors.bottom: mainPlaylistRoot.searchBox
// anchors.bottom: mainPlaylistRoot.searchBox
StackView
{
id: stackView
......
......@@ -6,6 +6,9 @@ BabeTable
{
id: tracksViewTable
trackNumberVisible: false
trackDuration: true
trackRating: true
function populate()
{
var map = bae.get(Q.Query.allTracks)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment