[vlc-commits] Qt4: correctly save the keys, indepententy from the locale

Jean-Baptiste Kempf git at videolan.org
Sat Sep 28 21:15:30 CEST 2013


vlc/vlc-2.1 | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sat Sep 28 20:58:55 2013 +0200| [e64801b6bc6e85030fc447d52908e54da6c0d1c2] | committer: Jean-Baptiste Kempf

Qt4: correctly save the keys, indepententy from the locale

(cherry picked from commit 2d37a070d7a92f15fb3d0aa60365593622f92beb)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/gui/qt4/components/preferences_widgets.cpp |   14 +++++++-------
 modules/gui/qt4/util/customwidgets.cpp             |    4 ++--
 modules/gui/qt4/util/customwidgets.hpp             |    2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/modules/gui/qt4/components/preferences_widgets.cpp b/modules/gui/qt4/components/preferences_widgets.cpp
index 1bf57c2..8af40af 100644
--- a/modules/gui/qt4/components/preferences_widgets.cpp
+++ b/modules/gui/qt4/components/preferences_widgets.cpp
@@ -1228,11 +1228,11 @@ void KeySelectorControl::finish()
             treeItem->setData( ACTION_COL, Qt::UserRole,
                                QVariant( qfu( p_config_item->psz_name ) ) );
 
-            QString keys = qfu( p_config_item->value.psz );
+            QString keys = qfu(p_config_item->value.psz ? _(p_config_item->value.psz) : "");
             treeItem->setText( HOTKEY_COL, keys );
             treeItem->setToolTip( HOTKEY_COL, qtr("Double click to change.\nDelete key to remove.") );
             treeItem->setToolTip( GLOBAL_HOTKEY_COL, qtr("Double click to change.\nDelete key to remove.") );
-            treeItem->setData( HOTKEY_COL, Qt::UserRole, QVariant( keys ) );
+            treeItem->setData( HOTKEY_COL, Qt::UserRole, QVariant( p_config_item->value.psz ) );
             table->addTopLevelItem( treeItem );
             continue;
         }
@@ -1313,7 +1313,7 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
 
     if( d->result() == QDialog::Accepted )
     {
-        QString newKey = VLCKeyToString( d->keyValue );
+        QString newKey = VLCKeyToString( d->keyValue, false );
 
         /* In case of conflict, reset other keys*/
         if( d->conflicts )
@@ -1331,7 +1331,7 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
             }
         }
 
-        keyItem->setText( column, newKey );
+        keyItem->setText( column, VLCKeyToString( d->keyValue, true ) );
         keyItem->setData( column, Qt::UserRole, newKey );
     }
     else if( d->result() == 2 )
@@ -1448,7 +1448,7 @@ void KeyInputDialog::setExistingkeysSet( const QSet<QString> *keyset )
 void KeyInputDialog::checkForConflicts( int i_vlckey, const QString &sequence )
 {
     QList<QTreeWidgetItem *> conflictList =
-        table->findItems( VLCKeyToString( i_vlckey ), Qt::MatchExactly,
+        table->findItems( VLCKeyToString( i_vlckey, true ), Qt::MatchExactly,
                           b_global ? 2 : 1 );
 
     if( conflictList.count() &&
@@ -1491,7 +1491,7 @@ void KeyInputDialog::keyPressEvent( QKeyEvent *e )
     int i_vlck = qtEventToVLCKey( e );
     QKeySequence sequence( e->key() | e->modifiers() );
     selected->setText( qtr( "Key or combination: " )
-                + QString("<b>%1</b>").arg( VLCKeyToString( i_vlck ) ) );
+                + QString("<b>%1</b>").arg( VLCKeyToString( i_vlck, true ) ) );
     checkForConflicts( i_vlck, sequence.toString() );
     keyValue = i_vlck;
 }
@@ -1499,7 +1499,7 @@ void KeyInputDialog::keyPressEvent( QKeyEvent *e )
 void KeyInputDialog::wheelEvent( QWheelEvent *e )
 {
     int i_vlck = qtWheelEventToVLCKey( e );
-    selected->setText( qtr( "Key: " ) + VLCKeyToString( i_vlck ) );
+    selected->setText( qtr( "Key: " ) + VLCKeyToString( i_vlck, true ) );
     checkForConflicts( i_vlck, QString() );
     keyValue = i_vlck;
 }
diff --git a/modules/gui/qt4/util/customwidgets.cpp b/modules/gui/qt4/util/customwidgets.cpp
index 1a00fe0..775218b 100644
--- a/modules/gui/qt4/util/customwidgets.cpp
+++ b/modules/gui/qt4/util/customwidgets.cpp
@@ -287,9 +287,9 @@ int qtWheelEventToVLCKey( QWheelEvent *e )
     return i_vlck;
 }
 
-QString VLCKeyToString( unsigned val )
+QString VLCKeyToString( unsigned val, bool locale )
 {
-    char *base = vlc_keycode2str (val, true);
+    char *base = vlc_keycode2str (val, locale);
     if (base == NULL)
         return qtr( "Unset" );
 
diff --git a/modules/gui/qt4/util/customwidgets.hpp b/modules/gui/qt4/util/customwidgets.hpp
index e7ccf46..37fce1d 100644
--- a/modules/gui/qt4/util/customwidgets.hpp
+++ b/modules/gui/qt4/util/customwidgets.hpp
@@ -167,6 +167,6 @@ class QInputEvent;
 int qtKeyModifiersToVLC( QInputEvent* e );
 int qtEventToVLCKey( QKeyEvent *e );
 int qtWheelEventToVLCKey( QWheelEvent *e );
-QString VLCKeyToString( unsigned val );
+QString VLCKeyToString( unsigned val, bool );
 
 #endif



More information about the vlc-commits mailing list