view libgui/src/m-editor/file-editor-interface.h @ 15980:6c0fce0632a4

gui: set keyboard focus when switching between dock widgets (bug #36957) * main-window.cc (handle_command_window_visible, handle_command_history_visible, handle_current_directory_visible, handle_workspace_visible, handle_editor_visible, handle_documentation_visible): slots for signal visibilityChanged, emitted when widgets get visible * main-window.cc (construct): connect signal visibilityChanged to slots * main-window.cc (focus_editor): call editor's own function for setting focus * main-window.h: declaration of new slots * file-editor.cc (set_focus): new function: setting focus to actual editor tab * file-editor.cc (add_file_editor_tab): connect signal fetab_set_focus to the slot set_focus of file_editor_tab * file-editor.h: new function set_focus and new signal fetab_set_focus * file-editor-interface.h: new virtual function set_focus * file-editor-tab.cc (set_focus): new slot for singal fetab_set_focus from file_editor, setting the focus to edit area * file-edtortab.h: new slot set_focus
author Torsten <ttl@justmail.de>
date Sat, 26 Jan 2013 20:33:46 +0100
parents 424edeca3c66
children 41471c02d51c
line wrap: on
line source

/*

Copyright (C) 2011-2012 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/>.

*/

#ifndef FILEEDITORINTERFACE_H
#define FILEEDITORINTERFACE_H

#include <QDockWidget>
#include <QMenu>
#include <QToolBar>

class file_editor_interface : public QDockWidget
{
  Q_OBJECT

  public:
  file_editor_interface (QWidget *p)
    : QDockWidget (p)
  {
    setObjectName ("FileEditor");

    connect (this, SIGNAL (visibilityChanged (bool)), this,
             SLOT (handle_visibility_changed (bool)));
  }

  virtual ~file_editor_interface () { }

  virtual QMenu *debug_menu () = 0;
  virtual QToolBar *toolbar () = 0;

  virtual void handle_entered_debug_mode () = 0;
  virtual void handle_quit_debug_mode () = 0;
  virtual void set_focus () = 0;

public slots:
  virtual void request_new_file () = 0;
  virtual void request_open_file () = 0;
  virtual void request_open_file (const QString& fileName) = 0;

signals:
  void active_changed (bool active);

protected:
  void closeEvent (QCloseEvent *e)
  {
    emit active_changed (false);
    QDockWidget::closeEvent (e);
  }

protected slots:
  void handle_visibility_changed (bool visible)
  {
    if (visible)
      emit active_changed (true);
  }
};

#endif // FILEEDITORINTERFACE_H