view libgui/src/terminal-dock-widget.cc @ 23808:2b1b2a795ba6

update clickable urls in terminal also when visible terminal has no focus * QTerminal.h: virtual slot for handling changes in the visibility of the terminal * QUnixTerminalImp.cpp (handle_visibility_changed): implementation of the virtual slot, calling function TerminalView::visibility_changed for doing required actions * QUnixTerminalImpl.h: new slothandle_visibility_changed * TerminalView.cpp (TerminalView): create timer for processing the filters; (blinkCursorEvent): do not update the filters here; (visibility_changed): function called from the visibility changed slot, en-/disabling cyclic timer for processing the filter chain * TerminalView.h: make processFilters a slot allowing to connect the new timer to it, new function visibility_changed, new class variable holding the time for processing the filter chain * terminal_dock_widget.cc (terminal_dock_widget): connect the signal for changed visibility to the new slot of the terminal
author Torsten <mttl@mailbox.org>
date Sat, 29 Jul 2017 09:17:53 +0200
parents 092078913d54
children 9107bae20480
line wrap: on
line source

/*

Copyright (C) 2013-2017 John W. Eaton
Copyright (C) 2011-2016 Jacob Dawid

This file is part of Octave.

Octave is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

Octave is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Octave; see the file COPYING.  If not, see
<http://www.gnu.org/licenses/>.

*/

#if defined (HAVE_CONFIG_H)
#  include "config.h"
#endif

#include "terminal-dock-widget.h"

terminal_dock_widget::terminal_dock_widget (QWidget *p)
  : octave_dock_widget (p), terminal (QTerminal::create (p))
{
  terminal->setObjectName ("OctaveTerminal");
  terminal->setFocusPolicy (Qt::StrongFocus);

  setObjectName ("TerminalDockWidget");
  setWindowIcon (QIcon (":/actions/icons/logo.png"));
  set_title (tr ("Command Window"));

  setWidget (terminal);
  setFocusProxy (terminal);

  connect (terminal, SIGNAL (interrupt_signal (void)),
           this, SLOT (terminal_interrupt ()));

  // Connect the visibility signal to the terminal for dis-/enabling timers
  connect (this, SIGNAL (visibilityChanged (bool)),
           terminal, SLOT (handle_visibility_changed (bool)));
}

bool
terminal_dock_widget::has_focus (void) const
{
  QWidget *w = widget ();

  return w->hasFocus ();
}

void
terminal_dock_widget::focus (void)
{
  octave_dock_widget::focus ();

  QWidget *w = widget ();

  w->setFocus ();
  w->activateWindow ();
  w->raise ();
}

void
terminal_dock_widget::terminal_interrupt (void)
{
  emit interrupt_signal ();
}

terminal_dock_widget::~terminal_dock_widget (void)
{
  delete terminal;
}