changeset 13577:e440b3f32f02

Fixed bug with closing subwindows.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Mon, 01 Aug 2011 18:51:36 +0200
parents 11fcb7094945
children 1ddef123bc1c
files gui/src/FilesDockWidget.cpp gui/src/FilesDockWidget.h gui/src/HistoryDockWidget.cpp gui/src/HistoryDockWidget.h gui/src/MainWindow.cpp gui/src/VariablesDockWidget.cpp gui/src/VariablesDockWidget.h
diffstat 7 files changed, 69 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/gui/src/FilesDockWidget.cpp	Mon Aug 01 18:10:33 2011 +0200
+++ b/gui/src/FilesDockWidget.cpp	Mon Aug 01 18:51:36 2011 +0200
@@ -97,6 +97,8 @@
   QCompleter *
     completer = new QCompleter (m_fileSystemModel, this);
   m_currentDirectory->setCompleter (completer);
+
+  connect (this, SIGNAL (visibilityChanged(bool)), this, SLOT(handleVisibilityChanged(bool)));
 }
 
 void
@@ -180,3 +182,17 @@
   //if (settings.value ("showHiddenFiles").toBool ())
   // TODO: React on option for hidden files.
 }
+
+void
+FilesDockWidget::handleVisibilityChanged (bool visible)
+{
+  if (visible)
+    emit activeChanged (true);
+}
+
+void
+FilesDockWidget::closeEvent (QCloseEvent *event)
+{
+  emit activeChanged (false);
+  QDockWidget::closeEvent (event);
+}
--- a/gui/src/FilesDockWidget.h	Mon Aug 01 18:10:33 2011 +0200
+++ b/gui/src/FilesDockWidget.h	Mon Aug 01 18:51:36 2011 +0200
@@ -65,10 +65,17 @@
 
   /** Tells the widget to notice settings that are probably new. */
   void noticeSettings ();
+  void handleVisibilityChanged (bool visible);
 
 signals:
   void openFile (QString fileName);
 
+  /** Custom signal that tells if a user has clicke away that dock widget. */
+  void activeChanged (bool active);
+
+protected:
+  void closeEvent (QCloseEvent *event);
+
 private:
   // TODO: Add toolbar with buttons for navigating the path, creating dirs, etc
 
--- a/gui/src/HistoryDockWidget.cpp	Mon Aug 01 18:10:33 2011 +0200
+++ b/gui/src/HistoryDockWidget.cpp	Mon Aug 01 18:51:36 2011 +0200
@@ -49,6 +49,7 @@
 
   connect (m_filterLineEdit, SIGNAL (textEdited (QString)), &m_sortFilterProxyModel, SLOT (setFilterWildcard(QString)));
   connect (m_historyListView, SIGNAL (doubleClicked (QModelIndex)), this, SLOT (handleDoubleClick (QModelIndex)));
+  connect (this, SIGNAL (visibilityChanged(bool)), this, SLOT(handleVisibilityChanged(bool)));
 }
 
 void
@@ -62,3 +63,17 @@
 {
   emit commandDoubleClicked (modelIndex.data().toString());
 }
+
+void
+HistoryDockWidget::handleVisibilityChanged (bool visible)
+{
+  if (visible)
+    emit activeChanged (true);
+}
+
+void
+HistoryDockWidget::closeEvent (QCloseEvent *event)
+{
+  emit activeChanged (false);
+  QDockWidget::closeEvent (event);
+}
--- a/gui/src/HistoryDockWidget.h	Mon Aug 01 18:10:33 2011 +0200
+++ b/gui/src/HistoryDockWidget.h	Mon Aug 01 18:51:36 2011 +0200
@@ -35,11 +35,15 @@
 public slots:
   /** Tells the widget to notice settings that are probably new. */
   void noticeSettings ();
+  void handleVisibilityChanged (bool visible);
 
 signals:
   void information (QString message);
   void commandDoubleClicked (QString command);
-
+  /** Custom signal that tells if a user has clicke away that dock widget. */
+  void activeChanged (bool active);
+protected:
+  void closeEvent (QCloseEvent *event);
 private slots:
   void handleDoubleClick (QModelIndex modelIndex);
 
