4
0
mirror of https://github.com/QuasarApp/SoundBand.git synced 2025-05-10 22:19:34 +00:00

fix nab page

This commit is contained in:
Andrei Yankovich 2018-03-08 16:08:40 +03:00
parent 0abfbec28d
commit 3051fdacdc
10 changed files with 89 additions and 38 deletions

@ -14,7 +14,12 @@ Item{
readonly property real textSize: Utils.dp(Screen.pixelDensity, 10)
readonly property real buttonHeight: Utils.dp(Screen.pixelDensity, 24)
function onItemClick(id) {
property int curentSongId: -1
signal cyrentsongChanged(int id, string name)
function onItemClick(id, name) {
cyrentsongChanged(id, name);
syncEngine.play(id);
}
@ -34,14 +39,15 @@ Item{
id: item
Rectangle {
color: Qt.rgba(0,0,0,0)
color: (curentSongId === songId)? "#ffffff":Qt.rgba(0,0,0,0)
id: rectangle;
anchors.fill: item
MouseArea{
anchors.fill: parent;
onClicked: {
onItemClick(songId);
onItemClick(songId, songName);
curentSongId = songId;
}
}
@ -64,7 +70,7 @@ Item{
anchors.left: rectangle.left
anchors.leftMargin: textmargin
anchors.verticalCenter: rectangle.verticalCenter
source: songId
source: "image://collection/" + songId
}
}
}

@ -1,71 +1,85 @@
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Window 2.0
import "./base" as Base
import "base/utils.js" as Utils
Item {
id: headerForm
property int currentSongId: 0
property string curentSongName: qsTr("Song is not selected")
function changeSong(id, name){
currentSongId = id;
curentSongName = name;
}
Image {
id: viewSong
fillMode: Image.PreserveAspectFit
anchors.leftMargin: 0
fillMode: Image.PreserveAspectCrop
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: groupBox.top
anchors.left: parent.right
source: "/image/res/logo.png"
anchors.bottom: songName.top
anchors.left: parent.left
source: "image://collection/" + currentSongId;
visible: true;
}
Base.BaseText {
id: songName
color: "#5e5858"
height: 20
text: qsTr("Song is not selected")
text: curentSongName
styleColor: "#554f4f"
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
anchors.left: parent.left
anchors.top: parent.top
anchors.leftMargin: 0
anchors.right: parent.right
anchors.rightMargin: 0
anchors.bottom: groupBox.top
anchors.bottomMargin: 0
font.pixelSize:16
}
GroupBox {
id: groupBox
y: 149
height: 160
height: 100
padding: 0;
anchors.left: parent.left
anchors.leftMargin: 0
anchors.right: parent.right
anchors.rightMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
title: qsTr("SoundBand")
Rectangle{
anchors.fill: parent;
color: Utils.backgroundColor()
}
Button {
id: prev
width: parent.width/4
width: parent.width/3
text: qsTr("<<")
anchors.left: parent.left
}
Button {
id: play
width: parent.width/4
width: parent.width/3
text: qsTr("Play")
anchors.left: prev.right
}
Button {
id: stop
width: parent.width/4
text: qsTr("Stop")
anchors.right: next.left
}
Button {
id: next
width: parent.width/4
width: parent.width/3
text: qsTr(">>")
anchors.right: parent.right
}
@ -99,4 +113,7 @@ Item {
anchors.right: parent.right
}
}
}

@ -11,15 +11,6 @@ Page {
function onLoaded(){
}
Header{
id:header
height: 300
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
}
Item{
SwipeView {
@ -34,6 +25,10 @@ Page {
CurentPlayList {
id:curentPlayList;
onCyrentsongChanged:{
header.changeSong(id, name);
}
}
PlayListsControl{
@ -56,6 +51,17 @@ Page {
anchors.right: parent.right
anchors.top: header.bottom
anchors.bottom: parent.bottom
}
Header{
id:header
height: 300
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
}
}

@ -38,7 +38,7 @@ bool App::run(){
if (qmlEngine->rootObjects().isEmpty())
return false;
return true;
return syncEngine->init();
}
App::~App(){

@ -23,7 +23,7 @@ QPixmap ImageProvider::requestPixmap(const QString &id, QSize *size, const QSize
return QPixmap(1,1);
if(!syncEngine->songImageById(songId, result)){
return QPixmap(1,1);
return QPixmap(":/image/res/logo.png");
}
return result.scaled(requestedSize);

@ -7,9 +7,8 @@ SyncEngine::SyncEngine()
sync = new syncLib::Sync();
sqlApi = sync->getSqlApi();
sync->updatePlayList(settings.value(CURRENT_PLAYLIST_KEY, ALL_SONGS_LIST).toString());
connect(sync, SIGNAL(networkStateChange()), this, SIGNAL(serversCountChanged()));
connect(sync, SIGNAL(curentPlayListChanged()), this, SIGNAL(curentPlayListCountChanged()));
}
int SyncEngine::curentSongIndex()const{
@ -31,6 +30,11 @@ bool SyncEngine::selectPlayList(const QString &list){
return true;
}
bool SyncEngine::init(){
sync->updatePlayList(settings.value(CURRENT_PLAYLIST_KEY, ALL_SONGS_LIST).toString());
return true;
}
const QList<syncLib::SongHeader>* SyncEngine::curentPlayList() const{
return sync->getPlayList();

@ -49,6 +49,11 @@ public:
*/
void allPlayLists(QStringList& playList) const;
/**
* @brief init - inited all avelable songs
*/
bool init();
~SyncEngine();
public slots:

@ -205,7 +205,7 @@ bool MySql::load(const SongHeader &song,Song &result){
bool MySql::updateAvailableSongs(QList<SongHeader>& list, const QString& playList){
QString qyer;
if(playList.isEmpty()){
if(playList.isEmpty() || playList == ALL_SONGS_LIST){
qyer = QString("SELECT id,name,size from songs");
}else{
qyer = QString("SELECT id,name,size from songs where "

@ -43,6 +43,12 @@ bool Sync::updateSongs(QList<SongHeader>& list, const QString& playList){
if(!sql->updateAvailableSongs(list, playList)){
return false;
}
if(lastUsedPlayList != playList){
lastUsedPlayList = playList;
emit selectedNewPlatList();
}
emit curentPlayListChanged();
return true;
}

@ -25,6 +25,7 @@ private:
Node *node;
Player *player;
QList<SongHeader> playList;
QString lastUsedPlayList;
int curentSongIndex;
QList<ETcpSocket*> servers;
bool fbroadcaster;
@ -261,6 +262,12 @@ signals:
*/
void curentPlayListChanged();
/**
* @brief curentPlayListChanged
* emited when selected a new playList
*/
void selectedNewPlatList();
};
}