From 927217c7f06017db23b232f055dd5343e39d871f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 15 May 2014 22:32:54 +0200 Subject: Status pills. This doesn't build yet. --- gui/MainWindow.cpp | 77 ++---------------------------------------------------- 1 file changed, 2 insertions(+), 75 deletions(-) (limited to 'gui/MainWindow.cpp') diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 58491a7e..725bf175 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -47,6 +47,7 @@ #include "gui/Platform.h" #include "gui/widgets/LabeledToolButton.h" +#include "widgets/ServerStatus.h" #include "gui/dialogs/SettingsDialog.h" #include "gui/dialogs/NewInstanceDialog.h" @@ -216,29 +217,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi connect(MMC->instances().get(), SIGNAL(dataIsInvalid()), SLOT(selectionBad())); m_statusLeft = new QLabel(tr("No instance selected"), this); - m_statusRight = new QLabel(tr("No status available"), this); - m_statusRefresh = new QToolButton(this); - m_statusRefresh->setCheckable(true); - m_statusRefresh->setToolButtonStyle(Qt::ToolButtonIconOnly); - m_statusRefresh->setIcon(QIcon::fromTheme("refresh")); - + m_statusRight = new ServerStatus(this); statusBar()->addPermanentWidget(m_statusLeft, 1); statusBar()->addPermanentWidget(m_statusRight, 0); - statusBar()->addPermanentWidget(m_statusRefresh, 0); - - // Start status checker - { - connect(MMC->statusChecker().get(), &StatusChecker::statusLoaded, this, - &MainWindow::updateStatusUI); - connect(MMC->statusChecker().get(), &StatusChecker::statusLoadingFailed, this, - &MainWindow::updateStatusFailedUI); - - connect(m_statusRefresh, &QAbstractButton::clicked, this, &MainWindow::reloadStatus); - connect(&statusTimer, &QTimer::timeout, this, &MainWindow::reloadStatus); - statusTimer.setSingleShot(true); - - reloadStatus(); - } // Add "manage accounts" button, right align QWidget *spacer = new QWidget(); @@ -620,60 +601,6 @@ void MainWindow::updateNewsLabel() } } -static QString convertStatus(const QString &status) -{ - QString ret = "?"; - - if (status == "green") - ret = "↑"; - else if (status == "yellow") - ret = "-"; - else if (status == "red") - ret = "↓"; - - return "" + ret + ""; -} - -void MainWindow::reloadStatus() -{ - m_statusRefresh->setChecked(true); - MMC->statusChecker()->reloadStatus(); - // updateStatusUI(); -} - -static QString makeStatusString(const QMap statuses) -{ - QString status = ""; - status += "Web: " + convertStatus(statuses["minecraft.net"]); - status += " Account: " + convertStatus(statuses["account.mojang.com"]); - status += " Skins: " + convertStatus(statuses["skins.minecraft.net"]); - status += " Auth: " + convertStatus(statuses["authserver.mojang.com"]); - status += " Session: " + convertStatus(statuses["sessionserver.mojang.com"]); - - return status; -} - -void MainWindow::updateStatusUI() -{ - auto statusChecker = MMC->statusChecker(); - auto statuses = statusChecker->getStatusEntries(); - - QString status = makeStatusString(statuses); - m_statusRefresh->setChecked(false); - - m_statusRight->setText(status); - - statusTimer.start(60 * 1000); -} - -void MainWindow::updateStatusFailedUI() -{ - m_statusRight->setText(makeStatusString(QMap())); - m_statusRefresh->setChecked(false); - - statusTimer.start(60 * 1000); -} - void MainWindow::updateAvailable(QString repo, QString versionName, int versionId) { UpdateDialog dlg; -- cgit v1.2.3