#include "ui_playermainwindow.h"
#include "configdialog.h"
#include "aboutdialog.h"
+#include "accountdialog.h"
PlayerMainWindow::PlayerMainWindow(QWidget *parent) :
ui->setupUi(this);
setWindowTitle("Vlc remote");
- QSettings settings;
- mIp = settings.value("ip").toString();
-
- if ( mIp.isEmpty())
- showConfig();
mTimer = new QTimer(this);
connect(ui->volDown,SIGNAL(clicked()),this,SLOT(volDown()));
connect(ui->slider,SIGNAL(sliderMoved(int)),this,SLOT(slide(int)));
- mTimer->start(5000);
+ init();
}
+void PlayerMainWindow::init()
+{
+ QSettings settings;
+ QString currentKey = settings.value("config/currentKey").toString();
+ mIp = settings.value("account/"+currentKey).toString()+":8080";
+
+ if ( mIp.isEmpty())
+ showConfig();
+ else
+ mTimer->start(5000);
+}
PlayerMainWindow::~PlayerMainWindow()
{
void PlayerMainWindow::showConfig()
{
-// ConfigDialog * dialog = new AccountDialog;
-// dialog->exec();
+ mTimer->stop();
+ AccountDialog * dialog = new AccountDialog;
+ dialog->exec();
+ init();
+
+
}
void PlayerMainWindow::showAbout()
{
}
-
void PlayerMainWindow::askStatus()
{
QNetworkReply * reply = mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml")));
connect(reply,SIGNAL(readyRead()),this,SLOT(parseXmlStatus()));
}
+
void PlayerMainWindow::parseXmlStatus()
{
QNetworkReply * reply = qobject_cast<QNetworkReply*>(sender());
QString state =docElem.namedItem("state").toElement().text();
QTime timeLength(0,0,0) ;
- timeLength = timeLength.addSecs(time);
+ timeLength = timeLength.addSecs(time);
-ui->timeLabel->setText(timeLength.toString("mm:ss"));
+ ui->timeLabel->setText(timeLength.toString("mm:ss"));
QDomNode infoNode = docElem.namedItem("information");