[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [dragon] /: implement menu toggle
From:       Harald Sitter <sitter () kde ! org>
Date:       2012-05-31 23:51:11
Message-ID: 20120531235111.DC348A60A9 () git ! kde ! org
[Download RAW message or body]

Git commit 119d3380a014b3af977f5cf7b3f7e0eac2f2180f by Harald Sitter.
Committed on 01/06/2012 at 01:51.
Pushed by sitter into branch 'master'.

implement menu toggle

FEATURE: 257843
FIXED-IN: 4.9.0

M  +1    -0    misc/dragonplayerui.rc
M  +26   -14   src/app/mainWindow.cpp
M  +4    -0    src/app/mainWindow.h

http://commits.kde.org/dragon/119d3380a014b3af977f5cf7b3f7e0eac2f2180f

diff --git a/misc/dragonplayerui.rc b/misc/dragonplayerui.rc
index c151b86..25ceaa0 100644
--- a/misc/dragonplayerui.rc
+++ b/misc/dragonplayerui.rc
@@ -23,6 +23,7 @@
       <Separator/>
       <Action name="options_configure_keybinding"/>
       <Action name="options_configure_toolbars"/>
+      <Action name="options_show_menubar"/>
    </Menu>
 </MenuBar>
 
diff --git a/src/app/mainWindow.cpp b/src/app/mainWindow.cpp
index 1bfc7b6..90d9667 100644
--- a/src/app/mainWindow.cpp
+++ b/src/app/mainWindow.cpp
@@ -98,11 +98,13 @@ MainWindow::MainWindow()
         , m_timeLabel( 0 )
         , m_titleLabel( new QLabel( this ) )
         , m_playDialog( 0 )
+        , m_menuToggleAction( 0 )
         , m_stopScreenSaver( 0 )
         , m_stopSleepCookie( -1 )
         , m_stopScreenPowerMgmtCookie( -1 )
         , m_toolbarIsHidden(false)
         , m_statusbarIsHidden(false)
+        , m_menuBarIsHidden(false)
         , m_FullScreenHandler( 0 )
 {
     s_instance = this;
@@ -267,7 +269,7 @@ void MainWindow::closeEvent (QCloseEvent *event)
     mainWindow()->setWindowState( Qt::WindowNoState );
     statusBar()->setHidden( m_statusbarIsHidden );
     toolBar()->setHidden( m_toolbarIsHidden );
-    menuBar()->setHidden( false );
+    menuBar()->setHidden( m_menuBarIsHidden );
 
     KMainWindow::closeEvent( event );
 }
@@ -304,6 +306,11 @@ MainWindow::setupActions()
     new PlayAction( this, SLOT(play()), ac );
     new VolumeAction( this, SLOT(toggleVolumeSlider(bool)), ac );
 
+    m_menuToggleAction =
+            static_cast<KToggleAction*>(ac->addAction(KStandardAction::ShowMenubar,
+                                                      menuBar(),
+                                                      SLOT(setVisible(bool))));
+
     KAction* playerStop = new KAction( KIcon(QLatin1String( "media-playback-stop" \
)), i18n("Stop"), ac );  playerStop->setObjectName( QLatin1String( "stop" ) );
     playerStop->setShortcut( Qt::Key_S );
@@ -675,19 +682,24 @@ MainWindow::setFullScreen( bool isFullScreen )
     kDebug() << "Setting full screen to " << isFullScreen;
     mainWindow()->setWindowState( (isFullScreen ? Qt::WindowFullScreen : \
Qt::WindowNoState ));  
-	if(isFullScreen)
-	{
-      m_statusbarIsHidden=statusBar()->isHidden();
-	  m_toolbarIsHidden=toolBar()->isHidden();
-	  toolBar()->setHidden( false );
-      statusBar()->setHidden( true );
-	}
-	else
-	{
-      statusBar()->setHidden(m_statusbarIsHidden);
-	  toolBar()->setHidden(m_toolbarIsHidden);
-	}
-    menuBar()->setHidden( isFullScreen );
+    if(isFullScreen)
+    {
+        m_statusbarIsHidden=statusBar()->isHidden();
+        m_toolbarIsHidden=toolBar()->isHidden();
+        m_menuBarIsHidden=menuBar()->isHidden();
+        toolBar()->setHidden( false );
+        statusBar()->setHidden( true );
+        menuBar()->setHidden(true);
+    }
+    else
+    {
+        statusBar()->setHidden(m_statusbarIsHidden);
+        toolBar()->setHidden(m_toolbarIsHidden);
+        menuBar()->setHidden(m_menuBarIsHidden);
+        // In case someone hit the shortcut while being in fullscreen, the action
+        // would be out of sync.
+        m_menuToggleAction->setChecked(!m_menuBarIsHidden);
+    }
     if( m_leftDock )
         m_leftDock->setHidden( isFullScreen );
     // the right dock is handled by the tool bar handler
diff --git a/src/app/mainWindow.h b/src/app/mainWindow.h
index 502758d..c84bcff 100644
--- a/src/app/mainWindow.h
+++ b/src/app/mainWindow.h
@@ -35,6 +35,7 @@
 #include <KXmlGuiWindow>
 
 class KNotificationRestrictions;
+class KToggleAction;
 class KUrl;
 class QActionGroup;
 class QCloseEvent;
@@ -132,6 +133,8 @@ namespace Dragon
       QList<QSlider*> m_sliders;
       QPointer<PlayDialog> m_playDialog;
 
+      KToggleAction *m_menuToggleAction;
+
       KNotificationRestrictions *m_stopScreenSaver;
       int m_screensaverDisableCookie;
       int m_stopSleepCookie;
@@ -139,6 +142,7 @@ namespace Dragon
 
       bool m_toolbarIsHidden;
       bool m_statusbarIsHidden;
+      bool m_menuBarIsHidden;
       FullScreenToolBarHandler *m_FullScreenHandler;
 
       QActionGroup *m_aspectRatios;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic