[vlmc-devel] MainWindow: QActions for the toolbar and the statusbar to show or hide

Yikai Lu git at videolan.org
Fri Aug 12 18:16:03 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Mon Aug  8 16:21:42 2016 -0500| [b2a97323ae766cd1f148c428b11f76e0907970df] | committer: Yikai Lu

MainWindow: QActions for the toolbar and the statusbar to show or hide

> https://code.videolan.org/videolan/vlmc/commit/b2a97323ae766cd1f148c428b11f76e0907970df
---

 src/Gui/MainWindow.cpp   | 24 ++++++++++++++++++++++--
 src/Gui/ui/MainWindow.ui | 26 +++++++++++++++++++-------
 2 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index a660212..a7bfdc9 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -84,9 +84,9 @@ MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent )
 
     // GUI
     createGlobalPreferences();
-    initializeDockWidgets();
     initToolbar();
     createStatusBar();
+    initializeDockWidgets();
     checkFolders();
     loadGlobalProxySettings();
     createProjectPreferences();
@@ -323,6 +323,26 @@ MainWindow::initVlmcPreferences()
     VLMC_CREATE_PRIVATE_PREFERENCE_STRING( "private/ImportPreviouslySelectPath", QDir::homePath() );
     VLMC_CREATE_PRIVATE_PREFERENCE_BYTEARRAY( "private/MainWindowGeometry", "" );
     VLMC_CREATE_PRIVATE_PREFERENCE_BYTEARRAY( "private/MainWindowState", "" );
+
+    // Toolbar
+    auto toolbarSetting = VLMC_CREATE_PRIVATE_PREFERENCE_BOOL( "private/ShowToolbar", false );
+    connect( toolbarSetting, &SettingValue::changed, this, [this]( const QVariant& var )
+    {
+        bool v = var.toBool();
+        m_ui.toolBar->setVisible( v );
+        m_ui.actionToolbar->setChecked( v );
+    } );
+    connect( m_ui.actionToolbar, &QAction::toggled, toolbarSetting, &SettingValue::set );
+
+    // Statusbar
+    auto statusbarSetting = VLMC_CREATE_PRIVATE_PREFERENCE_BOOL( "private/ShowStatusbar", false );
+    connect( statusbarSetting, &SettingValue::changed, this, [this]( const QVariant& var )
+    {
+        bool v = var.toBool();
+        m_ui.statusbar->setVisible( v );
+        m_ui.actionStatusbar->setChecked( v );
+    } );
+    connect( m_ui.actionStatusbar, &QAction::toggled, statusbarSetting, &SettingValue::set );
 }
 
 #undef CREATE_MENU_SHORTCUT
@@ -721,7 +741,7 @@ MainWindow::on_actionFullscreen_triggered( bool checked )
 void
 MainWindow::registerWidgetInWindowMenu( QDockWidget* widget )
 {
-    m_ui.menuWindow->addAction( widget->toggleViewAction() );
+    m_ui.menuView->insertAction( m_ui.actionFullscreen, widget->toggleViewAction() );
 }
 
 void
diff --git a/src/Gui/ui/MainWindow.ui b/src/Gui/ui/MainWindow.ui
index 4640741..73a8471 100644
--- a/src/Gui/ui/MainWindow.ui
+++ b/src/Gui/ui/MainWindow.ui
@@ -71,15 +71,12 @@
     <addaction name="separator"/>
     <addaction name="actionQuit"/>
    </widget>
-   <widget class="QMenu" name="menuWindow">
-    <property name="title">
-     <string>&Window</string>
-    </property>
-   </widget>
    <widget class="QMenu" name="menuView">
     <property name="title">
      <string>&View</string>
     </property>
+    <addaction name="actionToolbar"/>
+    <addaction name="actionStatusbar"/>
     <addaction name="actionFullscreen"/>
    </widget>
    <widget class="QMenu" name="menuTools">
@@ -91,7 +88,6 @@
    <addaction name="menuEdit"/>
    <addaction name="menuTools"/>
    <addaction name="menuView"/>
-   <addaction name="menuWindow"/>
    <addaction name="menuHelp"/>
   </widget>
   <widget class="QStatusBar" name="statusbar"/>
@@ -362,7 +358,23 @@
    </property>
    <property name="statusTip">
     <string>Use the Scissor Tool to cut regions in the timeline</string>
-  </property>
+   </property>
+  </action>
+  <action name="actionStatusbar">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Statusbar</string>
+   </property>
+  </action>
+  <action name="actionToolbar">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Toolbar</string>
+   </property>
   </action>
  </widget>
  <resources>



More information about the Vlmc-devel mailing list