mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-18 16:17:03 +00:00
GODT-2258: change login label and suggest email instead of username.
This commit is contained in:
@ -64,7 +64,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function primaryEmail() {
|
function primaryEmail() {
|
||||||
return (root.user && (root.user.addresses.length > 0)) ? root.user.addresses[0] : ""
|
return root.user ? root.user.primaryEmailOrUsername() : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// width expected to be set by parent object
|
// width expected to be set by parent object
|
||||||
|
|||||||
@ -117,7 +117,7 @@ QtObject {
|
|||||||
// fit above
|
// fit above
|
||||||
_y = iconRect.top - height
|
_y = iconRect.top - height
|
||||||
if (isInInterval(_y, screenRect.top, screenRect.bottom - height)) {
|
if (isInInterval(_y, screenRect.top, screenRect.bottom - height)) {
|
||||||
// position preferebly in the horizontal center but bound to the screen rect
|
// position preferably in the horizontal center but bound to the screen rect
|
||||||
_x = bound(iconRect.left + (iconRect.width - width)/2, screenRect.left, screenRect.right - width)
|
_x = bound(iconRect.left + (iconRect.width - width)/2, screenRect.left, screenRect.right - width)
|
||||||
return Qt.point(_x, _y)
|
return Qt.point(_x, _y)
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ QtObject {
|
|||||||
// fit below
|
// fit below
|
||||||
_y = iconRect.bottom
|
_y = iconRect.bottom
|
||||||
if (isInInterval(_y, screenRect.top, screenRect.bottom - height)) {
|
if (isInInterval(_y, screenRect.top, screenRect.bottom - height)) {
|
||||||
// position preferebly in the horizontal center but bound to the screen rect
|
// position preferably in the horizontal center but bound to the screen rect
|
||||||
_x = bound(iconRect.left + (iconRect.width - width)/2, screenRect.left, screenRect.right - width)
|
_x = bound(iconRect.left + (iconRect.width - width)/2, screenRect.left, screenRect.right - width)
|
||||||
return Qt.point(_x, _y)
|
return Qt.point(_x, _y)
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ QtObject {
|
|||||||
// fit to the left
|
// fit to the left
|
||||||
_x = iconRect.left - width
|
_x = iconRect.left - width
|
||||||
if (isInInterval(_x, screenRect.left, screenRect.right - width)) {
|
if (isInInterval(_x, screenRect.left, screenRect.right - width)) {
|
||||||
// position preferebly in the vertical center but bound to the screen rect
|
// position preferably in the vertical center but bound to the screen rect
|
||||||
_y = bound(iconRect.top + (iconRect.height - height)/2, screenRect.top, screenRect.bottom - height)
|
_y = bound(iconRect.top + (iconRect.height - height)/2, screenRect.top, screenRect.bottom - height)
|
||||||
return Qt.point(_x, _y)
|
return Qt.point(_x, _y)
|
||||||
}
|
}
|
||||||
@ -141,12 +141,12 @@ QtObject {
|
|||||||
// fit to the right
|
// fit to the right
|
||||||
_x = iconRect.right
|
_x = iconRect.right
|
||||||
if (isInInterval(_x, screenRect.left, screenRect.right - width)) {
|
if (isInInterval(_x, screenRect.left, screenRect.right - width)) {
|
||||||
// position preferebly in the vertical center but bound to the screen rect
|
// position preferably in the vertical center but bound to the screen rect
|
||||||
_y = bound(iconRect.top + (iconRect.height - height)/2, screenRect.top, screenRect.bottom - height)
|
_y = bound(iconRect.top + (iconRect.height - height)/2, screenRect.top, screenRect.bottom - height)
|
||||||
return Qt.point(_x, _y)
|
return Qt.point(_x, _y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback: position satatus window right above icon and let window manager decide.
|
// Fallback: position status window right above icon and let window manager decide.
|
||||||
console.warn("Can't position status window: screenRect =", screenRect, "iconRect =", iconRect)
|
console.warn("Can't position status window: screenRect =", screenRect, "iconRect =", iconRect)
|
||||||
_x = bound(iconRect.left + (iconRect.width - width)/2, screenRect.left, screenRect.right - width)
|
_x = bound(iconRect.left + (iconRect.width - width)/2, screenRect.left, screenRect.right - width)
|
||||||
_y = bound(iconRect.top + (iconRect.height - height)/2, screenRect.top, screenRect.bottom - height)
|
_y = bound(iconRect.top + (iconRect.height - height)/2, screenRect.top, screenRect.bottom - height)
|
||||||
|
|||||||
@ -188,7 +188,7 @@ Item {
|
|||||||
if (user.state !== EUserState.SignedOut) {
|
if (user.state !== EUserState.SignedOut) {
|
||||||
rightContent.showAccount()
|
rightContent.showAccount()
|
||||||
} else {
|
} else {
|
||||||
signIn.username = user.username
|
signIn.username = user.primaryEmailOrUsername()
|
||||||
rightContent.showSignIn()
|
rightContent.showSignIn()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -255,7 +255,8 @@ Item {
|
|||||||
return Backend.users.get(accounts.currentIndex)
|
return Backend.users.get(accounts.currentIndex)
|
||||||
}
|
}
|
||||||
onShowSignIn: {
|
onShowSignIn: {
|
||||||
signIn.username = this.user.username
|
var user = this.user
|
||||||
|
signIn.username = user ? user.primaryEmailOrUsername() : ""
|
||||||
rightContent.showSignIn()
|
rightContent.showSignIn()
|
||||||
}
|
}
|
||||||
onShowSetupGuide: function(user, address) {
|
onShowSetupGuide: function(user, address) {
|
||||||
|
|||||||
@ -116,7 +116,7 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((Backend.users.count === 1) && (u.state === EUserState.SignedOut)) {
|
if ((Backend.users.count === 1) && (u.state === EUserState.SignedOut)) {
|
||||||
showSignIn(u.username)
|
showSignIn(u.primaryEmailOrUsername())
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -204,7 +204,7 @@ FocusScope {
|
|||||||
TextField {
|
TextField {
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
id: usernameTextField
|
id: usernameTextField
|
||||||
label: qsTr("Username or email")
|
label: qsTr("Email or username")
|
||||||
focus: true
|
focus: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 24
|
Layout.topMargin: 24
|
||||||
@ -221,7 +221,7 @@ FocusScope {
|
|||||||
|
|
||||||
validator: function(str) {
|
validator: function(str) {
|
||||||
if (str.length === 0) {
|
if (str.length === 0) {
|
||||||
return qsTr("Enter username or email")
|
return qsTr("Enter email or username")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,6 +55,14 @@ void User::update(User const &user) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
/// \return The user's primary email. If not known, return turn username
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
QString User::primaryEmailOrUsername() const {
|
||||||
|
return addresses_.isEmpty() ? username_ : addresses_.front();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
/// \param[in] makeItActive Should split mode be made active.
|
/// \param[in] makeItActive Should split mode be made active.
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
|
|||||||
@ -73,6 +73,7 @@ public: // member functions.
|
|||||||
User &operator=(User const &) = delete; ///< Disabled assignment operator.
|
User &operator=(User const &) = delete; ///< Disabled assignment operator.
|
||||||
User &operator=(User &&) = delete; ///< Disabled move assignment operator.
|
User &operator=(User &&) = delete; ///< Disabled move assignment operator.
|
||||||
void update(User const &user); ///< Update the user.
|
void update(User const &user); ///< Update the user.
|
||||||
|
Q_INVOKABLE QString primaryEmailOrUsername() const; ///< Return the user primary email, or, if unknown its username.
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// slots for QML generated calls
|
// slots for QML generated calls
|
||||||
|
|||||||
Reference in New Issue
Block a user