Add static currentIP() in AccountDialog and change all
[vlc-remote] / browsemainwindow.cpp
index 599b632..f4bcef5 100644 (file)
@@ -21,7 +21,7 @@
 #include "configdialog.h"
 #include "aboutdialog.h"
 #include "vlcbrowseelement.h"
-
+#include "accountdialog.h"
 
 BrowseMainWindow::BrowseMainWindow(QWidget *parent) :
         QMainWindow(parent),
@@ -32,8 +32,6 @@ BrowseMainWindow::BrowseMainWindow(QWidget *parent) :
     mCurrentDir = "~/"; // This works on win as well as linux, would guess mac too.
     setWindowTitle("Vlc remote");
 
-    QSettings settings;
-    mIp = settings.value("ip").toString();
 
     mNetManager = new QNetworkAccessManager(this);
 
@@ -53,7 +51,14 @@ BrowseMainWindow::BrowseMainWindow(QWidget *parent) :
     connect(ui->playButton,SIGNAL(clicked()),this,SLOT(onPlay()));
     connect(ui->listWidget, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged()));
 
-    this->browseDirectory(mCurrentDir);
+    init();
+
+
+}
+void BrowseMainWindow::init()  // THIS METHOD IS CALLED WHEN CONFIG CHANGED...
+{
+    mIp = AccountDialog::currentIp();
+    browseDirectory(mCurrentDir);
 }
 
 BrowseMainWindow::~BrowseMainWindow()
@@ -122,11 +127,11 @@ void BrowseMainWindow::onBrowse() {
 
 void BrowseMainWindow::onAddToPlaylist() {
     /*QNetworkReply * reply = */ mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=in_enqueue&input=" + mCurrentElement.path)));
-}
+                             }
 
 void BrowseMainWindow::onPlay() {
     /*QNetworkReply * reply = */ mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=in_play&input=" + mCurrentElement.path)));
-}
+                             }
 
 void BrowseMainWindow::browseDirectory(QString dir) {
     mContents->clear();
@@ -189,11 +194,11 @@ void BrowseMainWindow::parseXmlDirectory() {
 
 void BrowseMainWindow::writeFile(QString path, QByteArray text) {
     QFile file(path);
-         if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
-             return;
+    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+        return;
 
-         QTextStream out(&file);
-         out << text;
+    QTextStream out(&file);
+    out << text;
 }
 
 void BrowseMainWindow::updateList() {