diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-04-19 17:58:53 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-04-19 17:58:53 +0200 |
commit | 4f417d527e8cf39d2c7653d80f1aade9155827de (patch) | |
tree | 13017a2ae3609504e804e6640f66cbe213e78b48 /application/widgets | |
parent | c7c81463fd3ab01c9e096f75e7e8ad8b50902a98 (diff) | |
download | MultiMC-4f417d527e8cf39d2c7653d80f1aade9155827de.tar MultiMC-4f417d527e8cf39d2c7653d80f1aade9155827de.tar.gz MultiMC-4f417d527e8cf39d2c7653d80f1aade9155827de.tar.lz MultiMC-4f417d527e8cf39d2c7653d80f1aade9155827de.tar.xz MultiMC-4f417d527e8cf39d2c7653d80f1aade9155827de.zip |
GH-894 link server status widgets to help.mojang.com
Diffstat (limited to 'application/widgets')
-rw-r--r-- | application/widgets/ServerStatus.cpp | 56 | ||||
-rw-r--r-- | application/widgets/ServerStatus.h | 3 |
2 files changed, 57 insertions, 2 deletions
diff --git a/application/widgets/ServerStatus.cpp b/application/widgets/ServerStatus.cpp index 0c11b9bf..f0a7f97a 100644 --- a/application/widgets/ServerStatus.cpp +++ b/application/widgets/ServerStatus.cpp @@ -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" diff --git a/application/widgets/ServerStatus.h b/application/widgets/ServerStatus.h index fdd43677..f0b6e223 100644 --- a/application/widgets/ServerStatus.h +++ b/application/widgets/ServerStatus.h @@ -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); |