summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/widgets/ServerStatus.cpp29
-rw-r--r--gui/widgets/ServerStatus.h3
2 files changed, 23 insertions, 9 deletions
diff --git a/gui/widgets/ServerStatus.cpp b/gui/widgets/ServerStatus.cpp
index 10ed79fb..3b02fd24 100644
--- a/gui/widgets/ServerStatus.cpp
+++ b/gui/widgets/ServerStatus.cpp
@@ -17,6 +17,7 @@ ServerStatus::ServerStatus(QWidget *parent, Qt::WindowFlags f) : QWidget(parent,
layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
goodIcon = QIcon::fromTheme("status-good");
+ yellowIcon = QIcon::fromTheme("status-yellow");
badIcon = QIcon::fromTheme("status-bad");
addStatus("minecraft.net", tr("Web"));
@@ -78,32 +79,44 @@ void ServerStatus::addStatus(QString key, QString name)
}
}
-void ServerStatus::setStatus(QString key, bool value)
+void ServerStatus::setStatus(QString key, int value)
{
if (!serverLabels.contains(key))
return;
IconLabel *label = serverLabels[key];
- label->setIcon(value ? goodIcon : badIcon);
+ switch(value)
+ {
+ case 0:
+ label->setIcon(goodIcon);
+ break;
+ case 1:
+ label->setIcon(yellowIcon);
+ break;
+ default:
+ case 2:
+ label->setIcon(badIcon);
+ break;
+ }
}
void ServerStatus::StatusChanged(const QMap<QString, QString> statusEntries)
{
- auto convertStatus = [&](QString status)->bool
+ auto convertStatus = [&](QString status)->int
{
if (status == "green")
- return true;
+ return 0;
else if (status == "yellow")
- return false;
+ return 1;
else if (status == "red")
- return false;
- return false;
+ return 2;
+ return 2;
}
;
auto iter = statusEntries.begin();
while (iter != statusEntries.end())
{
QString key = iter.key();
- bool value = convertStatus(iter.value());
+ auto value = convertStatus(iter.value());
setStatus(key, value);
iter++;
}
diff --git a/gui/widgets/ServerStatus.h b/gui/widgets/ServerStatus.h
index 2244031b..1c6ae428 100644
--- a/gui/widgets/ServerStatus.h
+++ b/gui/widgets/ServerStatus.h
@@ -24,11 +24,12 @@ public slots:
private: /* methods */
void addLine();
void addStatus(QString key, QString name);
- void setStatus(QString key, bool value);
+ void setStatus(QString key, int value);
private: /* data */
QHBoxLayout * layout = nullptr;
QToolButton *m_statusRefresh = nullptr;
QMap<QString, IconLabel *> serverLabels;
QIcon goodIcon;
+ QIcon yellowIcon;
QIcon badIcon;
};