Ignore second tray icon click in short time.

Fixes #4479.
This commit is contained in:
John Preston 2018-03-09 15:53:44 +03:00
parent e6c0f0f774
commit 8c3b7f6417
2 changed files with 11 additions and 1 deletions

View file

@ -779,15 +779,22 @@ void MainWindow::toggleTray(QSystemTrayIcon::ActivationReason reason) {
if (reason == QSystemTrayIcon::Context) {
updateTrayMenu(true);
QTimer::singleShot(1, this, SLOT(psShowTrayMenu()));
} else {
} else if (!skipTrayClick()) {
if (isActive()) {
minimizeToTray();
} else {
showFromTray(reason);
}
_lastTrayClickTime = getms();
}
}
bool MainWindow::skipTrayClick() const {
return (_lastTrayClickTime > 0)
&& (getms() - _lastTrayClickTime
< QApplication::doubleClickInterval());
}
void MainWindow::toggleDisplayNotifyFromTray() {
if (App::passcoded()) {
if (!isActive()) showFromTray();

View file

@ -177,6 +177,8 @@ private:
void showConnecting(const QString &text, const QString &reconnect = QString());
void hideConnecting();
[[nodiscard]] bool skipTrayClick() const;
void ensureLayerCreated();
void destroyLayerDelayed();
@ -196,6 +198,7 @@ private:
};
QList<DelayedServiceMsg> _delayedServiceMsgs;
mtpRequestId _serviceHistoryRequest = 0;
TimeMs _lastTrayClickTime = 0;
object_ptr<PasscodeWidget> _passcode = { nullptr };
object_ptr<Intro::Widget> _intro = { nullptr };