1/*
2 * Copyright (C) 2014 by Daniel Molkentin <danimo@owncloud.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */
14
15#include "authenticationdialog.h"
16
17#include <QLabel>
18#include <QLineEdit>
19#include <QVBoxLayout>
20#include <QFormLayout>
21#include <QDialogButtonBox>
22
23namespace OCC {
24
25AuthenticationDialog::AuthenticationDialog(const QString &realm, const QString &domain, QWidget *parent)
26 : QDialog(parent)
27 , _user(new QLineEdit)
28 , _password(new QLineEdit)
29{
30 setWindowTitle(tr("Authentication Required"));
31 QVBoxLayout *lay = new QVBoxLayout(this);
32 QLabel *label = new QLabel(tr("Enter username and password for '%1' at %2.").arg(realm, domain));
33 label->setTextFormat(Qt::PlainText);
34 lay->addWidget(label);
35
36 QFormLayout *form = new QFormLayout;
37 form->addRow(tr("&User:"), _user);
38 form->addRow(tr("&Password:"), _password);
39 lay->addLayout(form);
40 _password->setEchoMode(QLineEdit::Password);
41
42 QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal);
43 connect(box, &QDialogButtonBox::accepted, this, &QDialog::accept);
44 connect(box, &QDialogButtonBox::rejected, this, &QDialog::reject);
45 lay->addWidget(box);
46}
47
48QString AuthenticationDialog::user() const
49{
50 return _user->text();
51}
52
53QString AuthenticationDialog::password() const
54{
55 return _password->text();
56}
57
58} // namespace OCC
59