aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/desktop-utils')
-rw-r--r--src-qt5/desktop-utils/lumina-mediaplayer/PianoBarProcess.cpp47
-rw-r--r--src-qt5/desktop-utils/lumina-mediaplayer/PianoBarProcess.h8
-rw-r--r--src-qt5/desktop-utils/lumina-mediaplayer/mainUI.cpp27
-rw-r--r--src-qt5/desktop-utils/lumina-mediaplayer/mainUI.h5
-rw-r--r--src-qt5/desktop-utils/lumina-mediaplayer/mainUI.ui12
5 files changed, 83 insertions, 16 deletions
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("<NEW>"); //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("<NEW>"); //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=="<NEW>"){
+ if(makingStation){
//Compare the new list to the previous list and switch to the new one automatically
for(int j=0; j<infoList.length(); j++){
if(!stationList.contains(infoList[j])){ cstation = infoList[j]; break; }
}
+ makingStation = false; //done changing the current station
}
stationList = infoList; //save this list for later
infoList.clear();
@@ -324,7 +347,19 @@ void PianoBarProcess::ProcUpdate(){
sendToProcess(QString::number(stationList.length()-1), true);
}
}
+ }else if( !infoList.isEmpty() ){
+ qDebug() << "Got Question with List:" << info[i] << infoList;
+ emit NewQuestion(info[i].section("[?]",1,-1).simplified(), infoList);
+ }else if(info[i].contains(" Select ") ){
+ qDebug() << "Got Question without List:" << info[i];
+ //Got a prompt without a list of answers - just cancel the prompt
+ sendToProcess("",true);
+ if(makingStation){
+ emit showError(tr("Could not find any matches. Please try a different search term"));
+ makingStation = false; //make sure this flag is reset
+ }
}
+ infoList.clear(); //done with question - make sure this is cleared
}else if(info[i].startsWith("#")){
//Time Stamp
diff --git a/src-qt5/desktop-utils/lumina-mediaplayer/PianoBarProcess.h b/src-qt5/desktop-utils/lumina-mediaplayer/PianoBarProcess.h
index 686eb122..eadd314d 100644
--- a/src-qt5/desktop-utils/lumina-mediaplayer/PianoBarProcess.h
+++ b/src-qt5/desktop-utils/lumina-mediaplayer/PianoBarProcess.h
@@ -40,6 +40,8 @@ public:
QStringList stations();
void setCurrentStation(QString station);
+ void answerQuestion(int selection = -1); //-1 = cancel
+
//Settings Manipulation
QString audioQuality(); // "audio_quality" = [low, medium, high]
void setAudioQuality(QString); // [low, medium, high]
@@ -76,6 +78,7 @@ private:
//Cached Info
QString cstation; //current station
QStringList stationList;
+ bool makingStation;
public slots:
void play(); // "P"
@@ -92,7 +95,7 @@ public slots:
void bookmarkArtist(){ sendToProcess("b"); sendToProcess("a",true); } //"b"->"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 <LUtils.h>
#include <QDesktopServices>
#include <QUrl>
-
+#include <QInputDialog>
#include <QFileDialog>
+#include <QMessageBox>
//#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 @@
<x>0</x>
<y>0</y>
<width>385</width>
- <height>416</height>
+ <height>479</height>
</rect>
</property>
<property name="windowTitle">
@@ -673,7 +673,7 @@
<x>0</x>
<y>0</y>
<width>385</width>
- <height>20</height>
+ <height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@@ -811,6 +811,14 @@
<string>Show song notifications</string>
</property>
</action>
+ <action name="action_pandora_newstation_search">
+ <property name="text">
+ <string>Search...</string>
+ </property>
+ <property name="toolTip">
+ <string>Search for a new station</string>
+ </property>
+ </action>
</widget>
<resources>
<include location="extra/resources.qrc"/>
bgstack15