Skip to content

Commit 98749df

Browse files
committed
feat: Attract attention for platforms
1 parent ce86090 commit 98749df

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/backend.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <QSettings>
2828
#include <QStandardPaths>
2929
#include <QUrl>
30+
#include <QWindow>
3031
#include <QVariantMap>
3132
#include <QtDebug>
3233
#include <algorithm>
@@ -387,6 +388,7 @@ Backend::~Backend() {
387388
}
388389

389390
void Backend::initializeSound(QWindow *window) {
391+
mainWindow_ = window;
390392
soundNotifier_.initialize(window);
391393
}
392394

@@ -976,6 +978,18 @@ void Backend::setChatReminderEnabled(bool enabled) {
976978
emit chatReminderEnabledChanged();
977979
}
978980

981+
void Backend::requestUserAttention() {
982+
if (!mainWindow_) {
983+
return;
984+
}
985+
// Only nudge the user when the window is not already active.
986+
if (QGuiApplication::applicationState() == Qt::ApplicationActive &&
987+
mainWindow_->isActive()) {
988+
return;
989+
}
990+
mainWindow_->alert(0);
991+
}
992+
979993
void Backend::setLobbyFilter(const QString &text) {
980994
if (lobbyFilter_ == text) {
981995
return;
@@ -1491,6 +1505,7 @@ void Backend::handleChatMessage(uint64_t senderId, const QString &message) {
14911505

14921506
if (!entry.isSelf && chatReminderEnabled_) {
14931507
soundNotifier_.playMessageAlert();
1508+
requestUserAttention();
14941509
}
14951510

14961511
chatModel_.appendMessage(std::move(entry));

src/backend.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ class Backend : public QObject {
208208
void refreshHostId();
209209
void updateFriendCooldown(const QString &steamId, int seconds);
210210
void updateLobbyInfoSignals();
211+
void requestUserAttention();
211212
void setFriendsRefreshing(bool refreshing);
212213
void updateRelayPing();
213214
void handlePinnedMessageMetadata(const QString &payload);
@@ -270,6 +271,7 @@ class Backend : public QObject {
270271
MembersModel membersModel_;
271272
ChatModel chatModel_;
272273
SoundNotifier soundNotifier_;
274+
QPointer<QWindow> mainWindow_;
273275
QString friendFilter_;
274276
std::unordered_map<uint64_t, QString> memberAvatars_;
275277
std::unordered_map<uint64_t, int> inviteCooldowns_;

0 commit comments

Comments
 (0)