feat(GODT-2517): replace status window with native tray icon context menu.

feat(GODT-2517): show main windows on left click (Linux & Windows).
feat(GODT-2517): removed old QML status window.
feat(GODT-2517): polishing.
feat(GODT-2517): renaming + removal of dead code (v2 tests).
This commit is contained in:
Xavier Michelon
2023-01-21 20:20:59 +01:00
parent 7383d65cb2
commit e9629aca47
15 changed files with 461 additions and 2021 deletions

View File

@ -49,6 +49,9 @@ QMLBackend::QMLBackend()
/// \param[in] serviceConfig
//****************************************************************************************************************************************************
void QMLBackend::init(GRPCConfig const &serviceConfig) {
trayIcon_.reset(new TrayIcon());
this->setNormalTrayIcon();
connect(this, &QMLBackend::fatalError, &app(), &AppController::onFatalError);
users_ = new UserList(this);
@ -99,6 +102,14 @@ bool QMLBackend::waitForEventStreamReaderToFinish(qint32 timeoutMs) {
}
//****************************************************************************************************************************************************
/// \return The list of users
//****************************************************************************************************************************************************
UserList const &QMLBackend::users() const {
return *users_;
}
//****************************************************************************************************************************************************
/// \return The build year as a string (e.g. 2023)
//****************************************************************************************************************************************************
@ -591,7 +602,6 @@ void QMLBackend::toggleIsTelemetryDisabled(bool isDisabled) {
}
//****************************************************************************************************************************************************
/// \param[in] scheme the scheme name
//****************************************************************************************************************************************************
@ -861,6 +871,49 @@ void QMLBackend::sendBadEventUserFeedback(QString const &userID, bool doResync)
}
//****************************************************************************************************************************************************
//
//****************************************************************************************************************************************************
void QMLBackend::setNormalTrayIcon() {
if (trayIcon_) {
trayIcon_->setState(TrayIcon::State::Normal, tr("Connected"), ":/qml/icons/ic-connected.svg");
}
}
//****************************************************************************************************************************************************
/// \param[in] stateString A string describing the state.
/// \param[in] statusIcon The path of the status icon.
//****************************************************************************************************************************************************
void QMLBackend::setErrorTrayIcon(QString const &stateString, QString const &statusIcon) {
if (trayIcon_) {
trayIcon_->setState(TrayIcon::State::Error, stateString, statusIcon);
}
}
//****************************************************************************************************************************************************
/// \param[in] stateString A string describing the state.
/// \param[in] statusIcon The path of the status icon.
//****************************************************************************************************************************************************
void QMLBackend::setWarnTrayIcon(QString const &stateString, QString const &statusIcon) {
if (trayIcon_) {
trayIcon_->setState(TrayIcon::State::Warn, stateString, statusIcon);
}
}
//****************************************************************************************************************************************************
/// \param[in] stateString A string describing the state.
/// \param[in] statusIcon The path of the status icon.
//****************************************************************************************************************************************************
void QMLBackend::setUpdateTrayIcon(QString const &stateString, QString const &statusIcon) {
if (trayIcon_) {
trayIcon_->setState(TrayIcon::State::Update, stateString, statusIcon);
}
}
//****************************************************************************************************************************************************
/// \param[in] imapPort The IMAP port.
/// \param[in] smtpPort The SMTP port.
@ -915,7 +968,7 @@ void QMLBackend::onLoginAlreadyLoggedIn(QString const &userID) {
//****************************************************************************************************************************************************
/// \param[in] userID The userID.
//****************************************************************************************************************************************************
void QMLBackend::onUserBadEvent(QString const &userID, QString const& ) {
void QMLBackend::onUserBadEvent(QString const &userID, QString const &) {
HANDLE_EXCEPTION(
if (badEventDisplayQueue_.contains(userID)) {
app().log().error("Received 'bad event' for a user that is already in the queue.");
@ -944,8 +997,9 @@ void QMLBackend::onIMAPLoginFailed(QString const &username) {
if ((!user) || (user->state() != UserState::SignedOut)) { // We want to pop-up only if a signed-out user has been detected
return;
}
if (user->isInIMAPLoginFailureCooldown())
if (user->isInIMAPLoginFailureCooldown()) {
return;
}
user->startImapLoginFailureCooldown(60 * 60 * 1000); // 1 hour cooldown during which we will not display this notification to this user again.
emit selectUser(user->id());
emit imapLoginWhileSignedOut(username);