2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Henri Lampela - henri.lampela@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24 #include <QFormLayout>
25 #include "logindialog.h"
27 LoginDialog::LoginDialog(QWidget *parent)
30 qDebug() << __PRETTY_FUNCTION__;
32 setWindowTitle(tr("Login to Situare with Facebook account"));
34 m_emailEdit = new QLineEdit();
35 m_passwordEdit = new QLineEdit();
36 m_passwordEdit->setEchoMode(QLineEdit::Password);
38 QGridLayout *gridLayout = new QGridLayout(this);
39 QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical);
40 QPushButton *connectButton = buttonBox->addButton(QDialogButtonBox::Ok);
41 QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
42 connectButton->setText(tr("Login"));
44 QFormLayout *form = new QFormLayout();
45 form->addRow(new QLabel(tr("E-mail:")), m_emailEdit);
46 form->addRow(new QLabel(tr("Password:")), m_passwordEdit);
48 gridLayout->addLayout(form, 0, 0, 2, 1);
49 gridLayout->addWidget(buttonBox, 0, 1, 1, 1);
51 connect(connectButton, SIGNAL(clicked()),
52 this, SLOT(accept()));
53 connect(cancelButton, SIGNAL(clicked()),
54 this, SLOT(reject()));
56 setLayout(gridLayout);
59 void LoginDialog::setEmailField(const QString &email)
61 qDebug() << __PRETTY_FUNCTION__;
62 if(!email.isEmpty()) {
63 m_emailEdit->setText(email);
64 m_passwordEdit->setFocus(Qt::OtherFocusReason);
68 void LoginDialog::clearTextFields()
70 qDebug() << __PRETTY_FUNCTION__;
72 m_passwordEdit->clearFocus();
73 m_emailEdit->setText(""); // clear() method bugging in Qt 4.6, it leaves "dead" cursor
74 m_emailEdit->setFocus(Qt::OtherFocusReason);
75 m_passwordEdit->setText("");
79 void LoginDialog::userInput(QString &email, QString &password)
81 qDebug() << __PRETTY_FUNCTION__;
83 email = m_emailEdit->text();
84 password = m_passwordEdit->text();