]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/util/customwidgets.cpp
Qt: respect font sizes
[vlc] / modules / gui / qt4 / util / customwidgets.cpp
index a99456d4dbf536828f7eaa831f91dbe20e32933a..26e808f9411ce2a88a5de19f02a21547dbc723d7 100644 (file)
@@ -208,6 +208,25 @@ void SearchLineEdit::paintEvent( QPaintEvent *event )
   painter.drawText( rect, Qt::AlignLeft | Qt::AlignVCenter, qtr( I_PL_FILTER ) );
 }
 
+
+QVLCElidingLabel::QVLCElidingLabel( const QString &s, Qt::TextElideMode mode, QWidget * parent )
+  : elideMode( mode ), QLabel( s, parent )
+{ }
+
+void QVLCElidingLabel::setElideMode( Qt::TextElideMode mode )
+{
+    elideMode = mode;
+    repaint();
+}
+
+void QVLCElidingLabel::paintEvent( QPaintEvent * event )
+{
+    QPainter p( this );
+    int space = frameWidth() + margin();
+    QRect r = rect().adjusted( space, space, -space, -space );
+    p.drawText( r, fontMetrics().elidedText( text(), elideMode, r.width() ), alignment() );
+}
+
 /***************************************************************************
  * Hotkeys converters
  ***************************************************************************/