Merge pull request #765 from Cockatrice/no-spec-alerts
Game events do not notify taskbar while spectating.
This commit is contained in:
commit
66678e95dc
6 changed files with 41 additions and 12 deletions
|
@ -446,6 +446,11 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
|||
|
||||
notificationsEnabledCheckBox.setChecked(settingsCache->getNotificationsEnabled());
|
||||
connect(¬ificationsEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setNotificationsEnabled(int)));
|
||||
connect(¬ificationsEnabledCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setSpecNotificationEnabled(int)));
|
||||
|
||||
specNotificationsEnabledCheckBox.setChecked(settingsCache->getSpectatorNotificationsEnabled());
|
||||
specNotificationsEnabledCheckBox.setEnabled(settingsCache->getNotificationsEnabled());
|
||||
connect(&specNotificationsEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setSpectatorNotificationsEnabled(int)));
|
||||
|
||||
doubleClickToPlayCheckBox.setChecked(settingsCache->getDoubleClickToPlay());
|
||||
connect(&doubleClickToPlayCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDoubleClickToPlay(int)));
|
||||
|
@ -455,8 +460,9 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
|||
|
||||
QGridLayout *generalGrid = new QGridLayout;
|
||||
generalGrid->addWidget(¬ificationsEnabledCheckBox, 0, 0);
|
||||
generalGrid->addWidget(&doubleClickToPlayCheckBox, 1, 0);
|
||||
generalGrid->addWidget(&playToStackCheckBox, 2, 0);
|
||||
generalGrid->addWidget(&specNotificationsEnabledCheckBox, 1, 0);
|
||||
generalGrid->addWidget(&doubleClickToPlayCheckBox, 2, 0);
|
||||
generalGrid->addWidget(&playToStackCheckBox, 3, 0);
|
||||
|
||||
generalGroupBox = new QGroupBox;
|
||||
generalGroupBox->setLayout(generalGrid);
|
||||
|
@ -500,10 +506,15 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
|||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
void UserInterfaceSettingsPage::setSpecNotificationEnabled(int i) {
|
||||
specNotificationsEnabledCheckBox.setEnabled(i != 0);
|
||||
}
|
||||
|
||||
void UserInterfaceSettingsPage::retranslateUi()
|
||||
{
|
||||
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)"));
|
||||
playToStackCheckBox.setText(tr("&Play all nonlands onto the stack (not the battlefield) by default"));
|
||||
animationGroupBox->setTitle(tr("Animation settings"));
|
||||
|
|
|
@ -115,10 +115,12 @@ class UserInterfaceSettingsPage : public AbstractSettingsPage {
|
|||
private slots:
|
||||
void soundPathClearButtonClicked();
|
||||
void soundPathButtonClicked();
|
||||
void setSpecNotificationEnabled(int);
|
||||
signals:
|
||||
void soundPathChanged();
|
||||
private:
|
||||
QCheckBox notificationsEnabledCheckBox;
|
||||
QCheckBox specNotificationsEnabledCheckBox;
|
||||
QCheckBox doubleClickToPlayCheckBox;
|
||||
QCheckBox playToStackCheckBox;
|
||||
QCheckBox tapAnimationCheckBox;
|
||||
|
|
|
@ -35,6 +35,7 @@ SettingsCache::SettingsCache()
|
|||
|
||||
mainWindowGeometry = settings->value("interface/main_window_geometry").toByteArray();
|
||||
notificationsEnabled = settings->value("interface/notificationsenabled", true).toBool();
|
||||
spectatorNotificationsEnabled = settings->value("interface/specnotificationsenabled", false).toBool();
|
||||
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
|
||||
playToStack = settings->value("interface/playtostack", false).toBool();
|
||||
cardInfoMinimized = settings->value("interface/cardinfominimized", 0).toInt();
|
||||
|
@ -183,6 +184,11 @@ void SettingsCache::setNotificationsEnabled(int _notificationsEnabled)
|
|||
settings->setValue("interface/notificationsenabled", notificationsEnabled);
|
||||
}
|
||||
|
||||
void SettingsCache::setSpectatorNotificationsEnabled(int _spectatorNotificationsEnabled) {
|
||||
spectatorNotificationsEnabled = _spectatorNotificationsEnabled;
|
||||
settings->setValue("interface/specnotificationsenabled", spectatorNotificationsEnabled);
|
||||
}
|
||||
|
||||
void SettingsCache::setDoubleClickToPlay(int _doubleClickToPlay)
|
||||
{
|
||||
doubleClickToPlay = _doubleClickToPlay;
|
||||
|
|
|
@ -48,6 +48,7 @@ private:
|
|||
bool picDownload;
|
||||
bool picDownloadHq;
|
||||
bool notificationsEnabled;
|
||||
bool spectatorNotificationsEnabled;
|
||||
bool doubleClickToPlay;
|
||||
bool playToStack;
|
||||
int cardInfoMinimized;
|
||||
|
@ -91,6 +92,8 @@ public:
|
|||
bool getPicDownload() const { return picDownload; }
|
||||
bool getPicDownloadHq() const { return picDownloadHq; }
|
||||
bool getNotificationsEnabled() const { return notificationsEnabled; }
|
||||
bool getSpectatorNotificationsEnabled() const { return spectatorNotificationsEnabled; }
|
||||
|
||||
bool getDoubleClickToPlay() const { return doubleClickToPlay; }
|
||||
bool getPlayToStack() const { return playToStack; }
|
||||
int getCardInfoMinimized() const { return cardInfoMinimized; }
|
||||
|
@ -139,6 +142,7 @@ public slots:
|
|||
void setPicDownload(int _picDownload);
|
||||
void setPicDownloadHq(int _picDownloadHq);
|
||||
void setNotificationsEnabled(int _notificationsEnabled);
|
||||
void setSpectatorNotificationsEnabled(int _spectatorNotificationsEnabled);
|
||||
void setDoubleClickToPlay(int _doubleClickToPlay);
|
||||
void setPlayToStack(int _playToStack);
|
||||
void setCardInfoMinimized(int _cardInfoMinimized);
|
||||
|
|
|
@ -514,6 +514,11 @@ void TabGame::addMentionTag(QString value) {
|
|||
sayEdit->setFocus();
|
||||
}
|
||||
|
||||
void TabGame::emitUserEvent() {
|
||||
bool globalEvent = !spectator || settingsCache->getSpectatorNotificationsEnabled();
|
||||
emit userEvent(globalEvent);
|
||||
}
|
||||
|
||||
TabGame::~TabGame()
|
||||
{
|
||||
delete replay;
|
||||
|
@ -806,7 +811,7 @@ void TabGame::processGameEventContainer(const GameEventContainer &cont, Abstract
|
|||
break;
|
||||
}
|
||||
player->processGameEvent(eventType, event, context);
|
||||
emit userEvent();
|
||||
emitUserEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -929,7 +934,7 @@ void TabGame::eventSpectatorLeave(const Event_Leave & /*event*/, int eventPlayer
|
|||
playerListWidget->removePlayer(eventPlayerId);
|
||||
spectators.remove(eventPlayerId);
|
||||
|
||||
emit userEvent();
|
||||
emitUserEvent();
|
||||
}
|
||||
|
||||
void TabGame::eventGameStateChanged(const Event_GameStateChanged &event, int /*eventPlayerId*/, const GameEventContext & /*context*/)
|
||||
|
@ -988,7 +993,7 @@ void TabGame::eventGameStateChanged(const Event_GameStateChanged &event, int /*e
|
|||
scene->clearViews();
|
||||
}
|
||||
gameStateKnown = true;
|
||||
emit userEvent();
|
||||
emitUserEvent();
|
||||
}
|
||||
|
||||
void TabGame::eventPlayerPropertiesChanged(const Event_PlayerPropertiesChanged &event, int eventPlayerId, const GameEventContext &context)
|
||||
|
@ -1056,7 +1061,7 @@ void TabGame::eventJoin(const Event_Join &event, int /*eventPlayerId*/, const Ga
|
|||
messageLog->logJoin(newPlayer);
|
||||
}
|
||||
playerListWidget->addPlayer(playerInfo);
|
||||
emit userEvent();
|
||||
emitUserEvent();
|
||||
}
|
||||
|
||||
void TabGame::eventLeave(const Event_Leave & /*event*/, int eventPlayerId, const GameEventContext & /*context*/)
|
||||
|
@ -1077,7 +1082,7 @@ void TabGame::eventLeave(const Event_Leave & /*event*/, int eventPlayerId, const
|
|||
while (playerIterator.hasNext())
|
||||
playerIterator.next().value()->updateZones();
|
||||
|
||||
emit userEvent();
|
||||
emitUserEvent();
|
||||
}
|
||||
|
||||
void TabGame::eventKicked(const Event_Kicked & /*event*/, int /*eventPlayerId*/, const GameEventContext & /*context*/)
|
||||
|
@ -1092,7 +1097,7 @@ void TabGame::eventKicked(const Event_Kicked & /*event*/, int /*eventPlayerId*/,
|
|||
msgBox.setIcon(QMessageBox::Information);
|
||||
msgBox.exec();
|
||||
|
||||
emit userEvent();
|
||||
emitUserEvent();
|
||||
}
|
||||
|
||||
void TabGame::eventGameHostChanged(const Event_GameHostChanged & /*event*/, int eventPlayerId, const GameEventContext & /*context*/)
|
||||
|
@ -1104,7 +1109,7 @@ void TabGame::eventGameClosed(const Event_GameClosed & /*event*/, int /*eventPla
|
|||
{
|
||||
closeGame();
|
||||
messageLog->logGameClosed();
|
||||
emit userEvent();
|
||||
emitUserEvent();
|
||||
}
|
||||
|
||||
Player *TabGame::setActivePlayer(int id)
|
||||
|
@ -1128,7 +1133,7 @@ Player *TabGame::setActivePlayer(int id)
|
|||
}
|
||||
}
|
||||
currentPhase = -1;
|
||||
emit userEvent();
|
||||
emitUserEvent();
|
||||
return player;
|
||||
}
|
||||
|
||||
|
@ -1138,7 +1143,7 @@ void TabGame::eventSetActivePlayer(const Event_SetActivePlayer &event, int /*eve
|
|||
if (!player)
|
||||
return;
|
||||
messageLog->logSetActivePlayer(player);
|
||||
emit userEvent();
|
||||
emitUserEvent();
|
||||
}
|
||||
|
||||
void TabGame::setActivePhase(int phase)
|
||||
|
@ -1155,7 +1160,7 @@ void TabGame::eventSetActivePhase(const Event_SetActivePhase &event, int /*event
|
|||
if (currentPhase != phase)
|
||||
messageLog->logSetActivePhase(phase);
|
||||
setActivePhase(phase);
|
||||
emit userEvent();
|
||||
emitUserEvent();
|
||||
}
|
||||
|
||||
void TabGame::newCardAdded(AbstractCardItem *card)
|
||||
|
|
|
@ -164,6 +164,7 @@ private:
|
|||
void setActivePhase(int phase);
|
||||
void eventSetActivePhase(const Event_SetActivePhase &event, int eventPlayerId, const GameEventContext &context);
|
||||
void eventPing(const Event_Ping &event, int eventPlayerId, const GameEventContext &context);
|
||||
void emitUserEvent();
|
||||
signals:
|
||||
void gameClosing(TabGame *tab);
|
||||
void playerAdded(Player *player);
|
||||
|
|
Loading…
Reference in a new issue