+/* VLC-REMOTE for MAEMO 5
+ * Copyright (C) 2010 Schutz Sacha <istdasklar@gmail.com>
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * or (at your option) any later version, as published by the Free
+ * Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
#include <QDebug>
#include <QTime>
#include "playermainwindow.h"
#include "ui_playermainwindow.h"
#include "configdialog.h"
#include "aboutdialog.h"
+#include "accountdialog.h"
+
PlayerMainWindow::PlayerMainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::PlayerMainWindow)
{
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 ConfigDialog;
+ 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");