From 66170fc0b9f8feeed1f22145b8e373e9d5fa8256 Mon Sep 17 00:00:00 2001 From: schutz Date: Sun, 15 Aug 2010 20:54:26 +0200 Subject: [PATCH] add Yannux version with account manager --- Maemo_VLC_remote.svg | 453 +++++++++++++++++++++++++++++++++++++++++++++++++ accountdialog.cpp | 80 +++++---- accountdialog.h | 1 + accountdialog.ui | 15 +- configdialog.cpp | 5 - newaccountdialog.cpp | 62 +++++++ newaccountdialog.h | 31 ++++ playermainwindow.cpp | 33 ++-- playermainwindow.h | 1 + playermainwindow.ui | 4 +- playlistmainwindow.ui | 4 +- todo.txt | 2 +- vlcRemote.pro | 12 +- vlcremote_fr_FR.qm | Bin 9747 -> 10424 bytes vlcremote_fr_FR.ts | 72 +++++++- 15 files changed, 711 insertions(+), 64 deletions(-) create mode 100644 Maemo_VLC_remote.svg create mode 100644 newaccountdialog.cpp create mode 100644 newaccountdialog.h diff --git a/Maemo_VLC_remote.svg b/Maemo_VLC_remote.svg new file mode 100644 index 0000000..83ad807 --- /dev/null +++ b/Maemo_VLC_remote.svg @@ -0,0 +1,453 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/accountdialog.cpp b/accountdialog.cpp index 51a360a..4256d06 100644 --- a/accountdialog.cpp +++ b/accountdialog.cpp @@ -1,8 +1,10 @@ #include "accountdialog.h" #include "ui_accountdialog.h" +#include "newaccountdialog.h" #include #include #include +#include AccountDialog::AccountDialog(QWidget *parent) : QDialog(parent), @@ -13,9 +15,10 @@ AccountDialog::AccountDialog(QWidget *parent) : connect(ui->addButton,SIGNAL(clicked()),this,SLOT(add())); connect(ui->editButton,SIGNAL(clicked()),this,SLOT(edit())); connect(ui->remButton,SIGNAL(clicked()),this,SLOT(rem())); + connect(ui->useButton,SIGNAL(clicked()),this,SLOT(use())); connect(ui->listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(enableUi())); - load(); // On charge les compte + load(); } @@ -23,62 +26,64 @@ AccountDialog::~AccountDialog() { delete ui; } + void AccountDialog::add() { - QString ip = QInputDialog::getText(this,"ip?","enter your ip"); - // On peut checker si c'est une bonne forme d'ip avec QRegExp - - if (!ip.isEmpty()) { - QString ipKey = "Label"+ip; // La faudra l'integré dans un widget personnalisé ( entrez le label, entrez l' IP) - - QSettings settings; - settings.beginGroup("account"); - settings.setValue(ipKey, ip); - settings.endGroup(); - - load(); // On recharge les compte - } + NewAccountDialog *dialog = new NewAccountDialog(this); + dialog->exec(); + load(); } + void AccountDialog::load() { ui->editButton->setEnabled(false); ui->remButton->setEnabled(false); + ui->useButton->setEnabled(false); ui->listWidget->clear(); // tjr effacer , sinon on rajoute QSettings settings; + settings.beginGroup("config"); + QString useKey = settings.value("currentKey").toString(); + settings.endGroup(); + settings.beginGroup("account"); foreach ( QString key, settings.allKeys()) { QListWidgetItem * item = new QListWidgetItem; + + // ========> NEED TO USE QFUTUR + // QString hostIp = settings.value(key).toString(); + // QTcpSocket * socket = new QTcpSocket(this); + // socket->connectToHost(hostIp, 80); + // if (socket->waitForConnected(1000)) + // item->setBackgroundColor(Qt::green); + // else + // item->setBackgroundColor(Qt::red); + + item->setText(key); - item->setData(Qt::UserRole,settings.value(key)); + item->setData(Qt::UserRole, settings.value(key)); + if (useKey == key) { + QFont font = item->font(); + font.setBold(true); + item->setFont(font); + } ui->listWidget->addItem(item); - } settings.endGroup(); } void AccountDialog::edit() { - QString currentValue = ui->listWidget->currentItem()->data(Qt::UserRole).toString(); + QString currentIp = ui->listWidget->currentItem()->data(Qt::UserRole).toString(); QString currentKey = ui->listWidget->currentItem()->text(); + NewAccountDialog *dialog = new NewAccountDialog(this); + dialog->edit(currentKey, currentIp); + dialog->exec(); - QString ip = QInputDialog::getText(this, "ip ?", "enter your ip", QLineEdit::Normal, currentValue); - - if (!ip.isEmpty()) { - QString ipKey = "Label"+ip; // La faudra l'integré dans un widget personnalisé ( entrez le label, entrez l' IP) - - QSettings settings; - settings.beginGroup("account"); - settings.remove(currentKey); - settings.setValue(ipKey, ip); - settings.endGroup(); - - load(); - - } + load(); } void AccountDialog::rem() @@ -93,8 +98,21 @@ void AccountDialog::rem() load(); // On recharge les compte } +void AccountDialog::use() +{ + QString currentKey = ui->listWidget->currentItem()->text(); + + QSettings settings; + settings.beginGroup("config"); + settings.setValue("currentKey", currentKey); + settings.endGroup(); + + load(); +} + void AccountDialog::enableUi() { ui->editButton->setEnabled(true); ui->remButton->setEnabled(true); + ui->useButton->setEnabled(true); } diff --git a/accountdialog.h b/accountdialog.h index ecdde58..11cdda1 100644 --- a/accountdialog.h +++ b/accountdialog.h @@ -19,6 +19,7 @@ public slots: void add(); void edit(); void rem(); + void use(); void load(); void enableUi(); diff --git a/accountdialog.ui b/accountdialog.ui index 3a7addd..8b0dd97 100644 --- a/accountdialog.ui +++ b/accountdialog.ui @@ -11,7 +11,7 @@ - Dialog + Accounts @@ -53,6 +53,9 @@ + + + Qt::Vertical @@ -65,6 +68,16 @@ + + + + false + + + Use + + + diff --git a/configdialog.cpp b/configdialog.cpp index 788319a..b65d414 100644 --- a/configdialog.cpp +++ b/configdialog.cpp @@ -46,8 +46,6 @@ void ConfigDialog::changeEvent(QEvent *e) } void ConfigDialog::load() { - - QSettings settings; ui->lineEdit->setText(settings.value("ip").toString()); @@ -60,7 +58,4 @@ void ConfigDialog::save() settings.setValue("ip",ui->lineEdit->text()); emit accept(); - - - } diff --git a/newaccountdialog.cpp b/newaccountdialog.cpp new file mode 100644 index 0000000..4f9c39e --- /dev/null +++ b/newaccountdialog.cpp @@ -0,0 +1,62 @@ +#include "newaccountdialog.h" +#include +#include +#include +//#include + +NewAccountDialog::NewAccountDialog(QWidget *parent) +{ + this->setWindowTitle(tr("Add account")); + + mMyKeyLineEdit = new QLineEdit; + mMyIpLineEdit = new QLineEdit; + + mButtonBox = new QDialogButtonBox; + mButtonBox->addButton(QDialogButtonBox::Save); + mButtonBox->addButton(QDialogButtonBox::Cancel); + + connect(mButtonBox, SIGNAL(accepted()), this, SLOT(save())); + connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject())); + + QFormLayout *layout = new QFormLayout; + layout->expandingDirections(); + layout->addRow(tr("Name:"), mMyKeyLineEdit); + layout->addRow(tr("Ip:"), mMyIpLineEdit); + layout->addWidget(mButtonBox); + + setLayout(layout); +} + +void NewAccountDialog::save() +{ + QString myKey = mMyKeyLineEdit->text(); + QString myIp = mMyIpLineEdit->text(); + + QSettings settings; + settings.beginGroup("account"); + if (!mEditKey.isEmpty()) { + settings.remove(mEditKey); + } + + if (!myIp.isEmpty() && !myKey.isEmpty()) { + settings.setValue(myKey, myIp); + // Rajouter des tests pour vérifier qu'on est sur Maemo + //QMaemo5InformationBox::information(this, tr("Account saved"), QMaemo5InformationBox::DefaultTimeout); + } + settings.endGroup(); + + emit accept(); +} + +void NewAccountDialog::edit(QString &key, QString &ip) +{ + this->setWindowTitle(tr("Edit account")); + + mEditKey = key; + mEditIp = ip; + + mMyKeyLineEdit->setText(key); + mMyKeyLineEdit->setDisabled(true); + mMyIpLineEdit->setText(ip); +} + diff --git a/newaccountdialog.h b/newaccountdialog.h new file mode 100644 index 0000000..85c8e25 --- /dev/null +++ b/newaccountdialog.h @@ -0,0 +1,31 @@ +#ifndef NEWACCOUNTDIALOG_H +#define NEWACCOUNTDIALOG_H + +#include +#include +#include +#include + +class NewAccountDialog : public QDialog +{ + Q_OBJECT + +public: + explicit NewAccountDialog(QWidget *parent = 0); + void edit(QString &key, QString &ip); + +public slots: + void save(); + +private: + QLineEdit *mMyKeyLineEdit; + QLineEdit *mMyIpLineEdit; + QPushButton *mSavePushButton; + QPushButton *mCancelPushButton; + QDialogButtonBox *mButtonBox; + + QString mEditKey; + QString mEditIp; +}; + +#endif // NEWACCOUNTDIALOG_H diff --git a/playermainwindow.cpp b/playermainwindow.cpp index 24534f2..874944d 100644 --- a/playermainwindow.cpp +++ b/playermainwindow.cpp @@ -21,7 +21,6 @@ #include "ui_playermainwindow.h" #include "configdialog.h" #include "aboutdialog.h" - #include "accountdialog.h" @@ -32,11 +31,6 @@ 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); @@ -77,8 +71,19 @@ PlayerMainWindow::PlayerMainWindow(QWidget *parent) : 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() @@ -148,8 +153,12 @@ void PlayerMainWindow::slide(int value) void PlayerMainWindow::showConfig() { -AccountDialog * dialog = new AccountDialog; -dialog->exec(); + mTimer->stop(); + AccountDialog * dialog = new AccountDialog; + dialog->exec(); + init(); + + } void PlayerMainWindow::showAbout() { @@ -159,13 +168,13 @@ 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(sender()); @@ -180,9 +189,9 @@ void PlayerMainWindow::parseXmlStatus() 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"); diff --git a/playermainwindow.h b/playermainwindow.h index d11af4c..3572058 100644 --- a/playermainwindow.h +++ b/playermainwindow.h @@ -52,6 +52,7 @@ protected slots: void parseXmlStatus(); protected: void changeEvent(QEvent *e); + void init(); private: Ui::PlayerMainWindow *ui; diff --git a/playermainwindow.ui b/playermainwindow.ui index 2eaeaf9..efc167d 100644 --- a/playermainwindow.ui +++ b/playermainwindow.ui @@ -11,7 +11,7 @@ - MainWindow + Vlc-Remote @@ -152,7 +152,7 @@ 0 0 800 - 27 + 25 diff --git a/playlistmainwindow.ui b/playlistmainwindow.ui index 2eba144..b127009 100644 --- a/playlistmainwindow.ui +++ b/playlistmainwindow.ui @@ -11,7 +11,7 @@ - MainWindow + Playlist @@ -96,7 +96,7 @@ 0 0 800 - 27 + 25 diff --git a/todo.txt b/todo.txt index 2969be3..9daeafb 100644 --- a/todo.txt +++ b/todo.txt @@ -1 +1 @@ -test 2 +test diff --git a/vlcRemote.pro b/vlcRemote.pro index 236f92d..03738d6 100644 --- a/vlcRemote.pro +++ b/vlcRemote.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui network xml +QT += core gui network xml maemo5 TARGET = vlc-remote TEMPLATE = app @@ -15,7 +15,8 @@ SOURCES += main.cpp\ playermainwindow.cpp \ configdialog.cpp \ aboutdialog.cpp \ - accountdialog.cpp + accountdialog.cpp \ + newaccountdialog.cpp HEADERS += \ @@ -23,7 +24,8 @@ HEADERS += \ playermainwindow.h \ configdialog.h \ aboutdialog.h \ - accountdialog.h + accountdialog.h \ + newaccountdialog.h FORMS += \ @@ -31,8 +33,7 @@ FORMS += \ playermainwindow.ui \ configdialog.ui \ aboutdialog.ui \ - accountdialog.ui \ - accountnewdialog.ui + accountdialog.ui OTHER_FILES += \ @@ -41,4 +42,3 @@ OTHER_FILES += \ RESOURCES += \ ressources.qrc -TRANSLATIONS = vlcremote_fr_FR.ts diff --git a/vlcremote_fr_FR.qm b/vlcremote_fr_FR.qm index ed673a52950a79757aa191e9b64ae4bab76e877e..1b65df30bf1973ab0f1a4924c699b395201d3ad7 100644 GIT binary patch delta 999 zcmah{NoW&c7=6iPvS(WBQV%MVWReJ47f_K93bC!FRf4T1Qt*(F3_6;PWKu6ez*Izy zRTx?jya;a4qDT-5Rf1FxEmWb^i=aY1c##S&C!zRFQ>P6QBupOP@W17I|0qW%`ig;x z#O9fAw?}53TdL7J&p#XjblU+00HH+KPB;b_Du8DIV6Oq*3xwAR9{}BV0j>i$<_Db5 zfKwwhFTgNqARGjHAPTrf!HyAnkH8cN1MV+1^lgNxn7ab_+F=?ep{7=JkG>>=P(xuJ zy*n<_9L0&!RWevaq)Y~$8QnoU1#9Zk5AT0V^OF9?&sStHr@yJrt~ZQ3y^qd|%+$SI zv;+)~OD6%xyBhLyZ22&q=N_`1<#R)nXq)kC>?7eV!X*-Pm_EH$1=d^6d?q8$kmdf1 zDI(Y`zh?_{Zosx@{wX!nB2oIxlkXf?1cwe}kU|zRMC8q?uaO>eFdoko(sJHJgJWgr zlw!%uX&pnaI0SK)n1y9tPUA7bM4|!3j%g$yttAvm$=LgpbwQRKqrh#Pk35>D9`SNJG_1z}HAst?ra=eWM|NMLn4Dd`48 m=o;c^LqAi3DpRjQ6T_*+xh8sX^!@!`V2c+$QbQl8z%Vq`!Wfleo z)@}v{l`J6L3#6wqu$m<>FerF4u&xHuDwYiFHlYj*ijyF;$^i!UqE4XrO9uC8M;I97 zZ$fCLItDN8CZIl1hOqjcsX&8wFk0{cE#l*5>NC9poEeXS<|*rQ{ytj@6ldW!xV#le z@6BXjP?ch4VBk~%dQg$Ug< + AccountDialog + + + Accounts + Comptes + + + + test + test + + + + Add + Ajouter + + + + Edit + Éditer + + + + Remove + Supprimer + + + + Use + Utiliser + + + ConfigDialog @@ -70,11 +103,38 @@ p, li { white-space: pre-wrap; } + NewAccountDialog + + + Add account + Ajouter un compte + + + + Name: + Nom : + + + + Ip: + Ip : + + + + Edit account + Édition d'un compte + + + PlayListMainWindow - MainWindow - Vlc remote + Vlc remote + + + + Playlist + Liste de lecture @@ -122,9 +182,13 @@ p, li { white-space: pre-wrap; } PlayerMainWindow - MainWindow - Vlc remote + Vlc remote + + + + Vlc-Remote + Vlc-Remote -- 1.7.9.5