mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 20:56:51 +00:00
fix(GODT-2467): elide long email adresses in 'bad event' QML notification dialog.
This commit is contained in:
@ -23,6 +23,7 @@
|
|||||||
#include <bridgepp/GRPC/GRPCClient.h>
|
#include <bridgepp/GRPC/GRPCClient.h>
|
||||||
#include <bridgepp/Exception/Exception.h>
|
#include <bridgepp/Exception/Exception.h>
|
||||||
#include <bridgepp/Worker/Overseer.h>
|
#include <bridgepp/Worker/Overseer.h>
|
||||||
|
#include <bridgepp/BridgeUtils.h>
|
||||||
|
|
||||||
|
|
||||||
#define HANDLE_EXCEPTION(x) try { x } \
|
#define HANDLE_EXCEPTION(x) try { x } \
|
||||||
@ -1033,7 +1034,7 @@ void QMLBackend::displayBadEventDialog(QString const &userID) {
|
|||||||
|
|
||||||
emit userBadEvent(userID,
|
emit userBadEvent(userID,
|
||||||
tr("Bridge ran into an internal error and it is not able to proceed with the account %1. Synchronize your local database now or logout"
|
tr("Bridge ran into an internal error and it is not able to proceed with the account %1. Synchronize your local database now or logout"
|
||||||
" to do it later. Synchronization time depends on the size of your mailbox.").arg(user->primaryEmailOrUsername()));
|
" to do it later. Synchronization time depends on the size of your mailbox.").arg(elideLongString(user->primaryEmailOrUsername(), 30)));
|
||||||
emit selectUser(userID);
|
emit selectUser(userID);
|
||||||
emit showMainWindow();
|
emit showMainWindow();
|
||||||
)
|
)
|
||||||
|
|||||||
@ -280,4 +280,20 @@ bool onWindows() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
/// Elision is performed by inserting '...' around the (maxLen / 2) - 2 left-most and right-most characters of the string.
|
||||||
|
///
|
||||||
|
/// \return The elided string, or the original string if its length does not exceed maxLength.
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
QString elideLongString(QString const &str, qint32 maxLength) {
|
||||||
|
qint32 const len = str.length();
|
||||||
|
if (len <= maxLength) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
qint32 const hLen = qMax(0, (maxLength / 2) - 2);
|
||||||
|
return str.left(hLen) + "..." + str.right(hLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace bridgepp
|
} // namespace bridgepp
|
||||||
|
|||||||
@ -49,6 +49,7 @@ OS os(); ///< Return the operating system.
|
|||||||
bool onLinux(); ///< Check if the OS is Linux.
|
bool onLinux(); ///< Check if the OS is Linux.
|
||||||
bool onMacOS(); ///< Check if the OS is macOS.
|
bool onMacOS(); ///< Check if the OS is macOS.
|
||||||
bool onWindows(); ///< Check if the OS in Windows.
|
bool onWindows(); ///< Check if the OS in Windows.
|
||||||
|
QString elideLongString(QString const &str, qint32 maxLength); ///< Elide a string in the middle if its length exceed maxLength.
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user