diff options
author | Petr Mrázek <peterix@gmail.com> | 2018-07-15 14:51:05 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2018-07-15 14:51:05 +0200 |
commit | bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9 (patch) | |
tree | e6497e304b7b9368367565fbc7c06efab1124b1c /application/widgets/ServerStatus.cpp | |
parent | 03280cc62e75f8073f8d3d9e9e3952acf21fa77d (diff) | |
download | MultiMC-bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9.tar MultiMC-bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9.tar.gz MultiMC-bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9.tar.lz MultiMC-bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9.tar.xz MultiMC-bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9.zip |
NOISSUE tabs -> spaces
Diffstat (limited to 'application/widgets/ServerStatus.cpp')
-rw-r--r-- | application/widgets/ServerStatus.cpp | 214 |
1 files changed, 107 insertions, 107 deletions
diff --git a/application/widgets/ServerStatus.cpp b/application/widgets/ServerStatus.cpp index f1963b68..a7016c0c 100644 --- a/application/widgets/ServerStatus.cpp +++ b/application/widgets/ServerStatus.cpp @@ -15,80 +15,80 @@ class ClickableLabel : public QLabel { - Q_OBJECT + Q_OBJECT public: - ClickableLabel(QWidget *parent) : QLabel(parent) - { - setCursor(Qt::PointingHandCursor); - } + ClickableLabel(QWidget *parent) : QLabel(parent) + { + setCursor(Qt::PointingHandCursor); + } - ~ClickableLabel(){}; + ~ClickableLabel(){}; signals: - void clicked(); + void clicked(); protected: - void mousePressEvent(QMouseEvent *event) - { - emit clicked(); - } + void mousePressEvent(QMouseEvent *event) + { + emit clicked(); + } }; class ClickableIconLabel : public IconLabel { - Q_OBJECT + Q_OBJECT public: - ClickableIconLabel(QWidget *parent, QIcon icon, QSize size) : IconLabel(parent, icon, size) - { - setCursor(Qt::PointingHandCursor); - } + ClickableIconLabel(QWidget *parent, QIcon icon, QSize size) : IconLabel(parent, icon, size) + { + setCursor(Qt::PointingHandCursor); + } - ~ClickableIconLabel(){}; + ~ClickableIconLabel(){}; signals: - void clicked(); + void clicked(); protected: - void mousePressEvent(QMouseEvent *event) - { - emit clicked(); - } + void mousePressEvent(QMouseEvent *event) + { + emit clicked(); + } }; ServerStatus::ServerStatus(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) { - layout = new QHBoxLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - goodIcon = MMC->getThemedIcon("status-good"); - yellowIcon = MMC->getThemedIcon("status-yellow"); - badIcon = MMC->getThemedIcon("status-bad"); - - addStatus("authserver.mojang.com", tr("Auth")); - addLine(); - addStatus("sessionserver.mojang.com", tr("Session")); - addLine(); - addStatus("textures.minecraft.net", tr("Skins")); - addLine(); - addStatus("api.mojang.com", tr("API")); - - m_statusRefresh = new QToolButton(this); - m_statusRefresh->setCheckable(true); - m_statusRefresh->setToolButtonStyle(Qt::ToolButtonIconOnly); - m_statusRefresh->setIcon(MMC->getThemedIcon("refresh")); - layout->addWidget(m_statusRefresh); - - setLayout(layout); - - // Start status checker - m_statusChecker.reset(new StatusChecker()); - { - auto reloader = m_statusChecker.get(); - connect(reloader, &StatusChecker::statusChanged, this, &ServerStatus::StatusChanged); - connect(reloader, &StatusChecker::statusLoading, this, &ServerStatus::StatusReloading); - connect(m_statusRefresh, &QAbstractButton::clicked, this, &ServerStatus::reloadStatus); - m_statusChecker->startTimer(60000); - reloadStatus(); - } + layout = new QHBoxLayout(this); + layout->setContentsMargins(0, 0, 0, 0); + goodIcon = MMC->getThemedIcon("status-good"); + yellowIcon = MMC->getThemedIcon("status-yellow"); + badIcon = MMC->getThemedIcon("status-bad"); + + addStatus("authserver.mojang.com", tr("Auth")); + addLine(); + addStatus("sessionserver.mojang.com", tr("Session")); + addLine(); + addStatus("textures.minecraft.net", tr("Skins")); + addLine(); + addStatus("api.mojang.com", tr("API")); + + m_statusRefresh = new QToolButton(this); + m_statusRefresh->setCheckable(true); + m_statusRefresh->setToolButtonStyle(Qt::ToolButtonIconOnly); + m_statusRefresh->setIcon(MMC->getThemedIcon("refresh")); + layout->addWidget(m_statusRefresh); + + setLayout(layout); + + // Start status checker + m_statusChecker.reset(new StatusChecker()); + { + auto reloader = m_statusChecker.get(); + connect(reloader, &StatusChecker::statusChanged, this, &ServerStatus::StatusChanged); + connect(reloader, &StatusChecker::statusLoading, this, &ServerStatus::StatusReloading); + connect(m_statusRefresh, &QAbstractButton::clicked, this, &ServerStatus::reloadStatus); + m_statusChecker->startTimer(60000); + reloadStatus(); + } } ServerStatus::~ServerStatus() @@ -97,83 +97,83 @@ ServerStatus::~ServerStatus() void ServerStatus::reloadStatus() { - m_statusChecker->reloadStatus(); + m_statusChecker->reloadStatus(); } void ServerStatus::addLine() { - layout->addWidget(new LineSeparator(this, Qt::Vertical)); + layout->addWidget(new LineSeparator(this, Qt::Vertical)); } void ServerStatus::addStatus(QString key, QString name) { - { - auto label = new ClickableIconLabel(this, badIcon, QSize(16, 16)); - label->setToolTip(key); - serverLabels[key] = label; - layout->addWidget(label); - connect(label,SIGNAL(clicked()),SLOT(clicked())); - } - { - auto label = new ClickableLabel(this); - label->setText(name); - label->setToolTip(key); - layout->addWidget(label); - connect(label,SIGNAL(clicked()),SLOT(clicked())); - } + { + auto label = new ClickableIconLabel(this, badIcon, QSize(16, 16)); + label->setToolTip(key); + serverLabels[key] = label; + layout->addWidget(label); + connect(label,SIGNAL(clicked()),SLOT(clicked())); + } + { + auto label = new ClickableLabel(this); + label->setText(name); + label->setToolTip(key); + layout->addWidget(label); + connect(label,SIGNAL(clicked()),SLOT(clicked())); + } } void ServerStatus::clicked() { - DesktopServices::openUrl(QUrl("https://help.mojang.com/")); + DesktopServices::openUrl(QUrl("https://help.mojang.com/")); } void ServerStatus::setStatus(QString key, int value) { - if (!serverLabels.contains(key)) - return; - IconLabel *label = serverLabels[key]; - switch(value) - { - case 0: - label->setIcon(goodIcon); - break; - case 1: - label->setIcon(yellowIcon); - break; - default: - case 2: - label->setIcon(badIcon); - break; - } + if (!serverLabels.contains(key)) + return; + IconLabel *label = serverLabels[key]; + 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)->int - { - if (status == "green") - return 0; - else if (status == "yellow") - return 1; - else if (status == "red") - return 2; - return 2; - } - ; - auto iter = statusEntries.begin(); - while (iter != statusEntries.end()) - { - QString key = iter.key(); - auto value = convertStatus(iter.value()); - setStatus(key, value); - iter++; - } + auto convertStatus = [&](QString status)->int + { + if (status == "green") + return 0; + else if (status == "yellow") + return 1; + else if (status == "red") + return 2; + return 2; + } + ; + auto iter = statusEntries.begin(); + while (iter != statusEntries.end()) + { + QString key = iter.key(); + auto value = convertStatus(iter.value()); + setStatus(key, value); + iter++; + } } void ServerStatus::StatusReloading(bool is_reloading) { - m_statusRefresh->setChecked(is_reloading); + m_statusRefresh->setChecked(is_reloading); } #include "ServerStatus.moc" |