]> git.sesse.net Git - vlc/commitdiff
Qt: menu, code simplification.
authorJean-Baptiste Kempf <jb@sasmira.jbkempf.com>
Fri, 20 Feb 2009 00:18:22 +0000 (01:18 +0100)
committerJean-Baptiste Kempf <jb@sasmira.jbkempf.com>
Fri, 20 Feb 2009 00:18:22 +0000 (01:18 +0100)
modules/gui/qt4/actions_manager.hpp
modules/gui/qt4/menus.cpp

index 9fa3e886ce9a7cff8221bd9a36590c6ce50cbd22..463edc5fa4c010df620d80a1c27687b50000b614 100644 (file)
@@ -79,8 +79,8 @@ public slots:
     void toggleMuteAudio();
     void AudioUp();
     void AudioDown();
-protected slots:
     void play();
+protected slots:
     void fullscreen();
     void snapshot();
     void playlist();
index a6c2319752f11cae1f99313498879cd617221be6..1db464436366645949d048b292a329a35ae738ba 100644 (file)
@@ -614,6 +614,7 @@ QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
 
     }
 
+    /* */
     input_thread_t *p_object;
     vector<vlc_object_t *> objects;
     vector<const char *> varnames;
@@ -622,15 +623,20 @@ QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
     if( p_object )
         vlc_object_hold( p_object );
     InputAutoMenuBuilder( p_object, objects, varnames );
+
+    /* Title and so on */
     PUSH_VAR( "prev-title" );
     PUSH_VAR( "next-title" );
     PUSH_VAR( "prev-chapter" );
     PUSH_VAR( "next-chapter" );
+
+    menu->addSeparator();
+
     EnableStaticEntries( menu, ( p_object != NULL ) );
+
     if( p_object )
-    {
         vlc_object_release( p_object );
-    }
+
     return Populate( p_intf, menu, varnames, objects );
 }
 
@@ -715,23 +721,17 @@ void QVLCMenu::PopupMenuControlEntries( QMenu *menu,
                                         intf_thread_t *p_intf,
                                         input_thread_t *p_input )
 {
-    if( p_input )
+    if( !p_input || var_GetInteger( p_input, "state" ) != PLAYING_S )
+    {
+        QAction *action = menu->addAction( qtr( "Play" ),
+                ActionsManager::getInstance( p_intf ), SLOT( play() ) );
+        action->setIcon( QIcon( ":/play" ) );
+    }
+    else
     {
-        vlc_value_t val;
-        var_Get( p_input, "state", &val );
-        if( val.i_int == PLAYING_S )
             addMIMStaticEntry( p_intf, menu, qtr( "Pause" ),
                     ":/pause", SLOT( togglePlayPause() ) );
-        else
-            addMIMStaticEntry( p_intf, menu, qtr( "Play" ),
-                    ":/play", SLOT( togglePlayPause() ) );
     }
-    else if( THEPL->items.i_size )
-        addMIMStaticEntry( p_intf, menu, qtr( "Play" ),
-                ":/play", SLOT( togglePlayPause() ) );
-    else
-        addDPStaticEntry( menu, qtr( "Play" ),
-                ":/play", SLOT( openDialog() ) );
 
     addMIMStaticEntry( p_intf, menu, qtr( "Stop" ),
             ":/stop", SLOT( stop() ) );