Commit d99b7e7a authored by Camilo higuita's avatar Camilo higuita

now selectionbar is completely working

parent 7e855c85
......@@ -28,7 +28,7 @@ var GET = {
artistTags_: "select distinct tag from artists_tags where context = 'tag' and artist = \"%1\"",
colorTracks_: "select t.*, al.artwork from tracks t inner join albums al on al.album = t.album and al.artist = t.artist where t.art = \"%1\""
colorTracks_: "select t.*, al.artwork from tracks t inner join albums al on al.album = t.album and al.artist = t.artist where t.color = \"%1\""
}
......
......@@ -36,6 +36,9 @@ import Player 1.0
import AlbumsList 1.0
import TracksList 1.0
import BaseModel 1.0
import TracksList 1.0
Maui.ApplicationWindow
{
......@@ -45,7 +48,7 @@ Maui.ApplicationWindow
/******************** ALIASES ********************/
/*************************************************/
property alias mainPlaylist: mainPlaylist
property alias selectionBar: selectionBar
property alias selectionBar: _selectionBar
property alias progressBar: progressBar
about.appIcon: "qrc:/assets/vvave.svg"
......@@ -204,6 +207,7 @@ Maui.ApplicationWindow
}
]
footBar.visible: !mainlistEmpty
footBar.implicitHeight: footBar.visible ? toolBarHeight * 1.2 : 0
page.footBarItem: ColumnLayout
{
......@@ -272,10 +276,11 @@ Maui.ApplicationWindow
leftContent: Maui.ToolButton
{
iconName: "headphones"
visible: _drawer.modal
iconColor: _drawer.visible ? babeColor : textColor
onClicked: _drawer.visible = !_drawer.visible
colorScheme.highlightColor: babeColor
// text: qsTr("Now")
// text: qsTr("Now")
}
middleContent: [
......@@ -306,10 +311,7 @@ Maui.ApplicationWindow
id: playIcon
iconColor: textColor
iconName: isPlaying ? "media-playback-pause" : "media-playback-start"
onClicked:
{
player.playing = !player.playing
}
onClicked: player.playing = !player.playing
},
Maui.ToolButton
......@@ -336,7 +338,6 @@ Maui.ApplicationWindow
}
}
footBar.visible: !mainlistEmpty
leftIcon.iconColor: currentView === viewsIndex.search ? babeColor : altColorText
onSearchButtonClicked:
......@@ -368,13 +369,6 @@ Maui.ApplicationWindow
id: sourcesDialog
}
BabeConsole
{
id: babeConsole
}
// menuDrawer.bannerImageSource: "qrc:/assets/banner.svg"
mainMenu: [
// Maui.MenuItem
......@@ -649,8 +643,8 @@ Maui.ApplicationWindow
onCurrentIndexChanged:
{
currentView = currentIndex
if (!babeitView.isConnected && currentIndex === viewsIndex.vvave)
babeitView.logginDialog.open()
// if (!babeitView.isConnected && currentIndex === viewsIndex.vvave)
// babeitView.logginDialog.open()
}
TracksView
......@@ -794,8 +788,6 @@ Maui.ApplicationWindow
onPlayAll:
{
var query = playlistsView.playlistQuery
mainPlaylist.list.clear()
mainPlaylist.list.sortBy = Tracks.NONE
mainPlaylist.list.query = query
......@@ -833,6 +825,7 @@ Maui.ApplicationWindow
onQuickPlayTrack: Player.quickPlay(searchView.list.get(index))
onPlayAll:
{
mainPlaylist.list.clear()
var tracks = searchView.list.getAll()
for(var i in tracks)
Player.appendTrack(tracks[i])
......@@ -912,48 +905,52 @@ Maui.ApplicationWindow
Maui.SelectionBar
{
id: selectionBar
id: _selectionBar
property alias listView: _selectionBar.selectionList
Layout.fillWidth: true
Layout.margins: space.huge
Layout.topMargin: space.small
Layout.bottomMargin: space.big
onIconClicked: contextMenu.show(selectedPaths)
onIconClicked: _contextMenu.popup()
onExitClicked: clear()
model: BaseModel
{
list: _selectionBarModelList
}
Tracks
{
id: _selectionBarModelList
}
SelectionBarMenu
{
id: _contextMenu
}
TableMenu
function append(item)
{
id: contextMenu
menuItem: Maui.MenuItem
if(selectedPaths.indexOf(item.path) < 0)
{
text: qsTr("Play all")
onTriggered:
{
var data = bae.getList(selectionBar.selectedPaths)
contextMenu.close()
selectionMode = false
selectionBar.clear()
Player.playAll(data)
selectedItems.push(item)
selectedPaths.push(item.path)
}
}
// for(var i = 0; i < selectionList.count ; i++ )
// if(selectionList.model.get(i).path === item.path)
// {
// selectionList.model.remove(i)
// return
// }
onFavClicked: H.faveIt(paths)
selectionList.model.list.append(item)
selectionList.positionViewAtEnd()
onQueueClicked: H.queueIt(paths)
onSaveToClicked:
{
playlistDialog.tracks = paths
playlistDialog.open()
}
onOpenWithClicked: bae.showFolder(paths)
if(position === Qt.Vertical) return
onRemoveClicked:
{
if(typeof(riseContent) === "undefined") return
riseContent()
}
onRateClicked: H.rateIt(paths, rate)
onColorClicked: H.moodIt(paths, color)
}
}
}
......
......@@ -72,6 +72,8 @@ public slots:
Q_UNUSED(index);
return false;
}
virtual void clear(){}
};
#endif // BASELIST_H
......@@ -114,5 +114,10 @@ void BaseModel::setList(BaseList *value)
QVariantMap BaseModel::get(const int &index) const
{
return this->mList->get(index);
return this->mList->get(index);
}
void BaseModel::clear()
{
this->mList->clear();
}
......@@ -35,6 +35,7 @@ signals:
public slots:
QVariantMap get(const int &index) const;
void clear();
};
#endif // NOTESMODEL_H
......@@ -306,7 +306,7 @@ bool TracksModel::fav(const int &index, const bool &value)
{
this->list[index][FMH::MODEL_KEY::FAV] = value ? "1" : "0";
emit this->updateModel(index, {FMH::MODEL_KEY::FAV});
qDebug()<< "FAVVING TRACKS"<< item;
return true;
}
......
......@@ -59,7 +59,7 @@ public slots:
void append(const QVariantMap &item, const int &at);
void appendQuery(const QString &query);
void searchQueries(const QStringList &queries);
void clear();
void clear() override;
bool color(const int &index, const QString &color);
bool fav(const int &index, const bool &value);
bool rate(const int &index, const int &value);
......
......@@ -72,5 +72,6 @@
<file>assets/vvave.svg</file>
<file>assets/materialdesignicons-webfont.ttf</file>
<file>widgets/CloudView/CloudView.qml</file>
<file>widgets/SelectionBarMenu.qml</file>
</qresource>
</RCC>
......@@ -79,7 +79,7 @@ Page
function populate(tracks)
{
youtubeTable.clearTable()
youtubeTable.model.clear()
for(var i in tracks)
youtubeTable.model.append(tracks[i])
}
......@@ -222,99 +222,56 @@ Page
}
initialItem: Item
initialItem: BabeTable
{
id: youtubeList
ColumnLayout
id: youtubeTable
trackNumberVisible: false
headBar.visible: true
headBarExit: true
headBarExitIcon: "edit-clear"
headBarTitle: "YouTube"
holder.emoji: "qrc:/assets/Astronaut.png"
holder.isMask: false
holder.title : "No Results!"
holder.body: "Try with another query"
holder.emojiSize: iconSizes.huge
coverArtVisible: true
trackDuration: true
trackRating: true
onExit: clearSearch()
isArtworkRemote: true
allowMenu: false
model: ListModel{}
appendBtn.visible: false
playAllBtn.visible: false
headBar.rightContent: Maui.ToolButton
{
anchors.fill: parent
width: parent.width
height: parent.height
id: menuBtn
iconName: "application-menu"
onClicked: configPopup.open()
}
Layout.margins: 0
spacing: 0
onRowClicked:
{
watchVideo(youtubeTable.model.get(index))
}
BabeTable
{
id: youtubeTable
Layout.fillHeight: true
Layout.fillWidth: true
trackNumberVisible: false
headBar.visible: true
headBarExit: true
headBarExitIcon: "edit-clear"
headBarTitle: "YouTube"
holder.emoji: "qrc:/assets/Astronaut.png"
holder.isMask: false
holder.title : "No Results!"
holder.body: "Try with another query"
holder.emojiSize: iconSizes.huge
coverArtVisible: true
trackDuration: true
trackRating: true
onExit: clearSearch()
isArtworkRemote: true
allowMenu: false
appendBtn.visible: false
playAllBtn.visible: false
menuBtn.visible: false
headBar.rightContent: Maui.ToolButton
{
id: menuBtn
iconName: "application-menu"
onClicked: configPopup.open()
}
onRowClicked:
{
watchVideo(youtubeTable.model.get(index))
}
onQuickPlayTrack:
{
playTrack(youtubeTable.model.get(index).url)
}
}
onQuickPlayTrack:
{
playTrack(youtubeTable.model.get(index).url)
}
ToolBar
{
id: searchBox
Layout.fillWidth: true
position: ToolBar.Footer
RowLayout
{
anchors.fill: parent
TextInput
{
id: searchInput
color: textColor
Layout.fillWidth: true
Layout.fillHeight: true
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
selectByMouse: !isMobile
selectionColor: highlightColor
selectedTextColor: highlightedTextColor
focus: true
text: ""
wrapMode: TextEdit.Wrap
onAccepted: runSearch(searchInput.text)
}
Maui.ToolButton
{
Layout.rightMargin: contentMargins
iconName: "edit-clear"
onClicked: searchInput.clear()
}
}
}
footBar.middleContent: Maui.TextField
{
id: searchInput
width: youtubeTable.footBar.middleLayout.width * 0.9
placeholderText: qsTr("Search videos...")
wrapMode: TextEdit.Wrap
onAccepted: runSearch(searchInput.text)
}
}
......
......@@ -6,96 +6,40 @@ import "../../view_models"
import org.kde.kirigami 2.2 as Kirigami
import org.kde.mauikit 1.0 as Maui
Page
Maui.Page
{
id: videoPlayback
property alias webView: webViewer.item
property bool wasPlaying: false
property var currentYt : ({})
margins: 0
ColumnLayout
{
anchors.fill: parent
headBarExitIcon: "go-previous"
onExit: stackView.pop(youtubeTable)
headBarTitle: currentYt ? currentYt.title : "YouTube"
spacing: 0
headBar.rightContent: [
ToolBar
Maui.ToolButton
{
id: headerRoot
width: parent.width
Layout.fillWidth: true
focus: true
RowLayout
{
id: headerBar
anchors.fill: parent
Maui.ToolButton
{
Layout.alignment : Qt.AlignLeft
Layout.leftMargin: contentMargins
width: rowHeight
iconName : "go-previous"
onClicked: stackView.pop(youtubeList)
}
Label
{
text : currentYt ? currentYt.title : "YouTube"
Layout.fillHeight : true
Layout.fillWidth : true
Layout.alignment : Qt.AlignCenter
color: textColor
elide : Text.ElideRight
font.bold : false
font.pointSize: fontSizes.big
horizontalAlignment : Text.AlignHCenter
verticalAlignment : Text.AlignVCenter
}
Maui.ToolButton
{
Layout.alignment : Qt.AlignLeft
width: rowHeight
iconName : "link"
onClicked: webView.url = currentYt.url.replace("embed/", "watch?v=")
}
Maui.ToolButton
{
Layout.alignment : Qt.AlignLeft
width: rowHeight
iconName : "download"
onClicked: bae.getYoutubeTrack(JSON.stringify(currentYt))
}
iconName : "link"
onClicked: webView.url = currentYt.url.replace("embed/", "watch?v=")
},
Maui.ToolButton
{
Layout.alignment : Qt.AlignLeft
Layout.rightMargin: contentMargins
width: rowHeight
iconName : "overflow-menu"
}
}
}
Loader
Maui.ToolButton
{
id: webViewer
clip: true
Layout.fillHeight: true
Layout.fillWidth: true
source: isAndroid ? "qrc:/services/web/WebView_A.qml" : "qrc:/services/web/WebView.qml"
onVisibleChanged:
{
if(!visible) webView.url = "about:blank"
console.log(webView.url, visible)
}
iconName : "download"
onClicked: bae.getYoutubeTrack(JSON.stringify(currentYt))
}
]
Loader
{
id: webViewer
clip: true
anchors.fill: parent
source: isAndroid ? "qrc:/services/web/WebView_A.qml" : "qrc:/services/web/WebView.qml"
onVisibleChanged: if(!visible) webView.url = "about:blank"
}
}
......@@ -106,14 +106,12 @@ function addSource()
function addToSelection(item)
{
selectionBar.append({
thumbnail: item.artwork,
label: item.title,
mime: "image",
tooltip: item.url,
path: item.url
})
item.thumbnail= item.artwork
item.label= item.title
item.mime= "image"
item.tooltip= item.url
item.path= item.url
selectionBar.append(item)
}
......
......@@ -35,12 +35,10 @@ BabeList
property bool group : false
property alias headerMenu: headerMenu
property alias contextMenu : contextMenu
property alias playAllBtn : playAllBtn
property alias appendBtn : appendBtn
property alias menuBtn : menuBtn
signal rowClicked(int index)
signal rowPressed(int index)
......@@ -178,49 +176,33 @@ BabeList
Maui.ToolButton
{
id: menuBtn
iconName: /*"application-menu"*/ "overflow-menu"
onClicked: headerMenu.popup()
iconName: "item-select"
onClicked: selectionMode = !selectionMode
checkable: true
checked: selectionMode
}
]
HeaderMenu
{
id: headerMenu
onSaveListClicked: saveList()
onQueueListClicked: queueList()
}
TableMenu
{
id: contextMenu
menuItem: [
Maui.MenuItem
{
text: qsTr("Select...")
onTriggered:
{
H.addToSelection(listView.model.get(listView.currentIndex))
contextMenu.close()
}
},
MenuSeparator {},
MenuSeparator {}
Maui.MenuItem
{
text: qsTr("Go to Artist")
onTriggered: goToArtist()
Maui.MenuItem
{
text: qsTr("Go to Artist")
onTriggered: goToArtist()
}
},
Maui.MenuItem
{
text: qsTr("Go to Album")
onTriggered: goToAlbum()
}
Maui.MenuItem
{
text: qsTr("Go to Album")
onTriggered: goToAlbum()
}
]
onFavClicked:
{
......@@ -231,10 +213,11 @@ BabeList
onSaveToClicked:
{
playlistDialog.tracks = paths
playlistDialog.tracks = [list.get(listView.currentIndex).url]
playlistDialog.open()
}
onOpenWithClicked: bae.showFolder(paths)
onOpenWithClicked: bae.showFolder([list.get(listView.currentIndex).url])
onRemoveClicked:
{
......@@ -260,6 +243,12 @@ BabeList
{
cloudView.list.upload(listView.currentIndex)
}
onShareClicked:
{
isAndroid ? Maui.Android.shareDialog(list.get(listView.currentIndex)) :
shareDialog.show([list.get(listView.currentIndex).url])
}
}
listView.highlightFollowsCurrentItem: false
......@@ -355,7 +344,7 @@ BabeList
currentIndex = index
contextMenu.rate = list.get(currentIndex).rate
contextMenu.fav = list.get(currentIndex).fav == "1"
contextMenu.show([list.get(currentIndex).url])
contextMenu.popup()
rowPressed(index)
......
......@@ -51,11 +51,7 @@ Maui.Menu
MenuSeparator {}
Maui.MenuItem
{
text: qsTr("Selection "+ (selectionMode ? "OFF" : "ON"))
onTriggered: selectionMode = !selectionMode
}
Column
{
......
......@@ -332,7 +332,7 @@ SwipeDelegate
Layout.column: /*trackDurationVisible &&*/ sameAlbum ? 4 : 3
horizontalAlignment: Qt.AlignRight
verticalAlignment: Qt.AlignVCenter
text: model.fav == "1" ? "\uf2D1" : ""
text: model.fav ? (model.fav == "1" ? "\uf2D1" : "") : ""
font.bold: false
elide: Text.ElideRight
font.pointSize: fontSizes.small
......@@ -354,7 +354,7 @@ SwipeDelegate
// Layout.columnSpan: trackRatingVisible && sameAlbum ? 4 : 3
horizontalAlignment: Qt.AlignRight
verticalAlignment: Qt.AlignVCenter
text: H.setStars(model.rate)
text: model.rate ? H.setStars(model.rate) : ""
font.bold: false
elide: Text.ElideRight
font.pointSize: fontSizes.small
......
......@@ -4,13 +4,14 @@ import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../../utils"
import ".."
import "../../utils/Help.js" as H
import org.kde.mauikit 1.0 as Maui