From bf12b1c6cefe2fbe9ee1b9b8c256eb4b51a6b305 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 31 Jan 2014 09:29:49 +0100 Subject: [PATCH] Work on authentication design. --- src/gui/formstandardfeeddetails.cpp | 41 ++++++++++++++++++++++++ src/gui/formstandardfeeddetails.h | 5 ++- src/gui/formstandardfeeddetails.ui | 49 ++++++++++++++++++++++++++++- 3 files changed, 93 insertions(+), 2 deletions(-) diff --git a/src/gui/formstandardfeeddetails.cpp b/src/gui/formstandardfeeddetails.cpp index 184c7cccd..276e5d8d7 100644 --- a/src/gui/formstandardfeeddetails.cpp +++ b/src/gui/formstandardfeeddetails.cpp @@ -31,6 +31,8 @@ FormStandardFeedDetails::FormStandardFeedDetails(FeedsModel *model, QWidget *par onTitleChanged(QString()); onDescriptionChanged(QString()); onUrlChanged(QString()); + onUsernameChanged(QString()); + onPasswordChanged(QString()); } FormStandardFeedDetails::~FormStandardFeedDetails() { @@ -104,6 +106,33 @@ void FormStandardFeedDetails::onUrlChanged(const QString &new_url) { checkOkButtonEnabled(); } +void FormStandardFeedDetails::onUsernameChanged(const QString &new_username) { + bool is_username_ok = !m_ui->m_gbAuthentication->isChecked() || !new_username.simplified().isEmpty(); + + m_ui->m_txtUsername->setStatus(is_username_ok ? + LineEditWithStatus::Ok : + LineEditWithStatus::Warning, + is_username_ok ? + tr("Username is ok or it is not needed.") : + tr("Username is empty.")); +} + +void FormStandardFeedDetails::onPasswordChanged(const QString &new_password) { + bool is_password_ok = !m_ui->m_gbAuthentication->isChecked() || !new_password.simplified().isEmpty(); + + m_ui->m_txtPassword->setStatus(is_password_ok ? + LineEditWithStatus::Ok : + LineEditWithStatus::Warning, + is_password_ok ? + tr("Password is ok or it is not needed.") : + tr("Password is empty.")); +} + +void FormStandardFeedDetails::onAuthenticationSwitched() { + onUsernameChanged(m_ui->m_txtUsername->lineEdit()->text()); + onPasswordChanged(m_ui->m_txtPassword->lineEdit()->text()); +} + void FormStandardFeedDetails::checkOkButtonEnabled() { LineEditWithStatus::StatusType title_status = m_ui->m_txtTitle->status(); LineEditWithStatus::StatusType url_status = m_ui->m_txtUrl->status(); @@ -185,6 +214,12 @@ void FormStandardFeedDetails::createConnections() { this, SLOT(onDescriptionChanged(QString))); connect(m_ui->m_txtUrl->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(onUrlChanged(QString))); + connect(m_ui->m_txtUsername->lineEdit(), SIGNAL(textChanged(QString)), + this, SLOT(onUsernameChanged(QString))); + connect(m_ui->m_txtPassword->lineEdit(), SIGNAL(textChanged(QString)), + this, SLOT(onPasswordChanged(QString))); + connect(m_ui->m_gbAuthentication, SIGNAL(toggled(bool)), + this, SLOT(onAuthenticationSwitched())); // Icon connections. connect(m_actionLoadIconFromFile, SIGNAL(triggered()), this, SLOT(onLoadIconFromFile())); @@ -225,6 +260,12 @@ void FormStandardFeedDetails::initialize() { m_ui->m_txtUrl->lineEdit()->setPlaceholderText(tr("Full feed url including scheme")); m_ui->m_txtUrl->lineEdit()->setToolTip(tr("Set url for your feed.")); + m_ui->m_txtUsername->lineEdit()->setPlaceholderText(tr("Username")); + m_ui->m_txtUsername->lineEdit()->setToolTip(tr("Set username to access the feed.")); + + m_ui->m_txtPassword->lineEdit()->setPlaceholderText(tr("Password")); + m_ui->m_txtPassword->lineEdit()->setToolTip(tr("Set password to access the feed.")); + #if !defined(Q_OS_WIN) MessageBox::iconify(m_ui->m_buttonBox); #endif diff --git a/src/gui/formstandardfeeddetails.h b/src/gui/formstandardfeeddetails.h index af4506a31..97abed0ff 100644 --- a/src/gui/formstandardfeeddetails.h +++ b/src/gui/formstandardfeeddetails.h @@ -31,10 +31,13 @@ class FormStandardFeedDetails : public QDialog { // Applies changes. void apply(); - // Trigerred when title/description/url changes. + // Trigerred when title/description/url/username/password changes. void onTitleChanged(const QString &new_title); void onDescriptionChanged(const QString &new_description); void onUrlChanged(const QString &new_url); + void onUsernameChanged(const QString &new_username); + void onPasswordChanged(const QString &new_password); + void onAuthenticationSwitched(); // Check if "OK" button can be enabled or not. void checkOkButtonEnabled(); diff --git a/src/gui/formstandardfeeddetails.ui b/src/gui/formstandardfeeddetails.ui index 3b20f32c1..02d18f46d 100644 --- a/src/gui/formstandardfeeddetails.ui +++ b/src/gui/formstandardfeeddetails.ui @@ -7,7 +7,7 @@ 0 0 375 - 269 + 337 @@ -147,6 +147,53 @@ + + + + Some feeds require authentication, including GMail feeds. BASIC, NTLM-2 and DIGEST-MD5 authentication schemes are supported. + + + Requires authentication + + + false + + + true + + + false + + + + + + Username + + + m_txtUsername + + + + + + + + + + Password + + + m_txtPassword + + + + + + + + +