[vlc-devel] [PATCH 3/3] Qt: implement play-and-shutdown in the menu

Ludovic Fauvet etix at videolan.org
Wed Apr 17 12:46:48 CEST 2013


The checkbox will be greyed out if one of these conditions is met:
- the user has insufficient permissions
- stub unimplemented for the target OS
---
 modules/gui/qt4/input_manager.cpp | 10 ++++++++++
 modules/gui/qt4/input_manager.hpp |  2 ++
 modules/gui/qt4/menus.cpp         |  7 +++++++
 3 files changed, 19 insertions(+)

diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 1daf5b8..b8a539e 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -1173,6 +1173,16 @@ bool MainInputManager::getPlayExitState()
     return var_GetBool( THEPL, "play-and-exit" );
 }
 
+void MainInputManager::activatePlayShutdown( bool b_shutdown )
+{
+    var_SetBool( THEPL, "play-and-shutdown", b_shutdown );
+}
+
+bool MainInputManager::getPlayShutdownState()
+{
+    return var_GetBool( THEPL, "play-and-shutdown" );
+}
+
 bool MainInputManager::hasEmptyPlaylist()
 {
     playlist_Lock( THEPL );
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index dcf23ee..14571b8 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -266,6 +266,7 @@ public:
     audio_output_t *getAout();
 
     bool getPlayExitState();
+    bool getPlayShutdownState();
     bool hasEmptyPlaylist();
 
     void requestVoutUpdate() { return im->UpdateVout(); }
@@ -293,6 +294,7 @@ public slots:
     void prev();
     void prevOrReset();
     void activatePlayQuit( bool );
+    void activatePlayShutdown( bool );
 
     void loopRepeatLoopStatus();
 
diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp
index 0e4088f..e692bc6 100644
--- a/modules/gui/qt4/menus.cpp
+++ b/modules/gui/qt4/menus.cpp
@@ -38,6 +38,7 @@
 #include <vlc_intf_strings.h>
 #include <vlc_vout.h>                             /* vout_thread_t */
 #include <vlc_aout.h>                             /* audio_output_t */
+#include <vlc_os.h>                               /* vlc_can_power_off */
 
 #include "menus.hpp"
 
@@ -386,6 +387,12 @@ QMenu *VLCMenuBar::FileMenu( intf_thread_t *p_intf, QWidget *parent, MainInterfa
     action->setCheckable( true );
     action->setChecked( THEMIM->getPlayExitState() );
 
+    action = addMIMStaticEntry( p_intf, menu, qtr( "Shutdown the computer at the end of playlist" ),
+            "", SLOT( activatePlayShutdown( bool ) ) );
+    action->setCheckable( true );
+    action->setChecked( THEMIM->getPlayShutdownState() );
+    action->setEnabled( vlc_can_power_off() );
+
     if( mi->getSysTray() )
     {
         action = menu->addAction( qtr( "Close to systray"), mi,
-- 
1.8.2




More information about the vlc-devel mailing list