[vlc-commits] Qt, recents: elipse on the left the mrl

Jean-Baptiste Kempf git at videolan.org
Mon May 9 23:20:55 CEST 2011


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon May  9 23:19:39 2011 +0200| [7e1526b90947a146aa963e92f8a7326b6a697712] | committer: Jean-Baptiste Kempf

Qt, recents: elipse on the left the mrl

First, I ain't sure we should display the mrl and not a "nice version of it"
Then I ain't sure that we should elipse on the left...
But, this is a beginning... Improvements welcome.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7e1526b90947a146aa963e92f8a7326b6a697712
---

 modules/gui/qt4/recents.cpp |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/modules/gui/qt4/recents.cpp b/modules/gui/qt4/recents.cpp
index 5112c99..dd4c57d 100644
--- a/modules/gui/qt4/recents.cpp
+++ b/modules/gui/qt4/recents.cpp
@@ -31,6 +31,7 @@
 #include <QSettings>
 #include <QRegExp>
 #include <QSignalMapper>
+#include <QFontMetrics>
 
 #ifdef WIN32
     #include <shlobj.h>
@@ -42,7 +43,7 @@
         SHARD_APPIDINFOIDLIST   = 0x00000005,
         SHARD_LINK              = 0x00000006,
         SHARD_APPIDINFOLINK     = 0x00000007,
-        SHARD_SHELLITEM         = 0x00000008 
+        SHARD_SHELLITEM         = 0x00000008
     } SHARD; */
     #define SHARD_PATHW 0x00000003
 #endif
@@ -90,8 +91,9 @@ void RecentsMRL::addRecent( const QString &mrl )
     /* Add to the Windows 7 default list in taskbar */
     SHAddToRecentDocs( SHARD_PATHW, qtu( mrl ) );
 #endif
+    QString mrl2 = QApplication::fontMetrics().elidedText( mrl, Qt::ElideLeft, 400 );
 
-    int i_index = stack->indexOf( mrl );
+    int i_index = stack->indexOf( mrl2 );
     if( 0 <= i_index )
     {
         /* move to the front */
@@ -99,7 +101,7 @@ void RecentsMRL::addRecent( const QString &mrl )
     }
     else
     {
-        stack->prepend( mrl );
+        stack->prepend( mrl2 );
         if( stack->size() > RECENTS_LIST_SIZE )
             stack->takeLast();
     }



More information about the vlc-commits mailing list