mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-28 19:58:56 +03:00
Merge pull request #5013 from nextcloud/bugfix/webflow-user-strings
Improve "pretty user name"-related strings, display in webflow credentials
This commit is contained in:
commit
f2f7d82848
6 changed files with 38 additions and 21 deletions
|
@ -29,15 +29,16 @@
|
|||
#include "ui_mnemonicdialog.h"
|
||||
|
||||
namespace {
|
||||
static const char urlC[] = "url";
|
||||
static const char authTypeC[] = "authType";
|
||||
static const char userC[] = "user";
|
||||
static const char httpUserC[] = "http_user";
|
||||
static const char davUserC[] = "dav_user";
|
||||
static const char caCertsKeyC[] = "CaCertificates";
|
||||
static const char accountsC[] = "Accounts";
|
||||
static const char versionC[] = "version";
|
||||
static const char serverVersionC[] = "serverVersion";
|
||||
constexpr auto urlC = "url";
|
||||
constexpr auto authTypeC = "authType";
|
||||
constexpr auto userC = "user";
|
||||
constexpr auto displayNameC = "displayName";
|
||||
constexpr auto httpUserC = "http_user";
|
||||
constexpr auto davUserC = "dav_user";
|
||||
constexpr auto caCertsKeyC = "CaCertificates";
|
||||
constexpr auto accountsC = "Accounts";
|
||||
constexpr auto versionC = "version";
|
||||
constexpr auto serverVersionC = "serverVersion";
|
||||
|
||||
// The maximum versions that this client can read
|
||||
static const int maxAccountsVersion = 2;
|
||||
|
@ -222,7 +223,9 @@ void AccountManager::saveAccountHelper(Account *acc, QSettings &settings, bool s
|
|||
settings.setValue(QLatin1String(versionC), maxAccountVersion);
|
||||
settings.setValue(QLatin1String(urlC), acc->_url.toString());
|
||||
settings.setValue(QLatin1String(davUserC), acc->_davUser);
|
||||
settings.setValue(QLatin1String(displayNameC), acc->_displayName);
|
||||
settings.setValue(QLatin1String(serverVersionC), acc->_serverVersion);
|
||||
|
||||
if (acc->_credentials) {
|
||||
if (saveCredentials) {
|
||||
// Only persist the credentials if the parameter is set, on migration from 1.8.x
|
||||
|
@ -321,6 +324,7 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings)
|
|||
|
||||
// We want to only restore settings for that auth type and the user value
|
||||
acc->_settingsMap.insert(QLatin1String(userC), settings.value(userC));
|
||||
acc->_displayName = settings.value(QLatin1String(displayNameC), "").toString();
|
||||
QString authTypePrefix = authType + "_";
|
||||
for (const auto &key : settings.childKeys()) {
|
||||
if (!key.startsWith(authTypePrefix))
|
||||
|
|
|
@ -164,7 +164,7 @@ void WebFlowCredentials::askFromUser() {
|
|||
}
|
||||
|
||||
QString msg = tr("You have been logged out of your account %1 at %2. Please login again.")
|
||||
.arg(_user, _account->displayName());
|
||||
.arg(_account->prettyName(), _account->url().toDisplayString());
|
||||
_askDialog->setInfo(msg);
|
||||
|
||||
_askDialog->show();
|
||||
|
@ -188,7 +188,7 @@ void WebFlowCredentials::slotAskFromUserCredentialsProvided(const QString &user,
|
|||
qCInfo(lcWebFlowCredentials()) << "Authed with the wrong user!";
|
||||
|
||||
QString msg = tr("Please login with the account: %1")
|
||||
.arg(_user);
|
||||
.arg(_account->prettyName());
|
||||
_askDialog->setError(msg);
|
||||
|
||||
if (!_askDialog->isUsingFlow2()) {
|
||||
|
|
|
@ -57,10 +57,7 @@ const float buttonSizeRatio = 1.618f; // golden ratio
|
|||
*/
|
||||
QString shortDisplayNameForSettings(OCC::Account *account, int width)
|
||||
{
|
||||
QString user = account->davDisplayName();
|
||||
if (user.isEmpty()) {
|
||||
user = account->credentials()->user();
|
||||
}
|
||||
QString user = account->prettyName();
|
||||
QString host = account->url().host();
|
||||
int port = account->url().port();
|
||||
if (port > 0 && port != 80 && port != 443) {
|
||||
|
|
|
@ -733,12 +733,7 @@ void User::logout() const
|
|||
|
||||
QString User::name() const
|
||||
{
|
||||
// If davDisplayName is empty (can be several reasons, simplest is missing login at startup), fall back to username
|
||||
QString name = _account->account()->davDisplayName();
|
||||
if (name == "") {
|
||||
name = _account->account()->credentials()->user();
|
||||
}
|
||||
return name;
|
||||
return _account->account()->prettyName();
|
||||
}
|
||||
|
||||
QString User::server(bool shortened) const
|
||||
|
|
|
@ -131,6 +131,7 @@ void Account::setDavUser(const QString &newDavUser)
|
|||
return;
|
||||
_davUser = newDavUser;
|
||||
emit wantsAccountSaved(this);
|
||||
emit prettyNameChanged();
|
||||
}
|
||||
|
||||
#ifndef TOKEN_AUTH_ONLY
|
||||
|
@ -165,6 +166,19 @@ void Account::setDavDisplayName(const QString &newDisplayName)
|
|||
{
|
||||
_displayName = newDisplayName;
|
||||
emit accountChangedDisplayName();
|
||||
emit prettyNameChanged();
|
||||
}
|
||||
|
||||
QString Account::prettyName() const
|
||||
{
|
||||
// If davDisplayName is empty (can be several reasons, simplest is missing login at startup), fall back to username
|
||||
auto name = davDisplayName();
|
||||
|
||||
if (name.isEmpty()) {
|
||||
name = davUser();
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
QColor Account::headerColor() const
|
||||
|
|
|
@ -83,6 +83,7 @@ class OWNCLOUDSYNC_EXPORT Account : public QObject
|
|||
Q_PROPERTY(QString id MEMBER _id)
|
||||
Q_PROPERTY(QString davUser MEMBER _davUser)
|
||||
Q_PROPERTY(QString displayName MEMBER _displayName)
|
||||
Q_PROPERTY(QString prettyName READ prettyName NOTIFY prettyNameChanged)
|
||||
Q_PROPERTY(QUrl url MEMBER _url)
|
||||
|
||||
public:
|
||||
|
@ -113,6 +114,11 @@ public:
|
|||
/// The name of the account as shown in the toolbar
|
||||
[[nodiscard]] QString displayName() const;
|
||||
|
||||
/// The name of the account that is displayed as nicely as possible,
|
||||
/// e.g. the actual name of the user (John Doe). If this cannot be
|
||||
/// provided, defaults to davUser (e.g. johndoe)
|
||||
[[nodiscard]] QString prettyName() const;
|
||||
|
||||
[[nodiscard]] QColor accentColor() const;
|
||||
[[nodiscard]] QColor headerColor() const;
|
||||
[[nodiscard]] QColor headerTextColor() const;
|
||||
|
@ -319,6 +325,7 @@ signals:
|
|||
|
||||
void accountChangedAvatar();
|
||||
void accountChangedDisplayName();
|
||||
void prettyNameChanged();
|
||||
|
||||
/// Used in RemoteWipe
|
||||
void appPasswordRetrieved(QString);
|
||||
|
|
Loading…
Reference in a new issue