From fc02e9b54c001fe2e7c862ee577345826f6ac524 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 19 Apr 2017 11:33:19 -0400 Subject: A bit more work on lumina-mediaplayer: - Add support for creating generic stations from a search term. - Ensure that new stations are automatically switched to.. - Add support for changing the libao "audio driver" (some drivers just spit out static - like pulse, but the "oss" driver works great). --- .../lumina-mediaplayer/PianoBarProcess.cpp | 47 +++++++++++++++++++--- .../lumina-mediaplayer/PianoBarProcess.h | 8 +++- .../desktop-utils/lumina-mediaplayer/mainUI.cpp | 27 ++++++++++--- src-qt5/desktop-utils/lumina-mediaplayer/mainUI.h | 5 ++- src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui | 12 +++++- 5 files changed, 83 insertions(+), 16 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 63d2987b..73275acd 100644 --- a/src-qt5/desktop-utils/lumina-mediaplayer/PianoBarProcess.cpp +++ b/src-qt5/desktop-utils/lumina-mediaplayer/PianoBarProcess.cpp @@ -18,6 +18,7 @@ PianoBarProcess::PianoBarProcess(QWidget *parent) : QObject(parent){ saveTimer = new QTimer(this); saveTimer->setInterval(100); //1/10 second (just enough to change a few settings at once before dumping to disk) saveTimer->setSingleShot(true); + makingStation = false; connect(saveTimer, SIGNAL(timeout()), this, SLOT(saveSettingsFile()) ); if( !loadSettings() ){ GenerateSettings(); } } @@ -61,7 +62,19 @@ void PianoBarProcess::setCurrentStation(QString station){ cstation = station; sendToProcess("s"); } - + +void PianoBarProcess::answerQuestion(int selection){ + QString sel; + if(selection>=0){ sel = QString::number(selection); } + + if(makingStation && sel.isEmpty()){ makingStation = false; } //cancelled + sendToProcess(sel, true); + if(makingStation){ + //Need to prompt to list all the available stations to switch over right away + sendToProcess("s"); + } +} + 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 @@ -70,17 +83,26 @@ void PianoBarProcess::deleteCurrentStation(){ //"d" -> "y" setCurrentStation("QuickMix"); //this is always a valid station } -//void PianoBarProcess::createNewStation(); //"c" +void PianoBarProcess::createNewStation(QString searchterm){ //"c" -> search term + sendToProcess("c"); + sendToProcess(searchterm,true); + makingStation = true; +} + void PianoBarProcess::createStationFromCurrentSong(){ //"v" -> "s" sendToProcess("v"); sendToProcess("s",true); - setCurrentStation(""); //internal definition for auto-switching to a new station + makingStation = true; + //Need to prompt to list all the available stations to switch over right away + sendToProcess("s"); } void PianoBarProcess::createStationFromCurrentArtist(){ //"v" -> "a" sendToProcess("v"); sendToProcess("a",true); - setCurrentStation(""); //internal definition for auto-switching to a new station + makingStation = true; + //Need to prompt to list all the available stations to switch over right away + sendToProcess("s"); } //Settings Manipulation @@ -266,7 +288,7 @@ void PianoBarProcess::ProcUpdate(){ infoList << info[i].section(") ",1,-1).simplified(); continue; //done handling this line }else if(!info[i].startsWith("[?]") && !infoList.isEmpty()){ - emit NewList(infoList); + //emit NewList(infoList); infoList.clear(); } //Now parse the lines for messages/etc @@ -304,11 +326,12 @@ void PianoBarProcess::ProcUpdate(){ if(infoList[j].startsWith("q ")){ infoList[j] = infoList[j].section("q ",1,-1); } if(infoList[j].startsWith("Q ")){ infoList[j] = infoList[j].section("Q ",1,-1); } } - if(cstation==""){ + if(makingStation){ //Compare the new list to the previous list and switch to the new one automatically for(int j=0; j"a" void deleteCurrentStation(); //"d" - //void createNewStation(); //"c" + void createNewStation(QString searchterm); //"c" void createStationFromCurrentSong(); //"v" -> "s" void createStationFromCurrentArtist(); //"v" -> "a" @@ -112,8 +115,9 @@ signals: void NowPlayingStation(QString, QString); //[name, id] void NowPlayingSong(bool, QString,QString,QString, QString, QString); //[isLoved, title, artist, album, detailsURL, fromStation] void TimeUpdate(int, int); //[current secs, total secs]; - void NewList(QStringList); //arranged in order: 0-end + void NewQuestion(QString, QStringList); //text, options arranged in order: 0-end void StationListChanged(QStringList); void currentStateChanged(PianoBarProcess::State); + void showError(QString); //important error message to show the user }; #endif diff --git a/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.cpp b/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.cpp index 5bf65cb0..f56fbd3f 100644 --- a/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.cpp @@ -12,8 +12,9 @@ #include #include #include - +#include #include +#include //#include "VideoWidget.h" @@ -97,8 +98,9 @@ void MainUI::setupPandora(){ connect(PANDORA, SIGNAL(NowPlayingStation(QString, QString)), this, SLOT(PandoraStationChanged(QString)) ); connect(PANDORA, SIGNAL(NowPlayingSong(bool, QString,QString,QString, QString, QString)), this, SLOT(PandoraSongChanged(bool, QString, QString, QString, QString, QString)) ); connect(PANDORA, SIGNAL(TimeUpdate(int, int)), this, SLOT(PandoraTimeUpdate(int,int)) ); - connect(PANDORA, SIGNAL(NewList(QStringList)), this, SLOT(PandoraListInfo(QStringList)) ); + connect(PANDORA, SIGNAL(NewQuestion(QString, QStringList)), this, SLOT(PandoraInteractivePrompt(QString, QStringList)) ); connect(PANDORA, SIGNAL(StationListChanged(QStringList)), this, SLOT(PandoraStationListChanged(QStringList)) ); + connect(PANDORA, SIGNAL(showError(QString)), this, SLOT(PandoraError(QString)) ); //Setup a couple of the option lists ui->combo_pandora_quality->clear(); ui->combo_pandora_quality->addItem(tr("Low"),"low"); @@ -126,6 +128,8 @@ void MainUI::setupPandora(){ QMenu *tmp = new QMenu(this); tmp->addAction(ui->action_pandora_newstation_song); tmp->addAction(ui->action_pandora_newstation_artist); + tmp->addSeparator(); + tmp->addAction(ui->action_pandora_newstation_search); ui->tool_pandora_stationadd->setMenu( tmp ); } @@ -160,6 +164,7 @@ void MainUI::setupConnections(){ connect(ui->tool_pandora_stationrm, SIGNAL(clicked()), PANDORA, SLOT(deleteCurrentStation()) ); connect(ui->action_pandora_newstation_artist, SIGNAL(triggered()), PANDORA, SLOT(createStationFromCurrentArtist()) ); connect(ui->action_pandora_newstation_song, SIGNAL(triggered()), PANDORA, SLOT(createStationFromCurrentSong()) ); + connect(ui->action_pandora_newstation_search, SIGNAL(triggered()), this, SLOT(createPandoraStation()) ); connect(ui->line_pandora_email, SIGNAL(textChanged(QString)), this, SLOT(checkPandoraSettings()) ); connect(ui->line_pandora_pass, SIGNAL(textChanged(QString)), this, SLOT(checkPandoraSettings()) ); connect(ui->line_pandora_proxy, SIGNAL(textChanged(QString)), this, SLOT(checkPandoraSettings()) ); @@ -200,7 +205,7 @@ void MainUI::setupIcons(){ ui->tool_pandora_stationadd->setIcon( LXDG::findIcon("list-add","") ); ui->action_pandora_newstation_artist->setIcon( LXDG::findIcon("preferences-desktop-user","") ); ui->action_pandora_newstation_song->setIcon( LXDG::findIcon("bookmark-audio","media-playlist-audio") ); - + ui->action_pandora_newstation_search->setIcon( LXDG::findIcon("edit-find", "document-find") ); } void MainUI::setupTrayIcon(){ @@ -499,6 +504,13 @@ void MainUI::applyPandoraSettings(){ } } +void MainUI::createPandoraStation(){ + //Prompt for a search string + QString srch = QInputDialog::getText(this, tr("Pandora: Create Station"),"", QLineEdit::Normal, tr("Search Term")); + if(srch.isEmpty()){ return; } //cancelled + PANDORA->createNewStation(srch); +} + //Pandora Process Feedback void MainUI::PandoraStateChanged(PianoBarProcess::State state){ //qDebug() << "[STATE CHANGE]" << state; @@ -571,8 +583,13 @@ void MainUI::PandoraStationListChanged(QStringList list){ if(index>=0){ ui->combo_pandora_station->setCurrentIndex(index); } } -void MainUI::PandoraListInfo(QStringList list){ - qDebug() << "[LIST INFO]" << list; +void MainUI::PandoraInteractivePrompt(QString text, QStringList list){ + QString sel = QInputDialog::getItem(this, tr("Pandora Question"), text, list, false); + PANDORA->answerQuestion( list.indexOf(sel) ); +} + +void MainUI::PandoraError(QString err){ + QMessageBox::warning(this, tr("Pandora Error"), err); } //System Tray interactions diff --git a/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.h b/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.h index 6128f5f7..b616c8f5 100644 --- a/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.h +++ b/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.h @@ -92,6 +92,8 @@ private slots: void changePandoraStation(QString); void checkPandoraSettings(); void applyPandoraSettings(); + void createPandoraStation(); + //Pandora Process Feedback void PandoraStateChanged(PianoBarProcess::State); void NewPandoraInfo(QString); @@ -99,7 +101,8 @@ private slots: void PandoraSongChanged(bool, QString, QString, QString, QString, QString); //[isLoved, title, artist, album, detailsURL, fromStation] void PandoraTimeUpdate(int,int); //current secs, total secs void PandoraStationListChanged(QStringList); - void PandoraListInfo(QStringList); + void PandoraInteractivePrompt(QString, QStringList); + void PandoraError(QString); //System Tray interactions void toggleVisibility(); diff --git a/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui b/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui index 3489d2ae..d545e90a 100644 --- a/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui +++ b/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui @@ -7,7 +7,7 @@ 0 0 385 - 416 + 479 @@ -673,7 +673,7 @@ 0 0 385 - 20 + 24 @@ -811,6 +811,14 @@ Show song notifications + + + Search... + + + Search for a new station + + -- cgit