elidedlabel.hh (956B)
1 #ifndef __GUCK__BROWSER__STATUSBAR__ELIDEDLABEL__GUARD__ 2 #define __GUCK__BROWSER__STATUSBAR__ELIDEDLABEL__GUARD__ 3 4 #include <QFrame> 5 6 7 // https://doc.qt.io/qt-5/qtwidgets-widgets-elidedlabel-example.html 8 class elidedlabel_t : public QFrame 9 { 10 Q_OBJECT 11 Q_PROPERTY(QString text READ text WRITE setText) 12 Q_PROPERTY(bool isElided READ isElided) 13 14 public: 15 explicit elidedlabel_t(QWidget& parent, const QString& text = "") 16 : QFrame(&parent), 17 m_content(text), 18 m_elided(false) 19 { 20 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); 21 } 22 23 void setText(const QString&); 24 25 inline const QString& text() const { return m_content; } 26 inline bool isElided() const { return m_elided; } 27 28 protected: 29 void paintEvent(QPaintEvent*) override; 30 31 signals: 32 void elisionChanged(bool); 33 34 private: 35 QString m_content; 36 bool m_elided; 37 38 }; 39 40 #endif//__GUCK__BROWSER__STATUSBAR__ELIDEDLABEL__GUARD__