[vlc-commits] Merge ConfigKeyToString and KeyToString

Rémi Denis-Courmont git at videolan.org
Thu Feb 10 19:21:26 CET 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Feb 10 20:01:54 2011 +0200| [c810198e17bfe07f62326eae0fa3161f25e5f848] | committer: Rémi Denis-Courmont

Merge ConfigKeyToString and KeyToString

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

 include/vlc_keys.h                     |    2 +-
 modules/gui/macosx/simple_prefs.m      |    2 +-
 modules/gui/qt4/util/customwidgets.cpp |   24 ++++++------------------
 modules/gui/qt4/util/customwidgets.hpp |    2 +-
 modules/gui/skins2/events/evt_key.cpp  |    2 +-
 src/config/configuration.h             |    1 -
 src/config/file.c                      |    2 +-
 src/config/keys.c                      |   18 +-----------------
 src/libvlccore.sym                     |    2 +-
 9 files changed, 13 insertions(+), 42 deletions(-)

diff --git a/include/vlc_keys.h b/include/vlc_keys.h
index eae13be..700fa2d 100644
--- a/include/vlc_keys.h
+++ b/include/vlc_keys.h
@@ -86,7 +86,7 @@
 #define KEY_MOUSEWHEELLEFT   0x00F20000
 #define KEY_MOUSEWHEELRIGHT  0x00F30000
 
-VLC_EXPORT( char *, KeyToString, (uint_fast32_t i_key) ) LIBVLC_USED;
+VLC_EXPORT( char *, vlc_keycode2str, (uint_fast32_t i_key) ) LIBVLC_USED;
 
 typedef enum vlc_key {
     ACTIONID_NONE = 0,
diff --git a/modules/gui/macosx/simple_prefs.m b/modules/gui/macosx/simple_prefs.m
index ecd955a..c0e08be 100644
--- a/modules/gui/macosx/simple_prefs.m
+++ b/modules/gui/macosx/simple_prefs.m
@@ -87,7 +87,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
     if( val & KEY_MODIFIER_COMMAND )
         [o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x8C\x98"]];
 
-    char *base = KeyToString( val & ~KEY_MODIFIER );
+    char *base = vlc_keycode2str( val & ~KEY_MODIFIER );
     if( base )
     {
         [o_temp_str appendString: [NSString stringWithUTF8String: base]];
diff --git a/modules/gui/qt4/util/customwidgets.cpp b/modules/gui/qt4/util/customwidgets.cpp
index 8ff86c4..8adcae0 100644
--- a/modules/gui/qt4/util/customwidgets.cpp
+++ b/modules/gui/qt4/util/customwidgets.cpp
@@ -285,27 +285,15 @@ int qtWheelEventToVLCKey( QWheelEvent *e )
     return i_vlck;
 }
 
-QString VLCKeyToString( int val )
+QString VLCKeyToString( unsigned val )
 {
-    char *base = KeyToString (val & ~KEY_MODIFIER);
-
-    QString r = "";
-    if( val & KEY_MODIFIER_CTRL )
-        r+= qfu( "Ctrl+" );
-    if( val & KEY_MODIFIER_ALT )
-        r+= qfu( "Alt+" );
-    if( val & KEY_MODIFIER_SHIFT )
-        r+= qfu( "Shift+" );
-    if( val & KEY_MODIFIER_META )
-        r+= qfu( "Meta+" );
-
-    if (base)
-    {
-        r += qfu( base );
-        free( base );
-    }
-    else
-        r += qtr( "Unset" );
+    char *base = vlc_keycode2str (val);
+    if (base == NULL)
+        return qtr( "Unset" );
+
+    QString r = qfu( base );
+
+    free( base );
     return r;
 }
 
diff --git a/modules/gui/qt4/util/customwidgets.hpp b/modules/gui/qt4/util/customwidgets.hpp
index cb8701c..ad16de0 100644
--- a/modules/gui/qt4/util/customwidgets.hpp
+++ b/modules/gui/qt4/util/customwidgets.hpp
@@ -163,7 +163,7 @@ class QInputEvent;
 int qtKeyModifiersToVLC( QInputEvent* e );
 int qtEventToVLCKey( QKeyEvent *e );
 int qtWheelEventToVLCKey( QWheelEvent *e );
-QString VLCKeyToString( int val );
+QString VLCKeyToString( unsigned val );
 
 #endif
 
diff --git a/modules/gui/skins2/events/evt_key.cpp b/modules/gui/skins2/events/evt_key.cpp
index 9cf3467..417b9f0 100644
--- a/modules/gui/skins2/events/evt_key.cpp
+++ b/modules/gui/skins2/events/evt_key.cpp
@@ -39,7 +39,7 @@ const string EvtKey::getAsString() const
         msg_Warn( getIntf(), "Unknown action type" );
 
     // Add the key
-    char *keyName = KeyToString( m_key );
+    char *keyName = vlc_keycode2str( m_key & ~KEY_MODIFIER );
     if( keyName )
     {
         event += (string)":" + keyName;
diff --git a/src/config/configuration.h b/src/config/configuration.h
index ef2080b..98b2a26 100644
--- a/src/config/configuration.h
+++ b/src/config/configuration.h
@@ -50,7 +50,6 @@ static inline int IsConfigFloatType (int type)
 }
 
 uint_fast32_t ConfigStringToKey( const char * );
-char *ConfigKeyToString( uint_fast32_t );
 
 extern vlc_rwlock_t config_lock;
 
diff --git a/src/config/file.c b/src/config/file.c
index a832000..1406b34 100644
--- a/src/config/file.c
+++ b/src/config/file.c
@@ -549,7 +549,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
                 int64_t val = b_retain ? p_item->saved.i : p_item->value.i;
                 if (p_item->i_type == CONFIG_ITEM_KEY)
                 {
-                    char *psz_key = ConfigKeyToString (val);
+                    char *psz_key = vlc_keycode2str (val);
                     config_Write (file, p_item->psz_text, N_("key"),
                                   val == p_item->orig.i,
                                   p_item->psz_name, "%s",
diff --git a/src/config/keys.c b/src/config/keys.c
index 99fe3dc..59fd1ab 100644
--- a/src/config/keys.c
+++ b/src/config/keys.c
@@ -148,22 +148,6 @@ static char *utf8_cp (uint_fast32_t cp, char *buf)
     return buf;
 }
 
-char *KeyToString (uint_fast32_t sym)
-{
-    key_descriptor_t *d;
-
-    d = bsearch ((void *)(uintptr_t)sym, vlc_keys, vlc_num_keys,
-                 sizeof (vlc_keys[0]), cmpkey);
-    if (d)
-        return strdup (d->psz_key_string);
-
-    char buf[5];
-    if (utf8_cp (sym, buf))
-        return strdup (buf);
-
-    return NULL;
-}
-
 uint_fast32_t ConfigStringToKey (const char *name)
 {
     uint_fast32_t mods = 0;
@@ -193,7 +177,7 @@ uint_fast32_t ConfigStringToKey (const char *name)
     return (vlc_towc (name, &cp) > 0) ? (mods | cp) : 0;
 }
 
-char *ConfigKeyToString (uint_fast32_t code)
+char *vlc_keycode2str (uint_fast32_t code)
 {
     char *str, buf[5];
     uintptr_t key = code & ~KEY_MODIFIER;
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index c63fc7a..aacf1ff 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -679,4 +679,4 @@ xml_Delete
 xml_ReaderCreate
 xml_ReaderDelete
 xml_ReaderReset
-KeyToString
+vlc_keycode2str



More information about the vlc-commits mailing list