Add configuration option to send desktop notification on buddy presence (#3886)
This commit is contained in:
parent
63b4f9b2f0
commit
91dc8b3b08
8 changed files with 83 additions and 15 deletions
|
@ -373,6 +373,11 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
connect(&specNotificationsEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache,
|
connect(&specNotificationsEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache,
|
||||||
SLOT(setSpectatorNotificationsEnabled(int)));
|
SLOT(setSpectatorNotificationsEnabled(int)));
|
||||||
|
|
||||||
|
buddyConnectNotificationsEnabledCheckBox.setChecked(settingsCache->getBuddyConnectNotificationsEnabled());
|
||||||
|
buddyConnectNotificationsEnabledCheckBox.setEnabled(settingsCache->getNotificationsEnabled());
|
||||||
|
connect(&buddyConnectNotificationsEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache,
|
||||||
|
SLOT(setBuddyConnectNotificationsEnabled(int)));
|
||||||
|
|
||||||
doubleClickToPlayCheckBox.setChecked(settingsCache->getDoubleClickToPlay());
|
doubleClickToPlayCheckBox.setChecked(settingsCache->getDoubleClickToPlay());
|
||||||
connect(&doubleClickToPlayCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDoubleClickToPlay(int)));
|
connect(&doubleClickToPlayCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDoubleClickToPlay(int)));
|
||||||
|
|
||||||
|
@ -387,16 +392,22 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
[](int state) { settingsCache->setUseTearOffMenus(state == Qt::Checked); });
|
[](int state) { settingsCache->setUseTearOffMenus(state == Qt::Checked); });
|
||||||
|
|
||||||
auto *generalGrid = new QGridLayout;
|
auto *generalGrid = new QGridLayout;
|
||||||
generalGrid->addWidget(¬ificationsEnabledCheckBox, 0, 0);
|
generalGrid->addWidget(&doubleClickToPlayCheckBox, 0, 0);
|
||||||
generalGrid->addWidget(&specNotificationsEnabledCheckBox, 1, 0);
|
generalGrid->addWidget(&playToStackCheckBox, 1, 0);
|
||||||
generalGrid->addWidget(&doubleClickToPlayCheckBox, 2, 0);
|
generalGrid->addWidget(&annotateTokensCheckBox, 2, 0);
|
||||||
generalGrid->addWidget(&playToStackCheckBox, 3, 0);
|
generalGrid->addWidget(&useTearOffMenusCheckBox, 3, 0);
|
||||||
generalGrid->addWidget(&annotateTokensCheckBox, 4, 0);
|
|
||||||
generalGrid->addWidget(&useTearOffMenusCheckBox, 5, 0);
|
|
||||||
|
|
||||||
generalGroupBox = new QGroupBox;
|
generalGroupBox = new QGroupBox;
|
||||||
generalGroupBox->setLayout(generalGrid);
|
generalGroupBox->setLayout(generalGrid);
|
||||||
|
|
||||||
|
auto *notificationsGrid = new QGridLayout;
|
||||||
|
notificationsGrid->addWidget(¬ificationsEnabledCheckBox, 0, 0);
|
||||||
|
notificationsGrid->addWidget(&specNotificationsEnabledCheckBox, 1, 0);
|
||||||
|
notificationsGrid->addWidget(&buddyConnectNotificationsEnabledCheckBox, 2, 0);
|
||||||
|
|
||||||
|
notificationsGroupBox = new QGroupBox;
|
||||||
|
notificationsGroupBox->setLayout(notificationsGrid);
|
||||||
|
|
||||||
tapAnimationCheckBox.setChecked(settingsCache->getTapAnimation());
|
tapAnimationCheckBox.setChecked(settingsCache->getTapAnimation());
|
||||||
connect(&tapAnimationCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setTapAnimation(int)));
|
connect(&tapAnimationCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setTapAnimation(int)));
|
||||||
|
|
||||||
|
@ -408,6 +419,7 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
|
|
||||||
auto *mainLayout = new QVBoxLayout;
|
auto *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addWidget(generalGroupBox);
|
mainLayout->addWidget(generalGroupBox);
|
||||||
|
mainLayout->addWidget(notificationsGroupBox);
|
||||||
mainLayout->addWidget(animationGroupBox);
|
mainLayout->addWidget(animationGroupBox);
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
@ -421,12 +433,14 @@ void UserInterfaceSettingsPage::setSpecNotificationEnabled(int i)
|
||||||
void UserInterfaceSettingsPage::retranslateUi()
|
void UserInterfaceSettingsPage::retranslateUi()
|
||||||
{
|
{
|
||||||
generalGroupBox->setTitle(tr("General interface settings"));
|
generalGroupBox->setTitle(tr("General interface settings"));
|
||||||
notificationsEnabledCheckBox.setText(tr("Enable notifications in taskbar"));
|
|
||||||
specNotificationsEnabledCheckBox.setText(tr("Notify in the taskbar for game events while you are spectating"));
|
|
||||||
doubleClickToPlayCheckBox.setText(tr("&Double-click cards to play them (instead of single-click)"));
|
doubleClickToPlayCheckBox.setText(tr("&Double-click cards to play them (instead of single-click)"));
|
||||||
playToStackCheckBox.setText(tr("&Play all nonlands onto the stack (not the battlefield) by default"));
|
playToStackCheckBox.setText(tr("&Play all nonlands onto the stack (not the battlefield) by default"));
|
||||||
annotateTokensCheckBox.setText(tr("Annotate card text on tokens"));
|
annotateTokensCheckBox.setText(tr("Annotate card text on tokens"));
|
||||||
useTearOffMenusCheckBox.setText(tr("Use tear-off menus, allowing right click menus to persist on screen"));
|
useTearOffMenusCheckBox.setText(tr("Use tear-off menus, allowing right click menus to persist on screen"));
|
||||||
|
notificationsGroupBox->setTitle(tr("Notifications settings"));
|
||||||
|
notificationsEnabledCheckBox.setText(tr("Enable notifications in taskbar"));
|
||||||
|
specNotificationsEnabledCheckBox.setText(tr("Notify in the taskbar for game events while you are spectating"));
|
||||||
|
buddyConnectNotificationsEnabledCheckBox.setText(tr("Notify in the taskbar when users in your buddy list connect"));
|
||||||
animationGroupBox->setTitle(tr("Animation settings"));
|
animationGroupBox->setTitle(tr("Animation settings"));
|
||||||
tapAnimationCheckBox.setText(tr("&Tap/untap animation"));
|
tapAnimationCheckBox.setText(tr("&Tap/untap animation"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,12 +108,14 @@ private slots:
|
||||||
private:
|
private:
|
||||||
QCheckBox notificationsEnabledCheckBox;
|
QCheckBox notificationsEnabledCheckBox;
|
||||||
QCheckBox specNotificationsEnabledCheckBox;
|
QCheckBox specNotificationsEnabledCheckBox;
|
||||||
|
QCheckBox buddyConnectNotificationsEnabledCheckBox;
|
||||||
QCheckBox doubleClickToPlayCheckBox;
|
QCheckBox doubleClickToPlayCheckBox;
|
||||||
QCheckBox playToStackCheckBox;
|
QCheckBox playToStackCheckBox;
|
||||||
QCheckBox annotateTokensCheckBox;
|
QCheckBox annotateTokensCheckBox;
|
||||||
QCheckBox useTearOffMenusCheckBox;
|
QCheckBox useTearOffMenusCheckBox;
|
||||||
QCheckBox tapAnimationCheckBox;
|
QCheckBox tapAnimationCheckBox;
|
||||||
QGroupBox *generalGroupBox;
|
QGroupBox *generalGroupBox;
|
||||||
|
QGroupBox *notificationsGroupBox;
|
||||||
QGroupBox *animationGroupBox;
|
QGroupBox *animationGroupBox;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -227,6 +227,7 @@ SettingsCache::SettingsCache()
|
||||||
tokenDialogGeometry = settings->value("interface/token_dialog_geometry").toByteArray();
|
tokenDialogGeometry = settings->value("interface/token_dialog_geometry").toByteArray();
|
||||||
notificationsEnabled = settings->value("interface/notificationsenabled", true).toBool();
|
notificationsEnabled = settings->value("interface/notificationsenabled", true).toBool();
|
||||||
spectatorNotificationsEnabled = settings->value("interface/specnotificationsenabled", false).toBool();
|
spectatorNotificationsEnabled = settings->value("interface/specnotificationsenabled", false).toBool();
|
||||||
|
buddyConnectNotificationsEnabled = settings->value("interface/buddyconnectnotificationsenabled", true).toBool();
|
||||||
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
|
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
|
||||||
playToStack = settings->value("interface/playtostack", true).toBool();
|
playToStack = settings->value("interface/playtostack", true).toBool();
|
||||||
startingHandSize = settings->value("interface/startinghandsize", 7).toInt();
|
startingHandSize = settings->value("interface/startinghandsize", 7).toInt();
|
||||||
|
@ -438,6 +439,12 @@ void SettingsCache::setSpectatorNotificationsEnabled(int _spectatorNotifications
|
||||||
settings->setValue("interface/specnotificationsenabled", spectatorNotificationsEnabled);
|
settings->setValue("interface/specnotificationsenabled", spectatorNotificationsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsCache::setBuddyConnectNotificationsEnabled(int _buddyConnectNotificationsEnabled)
|
||||||
|
{
|
||||||
|
buddyConnectNotificationsEnabled = static_cast<bool>(_buddyConnectNotificationsEnabled);
|
||||||
|
settings->setValue("interface/buddyconnectnotificationsenabled", buddyConnectNotificationsEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsCache::setDoubleClickToPlay(int _doubleClickToPlay)
|
void SettingsCache::setDoubleClickToPlay(int _doubleClickToPlay)
|
||||||
{
|
{
|
||||||
doubleClickToPlay = static_cast<bool>(_doubleClickToPlay);
|
doubleClickToPlay = static_cast<bool>(_doubleClickToPlay);
|
||||||
|
|
|
@ -77,6 +77,7 @@ private:
|
||||||
bool picDownload;
|
bool picDownload;
|
||||||
bool notificationsEnabled;
|
bool notificationsEnabled;
|
||||||
bool spectatorNotificationsEnabled;
|
bool spectatorNotificationsEnabled;
|
||||||
|
bool buddyConnectNotificationsEnabled;
|
||||||
bool doubleClickToPlay;
|
bool doubleClickToPlay;
|
||||||
bool playToStack;
|
bool playToStack;
|
||||||
int startingHandSize;
|
int startingHandSize;
|
||||||
|
@ -202,6 +203,10 @@ public:
|
||||||
{
|
{
|
||||||
return spectatorNotificationsEnabled;
|
return spectatorNotificationsEnabled;
|
||||||
}
|
}
|
||||||
|
bool getBuddyConnectNotificationsEnabled() const
|
||||||
|
{
|
||||||
|
return buddyConnectNotificationsEnabled;
|
||||||
|
}
|
||||||
bool getNotifyAboutUpdates() const
|
bool getNotifyAboutUpdates() const
|
||||||
{
|
{
|
||||||
return notifyAboutUpdates;
|
return notifyAboutUpdates;
|
||||||
|
@ -476,6 +481,7 @@ public slots:
|
||||||
void setPicDownload(int _picDownload);
|
void setPicDownload(int _picDownload);
|
||||||
void setNotificationsEnabled(int _notificationsEnabled);
|
void setNotificationsEnabled(int _notificationsEnabled);
|
||||||
void setSpectatorNotificationsEnabled(int _spectatorNotificationsEnabled);
|
void setSpectatorNotificationsEnabled(int _spectatorNotificationsEnabled);
|
||||||
|
void setBuddyConnectNotificationsEnabled(int _buddyConnectNotificationsEnabled);
|
||||||
void setDoubleClickToPlay(int _doubleClickToPlay);
|
void setDoubleClickToPlay(int _doubleClickToPlay);
|
||||||
void setPlayToStack(int _playToStack);
|
void setPlayToStack(int _playToStack);
|
||||||
void setStartingHandSize(int _startingHandSize);
|
void setStartingHandSize(int _startingHandSize);
|
||||||
|
|
|
@ -158,11 +158,16 @@ void TabRoom::focusTab()
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabRoom::actShowMentionPopup(QString &sender)
|
void TabRoom::actShowMentionPopup(QString &sender)
|
||||||
|
{
|
||||||
|
this->actShowPopup(sender + tr(" mentioned you."));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabRoom::actShowPopup(const QString &message)
|
||||||
{
|
{
|
||||||
if (trayIcon && (tabSupervisor->currentIndex() != tabSupervisor->indexOf(this) ||
|
if (trayIcon && (tabSupervisor->currentIndex() != tabSupervisor->indexOf(this) ||
|
||||||
QApplication::activeWindow() == 0 || QApplication::focusWidget() == 0)) {
|
QApplication::activeWindow() == nullptr || QApplication::focusWidget() == nullptr)) {
|
||||||
disconnect(trayIcon, SIGNAL(messageClicked()), 0, 0);
|
disconnect(trayIcon, SIGNAL(messageClicked()), nullptr, nullptr);
|
||||||
trayIcon->showMessage(sender + tr(" mentioned you."), tr("Click to view"));
|
trayIcon->showMessage(message, tr("Click to view"));
|
||||||
connect(trayIcon, SIGNAL(messageClicked()), chatView, SLOT(actMessageClicked()));
|
connect(trayIcon, SIGNAL(messageClicked()), chatView, SLOT(actMessageClicked()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ private slots:
|
||||||
void addMentionTag(QString mentionTag);
|
void addMentionTag(QString mentionTag);
|
||||||
void focusTab();
|
void focusTab();
|
||||||
void actShowMentionPopup(QString &sender);
|
void actShowMentionPopup(QString &sender);
|
||||||
|
void actShowPopup(const QString &message);
|
||||||
void actCompleterChanged();
|
void actCompleterChanged();
|
||||||
|
|
||||||
void processListGamesEvent(const Event_ListGames &event);
|
void processListGamesEvent(const Event_ListGames &event);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "tab_supervisor.h"
|
#include "tab_supervisor.h"
|
||||||
#include "abstractclient.h"
|
#include "abstractclient.h"
|
||||||
|
#include "main.h"
|
||||||
#include "pixmapgenerator.h"
|
#include "pixmapgenerator.h"
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
#include "tab_admin.h"
|
#include "tab_admin.h"
|
||||||
|
@ -17,6 +18,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
#include "pb/event_game_joined.pb.h"
|
#include "pb/event_game_joined.pb.h"
|
||||||
#include "pb/event_notify_user.pb.h"
|
#include "pb/event_notify_user.pb.h"
|
||||||
|
@ -441,7 +443,7 @@ void TabSupervisor::replayLeft(TabGame *tab)
|
||||||
TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus)
|
TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus)
|
||||||
{
|
{
|
||||||
if (receiverName == QString::fromStdString(userInfo->name()))
|
if (receiverName == QString::fromStdString(userInfo->name()))
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
ServerInfo_User otherUser;
|
ServerInfo_User otherUser;
|
||||||
UserListTWI *twi = tabUserLists->getAllUsersList()->getUsers().value(receiverName);
|
UserListTWI *twi = tabUserLists->getAllUsersList()->getUsers().value(receiverName);
|
||||||
|
@ -561,6 +563,17 @@ void TabSupervisor::processUserMessageEvent(const Event_UserMessage &event)
|
||||||
tab->processUserMessageEvent(event);
|
tab->processUserMessageEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabSupervisor::actShowPopup(const QString &message)
|
||||||
|
{
|
||||||
|
qDebug() << "ACT SHOW POPUP";
|
||||||
|
if (trayIcon && (QApplication::activeWindow() == nullptr || QApplication::focusWidget() == nullptr)) {
|
||||||
|
qDebug() << "LAUNCHING POPUP";
|
||||||
|
// disconnect(trayIcon, SIGNAL(messageClicked()), nullptr, nullptr);
|
||||||
|
trayIcon->showMessage(message, tr("Click to view"));
|
||||||
|
// connect(trayIcon, SIGNAL(messageClicked()), chatView, SLOT(actMessageClicked()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TabSupervisor::processUserLeft(const QString &userName)
|
void TabSupervisor::processUserLeft(const QString &userName)
|
||||||
{
|
{
|
||||||
TabMessage *tab = messageTabs.value(userName);
|
TabMessage *tab = messageTabs.value(userName);
|
||||||
|
@ -568,11 +581,29 @@ void TabSupervisor::processUserLeft(const QString &userName)
|
||||||
tab->processUserLeft();
|
tab->processUserLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::processUserJoined(const ServerInfo_User &userInfo)
|
void TabSupervisor::processUserJoined(const ServerInfo_User &userInfoJoined)
|
||||||
{
|
{
|
||||||
TabMessage *tab = messageTabs.value(QString::fromStdString(userInfo.name()));
|
QString userName = QString::fromStdString(userInfoJoined.name());
|
||||||
|
if (isUserBuddy(userName)) {
|
||||||
|
Tab *tab = static_cast<Tab *>(getUserListsTab());
|
||||||
|
|
||||||
|
if (tab != currentWidget()) {
|
||||||
|
tab->setContentsChanged(true);
|
||||||
|
QPixmap avatarPixmap =
|
||||||
|
UserLevelPixmapGenerator::generatePixmap(13, (UserLevelFlags)userInfoJoined.user_level(), true,
|
||||||
|
QString::fromStdString(userInfoJoined.privlevel()));
|
||||||
|
setTabIcon(indexOf(tab), QPixmap(avatarPixmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settingsCache->getBuddyConnectNotificationsEnabled()) {
|
||||||
|
QApplication::alert(this);
|
||||||
|
this->actShowPopup(tr("Your buddy %1 has signed on!").arg(userName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TabMessage *tab = messageTabs.value(userName);
|
||||||
if (tab)
|
if (tab)
|
||||||
tab->processUserJoined(userInfo);
|
tab->processUserJoined(userInfoJoined);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::updateCurrent(int index)
|
void TabSupervisor::updateCurrent(int index)
|
||||||
|
|
|
@ -115,11 +115,13 @@ public:
|
||||||
bool isUserBuddy(const QString &userName) const;
|
bool isUserBuddy(const QString &userName) const;
|
||||||
bool isUserIgnored(const QString &userName) const;
|
bool isUserIgnored(const QString &userName) const;
|
||||||
const ServerInfo_User *getOnlineUser(const QString &userName) const;
|
const ServerInfo_User *getOnlineUser(const QString &userName) const;
|
||||||
|
void actShowPopup(const QString &message);
|
||||||
signals:
|
signals:
|
||||||
void setMenu(const QList<QMenu *> &newMenuList = QList<QMenu *>());
|
void setMenu(const QList<QMenu *> &newMenuList = QList<QMenu *>());
|
||||||
void localGameEnded();
|
void localGameEnded();
|
||||||
void adminLockChanged(bool lock);
|
void adminLockChanged(bool lock);
|
||||||
void showWindowIfHidden();
|
void showWindowIfHidden();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
TabDeckEditor *addDeckEditorTab(const DeckLoader *deckToOpen);
|
TabDeckEditor *addDeckEditorTab(const DeckLoader *deckToOpen);
|
||||||
void openReplay(GameReplay *replay);
|
void openReplay(GameReplay *replay);
|
||||||
|
|
Loading…
Reference in a new issue