Commit 0541dcc9 authored by Camilo Higuita's avatar Camilo Higuita

rework on babetable delgates and intial work on keyboard navigation

parent 00c2c07a
......@@ -321,6 +321,18 @@ QString Babe::hightlightColor()
#endif
}
QString Babe::hightlightTextColor()
{
#if defined(Q_OS_ANDROID)
return "#FFF";
#elif defined(Q_OS_LINUX)
QWidget widget;
return widget.palette().color(QPalette::HighlightedText).name();
#elif defined(Q_OS_WIN32)
return "#FFF";
#endif
}
QString Babe::midColor()
{
#if defined(Q_OS_ANDROID)
......
......@@ -67,12 +67,14 @@ public:
Q_INVOKABLE static void savePlaylistPos(const int &pos);
Q_INVOKABLE static int lastPlaylistPos();
/*COLORS*/
Q_INVOKABLE static QString baseColor();
Q_INVOKABLE static QString darkColor();
Q_INVOKABLE static QString backgroundColor();
Q_INVOKABLE static QString foregroundColor();
Q_INVOKABLE static QString textColor();
Q_INVOKABLE static QString hightlightColor();
Q_INVOKABLE static QString hightlightTextColor();
Q_INVOKABLE static QString midColor();
Q_INVOKABLE static QString midLightColor();
Q_INVOKABLE static QString shadowColor();
......
......@@ -268,7 +268,7 @@ ApplicationWindow
onPlayAll: Player.playAll(bae.get(Q.Query.allTracks))
onAppendAll: Player.appendAll(bae.get(Q.Query.allTracks))
}
}
}
......
......@@ -10,7 +10,6 @@ ListView
id: list
// cacheBuffer : 300
property int currentRow : -1
property bool headerBar: false
property bool trackNumberVisible
......@@ -41,10 +40,36 @@ ListView
clip: true
highlight: highlight
highlightFollowsCurrentItem: false
keyNavigationWraps: root.isMobile
highlight: Rectangle
{
width: list.width
height: list.currentItem.height
color: bae.hightlightColor() || myPalette.highlight
// opacity: 0.7
y: list.currentItem.y
// Behavior on y
// {
// SpringAnimation
// {
// spring: 3
// damping: 0.2
// }
// }
}
focus: true
interactive: true
highlightFollowsCurrentItem: false
keyNavigationWraps: !isMobile
keyNavigationEnabled : !isMobile
Keys.onPressed: forceActiveFocus();
Keys.onUpPressed: decrementCurrentIndex()
Keys.onDownPressed: incrementCurrentIndex()
Keys.onReturnPressed: rowClicked(currentIndex)
// boundsBehavior: Flickable.StopAtBounds
// flickableDirection: Flickable.AutoFlickDirection
......@@ -153,28 +178,6 @@ ListView
}
Component
{
id: highlight
Rectangle
{
width: list.width
height: list.currentItem.height
color: bae.hightlightColor() || myPalette.highlight
opacity: 0.7
y: list.currentItem.y
// Behavior on y
// {
// SpringAnimation
// {
// spring: 3
// damping: 0.2
// }
// }
}
}
TableMenu
{
id: contextMenu
......@@ -184,7 +187,7 @@ ListView
model: listModel
delegate: TableDelegate
delegate: TableDelegate
{
id: delegate
width: list.width
......@@ -226,12 +229,13 @@ ListView
function openItemMenu(index)
{
currentRow = index
currentIndex = index
contextMenu.rate = bae.trackRate(list.model.get(currentRow).url)
contextMenu.rate = bae.trackRate(list.model.get(list.currentIndex).url)
if(root.isMobile) contextMenu.open()
else
contextMenu.popup()
list.rowPressed(index)
}
Component.onCompleted: forceActiveFocus()
}
......@@ -6,15 +6,17 @@ import "../utils"
ItemDelegate
{
id: delegate
id: delegateRoot
width: parent.width
height: sameAlbum ? 48 : 64
height: sameAlbum && coverArt ? 48 : 64
clip: true
signal play()
signal rightClicked()
signal artworkCoverDoubleClicked()
signal leftClicked()
signal artworkCoverClicked()
signal artworkCoverDoubleClicked()
readonly property bool sameAlbum :
{
......@@ -25,7 +27,7 @@ ItemDelegate
}else false
}
property string textColor: bae.foregroundColor()
property string textColor: ListView.isCurrentItem ? bae.hightlightTextColor() : bae.foregroundColor()
property bool number : false
property bool quickPlay : true
property bool coverArt : false
......@@ -36,10 +38,10 @@ ItemDelegate
property string trackMood : art
property alias trackRating : trackRating
checkable: true
background: Rectangle
Rectangle
{
anchors.fill: parent
color:
{
if(trackMood.length>0)
......@@ -53,7 +55,7 @@ ItemDelegate
MouseArea
{
anchors.fill: parent
acceptedButtons: Qt.RightButton
acceptedButtons: Qt.RightButton
onClicked:
{
if(!root.isMobile && mouse.button === Qt.RightButton)
......@@ -61,34 +63,24 @@ ItemDelegate
}
}
contentItem: RowLayout
RowLayout
{
id: gridLayout
height: sameAlbum ? 64 : delegate.height
width: delegate.width
anchors.fill: parent
spacing: 20
Item
{
visible:
{
if(coverArt)
{
if(sameAlbum)
artworkCover.source = ""
true
}else false
}
visible: coverArt
Layout.fillHeight: true
// Layout.fillWidth: true
// height: parent.height
width: parent.height
width: sameAlbum && coverArt ? 64 : parent.height
ToolButton
{
height: delegate.height
width: delegate.height
visible: !sameAlbum
height: parent.height
width: parent.height
anchors.verticalCenter: parent.verticalCenter
Image
......@@ -117,34 +109,36 @@ ItemDelegate
{
visible: quickPlay
Layout.fillHeight: true
// Layout.fillWidth: true
// height: parent.height
width: parent.height
ToolButton
{
id: playBtn
anchors.centerIn: parent
BabeIcon { text: MdiFont.Icon.playCircle }
onClicked: delegate.play()
BabeIcon { text: MdiFont.Icon.playCircle; color: textColor }
onClicked: play()
}
}
Item
{
height: delegate.height
Layout.fillHeight: true
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
Layout.margins: 15
anchors.verticalCenter: parent.verticalCenter
GridLayout
{
anchors.fill: parent
rows:2
columns:3
// rowSpacing: 0
// columnSpacing: 20
Label
{
......
......@@ -30,10 +30,10 @@ Menu
function rateIt(rank)
{
rate = rank
if(bae.rateTrack(list.model.get(currentRow).url, rate))
if(bae.rateTrack(list.model.get(list.currentIndex).url, rate))
{
list.currentItem.trackRating.text = rate
list.model.get(currentRow).stars = rate
list.model.get(list.currentIndex).stars = rate
}
if(!root.isMobile)
dismiss()
......@@ -42,10 +42,10 @@ Menu
function moodIt(color)
{
if(bae.moodTrack(list.model.get(currentRow).url, color))
if(bae.moodTrack(list.model.get(list.currentIndex).url, color))
{
list.currentItem.trackMood = color
list.model.get(currentRow).art = color
list.model.get(list.currentIndex).art = color
}
if(!root.isMobile)
dismiss()
......@@ -75,7 +75,7 @@ Menu
// height: root.isMobile ? menuItemHeight : 0
// horizontalAlignment: Qt.AlignHCenter
// elide: Text.ElideRight
// text: currentRow >= 0 ? list.model.get(currentRow).title : ""
// text: list.currentIndex >= 0 ? list.model.get(list.currentIndex).title : ""
// color: bae.foregroundColor()
// }
......
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