Work on authentication design.
This commit is contained in:
parent
673ee6a83c
commit
bf12b1c6ce
@ -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
|
||||
|
@ -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();
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>375</width>
|
||||
<height>269</height>
|
||||
<height>337</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -147,6 +147,53 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="m_gbAuthentication">
|
||||
<property name="toolTip">
|
||||
<string>Some feeds require authentication, including GMail feeds. BASIC, NTLM-2 and DIGEST-MD5 authentication schemes are supported.</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Requires authentication</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Username</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_txtUsername</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LineEditWithStatus" name="m_txtUsername" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_txtPassword</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="LineEditWithStatus" name="m_txtPassword" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user