Mercurial > hg > easyhg
diff src/clickablelabel.h @ 523:d869e6a18f63
Make the text labels in the work status area squeezable for small window sizes. Fixes #329
author | Chris Cannam |
---|---|
date | Tue, 15 Nov 2011 16:02:18 +0000 |
parents | b9c153e00e84 |
children | 533519ebc0cb |
line wrap: on
line diff
--- a/src/clickablelabel.h Tue Nov 15 14:47:19 2011 +0000 +++ b/src/clickablelabel.h Tue Nov 15 16:02:18 2011 +0000 @@ -18,9 +18,11 @@ #ifndef _CLICKABLE_LABEL_H_ #define _CLICKABLE_LABEL_H_ -#include <QLabel> +#include "squeezedlabel.h" -class ClickableLabel : public QLabel +#include <QMouseEvent> + +class ClickableLabel : public SqueezedLabel { Q_OBJECT @@ -28,12 +30,12 @@ public: ClickableLabel(const QString &text, QWidget *parent = 0) : - QLabel(text, parent), + SqueezedLabel(text, parent), m_naturalText(text) { } ClickableLabel(QWidget *parent = 0) : - QLabel(parent) + SqueezedLabel(parent) { } ~ClickableLabel() @@ -41,7 +43,7 @@ void setText(const QString &t) { m_naturalText = t; - QLabel::setText(t); + SqueezedLabel::setText(t); } bool mouseUnderline() const { @@ -62,18 +64,22 @@ protected: virtual void enterEvent(QEvent *) { if (m_mouseUnderline) { - QLabel::setText(tr("<u>%1</u>").arg(m_naturalText)); + SqueezedLabel::setText(tr("<u>%1</u>").arg(m_naturalText)); } } virtual void leaveEvent(QEvent *) { if (m_mouseUnderline) { - QLabel::setText(m_naturalText); + SqueezedLabel::setText(m_naturalText); } } - virtual void mousePressEvent(QMouseEvent *) { - emit clicked(); + virtual void mousePressEvent(QMouseEvent *ev) { + if (ev->button() == Qt::LeftButton) { + emit clicked(); + } else { + SqueezedLabel::mousePressEvent(ev); + } } private: