add patch from Dru Moore : Browser
[vlc-remote] / playermainwindow.cpp
index 874944d..f4b5361 100644 (file)
@@ -36,9 +36,14 @@ PlayerMainWindow::PlayerMainWindow(QWidget *parent) :
     mTimer = new QTimer(this);
     mNetManager = new QNetworkAccessManager(this);
     mPlayListMainWindow = new PlayListMainWindow;
+    mBrowserMainWindow = new BrowseMainWindow;
 
+    mVolume = 100;
+    mMuted = false;
 
     ui->playlistButton->setIcon(QIcon::fromTheme("notes_bullets"));
+    ui->browseButton->setIcon(QIcon::fromTheme("filemanager_media_folder"));
+
     ui->previousButton->setIcon(QIcon::fromTheme("pdf_viewer_first_page"));
     ui->nextButton->setIcon(QIcon::fromTheme("pdf_viewer_last_page"));
     ui->playButton->setIcon(QIcon::fromTheme("camera_playback"));
@@ -47,6 +52,8 @@ PlayerMainWindow::PlayerMainWindow(QWidget *parent) :
     ui->fullscreenButton->setIcon(QIcon::fromTheme("general_fullsize"));
     ui->volDown->setIcon(QIcon::fromTheme("statusarea_volumelevel1"));
     ui->volUp->setIcon(QIcon::fromTheme("statusarea_volumelevel4"));
+    ui->volMute->setIcon(QIcon::fromTheme("statusarea_volume_mute"));
+
 
 #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5)
     mPlayListMainWindow->setParent(this);
@@ -55,12 +62,22 @@ PlayerMainWindow::PlayerMainWindow(QWidget *parent) :
     mPlayListMainWindow->setAttribute(Qt::WA_Maemo5LandscapeOrientation,true);
     setAttribute(Qt::WA_Maemo5StackedWindow);
     mPlayListMainWindow->setWindowFlags(mPlayListMainWindow->windowFlags() | Qt::Window);
+
+    mBrowseMainWindow->setParent(this);
+    mBrowseMainWindow->setAttribute(Qt::WA_Maemo5StackedWindow);
+    mBrowseMainWindow->setAttribute(Qt::WA_Maemo5LandscapeOrientation,true);
+    mBrowseMainWindow->setAttribute(Qt::WA_Maemo5LandscapeOrientation,true);
+    setAttribute(Qt::WA_Maemo5StackedWindow);
+    mBrowseMainWindow->setWindowFlags(mBrowseMainWindow->windowFlags() | Qt::Window);
+
 #endif
 
     connect(mTimer,SIGNAL(timeout()),this,SLOT(askStatus()));
     connect(ui->actionConfiguration,SIGNAL(triggered()),this,SLOT(showConfig()));
     connect(ui->actionAbout,SIGNAL(triggered()),this,SLOT(showAbout()));
     connect(ui->playlistButton,SIGNAL(clicked()),mPlayListMainWindow,SLOT(show()));
+    connect(ui->browseButton,SIGNAL(clicked()),mBrowserMainWindow,SLOT(show()));
+
     connect(ui->playButton,SIGNAL(clicked()),this,SLOT(play()));
     connect(ui->stopButton,SIGNAL(clicked()),this,SLOT(stop()));
     connect(ui->pauseButton,SIGNAL(clicked()),this,SLOT(pause()));
@@ -69,6 +86,7 @@ PlayerMainWindow::PlayerMainWindow(QWidget *parent) :
     connect(ui->fullscreenButton,SIGNAL(clicked()),this,SLOT(fullscreen()));
     connect(ui->volUp,SIGNAL(clicked()),this,SLOT(volUp()));
     connect(ui->volDown,SIGNAL(clicked()),this,SLOT(volDown()));
+    connect(ui->volMute,SIGNAL(clicked()),this,SLOT(volMute()));
     connect(ui->slider,SIGNAL(sliderMoved(int)),this,SLOT(slide(int)));
 
     init();
@@ -136,8 +154,9 @@ void PlayerMainWindow::fullscreen()
 }
 void PlayerMainWindow::volUp()
 {
-    mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=volume&val=500")));
-
+    QUrl url = QUrl("http://"+mIp+"/requests/status.xml?command=volume");
+    url.addEncodedQueryItem(QByteArray("val"), QByteArray("%2B20"));
+    mNetManager->get(QNetworkRequest(url));
 }
 void PlayerMainWindow::volDown()
 {
@@ -145,6 +164,17 @@ void PlayerMainWindow::volDown()
     mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=volume&val=-20")));
 
 }
+void PlayerMainWindow::volMute()
+{
+    this->mMuted = !this->mMuted;
+    if (this->mMuted) {
+        mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=volume&val=0")));
+    }
+    else {
+        mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=volume&val="+QString::number(this->mVolume))));
+    }
+
+}
 void PlayerMainWindow::slide(int value)
 {
     mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=seek&val="+QString::number(value)+"%25")));
@@ -188,6 +218,16 @@ void PlayerMainWindow::parseXmlStatus()
     int position = docElem.namedItem("position").toElement().text().toInt();
     QString state  =docElem.namedItem("state").toElement().text();
 
+
+    if (0 < volume) {
+        this->mVolume = volume;
+        this->mMuted = false;
+    }
+    else {
+        this->mMuted = true;
+    }
+
+
     QTime timeLength(0,0,0) ;
     timeLength =  timeLength.addSecs(time);