Wizard: Implement alternative forms of inquiring about the userID

Settable in the theme.
This commit is contained in:
Daniel Molkentin 2016-03-17 16:47:27 +01:00
parent d7bd1300a8
commit fb75adcd57
4 changed files with 65 additions and 3 deletions

View file

@ -42,6 +42,22 @@ OwncloudHttpCredsPage::OwncloudHttpCredsPage(QWidget* parent)
registerField( QLatin1String("OCUser*"), _ui.leUsername);
registerField( QLatin1String("OCPasswd*"), _ui.lePassword);
Theme *theme = Theme::instance();
switch(theme->userIDType()) {
case Theme::UserIDUserName:
// default, handled in ui file
break;
case Theme::UserIDEmail:
_ui.usernameLabel->setText(tr("&E-mail address"));
break;
case Theme::UserIDCustom:
_ui.usernameLabel->setText(theme->customUserID());
break;
default:
break;
}
_ui.leUsername->setPlaceholderText(theme->userIDHint());
setTitle(WizardCommon::titleTemplate().arg(tr("Connect to %1").arg(Theme::instance()->appNameGUI())));
setSubTitle(WizardCommon::subTitleTemplate().arg(tr("Enter user credentials")));

View file

@ -33,7 +33,7 @@
<item row="1" column="1">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<widget class="QLabel" name="usernameLabel">
<property name="text">
<string>&amp;Username</string>
</property>
@ -127,8 +127,6 @@
</widget>
</item>
</layout>
<zorder>topLabel</zorder>
<zorder>bottomLabel</zorder>
</widget>
<resources/>
<connections/>

View file

@ -432,6 +432,21 @@ bool Theme::forceSystemNetworkProxy() const
return false;
}
Theme::UserIDType Theme::userIDType() const
{
return UserIDType::UserIDUserName;
}
QString Theme::customUserID() const
{
return QString();
}
QString Theme::userIDHint() const
{
return QString();
}
} // end namespace client

View file

@ -239,6 +239,39 @@ public:
virtual bool forceSystemNetworkProxy() const;
/**
* @brief How to handle the userID
*
* @value UserIDUserName Wizard asks for user name as ID
* @value UserIDEmail Wizard asks for an email as ID
* @value UserIDCustom Specify string in \ref customUserID
*/
enum UserIDType { UserIDUserName = 0, UserIDEmail, UserIDCustom };
/** @brief What to display as the userID (e.g. in the wizards)
*
* @return UserIDType::UserIDUserName, unless reimplemented
*/
virtual UserIDType userIDType() const;
/**
* @brief Allows to customize the type of user ID (e.g. user name, email)
*
* @note This string cannot be translated, but is still useful for
* referencing brand name IDs (e.g. "ACME ID", when using ACME.)
*
* @return An empty string, unless reimplemented
*/
virtual QString customUserID() const;
/**
* @brief Demo string to be displayed when no text has been
* entered for the user id (e.g. mylogin@company.com)
*
* @return An empty string, unless reimplemented
*/
virtual QString userIDHint() const;
protected:
#ifndef TOKEN_AUTH_ONLY
QIcon themeIcon(const QString& name, bool sysTray = false) const;