--- /dev/null
+/* 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 "browsemainwindow.h"
+#include "ui_browsemainwindow.h"
+#include <QSettings>
+#include <QDebug>
+#include "configdialog.h"
+#include "aboutdialog.h"
+#include "vlcbrowseelement.h"
+
+
+BrowseMainWindow::BrowseMainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::BrowseMainWindow)
+{
+
+ ui->setupUi(this);
+ mCurrentDir = "~/"; // This works on win as well as linux, would guess mac too.
+ setWindowTitle("Vlc remote");
+
+ QSettings settings;
+
+ QString key = settings.value("config/currentKey").toString();
+ mIp = settings.value("account/home").toString()+":8080";
+
+
+ mNetManager = new QNetworkAccessManager(this);
+
+ ui->playButton->setIcon(QIcon::fromTheme("camera_playback"));
+ ui->addButton->setIcon(QIcon::fromTheme("general_add"));
+ ui->browseButton->setIcon(QIcon::fromTheme("filemanager_media_folder"));
+ ui->browseButton->setDisabled(true);
+ ui->playButton->setDisabled(true);
+ ui->addButton->setDisabled(true);
+ //ui->listWidget->setHorizontalScrollMode(QListWidget::ScrollMode::ScrollPerItem);
+ //ui->listWidget->setHorizontalScrollHint(QListWidget::ScrollHint::PositionAtTop);
+
+ connect(ui->browseButton,SIGNAL(clicked()),this,SLOT(onBrowse()));
+ connect(ui->addButton,SIGNAL(clicked()),this,SLOT(onAddToPlaylist()));
+ connect(ui->playButton,SIGNAL(clicked()),this,SLOT(onPlay()));
+ connect(ui->listWidget, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged()));
+
+ this->browseDirectory(mCurrentDir);
+}
+
+BrowseMainWindow::~BrowseMainWindow()
+{
+ delete ui;
+}
+
+void BrowseMainWindow::changeEvent(QEvent *e)
+{
+ QMainWindow::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+
+void BrowseMainWindow::onListSelectionChanged() {
+ QList<QListWidgetItem *> items = ui->listWidget->selectedItems();
+ if (0 < items.count()) {
+ mCurrentElement = getElementFromText(items.at(0)->text());
+ // are we up dir?
+ if (0 == QString::compare("..", mCurrentElement.name)) {
+ ui->browseButton->setDisabled(true);
+ ui->playButton->setDisabled(true);
+ ui->addButton->setDisabled(true);
+ browseDirectory(mCurrentElement.path);
+ }
+ else {
+ // can we browse?
+ if (0 == QString::compare("directory", mCurrentElement.type)) {
+ ui->browseButton->setDisabled(false);
+ }
+ else {
+ ui->browseButton->setDisabled(true);
+ }
+ // can we play?
+ ui->playButton->setDisabled(false);
+ // can we playlist?
+ ui->addButton->setDisabled(false);
+ }
+ }
+}
+
+VlcBrowseElement BrowseMainWindow::getElementFromText(QString text) {
+ //if (0 != QString::compare("", text)) {
+ for (int idx = 0; idx < mContents->count(); ++idx) {
+ if (0 == QString::compare(text, mContents->at(idx).name)) {
+ return mContents->at(idx);
+ }
+ }
+ //}
+ return *(new VlcBrowseElement());
+}
+
+void BrowseMainWindow::onBrowse() {
+ // check for directory
+ if (0 == QString::compare("directory", mCurrentElement.type)) {
+ // call browseDirectory
+ this->browseDirectory(mCurrentElement.path);
+ }
+}
+
+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) {
+ ui->listWidget->clear();
+ QNetworkReply * reply = mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/browse.xml?dir=" + dir)));
+ connect(reply,SIGNAL(readyRead()),this,SLOT(parseXmlDirectory()));
+}
+void BrowseMainWindow::parseXmlDirectory() {
+ QNetworkReply * reply = qobject_cast<QNetworkReply*>(sender());
+ QDomDocument doc;
+ doc.setContent(reply->readAll());
+ QDomElement docElem = doc.documentElement();
+ QDomNodeList elements = docElem.elementsByTagName("element");
+ mContents = new QList<VlcBrowseElement>();
+ if (0 < elements.count()) {
+ int idx = 0;
+ do {
+ QDomNode node = elements.at(idx);
+ VlcBrowseElement* dir = new VlcBrowseElement();
+ dir->type = node.attributes().namedItem("type").nodeValue();
+ dir->size = node.attributes().namedItem("size").nodeValue().toInt();
+ dir->date = QDate::fromString(node.attributes().namedItem("date").nodeValue());
+ dir->path = node.attributes().namedItem("path").nodeValue();
+ dir->name = node.attributes().namedItem("name").nodeValue();
+ dir->extension = node.attributes().namedItem("extension").nodeValue();
+ ++idx;
+ this->mContents->append(*dir);
+ } while (idx < elements.count());
+ }
+ delete reply;
+
+ // Update UI
+ this->updateList();
+}
+
+void BrowseMainWindow::updateList() {
+ int ct = this->mContents->count();
+ if (0 < ct) {
+ for (int idx = 0; idx < ct; ++idx) {
+ VlcBrowseElement dir = mContents->at(idx);
+ QListWidgetItem* item;
+ if (0 == QString::compare("directory", dir.type)) {
+ if (0 == QString::compare("..", dir.name)) {
+ item = new QListWidgetItem(QIcon::fromTheme("filemanager_folder_up"), dir.name, ui->listWidget, 0);
+ }
+ else {
+ item = new QListWidgetItem(QIcon::fromTheme("general_folder"), dir.name, ui->listWidget, 0);
+ }
+ ui->listWidget->addItem(item);
+ }
+ else if (0 == QString::compare("file", dir.type)) {
+ if ( 0 == QString::compare(dir.extension, "jpg") ||
+ 0 == QString::compare(dir.extension, "jpeg") ||
+ 0 == QString::compare(dir.extension, "gif") ||
+ 0 == QString::compare(dir.extension, "png") ||
+ 0 == QString::compare(dir.extension, "bmp") ) {
+ item = new QListWidgetItem(QIcon::fromTheme("general_image"), dir.name, ui->listWidget, 0); // .jpg, .jpeg, .gif, .png, .bmp
+ }
+ else if ( 0 == QString::compare(dir.extension, "mp3") ||
+ 0 == QString::compare(dir.extension, "m4a") ||
+ 0 == QString::compare(dir.extension, "ogg") ||
+ 0 == QString::compare(dir.extension, "oga") ||
+ 0 == QString::compare(dir.extension, "wav") ||
+ 0 == QString::compare(dir.extension, "flac") ) {
+ item = new QListWidgetItem(QIcon::fromTheme("general_audio_file"), dir.name, ui->listWidget, 0); // .mp3, .m4a, .ogg, .oga, .wav, .flac
+ }
+ else if ( 0 == QString::compare(dir.extension, "flv") ||
+ 0 == QString::compare(dir.extension, "avi") ||
+ 0 == QString::compare(dir.extension, "mpeg") ||
+ 0 == QString::compare(dir.extension, "mov") ||
+ 0 == QString::compare(dir.extension, "mp4") ||
+ 0 == QString::compare(dir.extension, "wmv") ||
+ 0 == QString::compare(dir.extension, "mkv") ||
+ 0 == QString::compare(dir.extension, "ogv") ) {
+ item = new QListWidgetItem(QIcon::fromTheme("general_video_file"), dir.name, ui->listWidget, 0); // .flv, .avi, .mpeg, .mov, .mp4, .wmv, .mkv, .ogv
+ }
+ else {
+ if (dir.name.startsWith("Flash")) {
+ item = new QListWidgetItem(QIcon::fromTheme("general_video_file"), dir.name, ui->listWidget, 0);
+ }
+ else {
+ item = new QListWidgetItem(QIcon::fromTheme("filemanager_unknown_file"), dir.name, ui->listWidget, 0);
+ }
+ }
+ ui->listWidget->addItem(item);
+ }
+ // other types ignored
+ //if (item) delete item;
+ }
+ }
+}
+
+
--- /dev/null
+/* 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.
+ */
+#ifndef BROWSEMAINWINDOW_H
+#define BROWSEMAINWINDOW_H
+
+#include <QMainWindow>
+#include <QtNetwork>
+#include <QtXml>
+#include <QListWidgetItem>
+#include "vlcbrowseelement.h"
+
+namespace Ui {
+ class BrowseMainWindow;
+}
+
+class BrowseMainWindow : public QMainWindow {
+ Q_OBJECT
+public:
+ explicit BrowseMainWindow(QWidget *parent = 0);
+ ~BrowseMainWindow();
+
+public slots:
+ void browseDirectory(QString);
+ void onBrowse();
+ void onPlay();
+ void onAddToPlaylist();
+ void onListSelectionChanged();
+
+protected slots:
+ void parseXmlDirectory();
+ void updateList();
+
+protected:
+ void changeEvent(QEvent *e);
+ VlcBrowseElement getElementFromText(QString text);
+
+private:
+ Ui::BrowseMainWindow *ui;
+ QNetworkAccessManager * mNetManager;
+ QString mCurrentDir;
+ QString mIp;
+ QList<VlcBrowseElement>* mContents;
+ VlcBrowseElement mCurrentElement;
+};
+
+#endif // BROWSEMAINWINDOW_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>BrowseMainWindow</class>
+ <widget class="QMainWindow" name="BrowseMainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QListWidget" name="listWidget">
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="playButton">
+ <property name="text">
+ <string>Play</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="addButton">
+ <property name="text">
+ <string>Add to PlayList</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="browseButton">
+ <property name="text">
+ <string>Browse</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuConfiguration">
+ <property name="title">
+ <string>menu</string>
+ </property>
+ <addaction name="actionConfiguration"/>
+ <addaction name="actionAbout"/>
+ </widget>
+ <addaction name="menuConfiguration"/>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ <action name="actionConfiguration">
+ <property name="text">
+ <string>configuration</string>
+ </property>
+ </action>
+ <action name="actionAbout">
+ <property name="text">
+ <string>About</string>
+ </property>
+ </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
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"));
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);
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()));
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();
}
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()
{
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")));
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);
#include <QtXml>
#include <QTimer>
#include "playlistmainwindow.h"
+#include "browsemainwindow.h"
+
namespace Ui {
class PlayerMainWindow;
}
void fullscreen();
void volUp();
void volDown();
+ void volMute();
void slide(int value);
private:
Ui::PlayerMainWindow *ui;
PlayListMainWindow * mPlayListMainWindow;
+ BrowseMainWindow * mBrowserMainWindow;
QNetworkAccessManager * mNetManager;
QString mIp;
QTimer * mTimer;
+ int mVolume;
+ int mMuted;
};
</property>
</widget>
</item>
+ <item>
+ <widget class="QToolButton" name="volMute">
+ <property name="text">
+ <string>mute</string>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item>
- <widget class="QPushButton" name="playlistButton">
- <property name="text">
- <string>PlayList</string>
- </property>
- </widget>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QPushButton" name="playlistButton">
+ <property name="text">
+ <string>PlayList</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="browseButton">
+ <property name="text">
+ <string>Browse</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</widget>
<x>0</x>
<y>0</y>
<width>800</width>
- <height>25</height>
+ <height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuMenu">
-#-------------------------------------------------
-#
+# -------------------------------------------------
# Project created by QtCreator 2010-07-29T19:02:39
-#
-#-------------------------------------------------
-
-QT += core gui network xml maemo5
-
+# -------------------------------------------------
+QT += core \
+ gui \
+ network \
+ xml \
+ maemo5
TARGET = vlc-remote
TEMPLATE = app
-
-
-SOURCES += main.cpp\
+SOURCES += main.cpp \
playlistmainwindow.cpp \
playermainwindow.cpp \
configdialog.cpp \
aboutdialog.cpp \
accountdialog.cpp \
- newaccountdialog.cpp
-
-
-HEADERS += \
- playlistmainwindow.h \
+ newaccountdialog.cpp \
+ browsemainwindow.cpp \
+ vlcbrowseelement.cpp
+HEADERS += playlistmainwindow.h \
playermainwindow.h \
configdialog.h \
aboutdialog.h \
accountdialog.h \
- newaccountdialog.h
-
-
-FORMS += \
- playlistmainwindow.ui \
+ newaccountdialog.h \
+ browsemainwindow.h \
+ vlcbrowseelement.h
+FORMS += playlistmainwindow.ui \
playermainwindow.ui \
configdialog.ui \
aboutdialog.ui \
- accountdialog.ui
-
-
-OTHER_FILES += \
- vlc-remote.desktop
-
-RESOURCES += \
- ressources.qrc
-
+ accountdialog.ui \
+ browsemainwindow.ui
+OTHER_FILES += vlc-remote.desktop
+RESOURCES += ressources.qrc
--- /dev/null
+/* 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 "vlcbrowseelement.h"
+
--- /dev/null
+/* 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.
+ */
+#ifndef VLCBROWSEELEMENT_H
+#define VLCBROWSEELEMENT_H
+#include <QString>
+#include <QDate>
+
+struct VlcBrowseElement {
+ QString type;
+ int size;
+ QDate date;
+ QString path;
+ QString name;
+ QString extension;
+} ;
+
+
+#endif // VLCBROWSEELEMENT_H