]> git.sesse.net Git - vlc/commitdiff
Qt: fix the view checked() state in the ViewMenu
authorJean-Baptiste Kempf <jb@videolan.org>
Thu, 28 Oct 2010 01:59:02 +0000 (03:59 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Thu, 28 Oct 2010 12:30:19 +0000 (14:30 +0200)
modules/gui/qt4/components/playlist/playlist.cpp
modules/gui/qt4/components/playlist/playlist.hpp
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.hpp

index 5ba0aa7b215098a331f0c6ec58037175d013cdde..aa1790428b61a8ac425981cdfb77d9da26f5c226 100644 (file)
@@ -111,7 +111,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
     CONNECT( viewSelectionMapper, mapped( int ), mainView, showView( int ) );
 
     QActionGroup *actionGroup = new QActionGroup( this );
-    QAction *viewActions[StandardPLPanel::VIEW_COUNT];
+
     for( int i = 0; i < StandardPLPanel::VIEW_COUNT; i++ )
     {
         viewActions[i] = actionGroup->addAction( viewNames[i] );
@@ -119,6 +119,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
         viewSelectionMapper->setMapping( viewActions[i], i );
         CONNECT( viewActions[i], triggered(), viewSelectionMapper, map() );
     }
+    viewActions[0]->setChecked( true );
 
     QMenu *viewMenu = new QMenu( viewButton );
     viewMenu->addActions( actionGroup->actions() );
@@ -223,9 +224,10 @@ void PlaylistWidget::changeView( const QModelIndex& index )
 {
     searchEdit->clear();
     locationBar->setIndex( index );
+    int i = mainView->getViewNumber();
+    viewActions[i]->setChecked(true);
 }
 
-
 #include <QSignalMapper>
 #include <QMenu>
 #include <QPainter>
index 45d4481fda78f5a513c67dcdcf075a067ccf0c90..2b02388d97198979af09b8cd77030b4d125c4e12 100644 (file)
@@ -57,6 +57,8 @@ private:
     QSplitter            *leftSplitter;
     StandardPLPanel      *mainView;
 
+    QAction *viewActions[ 4 /* StandardPLPanel::VIEW_COUNT*/ ];
+
     LocationBar          *locationBar;
     SearchLineEdit       *searchEdit;
 
index 57902f7534f0c85bcf37dfa2e059e53e8300502c..76af88082738bf0b374a2ebfeb53a72e628d7d1a 100644 (file)
@@ -348,11 +348,20 @@ void StandardPLPanel::showView( int i_view )
     }
 
     viewStack->setCurrentWidget( currentView );
-    //viewActions[i_view]->setChecked( true );
     browseInto();
     gotoPlayingItem();
 }
 
+const int StandardPLPanel::getViewNumber()
+{
+    if( currentView == treeView )
+        return TREE_VIEW;
+    else if( currentView == iconView )
+        return ICON_VIEW;
+    else if( currentView == listView )
+        return LIST_VIEW;
+}
+
 void StandardPLPanel::cycleViews()
 {
     if( currentView == iconView )
index 12a3ba1ed4ce2b9a712a041a12a3313244a5dd2d..5ff490804962c83bbc045b426caad72b0501b427 100644 (file)
@@ -70,6 +70,8 @@ public:
            LIST_VIEW,
            VIEW_COUNT  };
 
+    const int getViewNumber();
+
 protected:
 
     PLModel *model;