]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/util/customwidgets.cpp
Qt: equalizer, fix the "too much space between preamp and first slider" bug
[vlc] / modules / gui / qt4 / util / customwidgets.cpp
index 5a509d435c8e6d7e6e76b7c5d601e8b4ea81dabf..a83d94dbd9e44510cdcda725238805069f0e4fa7 100644 (file)
@@ -109,7 +109,7 @@ QVLCFramelessButton::QVLCFramelessButton( QWidget *parent )
     setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
 }
 
-void QVLCFramelessButton::paintEvent( QPaintEvent * event )
+void QVLCFramelessButton::paintEvent( QPaintEvent * )
 {
     QPainter painter( this );
     QPixmap pix = icon().pixmap( size() );
@@ -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
  ***************************************************************************/
@@ -256,7 +275,19 @@ static const vlc_qt_key_t keys[] =
     // Qt::Key_CapsLock
     // Qt::Key_NumLock
     // Qt::Key_ScrollLock
-    /* F1 - F35 */
+    /* F1 - F35 - Qt goes to F35, VLC stops at F12 */
+    { Qt::Key_F1,                    KEY_F1 },
+    { Qt::Key_F2,                    KEY_F2 },
+    { Qt::Key_F3,                    KEY_F3 },
+    { Qt::Key_F4,                    KEY_F4 },
+    { Qt::Key_F5,                    KEY_F5 },
+    { Qt::Key_F6,                    KEY_F6 },
+    { Qt::Key_F7,                    KEY_F7 },
+    { Qt::Key_F8,                    KEY_F8 },
+    { Qt::Key_F9,                    KEY_F9 },
+    { Qt::Key_F10,                   KEY_F10 },
+    { Qt::Key_F11,                   KEY_F11 },
+    { Qt::Key_F12,                   KEY_F12 },
     // Qt::Key_Super_L
     // Qt::Key_Super_R
     { Qt::Key_Menu,                  KEY_MENU },
@@ -361,14 +392,11 @@ int qtEventToVLCKey( QKeyEvent *e )
 
     if( qtk <= 0xff )
         /* VLC and X11 use lowercase whereas Qt uses uppercase */
-#ifdef __STDC_ISO_10646__
+#if defined( __STDC_ISO_10646__ ) || defined( _WIN32 ) || defined( __APPLE__ )
         i_vlck = towlower( qtk );
 #else
 # error FIXME
 #endif
-    else /* Qt and X11 go to F35, but VLC stops at F12 */
-    if( qtk >= Qt::Key_F1 && qtk <= Qt::Key_F12 )
-        i_vlck = qtk - Qt::Key_F1 + KEY_F1;
     else
     {
         const vlc_qt_key_t *map;
@@ -408,6 +436,8 @@ QString VLCKeyToString( int val )
         r+= qfu( "Alt+" );
     if( val & KEY_MODIFIER_SHIFT )
         r+= qfu( "Shift+" );
+    if( val & KEY_MODIFIER_META )
+        r+= qfu( "Meta+" );
 
     if (base)
     {