mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-18 16:17:03 +00:00
feat(GODT-2678): When internet is off, do not display status dot icon for the user in the context menu.
This commit is contained in:
@ -109,6 +109,12 @@ UserList const &QMLBackend::users() const {
|
|||||||
return *users_;
|
return *users_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
/// \return the if bridge considers internet is on.
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
bool QMLBackend::isInternetOn() const {
|
||||||
|
return isInternetOn_;
|
||||||
|
}
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
/// \return The build year as a string (e.g. 2023)
|
/// \return The build year as a string (e.g. 2023)
|
||||||
@ -874,7 +880,6 @@ void QMLBackend::sendBadEventUserFeedback(QString const &userID, bool doResync)
|
|||||||
if (!badEventDisplayQueue_.isEmpty()) {
|
if (!badEventDisplayQueue_.isEmpty()) {
|
||||||
// we introduce a small delay here, so that the user notices the dialog disappear and pops up again.
|
// we introduce a small delay here, so that the user notices the dialog disappear and pops up again.
|
||||||
QTimer::singleShot(500, [&]() { this->displayBadEventDialog(badEventDisplayQueue_.front()); });
|
QTimer::singleShot(500, [&]() { this->displayBadEventDialog(badEventDisplayQueue_.front()); });
|
||||||
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -923,6 +928,25 @@ void QMLBackend::setUpdateTrayIcon(QString const &stateString, QString const &st
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
/// \param[in] isOn Does bridge consider internet as on.
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
void QMLBackend::internetStatusChanged(bool isOn) {
|
||||||
|
HANDLE_EXCEPTION(
|
||||||
|
if (isInternetOn_ == isOn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isInternetOn_ = isOn;
|
||||||
|
if (isOn) {
|
||||||
|
emit internetOn();
|
||||||
|
} else {
|
||||||
|
emit internetOff();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
/// \param[in] imapPort The IMAP port.
|
/// \param[in] imapPort The IMAP port.
|
||||||
/// \param[in] smtpPort The SMTP port.
|
/// \param[in] smtpPort The SMTP port.
|
||||||
@ -1086,7 +1110,7 @@ void QMLBackend::connectGrpcEvents() {
|
|||||||
GRPCClient *client = &app().grpc();
|
GRPCClient *client = &app().grpc();
|
||||||
|
|
||||||
// app events
|
// app events
|
||||||
connect(client, &GRPCClient::internetStatus, this, [&](bool isOn) { if (isOn) { emit internetOn(); } else { emit internetOff(); }});
|
connect(client, &GRPCClient::internetStatus, this, &QMLBackend::internetStatusChanged);
|
||||||
connect(client, &GRPCClient::toggleAutostartFinished, this, &QMLBackend::toggleAutostartFinished);
|
connect(client, &GRPCClient::toggleAutostartFinished, this, &QMLBackend::toggleAutostartFinished);
|
||||||
connect(client, &GRPCClient::resetFinished, this, &QMLBackend::onResetFinished);
|
connect(client, &GRPCClient::resetFinished, this, &QMLBackend::onResetFinished);
|
||||||
connect(client, &GRPCClient::reportBugFinished, this, &QMLBackend::reportBugFinished);
|
connect(client, &GRPCClient::reportBugFinished, this, &QMLBackend::reportBugFinished);
|
||||||
|
|||||||
@ -45,6 +45,7 @@ public: // member functions.
|
|||||||
void init(GRPCConfig const &serviceConfig); ///< Initialize the backend.
|
void init(GRPCConfig const &serviceConfig); ///< Initialize the backend.
|
||||||
bool waitForEventStreamReaderToFinish(qint32 timeoutMs); ///< Wait for the event stream reader to finish.
|
bool waitForEventStreamReaderToFinish(qint32 timeoutMs); ///< Wait for the event stream reader to finish.
|
||||||
UserList const& users() const; ///< Return the list of users
|
UserList const& users() const; ///< Return the list of users
|
||||||
|
bool isInternetOn() const; ///< Check if bridge considers internet as on.
|
||||||
|
|
||||||
// invokable methods can be called from QML. They generally return a value, which slots cannot do.
|
// invokable methods can be called from QML. They generally return a value, which slots cannot do.
|
||||||
Q_INVOKABLE static QString buildYear(); ///< Return the application build year.
|
Q_INVOKABLE static QString buildYear(); ///< Return the application build year.
|
||||||
@ -85,7 +86,6 @@ public: // Qt/QML properties. Note that the NOTIFY-er signal is required even fo
|
|||||||
Q_PROPERTY(UserList *users MEMBER users_ NOTIFY usersChanged)
|
Q_PROPERTY(UserList *users MEMBER users_ NOTIFY usersChanged)
|
||||||
Q_PROPERTY(bool dockIconVisible READ dockIconVisible WRITE setDockIconVisible NOTIFY dockIconVisibleChanged)
|
Q_PROPERTY(bool dockIconVisible READ dockIconVisible WRITE setDockIconVisible NOTIFY dockIconVisibleChanged)
|
||||||
|
|
||||||
|
|
||||||
// Qt Property system setters & getters.
|
// Qt Property system setters & getters.
|
||||||
bool showOnStartup() const; ///< Getter for the 'showOnStartup' property.
|
bool showOnStartup() const; ///< Getter for the 'showOnStartup' property.
|
||||||
void setShowSplashScreen(bool show); ///< Setter for the 'showSplashScreen' property.
|
void setShowSplashScreen(bool show); ///< Setter for the 'showSplashScreen' property.
|
||||||
@ -191,6 +191,7 @@ public slots: // slots for functions that need to be processed locally.
|
|||||||
void setUpdateTrayIcon(QString const& stateString, QString const &statusIcon); ///< Set the tray icon to 'update' state.
|
void setUpdateTrayIcon(QString const& stateString, QString const &statusIcon); ///< Set the tray icon to 'update' state.
|
||||||
|
|
||||||
public slots: // slot for signals received from gRPC that need transformation instead of simple forwarding
|
public slots: // slot for signals received from gRPC that need transformation instead of simple forwarding
|
||||||
|
void internetStatusChanged(bool isOn); ///< Check if bridge considers internet as on.
|
||||||
void onMailServerSettingsChanged(int imapPort, int smtpPort, bool useSSLForIMAP, bool useSSLForSMTP); ///< Slot for the ConnectionModeChanged gRPC event.
|
void onMailServerSettingsChanged(int imapPort, int smtpPort, bool useSSLForIMAP, bool useSSLForSMTP); ///< Slot for the ConnectionModeChanged gRPC event.
|
||||||
void onGenericError(bridgepp::ErrorInfo const &info); ///< Slot for generic errors received from the gRPC service.
|
void onGenericError(bridgepp::ErrorInfo const &info); ///< Slot for generic errors received from the gRPC service.
|
||||||
void onLoginFinished(QString const &userID, bool wasSignedOut); ///< Slot for LoginFinished gRPC event.
|
void onLoginFinished(QString const &userID, bool wasSignedOut); ///< Slot for LoginFinished gRPC event.
|
||||||
@ -273,8 +274,9 @@ private: // data members
|
|||||||
int smtpPort_ { 0 }; ///< The cached value for the SMTP port.
|
int smtpPort_ { 0 }; ///< The cached value for the SMTP port.
|
||||||
bool useSSLForIMAP_ { false }; ///< The cached value for useSSLForIMAP.
|
bool useSSLForIMAP_ { false }; ///< The cached value for useSSLForIMAP.
|
||||||
bool useSSLForSMTP_ { false }; ///< The cached value for useSSLForSMTP.
|
bool useSSLForSMTP_ { false }; ///< The cached value for useSSLForSMTP.
|
||||||
|
bool isInternetOn_ { true }; ///< Does bridge consider internet as on?
|
||||||
QList<QString> badEventDisplayQueue_; ///< THe queue for displaying 'bad event feedback request dialog'.
|
QList<QString> badEventDisplayQueue_; ///< THe queue for displaying 'bad event feedback request dialog'.
|
||||||
std::unique_ptr<TrayIcon> trayIcon_;
|
std::unique_ptr<TrayIcon> trayIcon_; ///< The tray icon for the application.
|
||||||
friend class AppController;
|
friend class AppController;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -344,6 +344,7 @@ void TrayIcon::refreshContextMenu() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool const internetOn = app().backend().isInternetOn();
|
||||||
menu_->clear();
|
menu_->clear();
|
||||||
menu_->addAction(statusIcon_, stateString_, &app().backend(), &QMLBackend::showMainWindow);
|
menu_->addAction(statusIcon_, stateString_, &app().backend(), &QMLBackend::showMainWindow);
|
||||||
menu_->addSeparator();
|
menu_->addSeparator();
|
||||||
@ -355,7 +356,9 @@ void TrayIcon::refreshContextMenu() {
|
|||||||
User const &user = *users.get(i);
|
User const &user = *users.get(i);
|
||||||
UserState const state = user.state();
|
UserState const state = user.state();
|
||||||
auto action = new QAction(user.primaryEmailOrUsername());
|
auto action = new QAction(user.primaryEmailOrUsername());
|
||||||
action->setIcon((UserState::Connected == state) ? greenDot_ : (UserState::Locked == state ? orangeDot_ : greyDot_));
|
if (internetOn) {
|
||||||
|
action->setIcon((UserState::Connected == state) ? greenDot_ : (UserState::Locked == state ? orangeDot_ : greyDot_));
|
||||||
|
}
|
||||||
action->setData(user.id());
|
action->setData(user.id());
|
||||||
connect(action, &QAction::triggered, this, &TrayIcon::onUserClicked);
|
connect(action, &QAction::triggered, this, &TrayIcon::onUserClicked);
|
||||||
if ((i < 10) && onMac) {
|
if ((i < 10) && onMac) {
|
||||||
|
|||||||
Reference in New Issue
Block a user