[vlmc-devel] commit: MainWindow: Correctly handle undocked widget states. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sat Oct 9 16:20:36 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Fri Oct  8 17:38:12 2010 +0200| [2f227018e77fd189591e75aabda4acc38ae68ea9] | committer: Hugo Beauzée-Luyssen 

MainWindow: Correctly handle undocked widget states.

Fixes #59

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=2f227018e77fd189591e75aabda4acc38ae68ea9
---

 src/Gui/DockWidgetManager.cpp |   14 +++++++++-----
 src/Gui/MainWindow.cpp        |   21 ++++++++++++---------
 src/Gui/ui/MainWindow.ui      |    5 +----
 3 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/src/Gui/DockWidgetManager.cpp b/src/Gui/DockWidgetManager.cpp
index b063f21..255f885 100644
--- a/src/Gui/DockWidgetManager.cpp
+++ b/src/Gui/DockWidgetManager.cpp
@@ -42,23 +42,26 @@ DockWidgetManager::~DockWidgetManager()
     qDeleteAll( m_dockWidgets );
 }
 
-void DockWidgetManager::setMainWindow( MainWindow *mainWin )
+void
+DockWidgetManager::setMainWindow( MainWindow *mainWin )
 {
     m_mainWin = mainWin;
 }
 
-QDockWidget* DockWidgetManager::addDockedWidget( QWidget *widget,
+QDockWidget*
+DockWidgetManager::addDockedWidget( QWidget *widget,
                                        const char *qs_name,
                                        Qt::DockWidgetAreas areas,
                                        QDockWidget::DockWidgetFeature features,
                                        Qt::DockWidgetArea startArea)
 {
     if ( m_dockWidgets.contains( qs_name ) )
-        return 0;
+        return NULL;
 
-    QDockWidget* dock = new QDockWidget( tr( qs_name ), m_mainWin );
+    QDockWidget*    dock = new QDockWidget( tr( qs_name ), m_mainWin );
 
     m_dockWidgets.insert( qs_name, dock );
+    dock->setObjectName( QString( "docked_" ) + qs_name );
     dock->setWidget( widget );
     dock->setAllowedAreas( areas );
     dock->setFeatures( features );
@@ -68,7 +71,8 @@ QDockWidget* DockWidgetManager::addDockedWidget( QWidget *widget,
     return dock;
 }
 
-void DockWidgetManager::retranslateUi()
+void
+DockWidgetManager::retranslateUi()
 {
     QMapIterator<const char*, QDockWidget*> i( m_dockWidgets );
 
diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 630d6d3..b996490 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -145,14 +145,6 @@ MainWindow::MainWindow( QWidget *parent ) :
 
 MainWindow::~MainWindow()
 {
-    QSettings s;
-    // Save the current geometry
-    s.setValue( "MainWindowGeometry", saveGeometry() );
-    // Save the current layout
-    s.setValue( "MainWindowState", saveState() );
-    s.setValue( "CleanQuit", true );
-    s.sync();
-
     if ( m_fileRenderer )
         delete m_fileRenderer;
     delete m_importController;
@@ -476,7 +468,8 @@ MainWindow::setupDockedWidgets()
                                   Qt::TopDockWidgetArea );
     dockManager->addDockedWidget( m_effectsList,
                                   QT_TRANSLATE_NOOP( "DockWidgetManager", "Effects List" ),
-                                  Qt::AllDockWidgetAreas, QDockWidget::AllDockWidgetFeatures,
+                                  Qt::AllDockWidgetAreas,
+                                  QDockWidget::AllDockWidgetFeatures,
                                   Qt::LeftDockWidgetArea );
     dockManager->addDockedWidget( UndoStack::getInstance( this ),
                                   QT_TRANSLATE_NOOP( "DockWidgetManager", "History" ),
@@ -745,7 +738,17 @@ MainWindow::closeEvent( QCloseEvent* e )
     if ( pm->askForSaveIfModified() )
         e->accept();
     else
+    {
         e->ignore();
+        return ;
+    }
+    QSettings s;
+    // Save the current geometry
+    s.setValue( "MainWindowGeometry", saveGeometry() );
+    // Save the current layout
+    s.setValue( "MainWindowState", saveState() );
+    s.setValue( "CleanQuit", true );
+    s.sync();
 }
 
 void
diff --git a/src/Gui/ui/MainWindow.ui b/src/Gui/ui/MainWindow.ui
index 0f3c88a..4d38c59 100644
--- a/src/Gui/ui/MainWindow.ui
+++ b/src/Gui/ui/MainWindow.ui
@@ -17,9 +17,6 @@
    <iconset resource="../../../resources.qrc">
     <normaloff>:/images/vlmc</normaloff>:/images/vlmc</iconset>
   </property>
-  <property name="dockNestingEnabled">
-   <bool>true</bool>
-  </property>
   <widget class="QWidget" name="centralwidget"/>
   <widget class="QMenuBar" name="menubar">
    <property name="geometry">
@@ -27,7 +24,7 @@
      <x>0</x>
      <y>0</y>
      <width>800</width>
-     <height>27</height>
+     <height>21</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuEdit">



More information about the Vlmc-devel mailing list