From 1a754cbd0c4a9b23af290f95f6526dc590cab5a5 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 3 Apr 2017 16:32:14 -0400 Subject: Update lumina-mediaplayer a bit more - get the UI starting to reflect the Pandora info, and hook up the station changing buttons. --- .../lumina-mediaplayer/PianoBarProcess.cpp | 26 +++++++++------- .../lumina-mediaplayer/PianoBarProcess.h | 2 +- .../desktop-utils/lumina-mediaplayer/mainUI.cpp | 35 +++++++++++++++++----- src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui | 3 ++ 4 files changed, 47 insertions(+), 19 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-mediaplayer') diff --git a/src-qt5/desktop-utils/lumina-mediaplayer/PianoBarProcess.cpp b/src-qt5/desktop-utils/lumina-mediaplayer/PianoBarProcess.cpp index 19b6b99b..55c85a33 100644 --- a/src-qt5/desktop-utils/lumina-mediaplayer/PianoBarProcess.cpp +++ b/src-qt5/desktop-utils/lumina-mediaplayer/PianoBarProcess.cpp @@ -61,7 +61,7 @@ void PianoBarProcess::setCurrentStation(QString station){ void PianoBarProcess::deleteCurrentStation(){ //"d" -> "y" if(cstation == "QuickMix" || cstation=="Thumbprint Radio"){ return; } //cannot delete these stations - provided by Pandora itself sendToProcess("d"); //delete current station - sendToProcess("y"); //yes, we want to delete it + sendToProcess("y",true); //yes, we want to delete it //Now need to automatically change to another station setCurrentStation("QuickMix"); //this is always a valid station } @@ -69,12 +69,12 @@ void PianoBarProcess::deleteCurrentStation(){ //"d" -> "y" //void PianoBarProcess::createNewStation(); //"c" void PianoBarProcess::createStationFromCurrentSong(){ //"v" -> "s" sendToProcess("v"); - sendToProcess("s"); + sendToProcess("s",true); } void PianoBarProcess::createStationFromCurrentArtist(){ //"v" -> "a" sendToProcess("v"); - sendToProcess("a"); + sendToProcess("a",true); } //Settings Manipulation @@ -189,9 +189,10 @@ void PianoBarProcess::setupProcess(){ connect(PROC, SIGNAL(readyRead()), this, SLOT(ProcUpdate()) ); } -void PianoBarProcess::sendToProcess(QString txt){ +void PianoBarProcess::sendToProcess(QString txt, bool withreturn){ if(PROC->state()==QProcess::Running){ - PROC->write( QString(txt+"\r\n").toLocal8Bit() ); + if(withreturn){ PROC->write( QString(txt+"\r\n").toLocal8Bit() ); } + else{ PROC->write( QString(txt).toLocal8Bit() ); } } } @@ -221,8 +222,8 @@ void PianoBarProcess::ProcUpdate(){ emit NowPlayingStation(data[0], data[1]); if(stationList.isEmpty()){ //Need to prompt to list all the available stations - sendToProcess("s"); - sendToProcess(""); //empty line - canceles the prompt + sendToProcess("s",true);//line return cancels the prompt + //sendToProcess("",true); //empty line - cancels the prompt } //Automatically save this station for autostart next time (make toggle-able later) if(data[1]!=autostartStation()){ setAutostartStation(data[1]); } @@ -233,18 +234,21 @@ void PianoBarProcess::ProcUpdate(){ }else if(info[i].startsWith("(i) ")){ //informational line emit NewInformation(info[i].section(" ",1,-1)); }else if(info[i].startsWith("[?] ")){ //waiting for reply to question - //qDebug() << "Got Question:" << info[i] << infoList; + qDebug() << "Got Question:" << info[i] << infoList; if(info[i].contains("Select station:")){ + qDebug() << "Change to Station:" << cstation; stationList = infoList; //save this list for later infoList.clear(); emit StationListChanged(stationList); //Find the station number which corresponds to the cstation variable/name for(int i=0; iactionVolDown, SIGNAL(triggered()), this, SLOT(voldownToggled()) ); connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(close()) ); connect(ui->push_pandora_apply, SIGNAL(clicked()), this, SLOT(applyPandoraSettings()) ); + connect(ui->combo_pandora_station, SIGNAL(activated(QString)), this, SLOT(changePandoraStation(QString)) ); } @@ -119,8 +120,8 @@ void MainUI::showPandoraSongInfo(){ } -void MainUI::changePandoraStation(QString){ - +void MainUI::changePandoraStation(QString station){ + PANDORA->setCurrentStation(station); } void MainUI::applyPandoraSettings(){ @@ -136,23 +137,43 @@ void MainUI::PandoraStateChanged(PianoBarProcess::State){ } void MainUI::NewPandoraInfo(QString info){ - qDebug() << "[INFO]" << info; + //qDebug() << "[INFO]" << info; + ui->statusbar->showMessage(info, 2000); } void MainUI::PandoraStationChanged(QString station){ - qDebug() << "[STATION CHANGE]" << station; + //qDebug() << "[STATION CHANGE]" << station; + int index = ui->combo_pandora_station->findText( station ); + if(index>=0){ ui->combo_pandora_station->setCurrentIndex(index); } } void MainUI::PandoraSongChanged(bool isLoved, QString title, QString artist, QString album, QString detailsURL, QString fromStation){ - qDebug() << "[SONG CHANGE]" << isLoved << title << artist << album << detailsURL << fromStation; + //qDebug() << "[SONG CHANGE]" << isLoved << title << artist << album << detailsURL << fromStation; + ui->tool_pandora_info->setWhatsThis(detailsURL); + ui->tool_pandora_love->setChecked(isLoved); + ui->tool_pandora_love->setEnabled(!isLoved); //pianobar cannot "unlove" a song + ui->label_pandora_album->setText(album); + ui->label_pandora_artist->setText(artist); + ui->label_pandora_title->setText(title); } void MainUI::PandoraTimeUpdate(int curS, int totS){ - qDebug() << "[TIME UPDATE]" << curS << "/" << totS; + //qDebug() << "[TIME UPDATE]" << curS << "/" << totS; + ui->progress_pandora->setRange(0, totS); + ui->progress_pandora->setValue(curS); } void MainUI::PandoraStationListChanged(QStringList list){ - qDebug() << "[STATION LIST]" << list; + //qDebug() << "[STATION LIST]" << list; + ui->combo_pandora_station->clear(); + for(int i=0; icombo_pandora_station->addItem(list[i]); + } + int index = ui->combo_pandora_station->findText( PANDORA->currentStation() ); + if(index>=0){ ui->combo_pandora_station->setCurrentIndex(index); } } void MainUI::PandoraListInfo(QStringList list){ diff --git a/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui b/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui index 9c8dd46a..6cd3ca14 100644 --- a/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui +++ b/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui @@ -130,6 +130,9 @@ 24 + + + -- cgit