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("Connect"));
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(connectPressed()));
53 // connect(cancelButton, SIGNAL(clicked()),
54 // this, SLOT(reject()));
55 connect(cancelButton, SIGNAL(clicked()),
56 this, SLOT(cancelPressed()));
58 setLayout(gridLayout);
61 void LoginDialog::cancelPressed()
63 qDebug() << __PRETTY_FUNCTION__;
68 void LoginDialog::connectPressed()
70 qDebug() << __PRETTY_FUNCTION__;
72 emit loginDialogDone(m_emailEdit->text(), m_passwordEdit->text());
77 void LoginDialog::setEmailField(const QString &email)
79 qDebug() << __PRETTY_FUNCTION__;
80 if(!email.isEmpty()) {
81 m_emailEdit->setText(email);
82 m_passwordEdit->setFocus(Qt::OtherFocusReason);
86 void LoginDialog::clearTextFields()
88 qDebug() << __PRETTY_FUNCTION__;
90 m_passwordEdit->clearFocus();
91 m_emailEdit->setText(""); // clear() method bugging in Qt 4.6, it leaves "dead" cursor
92 m_emailEdit->setFocus(Qt::OtherFocusReason);
93 m_passwordEdit->setText("");