1 /* VLC-REMOTE for MAEMO 5
2 * Copyright (C) 2010 Schutz Sacha <istdasklar@gmail.com>, Dru Moore <usr@dru-id.co.uk>, Yann Nave <yannux@onbebop.net>
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2,
5 * or (at your option) any later version, as published by the Free
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #include "newaccountdialog.h"
19 #include <QFormLayout>
22 //#include <QMaemo5InformationBox>
24 NewAccountDialog::NewAccountDialog(QWidget *parent)
27 this->setWindowTitle(tr("Add account"));
29 mKeyLineEdit = new QLineEdit;
30 mIpLineEdit = new QLineEdit;
31 mPortLineEdit = new QLineEdit;
32 mPortLineEdit->setText("8080");
33 mPortLineEdit->setReadOnly(false);
35 mButtonBox = new QDialogButtonBox;
36 mButtonBox->addButton(QDialogButtonBox::Save);
37 mButtonBox->addButton(QDialogButtonBox::Cancel);
39 connect(mButtonBox, SIGNAL(accepted()), this, SLOT(save()));
40 connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
42 QFormLayout *layout = new QFormLayout;
43 layout->expandingDirections();
44 layout->addRow(tr("Name:"), mKeyLineEdit);
45 layout->addRow(tr("Ip:"), mIpLineEdit);
46 layout->addRow(tr("Port:"), mPortLineEdit);
47 layout->addWidget(mButtonBox);
52 void NewAccountDialog::save()
54 QString myKey = mKeyLineEdit->text();
55 QString myIp = mIpLineEdit->text();
56 QString myPort = mPortLineEdit->text();
59 settings.beginGroup("account");
60 if (!mEditKey.isEmpty()) {
61 settings.remove(mEditKey);
64 if (!myIp.isEmpty() && !myKey.isEmpty()) {
65 if (myPort.isEmpty()) {
68 settings.setValue(myKey, myIp+":"+myPort);
69 // Rajouter des tests pour vérifier qu'on est sur Maemo
70 //QMaemo5InformationBox::information(this, tr("Account saved"), QMaemo5InformationBox::DefaultTimeout);
77 void NewAccountDialog::edit(QString &key, QString &ip)
80 this->setWindowTitle(tr("Edit account"));
83 settings.beginGroup("account");
84 QString value = settings.value(key).toString();
87 QStringList values = value.split(":");
90 mEditIp = values.first();
91 mEditPort = values.last();
93 mKeyLineEdit->setText(mEditKey);
94 mKeyLineEdit->setDisabled(true);
95 mIpLineEdit->setText(mEditIp);
96 mPortLineEdit->setText(mEditPort);