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,
23 #include <QDialogButtonBox>
24 #include <QFormLayout>
27 #include <QPushButton>
29 #include "logindialog.h"
31 LoginDialog::LoginDialog(QWidget *parent)
34 qDebug() << __PRETTY_FUNCTION__;
36 setWindowTitle(tr("Login to Situare with Facebook account"));
38 m_emailEdit = new QLineEdit();
39 m_passwordEdit = new QLineEdit();
40 m_passwordEdit->setEchoMode(QLineEdit::Password);
42 QGridLayout *gridLayout = new QGridLayout(this);
43 QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical);
44 QPushButton *connectButton = buttonBox->addButton(QDialogButtonBox::Ok);
45 QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
46 connectButton->setText(tr("Login"));
48 QFormLayout *form = new QFormLayout();
49 form->addRow(new QLabel(tr("E-mail:")), m_emailEdit);
50 form->addRow(new QLabel(tr("Password:")), m_passwordEdit);
52 gridLayout->addLayout(form, 0, 0, 2, 1);
53 gridLayout->addWidget(buttonBox, 0, 1, 1, 1);
55 connect(connectButton, SIGNAL(clicked()),
56 this, SLOT(accept()));
57 connect(cancelButton, SIGNAL(clicked()),
58 this, SLOT(reject()));
60 setLayout(gridLayout);
63 void LoginDialog::setEmailField(const QString &email)
65 qDebug() << __PRETTY_FUNCTION__;
66 if(!email.isEmpty()) {
67 m_emailEdit->setText(email);
68 m_passwordEdit->setFocus(Qt::OtherFocusReason);
72 void LoginDialog::clearTextFields()
74 qDebug() << __PRETTY_FUNCTION__;
76 m_passwordEdit->clearFocus();
77 m_emailEdit->setText(""); // clear() method bugging in Qt 4.6, it leaves "dead" cursor
78 m_emailEdit->setFocus(Qt::OtherFocusReason);
79 m_passwordEdit->setText("");
83 void LoginDialog::userInput(QString &email, QString &password)
85 qDebug() << __PRETTY_FUNCTION__;
87 email = m_emailEdit->text();
88 password = m_passwordEdit->text();