diff libgui/src/terminal-dock-widget.cc @ 16461:094bd3627ead

move common functionality to octave_dock_widget base class * octave-dock-widget.h (octave_dock_widget::handle_visibility, octave_dock_widget::connect_visibility_changed, octave_dock_widget::focus): New virtual functions. * documentation-dock-widget.cc, documentation-dock-widget.h, files-dock-widget.cc, files-dock-widget.h, history-dock-widget.cc, history-dock-widget.h, terminal-dock-widget.cc, terminal-dock-widget.h: Inherit handle_visibility, connect_visibility_changed, and focus methods.
author John W. Eaton <jwe@octave.org>
date Sun, 07 Apr 2013 12:36:07 -0400
parents 4d4e7c6f839d
children 7369b210dbd0
line wrap: on
line diff
--- a/libgui/src/terminal-dock-widget.cc	Sun Apr 07 12:07:10 2013 -0400
+++ b/libgui/src/terminal-dock-widget.cc	Sun Apr 07 12:36:07 2013 -0400
@@ -47,11 +47,6 @@
   connect (parent (), SIGNAL (relay_command_signal (const QString&)),
            this, SLOT (relay_command (const QString&)));
 
-  // topLevelChanged is emitted when floating property changes (floating
-  // = true)
-  connect (this, SIGNAL (topLevelChanged (bool)),
-           this, SLOT (top_level_changed (bool)));
-
   // Forward signals to QTerminal widget.
 
   connect (this, SIGNAL (notice_settings_signal (const QSettings *)),
@@ -68,37 +63,6 @@
 }
 
 void
-terminal_dock_widget::connect_visibility_changed (void)
-{
-  connect (this, SIGNAL (visibilityChanged (bool)),
-           this, SLOT (handle_visibility_changed (bool)));
-}
-
-void
-terminal_dock_widget::focus (void)
-{
-  if (! isVisible ())
-    setVisible (true);
-
-  setFocus ();
-  activateWindow ();
-  raise ();
-
-  widget ()->setFocus ();
-  widget ()->activateWindow ();
-  widget ()->raise ();
-}
-
-void
-terminal_dock_widget::handle_visibility (bool visible)
-{
-  // if widget is changed to visible and is not floating
-
-  if (visible && ! isFloating ())
-    focus ();
-}
-
-void
 terminal_dock_widget::notice_settings (const QSettings *settings)
 {
   emit notice_settings_signal (settings);
@@ -121,3 +85,15 @@
 {
   emit pasteClipboard_signal ();
 }
+
+void
+terminal_dock_widget::focus (void)
+{
+  octave_dock_widget::focus ();
+
+  QWidget *w = widget ();
+
+  w->setFocus ();
+  w->activateWindow ();
+  w->raise ();
+}