Add first commit - Alpha Version
authorschutz <schutz@schutz.(none)>
Fri, 30 Jul 2010 15:20:30 +0000 (17:20 +0200)
committerschutz <schutz@schutz.(none)>
Fri, 30 Jul 2010 15:20:30 +0000 (17:20 +0200)
13 files changed:
aboutdialog.cpp [new file with mode: 0644]
aboutdialog.h [new file with mode: 0644]
configdialog.cpp [new file with mode: 0644]
configdialog.h [new file with mode: 0644]
main.cpp [new file with mode: 0644]
mainwindow.cpp [new file with mode: 0644]
mainwindow.h [new file with mode: 0644]
playermainwindow.cpp [new file with mode: 0644]
playermainwindow.h [new file with mode: 0644]
playlistmainwindow.cpp [new file with mode: 0644]
playlistmainwindow.h [new file with mode: 0644]
vlc-remote.png [new file with mode: 0644]
vlcRemote.pro [new file with mode: 0644]

diff --git a/aboutdialog.cpp b/aboutdialog.cpp
new file mode 100644 (file)
index 0000000..e524b8b
--- /dev/null
@@ -0,0 +1,26 @@
+#include "aboutdialog.h"
+#include "ui_aboutdialog.h"
+
+AboutDialog::AboutDialog(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::AboutDialog)
+{
+    ui->setupUi(this);
+}
+
+AboutDialog::~AboutDialog()
+{
+    delete ui;
+}
+
+void AboutDialog::changeEvent(QEvent *e)
+{
+    QDialog::changeEvent(e);
+    switch (e->type()) {
+    case QEvent::LanguageChange:
+        ui->retranslateUi(this);
+        break;
+    default:
+        break;
+    }
+}
diff --git a/aboutdialog.h b/aboutdialog.h
new file mode 100644 (file)
index 0000000..f587fcd
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef ABOUTDIALOG_H
+#define ABOUTDIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+    class AboutDialog;
+}
+
+class AboutDialog : public QDialog {
+    Q_OBJECT
+public:
+    explicit AboutDialog(QWidget *parent = 0);
+    ~AboutDialog();
+
+protected:
+    void changeEvent(QEvent *e);
+
+private:
+    Ui::AboutDialog *ui;
+};
+
+#endif // ABOUTDIALOG_H
diff --git a/configdialog.cpp b/configdialog.cpp
new file mode 100644 (file)
index 0000000..f397e10
--- /dev/null
@@ -0,0 +1,48 @@
+#include "configdialog.h"
+#include "ui_configdialog.h"
+#include <QSettings>
+ConfigDialog::ConfigDialog(QWidget *parent) :
+        QDialog(parent),
+        ui(new Ui::ConfigDialog)
+{
+    ui->setupUi(this);
+    load();
+    connect(ui->buttonBox,SIGNAL(accepted()),this,SLOT(save()));
+}
+
+ConfigDialog::~ConfigDialog()
+{
+    delete ui;
+}
+
+void ConfigDialog::changeEvent(QEvent *e)
+{
+    QDialog::changeEvent(e);
+    switch (e->type()) {
+    case QEvent::LanguageChange:
+        ui->retranslateUi(this);
+        break;
+    default:
+        break;
+    }
+}
+void ConfigDialog::load()
+{
+
+
+    QSettings settings;
+    ui->lineEdit->setText(settings.value("ip").toString());
+
+}
+
+void ConfigDialog::save()
+{
+
+    QSettings settings;
+    settings.setValue("ip",ui->lineEdit->text());
+
+    emit accept();
+
+
+
+}
diff --git a/configdialog.h b/configdialog.h
new file mode 100644 (file)
index 0000000..7cf3fa8
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef CONFIGDIALOG_H
+#define CONFIGDIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+    class ConfigDialog;
+}
+
+class ConfigDialog : public QDialog {
+    Q_OBJECT
+public:
+    explicit ConfigDialog(QWidget *parent = 0);
+    ~ConfigDialog();
+public slots:
+void load();
+void save();
+protected:
+    void changeEvent(QEvent *e);
+
+private:
+    Ui::ConfigDialog *ui;
+};
+
+#endif // CONFIGDIALOG_H
diff --git a/main.cpp b/main.cpp
new file mode 100644 (file)
index 0000000..1703289
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,20 @@
+#include <QtGui/QApplication>
+#include <QSettings>
+#include "playlistmainwindow.h"
+#include "playermainwindow.h"
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+
+    QCoreApplication::setOrganizationName("Omed");
+    QCoreApplication::setOrganizationDomain("medsoft.blogspot.com/");
+    QCoreApplication::setApplicationName("Maemo VLC remote");
+
+    PlayerMainWindow * mainwindow = new PlayerMainWindow;
+
+
+    mainwindow->showMaximized();
+
+    return a.exec();
+}
diff --git a/mainwindow.cpp b/mainwindow.cpp
new file mode 100644 (file)
index 0000000..f73bd48
--- /dev/null
@@ -0,0 +1,26 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent) :
+    QMainWindow(parent),
+    ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+
+void MainWindow::changeEvent(QEvent *e)
+{
+    QMainWindow::changeEvent(e);
+    switch (e->type()) {
+    case QEvent::LanguageChange:
+        ui->retranslateUi(this);
+        break;
+    default:
+        break;
+    }
+}
diff --git a/mainwindow.h b/mainwindow.h
new file mode 100644 (file)
index 0000000..8a43e6c
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+namespace Ui {
+    class MainWindow;
+}
+
+class MainWindow : public QMainWindow {
+    Q_OBJECT
+public:
+    explicit MainWindow(QWidget *parent = 0);
+    ~MainWindow();
+
+protected:
+    void changeEvent(QEvent *e);
+
+private:
+    Ui::MainWindow *ui;
+};
+
+#endif // MAINWINDOW_H
diff --git a/playermainwindow.cpp b/playermainwindow.cpp
new file mode 100644 (file)
index 0000000..1b7ddbd
--- /dev/null
@@ -0,0 +1,178 @@
+#include <QDebug>
+#include <QTime>
+#include "playermainwindow.h"
+#include "ui_playermainwindow.h"
+#include "configdialog.h"
+#include "aboutdialog.h"
+
+PlayerMainWindow::PlayerMainWindow(QWidget *parent) :
+        QMainWindow(parent),
+        ui(new Ui::PlayerMainWindow)
+{
+    ui->setupUi(this);
+
+    QSettings settings;
+    mIp = settings.value("ip").toString();
+
+    if ( mIp.isEmpty())
+        showConfig();
+
+
+    mTimer = new QTimer(this);
+    mNetManager = new QNetworkAccessManager(this);
+    mPlayListMainWindow = new PlayListMainWindow;
+
+
+    ui->playlistButton->setIcon(QIcon::fromTheme("notes_bullets"));
+    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->stopButton->setIcon(QIcon::fromTheme("camera_video_stop"));
+    ui->pauseButton->setIcon(QIcon::fromTheme("camera_video_pause"));
+    ui->fullscreenButton->setIcon(QIcon::fromTheme("general_fullsize"));
+    ui->volDown->setIcon(QIcon::fromTheme("statusarea_volumelevel1"));
+    ui->volUp->setIcon(QIcon::fromTheme("statusarea_volumelevel4"));
+
+#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5)
+    mPlayListMainWindow->setParent(this);
+    mPlayListMainWindow->setAttribute(Qt::WA_Maemo5StackedWindow);
+    mPlayListMainWindow->setAttribute(Qt::WA_Maemo5LandscapeOrientation,true);
+    mPlayListMainWindow->setAttribute(Qt::WA_Maemo5LandscapeOrientation,true);
+    setAttribute(Qt::WA_Maemo5StackedWindow);
+    mPlayListMainWindow->setWindowFlags(mPlayListMainWindow->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->playButton,SIGNAL(clicked()),this,SLOT(play()));
+    connect(ui->stopButton,SIGNAL(clicked()),this,SLOT(stop()));
+    connect(ui->pauseButton,SIGNAL(clicked()),this,SLOT(pause()));
+    connect(ui->previousButton,SIGNAL(clicked()),this,SLOT(previous()));
+    connect(ui->nextButton,SIGNAL(clicked()),this,SLOT(next()));
+    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->slider,SIGNAL(sliderMoved(int)),this,SLOT(slide(int)));
+
+    mTimer->start(5000);
+
+}
+
+PlayerMainWindow::~PlayerMainWindow()
+{
+    delete ui;
+}
+
+void PlayerMainWindow::changeEvent(QEvent *e)
+{
+    QMainWindow::changeEvent(e);
+    switch (e->type()) {
+    case QEvent::LanguageChange:
+        ui->retranslateUi(this);
+        break;
+    default:
+        break;
+    }
+}
+
+void PlayerMainWindow::play()
+{
+
+    mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=pl_play")));
+
+}
+void PlayerMainWindow::stop()
+{
+    mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=pl_stop")));
+
+}
+void PlayerMainWindow::pause()
+{
+    mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=pl_pause")));
+
+}
+void PlayerMainWindow::previous()
+{
+    mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=pl_previous")));
+
+}
+void PlayerMainWindow::next()
+{
+    mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=pl_next")));
+
+}
+void PlayerMainWindow::fullscreen()
+{
+    mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=fullscreen")));
+
+}
+void PlayerMainWindow::volUp()
+{
+    mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=volume&val=500")));
+
+}
+void PlayerMainWindow::volDown()
+{
+
+    mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=volume&val=-20")));
+
+}
+void PlayerMainWindow::slide(int value)
+{
+    mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=seek&val="+QString::number(value)+"%25")));
+
+}
+
+void PlayerMainWindow::showConfig()
+{
+    ConfigDialog * dialog = new ConfigDialog;
+    dialog->exec();
+}
+void PlayerMainWindow::showAbout()
+{
+
+    AboutDialog * dialog = new AboutDialog;
+    dialog->exec();
+
+}
+
+
+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());
+    QDomDocument doc;
+    doc.setContent(reply->readAll());
+    QDomElement docElem = doc.documentElement();
+
+    int volume = docElem.namedItem("volume").toElement().text().toInt();
+    int length = docElem.namedItem("length").toElement().text().toInt();
+    int time = docElem.namedItem("time").toElement().text().toInt();
+    int position = docElem.namedItem("position").toElement().text().toInt();
+    QString state  =docElem.namedItem("state").toElement().text();
+
+    QTime timeLength(0,0,0) ;
+   timeLength =  timeLength.addSecs(time);
+
+ui->timeLabel->setText(timeLength.toString("mm:ss"));
+
+
+    QDomNode infoNode =  docElem.namedItem("information");
+    QDomNode metaInfoNode =  infoNode.namedItem("meta-information");
+    QString title = metaInfoNode.namedItem("title").toElement().text();
+
+    if ( position >= 0 && position <=100)
+        ui->slider->setValue(position);
+
+    ui->label->setText(title);
+    delete reply;
+
+}
+
diff --git a/playermainwindow.h b/playermainwindow.h
new file mode 100644 (file)
index 0000000..7315e61
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef PLAYERMAINWINDOW_H
+#define PLAYERMAINWINDOW_H
+
+#include <QMainWindow>
+#include <QtNetwork>
+#include <QtXml>
+#include <QTimer>
+#include "playlistmainwindow.h"
+namespace Ui {
+    class PlayerMainWindow;
+}
+
+class PlayerMainWindow : public QMainWindow {
+    Q_OBJECT
+public:
+    explicit PlayerMainWindow(QWidget *parent = 0);
+    ~PlayerMainWindow();
+
+public slots:
+    void askStatus();
+    void showConfig();
+    void showAbout();
+    void play();
+    void stop();
+    void pause();
+    void previous();
+    void next();
+    void fullscreen();
+    void volUp();
+    void volDown();
+    void slide(int value);
+
+
+protected slots:
+    void parseXmlStatus();
+protected:
+    void changeEvent(QEvent *e);
+
+private:
+    Ui::PlayerMainWindow *ui;
+    PlayListMainWindow * mPlayListMainWindow;
+    QNetworkAccessManager * mNetManager;
+    QString mIp;
+    QTimer * mTimer;
+
+};
+
+#endif // PLAYERMAINWINDOW_H
diff --git a/playlistmainwindow.cpp b/playlistmainwindow.cpp
new file mode 100644 (file)
index 0000000..c3d3c3b
--- /dev/null
@@ -0,0 +1,33 @@
+#include "playlistmainwindow.h"
+#include "ui_playlistmainwindow.h"
+#include <QPushButton>
+#include "configdialog.h"
+
+
+PlayListMainWindow::PlayListMainWindow(QWidget *parent) :
+        QMainWindow(parent),
+        ui(new Ui::PlayListMainWindow)
+{
+
+    ui->setupUi(this);
+    mTimer = new QTimer(this);
+
+}
+
+PlayListMainWindow::~PlayListMainWindow()
+{
+    delete ui;
+}
+
+void PlayListMainWindow::changeEvent(QEvent *e)
+{
+    QMainWindow::changeEvent(e);
+    switch (e->type()) {
+    case QEvent::LanguageChange:
+        ui->retranslateUi(this);
+        break;
+    default:
+        break;
+    }
+}
+
diff --git a/playlistmainwindow.h b/playlistmainwindow.h
new file mode 100644 (file)
index 0000000..f6e83df
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef PLAYLISTMAINWINDOW_H
+#define PLAYLISTMAINWINDOW_H
+
+#include <QMainWindow>
+#include <QTimer>
+
+namespace Ui {
+    class PlayListMainWindow;
+}
+
+class PlayListMainWindow : public QMainWindow {
+    Q_OBJECT
+public:
+    explicit PlayListMainWindow(QWidget *parent = 0);
+    ~PlayListMainWindow();
+
+protected:
+    void changeEvent(QEvent *e);
+
+private:
+    Ui::PlayListMainWindow *ui;
+    QTimer * mTimer;
+};
+
+#endif // PLAYLISTMAINWINDOW_H
diff --git a/vlc-remote.png b/vlc-remote.png
new file mode 100644 (file)
index 0000000..4ff8b11
Binary files /dev/null and b/vlc-remote.png differ
diff --git a/vlcRemote.pro b/vlcRemote.pro
new file mode 100644 (file)
index 0000000..b1cb5d2
--- /dev/null
@@ -0,0 +1,32 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-07-29T19:02:39
+#
+#-------------------------------------------------
+
+QT       += core gui network xml
+
+TARGET = vlc-remote
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+    playlistmainwindow.cpp \
+    playermainwindow.cpp \
+    configdialog.cpp \
+    aboutdialog.cpp
+
+HEADERS += \
+    playlistmainwindow.h \
+    playermainwindow.h \
+    configdialog.h \
+    aboutdialog.h
+
+FORMS += \
+    playlistmainwindow.ui \
+    playermainwindow.ui \
+    configdialog.ui \
+    aboutdialog.ui
+
+OTHER_FILES += \
+    vlc-remote.desktop