GH-894 link server status widgets to help.mojang.com

This commit is contained in:
Petr Mrázek 2015-04-19 17:58:53 +02:00
parent c7c81463fd
commit 4f417d527e
2 changed files with 57 additions and 2 deletions

View File

@ -11,6 +11,49 @@
#include <QMap>
#include <QToolButton>
#include <QAction>
#include <QDesktopServices>
class ClickableLabel : public QLabel
{
Q_OBJECT
public:
ClickableLabel(QWidget *parent) : QLabel(parent)
{
setCursor(Qt::PointingHandCursor);
}
~ClickableLabel(){};
signals:
void clicked();
protected:
void mousePressEvent(QMouseEvent *event)
{
emit clicked();
}
};
class ClickableIconLabel : public IconLabel
{
Q_OBJECT
public:
ClickableIconLabel(QWidget *parent, QIcon icon, QSize size) : IconLabel(parent, icon, size)
{
setCursor(Qt::PointingHandCursor);
}
~ClickableIconLabel(){};
signals:
void clicked();
protected:
void mousePressEvent(QMouseEvent *event)
{
emit clicked();
}
};
ServerStatus::ServerStatus(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)
{
@ -67,19 +110,26 @@ void ServerStatus::addLine()
void ServerStatus::addStatus(QString key, QString name)
{
{
auto label = new IconLabel(this, badIcon, QSize(16, 16));
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 QLabel(this);
auto label = new ClickableLabel(this);
label->setText(name);
label->setToolTip(key);
layout->addWidget(label);
connect(label,SIGNAL(clicked()),SLOT(clicked()));
}
}
void ServerStatus::clicked()
{
QDesktopServices::openUrl(QUrl("https://help.mojang.com/"));
}
void ServerStatus::setStatus(QString key, int value)
{
if (!serverLabels.contains(key))
@ -127,3 +177,5 @@ void ServerStatus::StatusReloading(bool is_reloading)
{
m_statusRefresh->setChecked(is_reloading);
}
#include "ServerStatus.moc"

View File

@ -22,6 +22,9 @@ public slots:
void StatusChanged(const QMap<QString, QString> statuses);
void StatusReloading(bool is_reloading);
private slots:
void clicked();
private: /* methods */
void addLine();
void addStatus(QString key, QString name);