/* 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.
- */
+* Copyright (C) 2010 Schutz Sacha <istdasklar@gmail.com>, Dru Moore <usr@dru-id.co.uk>, Yann Nave <yannux@onbebop.net>
+* 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 "browsemainwindow.h"
#include "ui_browsemainwindow.h"
#include <QSettings>
#include "configdialog.h"
#include "aboutdialog.h"
#include "vlcbrowseelement.h"
-#include "accountdialog.h"
+#include "appsettings.h"
BrowseMainWindow::BrowseMainWindow(QWidget *parent) :
QMainWindow(parent),
{
ui->setupUi(this);
- mCurrentDir = "~/"; // This works on win as well as linux, would guess mac too.
+ mCurrentDir = "~/"; //AppSettings::getHomeDirectory().path; // This works on win as well as linux, would guess mac too.
setWindowTitle("Vlc remote");
connect(ui->playButton,SIGNAL(clicked()),this,SLOT(onPlay()));
connect(ui->listWidget, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged()));
+ connect(ui->actionGoHome, SIGNAL(triggered()), this, SLOT(showHomeFolder()));
+ connect(ui->actionSetHome, SIGNAL(triggered()), this, SLOT(setHomeFolder()));
+ connect(ui->actionViewFavourites, SIGNAL(triggered()), this, SLOT(showFavourites()));
+ connect(ui->actionSetFavourite, SIGNAL(triggered()), this, SLOT(setFavourite()));
+
init();
}
void BrowseMainWindow::init() // THIS METHOD IS CALLED WHEN CONFIG CHANGED...
{
- mIp = AccountDialog::currentIp();
+ mIp = AppSettings::getCurrentIp(); // AccountDialog::currentIp();
+ setHomeDirectory();
+}
+void BrowseMainWindow::setHomeDirectory()
+{
+ mCurrentDir = AppSettings::getHomeDirectory().path;
}
void BrowseMainWindow::showCurrentDirectory() // THIS METHOD IS CALLED WHEN WINDOW IS OPENED...
{
}
}
+void BrowseMainWindow::showHomeFolder() {
+ browseDirectory(AppSettings::getHomeDirectory().path);
+}
+void BrowseMainWindow::setHomeFolder() {
+ if (0 < mCurrentDir.length()) {
+ VlcDirectory dir;
+ dir.name = "Home";
+ dir.path = mCurrentDir;
+ AppSettings::setHomeDirectory(dir);
+ }
+}
+void BrowseMainWindow::showFavourites() {}
+void BrowseMainWindow::setFavourite() {}
+
void BrowseMainWindow::onListSelectionChanged() {
QList<QListWidgetItem *> items = ui->listWidget->selectedItems();
if (0 < items.count()) {
ui->browseButton->setDisabled(true);
ui->playButton->setDisabled(true);
ui->addButton->setDisabled(true);
- browseDirectory(mCurrentElement.path);
+ mCurrentDir = mCurrentElement.path;
+ browseDirectory(mCurrentDir);
}
else {
// can we browse?
// check for directory
if (0 == QString::compare("directory", mCurrentElement.type)) {
// call browseDirectory
- this->browseDirectory(mCurrentElement.path);
+ mCurrentDir = mCurrentElement.path;
+ browseDirectory(mCurrentDir);
}
else {
ui->browseButton->setDisabled(true);
}
void BrowseMainWindow::onAddToPlaylist() {
- qDebug() << QUrl("http://"+mIp+"/requests/status.xml?command=in_enqueue&input=" + mCurrentElement.path.replace("\\", "\\\\")).toString();
- /*QNetworkReply * reply = */ mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=in_enqueue&input=" + mCurrentElement.path.replace("\\", "\\\\"))));
- }
+ QUrl url = QUrl("http://"+mIp+"/requests/status.xml?command=in_enqueue");
+ url.addEncodedQueryItem(QByteArray("input"), QUrl::toPercentEncoding(mCurrentElement.path.replace("\\", "\\\\")));
+ mNetManager->get(QNetworkRequest(url));
+ //mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=in_enqueue&input=" + mCurrentElement.path.replace("\\", "\\\\"))));
+}
void BrowseMainWindow::onPlay() {
- qDebug() << QUrl("http://"+mIp+"/requests/status.xml?command=in_play&input=" + mCurrentElement.path.replace("\\", "\\\\")).toString();
- /*QNetworkReply * reply = */ mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=in_play&input=" + mCurrentElement.path.replace("\\", "\\\\"))));
- }
+ QUrl url = QUrl("http://"+mIp+"/requests/status.xml?command=in_play");
+ url.addEncodedQueryItem(QByteArray("input"), QUrl::toPercentEncoding(mCurrentElement.path.replace("\\", "\\\\")));
+ mNetManager->get(QNetworkRequest(url));
+ //mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=in_play&input=" + mCurrentElement.path.replace("\\", "\\\\"))));
+}
void BrowseMainWindow::browseDirectory(QString dir) {
mContents->clear();
ui->listWidget->clear();
mResponse.clear();
- qDebug() << QUrl("http://"+mIp+"/requests/browse.xml?dir=" + dir.replace("\\", "\\\\")).toString();
- QNetworkReply * reply = mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/browse.xml?dir=" + dir.replace("\\", "\\\\"))));
+ QUrl url = QUrl("http://"+mIp+"/requests/browse.xml");
+ url.addEncodedQueryItem(QByteArray("dir"), QUrl::toPercentEncoding(dir));
+ QNetworkReply * reply = mNetManager->get(QNetworkRequest(url));
+ //QNetworkReply * reply = mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/browse.xml?dir=" + dir.replace("&", "%26").replace("\\", "\\\\"))));
connect(reply,SIGNAL(readyRead()),this,SLOT(readReady()));
connect(mNetManager,SIGNAL(finished(QNetworkReply *)),this,SLOT(finished(QNetworkReply *)));
}