gui part for #239 server ping state display

This commit is contained in:
doitux
2013-12-11 15:54:29 +01:00
parent 7fb8a8e948
commit 3997a40f09
9 changed files with 117 additions and 43 deletions
+2 -2
View File
@@ -64,7 +64,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
myConfigState = OK; myConfigState = OK;
// !!!! Revisionsnummer der Configdefaults !!!!! // !!!! Revisionsnummer der Configdefaults !!!!!
configRev = 103; configRev = 104;
//standard defaults //standard defaults
logOnOffDefault = "1"; logOnOffDefault = "1";
@@ -150,9 +150,9 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
configList.push_back(ConfigInfo("AppDataDir", CONFIG_TYPE_STRING, myQtToolsInterface->getDataPathStdString(myArgv0))); configList.push_back(ConfigInfo("AppDataDir", CONFIG_TYPE_STRING, myQtToolsInterface->getDataPathStdString(myArgv0)));
#endif #endif
configList.push_back(ConfigInfo("Language", CONFIG_TYPE_INT, myQtToolsInterface->getDefaultLanguage())); configList.push_back(ConfigInfo("Language", CONFIG_TYPE_INT, myQtToolsInterface->getDefaultLanguage()));
/*configList.push_back(ConfigInfo("InternetServerAddressIRCChannelUpdateDone", CONFIG_TYPE_INT, "1"));*/ //HACK
configList.push_back(ConfigInfo("ShowLeftToolBox", CONFIG_TYPE_INT, "1")); configList.push_back(ConfigInfo("ShowLeftToolBox", CONFIG_TYPE_INT, "1"));
configList.push_back(ConfigInfo("ShowCountryFlagInAvatar", CONFIG_TYPE_INT, "1")); configList.push_back(ConfigInfo("ShowCountryFlagInAvatar", CONFIG_TYPE_INT, "1"));
configList.push_back(ConfigInfo("ShowPingStateInAvatar", CONFIG_TYPE_INT, "1"));
configList.push_back(ConfigInfo("ShowRightToolBox", CONFIG_TYPE_INT, "1")); configList.push_back(ConfigInfo("ShowRightToolBox", CONFIG_TYPE_INT, "1"));
configList.push_back(ConfigInfo("ShowFadeOutCardsAnimation", CONFIG_TYPE_INT, "1")); configList.push_back(ConfigInfo("ShowFadeOutCardsAnimation", CONFIG_TYPE_INT, "1"));
configList.push_back(ConfigInfo("ShowFlipCardsAnimation", CONFIG_TYPE_INT, "1")); configList.push_back(ConfigInfo("ShowFlipCardsAnimation", CONFIG_TYPE_INT, "1"));
+6 -1
View File
@@ -681,7 +681,7 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent)
connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned)), this, SLOT(netClientPlayerLeft(unsigned))); connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned)), this, SLOT(netClientPlayerLeft(unsigned)));
connect(this, SIGNAL(signalNetClientSpectatorLeft(unsigned)), this, SLOT(netClientSpectatorLeft(unsigned))); connect(this, SIGNAL(signalNetClientSpectatorLeft(unsigned)), this, SLOT(netClientSpectatorLeft(unsigned)));
connect(this, SIGNAL(signalNetClientSpectatorJoined(unsigned)), this, SLOT(netClientSpectatorJoined(unsigned))); connect(this, SIGNAL(signalNetClientSpectatorJoined(unsigned)), this, SLOT(netClientSpectatorJoined(unsigned)));
connect(this, SIGNAL(signalNetClientPingUpdate(unsigned, unsigned, unsigned)), this, SLOT(pingUpdate(unsigned, unsigned, unsigned)));
#ifdef GUI_800x480 #ifdef GUI_800x480
connect( tabsButton, SIGNAL( clicked() ), this, SLOT( tabsButtonClicked() ) ); connect( tabsButton, SIGNAL( clicked() ), this, SLOT( tabsButtonClicked() ) );
@@ -4496,3 +4496,8 @@ void gameTableImpl::refreshSpectatorsDisplay()
} }
} }
void gameTableImpl::pingUpdate(unsigned minPing, unsigned avgPing, unsigned maxPing)
{
label_Avatar0->refreshPing(minPing, avgPing, maxPing);
}
+2
View File
@@ -175,6 +175,7 @@ signals:
void signalNetClientPlayerLeft(unsigned playerId); void signalNetClientPlayerLeft(unsigned playerId);
void signalNetClientSpectatorLeft(unsigned playerId); void signalNetClientSpectatorLeft(unsigned playerId);
void signalNetClientSpectatorJoined(unsigned playerId); void signalNetClientSpectatorJoined(unsigned playerId);
void signalNetClientPingUpdate(unsigned minPing, unsigned avgPing, unsigned maxPing);
public slots: public slots:
@@ -375,6 +376,7 @@ public slots:
void tabsButtonClose(); void tabsButtonClose();
#endif #endif
void refreshSpectatorsDisplay(); void refreshSpectatorsDisplay();
void pingUpdate(unsigned, unsigned, unsigned);
private: private:
+47 -3
View File
@@ -42,7 +42,7 @@
using namespace std; using namespace std;
MyAvatarLabel::MyAvatarLabel(QGroupBox* parent) MyAvatarLabel::MyAvatarLabel(QGroupBox* parent)
: QLabel(parent), voteRunning(false), transparent(false), myUniqueId(0) : QLabel(parent), voteRunning(false), transparent(false), myUniqueId(0), myPingState(0), myAvgPing(0), myMinPing(0), myMaxPing(0)
{ {
myContextMenu = new QMenu; myContextMenu = new QMenu;
@@ -398,10 +398,54 @@ void MyAvatarLabel::paintEvent(QPaintEvent*)
boost::shared_ptr<Session> mySession = myW->myStartWindow->getSession(); boost::shared_ptr<Session> mySession = myW->myStartWindow->getSession();
if(!playerIsOnIgnoreList(QString::fromUtf8(mySession->getClientPlayerInfo(myUniqueId).playerName.c_str()))) { if(!playerIsOnIgnoreList(QString::fromUtf8(mySession->getClientPlayerInfo(myUniqueId).playerName.c_str()))) {
painter.drawPixmap(0,0,myPixmap); painter.drawPixmap(0,0,myPixmap);
return;
} else if(myW->getMyConfig()->readConfigInt("DontHideAvatarsOfIgnored")) { } else if(myW->getMyConfig()->readConfigInt("DontHideAvatarsOfIgnored")) {
painter.drawPixmap(0,0,myPixmap); painter.drawPixmap(0,0,myPixmap);
return; }
if(myW->getMyConfig()->readConfigInt("ShowPingStateInAvatar")) {
//paint ping state color for network clients
if(mySession->isNetworkClientRunning() && myId == 0) {
QColor pingColor;
if(myAvgPing > 0 && myAvgPing <= 1000) {
pingColor.setNamedColor("green");
}
else if(myAvgPing > 1000 && myAvgPing <= 2000 ) {
pingColor.setNamedColor("yellow");
}
else if(myAvgPing > 2000) {
pingColor.setNamedColor("red");
}
else {
pingColor.setNamedColor("white");
}
QColor pen = pingColor.darker(200);
// pen.setAlpha(130);
painter.setPen(pen);
QColor brush = pingColor;
// brush.setAlpha(130);
painter.setBrush(brush);
painter.setRenderHint(QPainter::Antialiasing);
painter.drawEllipse(1, 1, 10, 10);
}
}
}
void MyAvatarLabel::refreshPing(unsigned minPing, unsigned avgPing, unsigned maxPing)
{
myMinPing = minPing;
myAvgPing = avgPing;
myMaxPing = maxPing;
this->update();
if(myW->getMyConfig()->readConfigInt("ShowPingStateInAvatar")) {
QString toolTip = "<b>"+tr("Server response times")+"</b>";
toolTip.append("<br>"+tr("Average: ")+QString("%1").arg(myAvgPing)+tr("ms"));
toolTip.append("<br>"+tr("Minimum: ")+QString("%1").arg(myMinPing)+tr("ms"));
toolTip.append("<br>"+tr("Maximum: ")+QString("%1").arg(myMaxPing)+tr("ms"));
this->setToolTip(toolTip);
}
else {
this->setToolTip("");
} }
} }
+6
View File
@@ -86,6 +86,8 @@ public slots:
void setPlayerRating(QString); void setPlayerRating(QString);
void refreshTooltips(); void refreshTooltips();
void refreshStars(); void refreshStars();
void refreshPing(unsigned, unsigned, unsigned);
private: private:
gameTableImpl *myW; gameTableImpl *myW;
@@ -103,6 +105,10 @@ private:
bool transparent; bool transparent;
int myId; int myId;
int myUniqueId; int myUniqueId;
unsigned myPingState;
unsigned myAvgPing;
unsigned myMinPing;
unsigned myMaxPing;
}; };
#endif #endif
@@ -291,42 +291,14 @@
<string>Network / Internet Game</string> <string>Network / Internet Game</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_24"> <layout class="QGridLayout" name="gridLayout_24">
<item row="0" column="0"> <item row="4" column="0">
<widget class="QCheckBox" name="checkBox_showCountryFlagInAvatar">
<property name="text">
<string>Show country flag in the corner of avatar</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_enableBetInputFocusSwitch">
<property name="text">
<string>Switch keyboard focus to bet-input-field if it's your turn</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBox_enableAccidentallyCallBlocker">
<property name="text">
<string>Activate the &quot;accidentally call after big raise&quot; blocker</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox_dontHideAvatarsOfIgnored"> <widget class="QCheckBox" name="checkBox_dontHideAvatarsOfIgnored">
<property name="text"> <property name="text">
<string>Do not hide avatars of players which are on the ignore list</string> <string>Do not hide avatars of players which are on the ignore list</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="6" column="0">
<widget class="QCheckBox" name="checkBox_disableChatEmoticons">
<property name="text">
<string>Disable emoticons in the chat</string>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer_7"> <spacer name="verticalSpacer_7">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@@ -339,6 +311,41 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="5" column="0">
<widget class="QCheckBox" name="checkBox_disableChatEmoticons">
<property name="text">
<string>Disable emoticons in the chat</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBox_enableBetInputFocusSwitch">
<property name="text">
<string>Switch keyboard focus to bet-input-field if it's your turn</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox_enableAccidentallyCallBlocker">
<property name="text">
<string>Activate the &quot;accidentally call after big raise&quot; blocker</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_showCountryFlagInAvatar">
<property name="text">
<string>Show country flag in the corner of avatar</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_showPingStateInAvatar">
<property name="text">
<string>Show multicolor network state display in the avatar</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
+2 -1
View File
@@ -343,7 +343,7 @@ void GuiWrapper::SignalNetClientStatsUpdate(const ServerStats &stats)
} }
void GuiWrapper::SignalNetClientPingUpdate(unsigned minPing, unsigned avgPing, unsigned maxPing) void GuiWrapper::SignalNetClientPingUpdate(unsigned minPing, unsigned avgPing, unsigned maxPing)
{ {
// TODO myW->signalNetClientPingUpdate(minPing, avgPing, maxPing);
} }
void GuiWrapper::SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec) void GuiWrapper::SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec)
{ {
@@ -533,3 +533,4 @@ void GuiWrapper::SignalRejectedGameInvitation(unsigned gameId, unsigned playerId
{ {
myStartWindow->signalRejectedGameInvitation(gameId, playerIdWho, reason); myStartWindow->signalRejectedGameInvitation(gameId, playerIdWho, reason);
} }
+13 -6
View File
@@ -289,7 +289,7 @@
<string>Network / Internet Game</string> <string>Network / Internet Game</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="6" column="1"> <item row="7" column="1">
<spacer name="verticalSpacer_9"> <spacer name="verticalSpacer_9">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@@ -309,41 +309,48 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="2"> <item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_UseLobbyChat"> <widget class="QCheckBox" name="checkBox_UseLobbyChat">
<property name="text"> <property name="text">
<string>Show lobby chat</string> <string>Show lobby chat</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_enableBetInputFocusSwitch"> <widget class="QCheckBox" name="checkBox_enableBetInputFocusSwitch">
<property name="text"> <property name="text">
<string>Switch keyboard focus to bet-input-field if it's your turn</string> <string>Switch keyboard focus to bet-input-field if it's your turn</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_enableAccidentallyCallBlocker"> <widget class="QCheckBox" name="checkBox_enableAccidentallyCallBlocker">
<property name="text"> <property name="text">
<string>Activate the &quot;accidentally call after big raise&quot; blocker</string> <string>Activate the &quot;accidentally call after big raise&quot; blocker</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_dontHideAvatarsOfIgnored"> <widget class="QCheckBox" name="checkBox_dontHideAvatarsOfIgnored">
<property name="text"> <property name="text">
<string>Do not hide avatars of players which are on the ignore list</string> <string>Do not hide avatars of players which are on the ignore list</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="6" column="0">
<widget class="QCheckBox" name="checkBox_disableChatEmoticons"> <widget class="QCheckBox" name="checkBox_disableChatEmoticons">
<property name="text"> <property name="text">
<string>Disable emoticons in the chat</string> <string>Disable emoticons in the chat</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_showPingStateInAvatar">
<property name="text">
<string>Show multicolor network state display in the corner of the avatar</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
@@ -287,6 +287,7 @@ void settingsDialogImpl::prepareDialog()
checkBox_showFlipCardsAnimation->setChecked(myConfig->readConfigInt("ShowFlipCardsAnimation")); checkBox_showFlipCardsAnimation->setChecked(myConfig->readConfigInt("ShowFlipCardsAnimation"));
checkBox_showBlindButtons->setChecked(myConfig->readConfigInt("ShowBlindButtons")); checkBox_showBlindButtons->setChecked(myConfig->readConfigInt("ShowBlindButtons"));
checkBox_showCountryFlagInAvatar->setChecked(myConfig->readConfigInt("ShowCountryFlagInAvatar")); checkBox_showCountryFlagInAvatar->setChecked(myConfig->readConfigInt("ShowCountryFlagInAvatar"));
checkBox_showPingStateInAvatar->setChecked(myConfig->readConfigInt("ShowPingStateInAvatar"));
checkBox_antiPeekMode->setChecked(myConfig->readConfigInt("AntiPeekMode")); checkBox_antiPeekMode->setChecked(myConfig->readConfigInt("AntiPeekMode"));
checkBox_enableBetInputFocusSwitch->setChecked(myConfig->readConfigInt("EnableBetInputFocusSwitch")); checkBox_enableBetInputFocusSwitch->setChecked(myConfig->readConfigInt("EnableBetInputFocusSwitch"));
checkBox_cardsChanceMonitor->setChecked(myConfig->readConfigInt("ShowCardsChanceMonitor")); checkBox_cardsChanceMonitor->setChecked(myConfig->readConfigInt("ShowCardsChanceMonitor"));
@@ -738,6 +739,7 @@ void settingsDialogImpl::isAccepted()
myConfig->writeConfigInt("ShowCardsChanceMonitor", checkBox_cardsChanceMonitor->isChecked()); myConfig->writeConfigInt("ShowCardsChanceMonitor", checkBox_cardsChanceMonitor->isChecked());
myConfig->writeConfigInt("AntiPeekMode", checkBox_antiPeekMode->isChecked()); myConfig->writeConfigInt("AntiPeekMode", checkBox_antiPeekMode->isChecked());
myConfig->writeConfigInt("ShowCountryFlagInAvatar", checkBox_showCountryFlagInAvatar->isChecked()); myConfig->writeConfigInt("ShowCountryFlagInAvatar", checkBox_showCountryFlagInAvatar->isChecked());
myConfig->writeConfigInt("ShowPingStateInAvatar", checkBox_showPingStateInAvatar->isChecked());
myConfig->writeConfigInt("DontTranslateInternationalPokerStringsFromStyle", checkBox_dontTranslatePokerStrings->isChecked()); myConfig->writeConfigInt("DontTranslateInternationalPokerStringsFromStyle", checkBox_dontTranslatePokerStrings->isChecked());
myConfig->writeConfigInt("DisableSplashScreenOnStartup", checkBox_disableSplashscreen->isChecked()); myConfig->writeConfigInt("DisableSplashScreenOnStartup", checkBox_disableSplashscreen->isChecked());
myConfig->writeConfigInt("EnableBetInputFocusSwitch", checkBox_enableBetInputFocusSwitch->isChecked()); myConfig->writeConfigInt("EnableBetInputFocusSwitch", checkBox_enableBetInputFocusSwitch->isChecked());