--- a/gui/src/MainWindow.cpp	Mon Aug 01 18:10:33 2011 +0200
+++ b/gui/src/MainWindow.cpp	Mon Aug 01 18:51:36 2011 +0200
@@ -28,7 +28,7 @@
 #include "SettingsDialog.h"
 #include "cmd-edit.h"
 
-#define VERSION_STRING "Octave GUI (0.7.2)"
+#define VERSION_STRING "Octave GUI (0.7.3)"
 
 MainWindow::MainWindow (QWidget * parent):QMainWindow (parent)
 {
@@ -350,14 +350,12 @@
   connect (aboutOctaveAction, SIGNAL (triggered ()), this, SLOT (showAboutOctave ()));
   connect (aboutQt, SIGNAL (triggered ()), this, SLOT (showAboutQt ()));
 
-  // TODO: Visibility cannot be taken as a signal, because it will be emitted even then
-  // the dock widget is tabbed or minimized.
   connect (showWorkspaceAction, SIGNAL (toggled (bool)), m_variablesDockWidget, SLOT (setShown (bool)));
-  //connect (m_variablesDockWidget, SIGNAL (visibilityChanged (bool)), showWorkspaceAction, SLOT (setChecked (bool)));
+  connect (m_variablesDockWidget, SIGNAL (activeChanged (bool)), showWorkspaceAction, SLOT (setChecked (bool)));
   connect (showHistoryAction, SIGNAL (toggled (bool)), m_historyDockWidget, SLOT (setShown (bool)));
-  //connect (m_historyDockWidget, SIGNAL (visibilityChanged (bool)), showHistoryAction, SLOT (setChecked (bool)));
+  connect (m_historyDockWidget, SIGNAL (activeChanged (bool)), showHistoryAction, SLOT (setChecked (bool)));
   connect (showFileBrowserAction, SIGNAL (toggled (bool)), m_filesDockWidget, SLOT (setShown (bool)));
-  //connect (m_filesDockWidget, SIGNAL (visibilityChanged (bool)), showFileBrowserAction, SLOT (setChecked (bool)));
+  connect (m_filesDockWidget, SIGNAL (activeChanged (bool)), showFileBrowserAction, SLOT (setChecked (bool)));
 
   connect (this, SIGNAL (settingsChanged ()), m_variablesDockWidget, SLOT (noticeSettings ()));
   connect (this, SIGNAL (settingsChanged ()), m_historyDockWidget, SLOT (noticeSettings ()));
--- a/gui/src/VariablesDockWidget.cpp	Mon Aug 01 18:10:33 2011 +0200
+++ b/gui/src/VariablesDockWidget.cpp	Mon Aug 01 18:51:36 2011 +0200
@@ -67,6 +67,8 @@
   m_variablesTreeWidget->expandAll ();
   m_variablesTreeWidget->setAlternatingRowColors (true);
   m_variablesTreeWidget->setAnimated (true);
+
+  connect (this, SIGNAL (visibilityChanged(bool)), this, SLOT(handleVisibilityChanged(bool)));
 }
 
 void
@@ -203,3 +205,17 @@
   QList < SymbolRecord > symbolTable = OctaveLink::instance ()->copyCurrentSymbolTable ();
   setVariablesList (symbolTable);
 }
+
+void
+VariablesDockWidget::handleVisibilityChanged (bool visible)
+{
+  if (visible)
+    emit activeChanged (true);
+}
+
+void
+VariablesDockWidget::closeEvent (QCloseEvent *event)
+{
+  emit activeChanged (false);
+  QDockWidget::closeEvent (event);
+}
--- a/gui/src/VariablesDockWidget.h	Mon Aug 01 18:10:33 2011 +0200
+++ b/gui/src/VariablesDockWidget.h	Mon Aug 01 18:51:36 2011 +0200
@@ -35,7 +35,12 @@
   /** Tells the widget to notice settings that are probably new. */
   void noticeSettings ();
   void fetchSymbolTable ();
-
+  void handleVisibilityChanged (bool visible);
+signals:
+  /** Custom signal that tells if a user has clicke away that dock widget. */
+  void activeChanged (bool active);
+protected:
+  void closeEvent (QCloseEvent *event);
 private:
   void construct ();
   void updateTreeEntry (QTreeWidgetItem * treeItem,