]> git.sesse.net Git - vlc/commitdiff
Qt: Playlist, map the click to cycleViews
authorJean-Baptiste Kempf <jb@videolan.org>
Fri, 29 Jan 2010 00:26:58 +0000 (01:26 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 29 Jan 2010 00:43:21 +0000 (01:43 +0100)
And adapt the actions in consequences

modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.hpp

index 87180ebef22a50e111cca65b5e88831f477b0521..a5147366b96b70fdcb40a5a188ab51a9c4b2b6dd 100644 (file)
@@ -108,16 +108,17 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
 
     QActionGroup *actionGroup = new QActionGroup( this );
 
-    QAction *action = actionGroup->addAction( "Detailed view" );
-    action->setCheckable( true );
-    viewSelectionMapper->setMapping( action, TREE_VIEW );
-    CONNECT( action, triggered(), viewSelectionMapper, map() );
+    treeViewAction = actionGroup->addAction( "Detailed view" );
+    treeViewAction->setCheckable( true );
+    viewSelectionMapper->setMapping( treeViewAction, TREE_VIEW );
+    CONNECT( treeViewAction, triggered(), viewSelectionMapper, map() );
 
-    action = actionGroup->addAction( "Icon view" );
-    action->setCheckable( true );
-    viewSelectionMapper->setMapping( action, ICON_VIEW );
-    CONNECT( action, triggered(), viewSelectionMapper, map() );
+    iconViewAction = actionGroup->addAction( "Icon view" );
+    iconViewAction->setCheckable( true );
+    viewSelectionMapper->setMapping( iconViewAction, ICON_VIEW );
+    CONNECT( iconViewAction, triggered(), viewSelectionMapper, map() );
 
+    BUTTONACT( viewButton, cycleViews() );
     QMenu *viewMenu = new QMenu( this );
     viewMenu->addActions( actionGroup->actions() );
 
@@ -372,6 +373,7 @@ void StandardPLPanel::showView( int i_view )
         if( iconView ) iconView->hide();
         treeView->show();
         currentView = treeView;
+        treeViewAction->setChecked( true );
         break;
     }
     case ICON_VIEW:
@@ -383,12 +385,23 @@ void StandardPLPanel::showView( int i_view )
         if( treeView ) treeView->hide();
         iconView->show();
         currentView = iconView;
+        iconViewAction->setChecked( true );
         break;
     }
     default:;
     }
 }
 
+void StandardPLPanel::cycleViews()
+{
+    if( currentView == iconView )
+        showView( TREE_VIEW );
+    else if( currentView == treeView )
+        showView( ICON_VIEW );
+    else
+        assert( 0 );
+}
+
 void StandardPLPanel::wheelEvent( QWheelEvent *e )
 {
     // Accept this event in order to prevent unwanted volume up/down changes
index 58c118ac8930dbf65e98662e028c546b6cf991ac..78c6920e6ccb5e2270af4dd54054fbff81d7f0db 100644 (file)
@@ -76,6 +76,7 @@ private:
     PlIconView  *iconView;
     QAbstractItemView *currentView;
 
+    QAction *iconViewAction, *treeViewAction;
     int currentRootId;
     QSignalMapper *selectColumnsSigMapper;
     QSignalMapper *viewSelectionMapper;
@@ -104,6 +105,7 @@ private slots:
     void popupPlView( const QPoint & );
     void toggleColumnShown( int );
     void showView( int );
+    void cycleViews();
     void activate( const QModelIndex & );
     void handleInputChange( input_thread_t * );
 };