# HG changeset patch
# User Torsten <mttl@mailbox.org>
# Date 1530452977 -7200
#      Sun Jul 01 15:49:37 2018 +0200
# Node ID 156c207aa03b3cf9b6edb9b13c511100468daaa6
# Parent  7dad5fa7e88e36b724b84e06a880ff01406c3245
provide mdi subwindows for the editor files instead od tab widgets (bug #53712)

* file-editor-tab.cc (file_editor_tab): use editor as parent as additional
  argument;
  (update_window_title): do not use file_named_changed signal, just update
  the title

* file-editor-tab.h: editor as new argument of the constructor,
  new inline method for setting the new class variable for the mdi area,

* file-editor.cc (check_actions): tab widget count is replaced by the list
  of subwindows;
  (empty_script): check count of subwindows for the need of an empty one;
  (focus): get the current editor tab from the current subwindow;
  (set_focus): set the related subwindow into active state;
  (reset_cancel): get the ID of all subwindows and remove all subwindows;
  (request_new_file): create new editor subwindow instead of a tab;
  (request_close_file): get current subwindow and close it;
  (request_close_all_files): get list of all subwindows and close them;
  (request_close_other_files): close other subwindows depending on the
  current ID and the lsit of all subwindows;
  (request_print_file, request_redo, request_cut, request_context_help,
   request_context_doc, request_context_edit, request_save_file,
   request_save_file_as, request_run_file, request_context_run,
   request_toggle_bookmark, request_next_bookmark, request_previous_bookmark,
   request_remove_bookmark, request_move_match_brace, request_sel_match_brace,
   request_toggle_breakpoint, request_next_breakpoint,
   request_previous_breakpoint, request_remove_breakpoint,
   request_delete_start_word, request_delete_end_word,
   request_delete_start_line, request_delete_end_line, request_delete_line,
   request_copy_line, request_cut_line, request_duplicate_selection,
   request_transpose_line, request_comment_selected_text,
   request_uncomment_selected_text, request_comment_var_selected_text,
   request_upper_case, request_lower_case, request_indent_selected_text,
   request_unindent_selected_text, request_smart_indent_line_or_selected_text,
   request_conv_eol_windows, request_conv_eol_unix, request_conv_eol_mac,
   request_find, request_find_next, request_find_previous, request_goto_line,
   request_completion, copyClipboard, pasteClipboard, selectAll, do_undo,
   zoom_in, zoom_out, zoom_normal):
   emit signal with widget of the current subwindow;
  (handle_file_name_changed): set new subwindow title;
  (handle_tab_close_request): close current subwindow;
  (handle_tab_remove_request): remove the current subwindow;
  (handle_add_filename_to_list): argument is subwindow ID;
  (active_subwindow_changed): new slot handling a new active subwindow
  (handle_editor_state_changed): remove focus proxy;
  (check_conflict_save): check existing subwindows for the one to be saved;
  (handle_delete_debugger_pointer_request): check for subwindow and activate it;
  (notice_settings): uncommenting obsolete settings which are not yet
  applicable, apply new settings for the view mode of the mdi area and its
  shortcuts;
  (request_open_file): consider sub windows when checking for already open,
  new arguments in file_editor_tab and add_file_editor_tab;
  (tabbed_view): new method for switching between tabbed and window view;
  (disable_tabbed_view): new method for using window view mode;
  (cascade_windows, h_tile_windows, v_tile_windows): new methods for arranging
  the subwindows;
  (construct): create an mdi area instead of a tabbed widget, new view/windows
  menu for arranging the windows, new actions for arranging the windows,
  add action for switching between windows (not yet fully implemented),
  commented out the related context menu (has to be implemented),
  connect new signals, set focus proxy to the mdi area;
  (add_file_editor): create new file editor sub window and update related
  signal connections, show and activate the new window;
  (find_tab_widget): look for subwindow related to a specific file name

* file-editor.h: update tab_info struct and store file_editor_tab instead
  of widget, new arguments for fetab_set_focus, set_focus,
  handle_tab_close_request, handle_add_filename_to_list, removed slot
  active_tab_changed, new slot active_subwindow_changed (QMdiSubWindow *w),
  new methods disable_tabbed_view, tabbed_view, cascade_windows,
  v_tile_windows, h_tile_windows, updated args in add_file_editor_tabtring,
  updated return value in find_tab_widget, new actions for arranging the
  windows, new menu for view/windows, no more class variable for tab widget,
  for mdi area

* shortcut-manager.cc (do_init_data): set default shortcuts for arranging
  the subwindows

diff -r 7dad5fa7e88e -r 156c207aa03b libgui/src/m-editor/file-editor-tab.cc
--- a/libgui/src/m-editor/file-editor-tab.cc	Sat Jun 30 20:11:05 2018 +0200
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sun Jul 01 15:49:37 2018 +0200
@@ -93,7 +93,9 @@ namespace octave
 
   // Make parent null for the file editor tab so that warning WindowModal
   // messages don't affect grandparents.
-  file_editor_tab::file_editor_tab (const QString& directory_arg)
+  file_editor_tab::file_editor_tab (file_editor *p,
+                                    const QString& directory_arg)
+    : QWidget (p), m_sub_win (nullptr)
   {
     _lexer_apis = nullptr;
     _is_octave_file = true;
@@ -208,11 +210,13 @@ namespace octave
     // auto completion
     _edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCSETCANCELATSTART, false);
 
+    // add edit area and status bar to sub window
     QVBoxLayout *edit_area_layout = new QVBoxLayout ();
     edit_area_layout->addWidget (_edit_area);
     edit_area_layout->addWidget (_status_bar);
     edit_area_layout->setMargin (0);
     setLayout (edit_area_layout);
+    setWindowIcon (QIcon ());
 
     // connect modified signal
     connect (_edit_area, SIGNAL (modificationChanged (bool)),
@@ -224,13 +228,10 @@ namespace octave
     connect (&_file_system_watcher, SIGNAL (fileChanged (const QString&)),
              this, SLOT (file_has_changed (const QString&)));
 
+    setFocusProxy (_edit_area);
+
+    // encoding, not updated with the settings
     QSettings *settings = resource_manager::get_settings ();
-    if (settings)
-      notice_settings (settings, true);
-
-    setFocusProxy (_edit_area);
-
-    // encoding, not updated with the settings
 #if defined (Q_OS_WIN32)
     _encoding = settings->value ("editor/default_encoding", "SYSTEM")
                 .toString ();
@@ -241,6 +242,8 @@ namespace octave
     _enc_indicator->setText (_encoding);
     // no changes in encoding yet
     _new_encoding = _encoding;
+
+    notice_settings (settings, true);
   }
 
   file_editor_tab::~file_editor_tab (void)
@@ -449,7 +452,6 @@ namespace octave
         _file_name = fileName;
         update_lexer ();
       }
-
     // update the file editor with current editing directory
     emit editor_state_changed (_copy_available, _is_octave_file);
 
@@ -1593,9 +1595,10 @@ namespace octave
       }
 
     if (modified)
-      emit file_name_changed (title.prepend ("* "), tooltip);
-    else
-      emit file_name_changed (title, tooltip);
+      title = title.prepend ("* ");
+
+    setWindowTitle (title);
+    setToolTip (tooltip);
   }
 
   void file_editor_tab::handle_copy_available (bool enableCopy)
diff -r 7dad5fa7e88e -r 156c207aa03b libgui/src/m-editor/file-editor-tab.h
--- a/libgui/src/m-editor/file-editor-tab.h	Sat Jun 30 20:11:05 2018 +0200
+++ b/libgui/src/m-editor/file-editor-tab.h	Sun Jul 01 15:49:37 2018 +0200
@@ -33,6 +33,7 @@ along with Octave; see the file COPYING.
 #include <QStatusBar>
 #include <QLabel>
 #include <QComboBox>
+#include <QMdiSubWindow>
 
 #include "find-dialog.h"
 #include "octave-qscintilla.h"
@@ -53,7 +54,7 @@ namespace octave
 
   public:
 
-    file_editor_tab (const QString& directory = "");
+    file_editor_tab (file_editor *p, const QString& directory = "");
 
     ~file_editor_tab (void);
 
@@ -65,6 +66,9 @@ namespace octave
     static void reset_cancel (void) {_cancelled = false;}
     static bool was_cancelled (void) {return _cancelled;}
 
+    QMdiSubWindow *sub_win (void) {return m_sub_win;}
+    void set_sub_win (QMdiSubWindow *w) {m_sub_win = w;}
+
   public slots:
 
     void update_window_title (bool modified);
@@ -156,7 +160,7 @@ namespace octave
     void editor_state_changed (bool copy_available, bool is_octave_file);
     void set_focus_editor_signal (QWidget *);
     void tab_remove_request (void);
-    void add_filename_to_list (const QString&, const QString&, QWidget *);
+    void add_filename_to_list (const QString&, const QString&, file_editor_tab *);
     void mru_add_file (const QString& file_name, const QString& encoding);
     void editor_check_conflict_save (const QString& saveFileName,
                                      bool remove_on_success);
@@ -315,6 +319,8 @@ namespace octave
     bool _lines_changed;
     bool _highlight_all_occurrences;
     int m_bp_restore_count;
+
+    QMdiSubWindow *m_sub_win;
   };
 }
 
diff -r 7dad5fa7e88e -r 156c207aa03b libgui/src/m-editor/file-editor.cc
--- a/libgui/src/m-editor/file-editor.cc	Sat Jun 30 20:11:05 2018 +0200
+++ b/libgui/src/m-editor/file-editor.cc	Sun Jul 01 15:49:37 2018 +0200
@@ -159,7 +159,8 @@ namespace octave
 
   void file_editor::check_actions (void)
   {
-    bool have_tabs = m_tab_widget->count () > 0;
+    QList<QMdiSubWindow *> mdi_list = m_mdi_area->subWindowList ();
+    bool have_tabs = ! mdi_list.isEmpty ();
 
     m_edit_cmd_menu->setEnabled (have_tabs);
     m_edit_fmt_menu->setEnabled (have_tabs);
@@ -191,7 +192,7 @@ namespace octave
     m_save_as_action->setEnabled (have_tabs);
     m_close_action->setEnabled (have_tabs);
     m_close_all_action->setEnabled (have_tabs);
-    m_close_others_action->setEnabled (have_tabs && m_tab_widget->count () > 1);
+    m_close_others_action->setEnabled (have_tabs && mdi_list.count () > 1);
   }
 
   // empty_script determines whether we have to create an empty script
@@ -211,7 +212,7 @@ namespace octave
     else
       real_visible = visible;
 
-    if (! real_visible || m_tab_widget->count () > 0)
+    if (! real_visible || m_mdi_area->subWindowList ().count () > 0)
       return;
 
     if (startup && ! isFloating ())
@@ -303,18 +304,19 @@ namespace octave
     octave_dock_widget::focus ();
 
     // set focus to current tab
-    QWidget *fileEditorTab = m_tab_widget->currentWidget ();
+    file_editor_tab *fileEditorTab
+        = static_cast<file_editor_tab *> (m_mdi_area->currentSubWindow ()->widget ());
     if (fileEditorTab)
       emit fetab_set_focus (fileEditorTab);
   }
 
-  void file_editor::set_focus (QWidget *fet)
+  void file_editor::set_focus (QMdiSubWindow *fet)
   {
     octave_dock_widget::focus ();
 
     // set focus to desired tab
     if (fet)
-      m_tab_widget->setCurrentWidget (fet);
+      m_mdi_area->setActiveSubWindow (fet);
   }
 
   // function enabling/disabling the menu accelerators depending on the
@@ -385,9 +387,16 @@ namespace octave
           {
             fetFileNames.append (file_name);
             fet_encodings.append (m_editor_tab_map[file_name].encoding);
+
             QString index;
-            fet_index.append (index.setNum
-                              (m_tab_widget->indexOf (m_editor_tab_map[file_name].fet_ID)));
+            QWidget *w = m_editor_tab_map[file_name].fet_ID;
+            QList<QMdiSubWindow *> list
+                = m_mdi_area->subWindowList (QMdiArea::StackingOrder);
+            for (int i = list.count () - 1; i >= 0; i--)
+              {
+                if (w == list.at (i)->widget ())
+                  fet_index.append (index.setNum (i));
+              }
           }
       }
 
@@ -402,11 +411,12 @@ namespace octave
     // hidden before, this state has to be restored afterwards
     bool vis = isVisible ();
 
-    for (int i = m_tab_widget->count () - 1; i >= 0; i--)
+    QList<QMdiSubWindow *> list = m_mdi_area->subWindowList ();
+    for (int i = list.count () - 1; i >= 0; i--)
       {
-        // backwards loop since m_tab_widget->count () changes during the loop
-        delete m_tab_widget->widget (i);
-        m_tab_widget->removeTab (i);
+        // backwards loop since m_mdi_area->count () changes during the loop
+        //delete m_mdi_area->widget (i);
+        m_mdi_area->removeSubWindow (list.at (i));
       }
 
     setVisible (vis);
@@ -425,10 +435,10 @@ namespace octave
     // editor tab has yet to be created and there is no object to
     // pass a signal to.  Hence, functionality is here.
 
-    file_editor_tab *fileEditorTab = new file_editor_tab (m_ced);
+    file_editor_tab *fileEditorTab = new file_editor_tab (this, m_ced);
     if (fileEditorTab)
       {
-        add_file_editor_tab (fileEditorTab, "");  // new tab with empty title
+        add_file_editor_tab (fileEditorTab);      // connect all signals
         fileEditorTab->new_file (commands);       // title is updated here
         focus ();                                 // focus editor and new tab
       }
@@ -437,7 +447,7 @@ namespace octave
   void file_editor::request_close_file (bool)
   {
     file_editor_tab *editor_tab
-      = static_cast<file_editor_tab *> (m_tab_widget->currentWidget ());
+      = static_cast<file_editor_tab *> (m_mdi_area->currentSubWindow ()->widget ());
     editor_tab->conditional_close ();
   }
 
@@ -446,9 +456,10 @@ namespace octave
     file_editor_tab *editor_tab;
 
     // loop over all tabs starting from last one otherwise deletion changes index
-    for (int index = m_tab_widget->count ()-1; index >= 0; index--)
+    QList<QMdiSubWindow *> list = m_mdi_area->subWindowList ();
+    for (int i = list.count () - 1; i >= 0; i--)
       {
-        editor_tab = static_cast<file_editor_tab *> (m_tab_widget->widget (index));
+        editor_tab = static_cast<file_editor_tab *> (list.at (i)->widget ());
         editor_tab->conditional_close ();
       }
   }
@@ -456,15 +467,16 @@ namespace octave
   void file_editor::request_close_other_files (bool)
   {
     file_editor_tab *editor_tab;
-    QWidget *tabID = m_tab_widget->currentWidget ();
+    QWidget *tabID = m_mdi_area->currentSubWindow ();
 
     // loop over all tabs starting from last one otherwise deletion changes index
-    for (int index = m_tab_widget->count ()-1; index >= 0; index--)
+    QList<QMdiSubWindow *> list = m_mdi_area->subWindowList ();
+    for (int i = list.count () - 1; i >= 0; i--)
       {
-        if (tabID != m_tab_widget->widget (index))
+        if (tabID != list.at (i))
           {
             editor_tab
-              = static_cast<file_editor_tab *> (m_tab_widget->widget (index));
+              = static_cast<file_editor_tab *> (list.at (i)->widget ());
             editor_tab->conditional_close ();
           }
       }
@@ -482,246 +494,246 @@ namespace octave
 
   void file_editor::request_print_file (bool)
   {
-    emit fetab_print_file (m_tab_widget->currentWidget ());
+    emit fetab_print_file (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_redo (bool)
   {
-    emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+    emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                   QsciScintillaBase::SCI_REDO);
   }
 
   void file_editor::request_cut (bool)
   {
-    emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+    emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                   QsciScintillaBase::SCI_CUT);
   }
 
   void file_editor::request_context_help (bool)
   {
-    emit fetab_context_help (m_tab_widget->currentWidget (), false);
+    emit fetab_context_help (m_mdi_area->currentSubWindow ()->widget (), false);
   }
 
   void file_editor::request_context_doc (bool)
   {
-    emit fetab_context_help (m_tab_widget->currentWidget (), true);
+    emit fetab_context_help (m_mdi_area->currentSubWindow ()->widget (), true);
   }
 
   void file_editor::request_context_edit (bool)
   {
-    emit fetab_context_edit (m_tab_widget->currentWidget ());
+    emit fetab_context_edit (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_save_file (bool)
   {
-    emit fetab_save_file (m_tab_widget->currentWidget ());
+    emit fetab_save_file (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_save_file_as (bool)
   {
-    emit fetab_save_file_as (m_tab_widget->currentWidget ());
+    emit fetab_save_file_as (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_run_file (bool)
   {
-    emit fetab_run_file (m_tab_widget->currentWidget ());
+    emit fetab_run_file (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_context_run (bool)
   {
-    emit fetab_context_run (m_tab_widget->currentWidget ());
+    emit fetab_context_run (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_toggle_bookmark (bool)
   {
-    emit fetab_toggle_bookmark (m_tab_widget->currentWidget ());
+    emit fetab_toggle_bookmark (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_next_bookmark (bool)
   {
-    emit fetab_next_bookmark (m_tab_widget->currentWidget ());
+    emit fetab_next_bookmark (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_previous_bookmark (bool)
   {
-    emit fetab_previous_bookmark (m_tab_widget->currentWidget ());
+    emit fetab_previous_bookmark (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_remove_bookmark (bool)
   {
-    emit fetab_remove_bookmark (m_tab_widget->currentWidget ());
+    emit fetab_remove_bookmark (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_move_match_brace (bool)
   {
-    emit fetab_move_match_brace (m_tab_widget->currentWidget (), false);
+    emit fetab_move_match_brace (m_mdi_area->currentSubWindow ()->widget (), false);
   }
 
   void file_editor::request_sel_match_brace (bool)
   {
-    emit fetab_move_match_brace (m_tab_widget->currentWidget (), true);
+    emit fetab_move_match_brace (m_mdi_area->currentSubWindow ()->widget (), true);
   }
 
   // FIXME: What should this do with conditional breakpoints?
   void file_editor::request_toggle_breakpoint (bool)
   {
-    emit fetab_toggle_breakpoint (m_tab_widget->currentWidget ());
+    emit fetab_toggle_breakpoint (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_next_breakpoint (bool)
   {
-    emit fetab_next_breakpoint (m_tab_widget->currentWidget ());
+    emit fetab_next_breakpoint (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_previous_breakpoint (bool)
   {
-    emit fetab_previous_breakpoint (m_tab_widget->currentWidget ());
+    emit fetab_previous_breakpoint (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_remove_breakpoint (bool)
   {
-    emit fetab_remove_all_breakpoints (m_tab_widget->currentWidget ());
+    emit fetab_remove_all_breakpoints (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   // slots for Edit->Commands actions
   void file_editor::request_delete_start_word (bool)
   {
-    emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+    emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                   QsciScintillaBase::SCI_DELWORDLEFT);
   }
 
   void file_editor::request_delete_end_word (bool)
   {
-    emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+    emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                   QsciScintillaBase::SCI_DELWORDRIGHT);
   }
 
   void file_editor::request_delete_start_line (bool)
   {
-    emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+    emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                   QsciScintillaBase::SCI_DELLINELEFT);
   }
 
   void file_editor::request_delete_end_line (bool)
   {
-    emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+    emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                   QsciScintillaBase::SCI_DELLINERIGHT);
   }
 
   void file_editor::request_delete_line (bool)
   {
-    emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+    emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                   QsciScintillaBase::SCI_LINEDELETE);
   }
 
   void file_editor::request_copy_line (bool)
   {
-    emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+    emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                   QsciScintillaBase::SCI_LINECOPY);
   }
 
   void file_editor::request_cut_line (bool)
   {
-    emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+    emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                   QsciScintillaBase::SCI_LINECUT);
   }
 
   void file_editor::request_duplicate_selection (bool)
   {
-    emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+    emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                   QsciScintillaBase::SCI_SELECTIONDUPLICATE);
   }
 
   void file_editor::request_transpose_line (bool)
   {
-    emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+    emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                   QsciScintillaBase::SCI_LINETRANSPOSE);
   }
 
   void file_editor::request_comment_selected_text (bool)
   {
-    emit fetab_comment_selected_text (m_tab_widget->currentWidget (), false);
+    emit fetab_comment_selected_text (m_mdi_area->currentSubWindow ()->widget (), false);
   }
 
   void file_editor::request_uncomment_selected_text (bool)
   {
-    emit fetab_uncomment_selected_text (m_tab_widget->currentWidget ());
+    emit fetab_uncomment_selected_text (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_comment_var_selected_text (bool)
   {
-    emit fetab_comment_selected_text (m_tab_widget->currentWidget (), true);
+    emit fetab_comment_selected_text (m_mdi_area->currentSubWindow ()->widget (), true);
   }
 
   // slots for Edit->Format actions
   void file_editor::request_upper_case (bool)
   {
-    emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+    emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                   QsciScintillaBase::SCI_UPPERCASE);
   }
 
   void file_editor::request_lower_case (bool)
   {
-    emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+    emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                   QsciScintillaBase::SCI_LOWERCASE);
   }
 
   void file_editor::request_indent_selected_text (bool)
   {
-    emit fetab_indent_selected_text (m_tab_widget->currentWidget ());
+    emit fetab_indent_selected_text (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_unindent_selected_text (bool)
   {
-    emit fetab_unindent_selected_text (m_tab_widget->currentWidget ());
+    emit fetab_unindent_selected_text (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_smart_indent_line_or_selected_text ()
   {
-    emit fetab_smart_indent_line_or_selected_text (m_tab_widget->currentWidget ());
+    emit fetab_smart_indent_line_or_selected_text (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_conv_eol_windows (bool)
   {
-    emit fetab_convert_eol (m_tab_widget->currentWidget (),
+    emit fetab_convert_eol (m_mdi_area->currentSubWindow ()->widget (),
                             QsciScintilla::EolWindows);
   }
   void
   file_editor::request_conv_eol_unix (bool)
   {
-    emit fetab_convert_eol (m_tab_widget->currentWidget (),
+    emit fetab_convert_eol (m_mdi_area->currentSubWindow ()->widget (),
                             QsciScintilla::EolUnix);
   }
 
   void file_editor::request_conv_eol_mac (bool)
   {
-    emit fetab_convert_eol (m_tab_widget->currentWidget (),
+    emit fetab_convert_eol (m_mdi_area->currentSubWindow ()->widget (),
                             QsciScintilla::EolMac);
   }
 
   void file_editor::request_find (bool)
   {
-    emit fetab_find (m_tab_widget->currentWidget (), m_fetab_actions);
+    emit fetab_find (m_mdi_area->currentSubWindow ()->widget (), m_fetab_actions);
   }
 
   void file_editor::request_find_next (bool)
   {
-    emit fetab_find_next (m_tab_widget->currentWidget ());
+    emit fetab_find_next (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_find_previous (bool)
   {
-    emit fetab_find_previous (m_tab_widget->currentWidget ());
+    emit fetab_find_previous (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_goto_line (bool)
   {
-    emit fetab_goto_line (m_tab_widget->currentWidget ());
+    emit fetab_goto_line (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::request_completion (bool)
   {
-    emit fetab_completion (m_tab_widget->currentWidget ());
+    emit fetab_completion (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::handle_file_name_changed (const QString& fname,
@@ -730,22 +742,21 @@ namespace octave
     QObject *fileEditorTab = sender ();
     if (fileEditorTab)
       {
-        for (int i = 0; i < m_tab_widget->count (); i++)
+        QList<QMdiSubWindow *> list = m_mdi_area->subWindowList ();
+        for (int i = 0; i < list.count (); i++)
           {
-            if (m_tab_widget->widget (i) == fileEditorTab)
+            if (list.at (i) == fileEditorTab)
               {
-                m_tab_widget->setTabText (i, fname);
-                m_tab_widget->setTabToolTip (i, tip);
+                list.at (i)->setWindowTitle (fname);
+                list.at (i)->setToolTip (tip);
               }
           }
       }
   }
 
-  void file_editor::handle_tab_close_request (int index)
+  void file_editor::handle_tab_close_request (file_editor_tab *sub_win)
   {
-    file_editor_tab *editor_tab
-      = static_cast<file_editor_tab *> (m_tab_widget->widget (index));
-    editor_tab->conditional_close ();
+    sub_win->conditional_close ();
   }
 
   void
@@ -754,17 +765,10 @@ namespace octave
     QObject *fileEditorTab = sender ();
     if (fileEditorTab)
       {
-        for (int i = 0; i < m_tab_widget->count (); i++)
-          {
-            if (m_tab_widget->widget (i) == fileEditorTab)
-              {
-                m_tab_widget->removeTab (i);
-                // Deleting sender is dodgy, but works because the signal
-                // is the last item in the sender's routines.
-                delete fileEditorTab;
-                break;
-              }
-          }
+        m_mdi_area->removeSubWindow (static_cast<file_editor_tab *> (fileEditorTab));
+        // Deleting sender is dodgy, but works because the signal
+        // is the last item in the sender's routines.
+        delete fileEditorTab;
       }
     check_actions ();
 
@@ -773,7 +777,8 @@ namespace octave
   }
 
   void file_editor::handle_add_filename_to_list (const QString& fileName,
-                                                 const QString& encoding, QWidget *ID)
+                                                 const QString& encoding,
+                                                 file_editor_tab *ID)
   {
     // Should we allow multiple tabs for a single file?
     m_editor_tab_map[fileName].fet_ID = ID;
@@ -781,10 +786,13 @@ namespace octave
   }
 
   // context menu of edit area
-  void file_editor::active_tab_changed (int index)
+  void file_editor::active_subwindow_changed (QMdiSubWindow *w)
   {
-    emit fetab_change_request (m_tab_widget->widget (index));
-    focus ();
+    if (w)
+      {
+        emit fetab_change_request (w->widget ());
+        setFocusProxy (w->widget ());
+      }
   }
 
   void file_editor::handle_editor_state_changed (bool copy_available,
@@ -792,15 +800,13 @@ namespace octave
   {
     // In case there is some scenario where traffic could be coming from
     // all the file editor tabs, just process info from the current active tab.
-    if (sender () == m_tab_widget->currentWidget ())
+    if (sender () == m_mdi_area->activeSubWindow ()->widget ())
       {
         if (m_copy_action)
           m_copy_action->setEnabled (copy_available);
         m_cut_action->setEnabled (copy_available);
         m_run_selection_action->setEnabled (copy_available);
         m_run_action->setEnabled (is_octave_file);
-
-        setFocusProxy (m_tab_widget->currentWidget ());
       }
   }
 
@@ -853,11 +859,12 @@ namespace octave
     QObject *saveFileObject = sender ();
     QWidget *saveFileWidget = nullptr;
 
-    for (int i = 0; i < m_tab_widget->count (); i++)
+    QList<QMdiSubWindow *> list = m_mdi_area->subWindowList ();
+    for (int i = 0; i < list.count (); i++)
       {
-        if (m_tab_widget->widget (i) == saveFileObject)
+        if (list.at (i) == saveFileObject)
           {
-            saveFileWidget = m_tab_widget->widget (i);
+            saveFileWidget = list.at (i);
             break;
           }
       }
@@ -892,11 +899,11 @@ namespace octave
     if (! file.isEmpty ())
       {
         // Check whether this file is already open in the editor.
-        QWidget *tab = find_tab_widget (file);
+        file_editor_tab *tab = find_tab_widget (file);
 
         if (tab)
           {
-            m_tab_widget->setCurrentWidget (tab);
+            m_mdi_area->setActiveSubWindow (tab->sub_win ());
 
             if (line > 0)
               emit fetab_delete_debugger_pointer (tab, line);
@@ -1003,15 +1010,35 @@ namespace octave
         QString style_sheet = QString ("QTabBar::tab "
                                        "{min-width: %1px; max-width: %2px;}")
                               .arg (tab_width_min).arg (tab_width_max);
-        m_tab_widget->setElideMode (Qt::ElideLeft);
-        m_tab_widget->setStyleSheet (style_sheet);
+        //m_mdi_area->setElideMode (Qt::ElideLeft);
+        //m_mdi_area->setStyleSheet (style_sheet);
       }
-    else
-      m_tab_widget->setElideMode (Qt::ElideNone);
-
-    m_tab_widget->setUsesScrollButtons (true);
+    //else
+      //m_mdi_area->setElideMode (Qt::ElideNone);
+
+    //m_mdi_area->setUsesScrollButtons (true);
 
     bool show_it;
+
+    show_it = settings->value ("editor/tabbed_view",true).toBool ();
+    m_tabbed_view_action->setChecked (show_it);
+    bool tabbed = m_mdi_area->viewMode () == QMdiArea::TabbedView;
+    if (tabbed == ! show_it)
+      {
+        if (show_it)
+          m_mdi_area->setViewMode (QMdiArea::TabbedView);
+        else
+          m_mdi_area->setViewMode (QMdiArea::SubWindowView);
+        QList<QMdiSubWindow *> list = m_mdi_area->subWindowList ();
+        for (int i = 0; i < list.count (); i++)
+          {
+            if (show_it)
+              list.at (i)->showMaximized ();
+            else
+              list.at (i)->showNormal ();
+          }
+      }
+
     show_it = settings->value ("editor/showLineNumbers",true).toBool ();
     m_show_linenum_action->setChecked (show_it);
     show_it = settings->value ("editor/show_white_space",false).toBool ();
@@ -1092,6 +1119,10 @@ namespace octave
     shortcut_manager::set_shortcut (m_conv_eol_mac_action,     "editor_edit:conv_eol_mac");
 
     // View menu
+    shortcut_manager::set_shortcut (m_tabbed_view_action, "editor_view:tabbed_view");
+    shortcut_manager::set_shortcut (m_cascade_action, "editor_view:cascade_windows");
+    shortcut_manager::set_shortcut (m_v_tile_action, "editor_view:v_tile_windows");
+    shortcut_manager::set_shortcut (m_h_tile_action, "editor_view:h_tile_windows");
     shortcut_manager::set_shortcut (m_show_linenum_action, "editor_view:show_line_numbers");
     shortcut_manager::set_shortcut (m_show_whitespace_action, "editor_view:show_white_spaces");
     shortcut_manager::set_shortcut (m_show_eol_action, "editor_view:show_eol_chars");
@@ -1154,28 +1185,28 @@ namespace octave
   void file_editor::copyClipboard (void)
   {
     if (editor_tab_has_focus ())
-      emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+      emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                     QsciScintillaBase::SCI_COPY);
   }
 
   void file_editor::pasteClipboard (void)
   {
     if (editor_tab_has_focus ())
-      emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+      emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                     QsciScintillaBase::SCI_PASTE);
   }
 
   void file_editor::selectAll (void)
   {
     if (editor_tab_has_focus ())
-      emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+      emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                     QsciScintillaBase::SCI_SELECTALL);
   }
 
   void file_editor::do_undo (void)
   {
     if (editor_tab_has_focus ())
-      emit fetab_scintilla_command (m_tab_widget->currentWidget (),
+      emit fetab_scintilla_command (m_mdi_area->currentSubWindow ()->widget (),
                                     QsciScintillaBase::SCI_UNDO);
   }
 
@@ -1199,11 +1230,11 @@ namespace octave
     else
       {
         // Check whether this file is already open in the editor.
-        QWidget *tab = find_tab_widget (openFileName);
+        file_editor_tab *tab = find_tab_widget (openFileName);
 
         if (tab)
           {
-            m_tab_widget->setCurrentWidget (tab);
+            m_mdi_area->setActiveSubWindow (tab->sub_win ());
 
             if (line > 0)
               {
@@ -1240,7 +1271,7 @@ namespace octave
 
             // If <unnamed> was absent or modified, create a new tab.
             if (! fileEditorTab)
-              fileEditorTab = new file_editor_tab ();
+              fileEditorTab = new file_editor_tab (this);
 
             if (fileEditorTab)
               {
@@ -1251,7 +1282,7 @@ namespace octave
                     // Supply empty title then have the file_editor_tab update
                     // with full or short name.
                     if (! reusing)
-                      add_file_editor_tab (fileEditorTab, "");
+                      add_file_editor_tab (fileEditorTab);
                     fileEditorTab->update_window_title (false);
                     // file already loaded, add file to mru list here
                     QFileInfo file_info = QFileInfo (openFileName);
@@ -1364,6 +1395,67 @@ namespace octave
     emit request_settings_dialog ("editor_styles");
   }
 
+
+  void file_editor::tabbed_view (bool)
+  {
+    toggle_preference ("editor/tabbed_view",true);
+  }
+
+  void file_editor::disable_tabbed_view ()
+  {
+    QSettings *settings = resource_manager::get_settings ();
+    settings->setValue ("editor/tabbed_view", false);
+    notice_settings (settings);
+  }
+
+  void file_editor::cascade_windows (bool)
+  {
+    m_mdi_area->cascadeSubWindows ();
+    disable_tabbed_view ();
+  }
+
+  void file_editor::h_tile_windows(bool)
+  {
+    QList<QMdiSubWindow *> list = m_mdi_area->subWindowList();
+
+    if (list.isEmpty())
+      return;
+
+    disable_tabbed_view ();
+
+    QPoint position (0, 0);
+
+    foreach (QMdiSubWindow *w, list)
+      {
+        QRect rect (0, 0, m_mdi_area->width (),
+                    m_mdi_area->height () / list.count ());
+        w->setGeometry (rect);
+        w->move (position);
+        position.setY (position.y () + w->height ());
+      }
+  }
+
+  void file_editor::v_tile_windows(bool)
+  {
+    QList<QMdiSubWindow *> list = m_mdi_area->subWindowList();
+
+    if (list.isEmpty())
+      return;
+
+    disable_tabbed_view ();
+
+    QPoint position(0, 0);
+
+    foreach (QMdiSubWindow *w, list)
+      {
+        QRect rect (0, 0, m_mdi_area->width () / list.count (),
+                    m_mdi_area->height ());
+        w->setGeometry (rect);
+        w->move (position);
+        position.setX (position.x () + w->width ());
+      }
+  }
+
   void file_editor::show_line_numbers (bool)
   {
     toggle_preference ("editor/showLineNumbers",true);
@@ -1406,17 +1498,17 @@ namespace octave
 
   void file_editor::zoom_in (bool)
   {
-    emit fetab_zoom_in (m_tab_widget->currentWidget ());
+    emit fetab_zoom_in (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::zoom_out (bool)
   {
-    emit fetab_zoom_out (m_tab_widget->currentWidget ());
+    emit fetab_zoom_out (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::zoom_normal (bool)
   {
-    emit fetab_zoom_normal (m_tab_widget->currentWidget ());
+    emit fetab_zoom_normal (m_mdi_area->currentSubWindow ()->widget ());
   }
 
   void file_editor::create_context_menu (QMenu *menu)
@@ -1526,7 +1618,10 @@ namespace octave
     m_tool_bar = new QToolBar (editor_widget);
     m_tool_bar->setMovable (true);
 
-    m_tab_widget = new file_editor_tab_widget (editor_widget);
+    m_mdi_area = new QMdiArea (editor_widget);
+    m_mdi_area->setOption (QMdiArea::DontMaximizeSubWindowOnActivation, true);
+    m_mdi_area->setTabsClosable (true);
+    m_mdi_area->setTabsMovable (true);
 
     // the mru-list and an empty array of actions
     QSettings *settings = resource_manager::get_settings ();
@@ -1826,6 +1921,25 @@ namespace octave
 
     QMenu *view_menu = add_menu (m_menu_bar, tr ("&View"));
 
+    m_view_windows_menu = view_menu->addMenu (tr ("&Windows"));
+
+    m_tabbed_view_action
+      = add_action (m_view_windows_menu,
+                    tr ("&Tabbed View"),
+                    SLOT (tabbed_view (bool)));
+    m_tabbed_view_action->setCheckable (true);
+
+    m_cascade_action = add_action (m_view_windows_menu, tr ("&Cascade Windows"),
+                                   SLOT (cascade_windows (bool)));
+
+    m_v_tile_action
+      = add_action (m_view_windows_menu, tr ("Tile Windows &Vertically"),
+                    SLOT (v_tile_windows (bool)));
+
+    m_h_tile_action
+      = add_action (m_view_windows_menu, tr ("Tile Windows &Horizontally"),
+                    SLOT (h_tile_windows (bool)));
+
     m_view_editor_menu = view_menu->addMenu (tr ("&Editor"));
 
     m_show_linenum_action
@@ -1961,21 +2075,22 @@ namespace octave
 
     // tab navigation (no menu, only actions; slots in tab_bar)
 
+// FIXME MDI: Derive own mdi area
     m_switch_left_tab_action
       = add_action (nullptr, "", SLOT (switch_left_tab (void)),
-                    m_tab_widget->get_tab_bar ());
+                    m_mdi_area);
 
     m_switch_right_tab_action
       = add_action (nullptr, "", SLOT (switch_right_tab (void)),
-                    m_tab_widget->get_tab_bar ());
+                    m_mdi_area);
 
     m_move_tab_left_action
       = add_action (nullptr, "", SLOT (move_tab_left (void)),
-                    m_tab_widget->get_tab_bar ());
+                    m_mdi_area);
 
     m_move_tab_right_action
       = add_action (nullptr, "", SLOT (move_tab_right (void)),
-                    m_tab_widget->get_tab_bar ());
+                    m_mdi_area);
 
     // toolbar
 
@@ -2012,17 +2127,18 @@ namespace octave
     QVBoxLayout *vbox_layout = new QVBoxLayout ();
     vbox_layout->addWidget (m_menu_bar);
     vbox_layout->addWidget (m_tool_bar);
-    vbox_layout->addWidget (m_tab_widget);
+    vbox_layout->addWidget (m_mdi_area);
     vbox_layout->setMargin (0);
     editor_widget->setLayout (vbox_layout);
     setWidget (editor_widget);
 
     // create the context menu of the tab bar
-    tab_bar *bar = m_tab_widget->get_tab_bar ();
-    QMenu *ctx_men = bar->get_context_menu ();
-    ctx_men->addAction (m_close_action);
-    ctx_men->addAction (m_close_all_action);
-    ctx_men->addAction (m_close_others_action);
+    // FIXME MDI
+    //tab_bar *bar = m_mdi_area->get_tab_bar ();
+    //QMenu *ctx_men = bar->get_context_menu ();
+    //ctx_men->addAction (m_close_action);
+    //ctx_men->addAction (m_close_all_action);
+    //ctx_men->addAction (m_close_others_action);
 
     // signals
     connect (this,
@@ -2038,22 +2154,28 @@ namespace octave
 
     mru_menu_update ();
 
-    connect (m_tab_widget, SIGNAL (tabCloseRequested (int)),
+    // FIXME MDI
+    connect (m_mdi_area, SIGNAL (tabCloseRequested (int)),
              this, SLOT (handle_tab_close_request (int)));
 
-    connect (m_tab_widget, SIGNAL (currentChanged (int)),
-             this, SLOT (active_tab_changed (int)));
+    connect (m_mdi_area, SIGNAL (subWindowActivated (QMdiSubWindow *)),
+             this, SLOT (active_subwindow_changed (QMdiSubWindow *)));
 
     resize (500, 400);
     setWindowIcon (QIcon (":/actions/icons/logo.png"));
     set_title (tr ("Editor"));
 
     check_actions ();
+
+    setFocusProxy (m_mdi_area);
   }
 
-  void file_editor::add_file_editor_tab (file_editor_tab *f, const QString& fn)
+  void file_editor::add_file_editor_tab (file_editor_tab *f)
   {
-    m_tab_widget->addTab (f, fn);
+    // Add to the mdi area, update settings and show
+    f->setAttribute (Qt::WA_DeleteOnClose);
+    QMdiSubWindow *sub_win = m_mdi_area->addSubWindow (f);
+    f->set_sub_win (sub_win);
 
     // signals from the qscintilla edit area
     connect (f->qsci_edit_area (), SIGNAL (status_update (bool, bool)),
@@ -2080,12 +2202,10 @@ namespace octave
     connect (f, SIGNAL (tab_remove_request ()),
              this, SLOT (handle_tab_remove_request ()));
 
-    connect (f, SIGNAL (add_filename_to_list (const QString&,
-                                              const QString&, QWidget*)),
-             this, SLOT (handle_add_filename_to_list (const QString&,
-                                                      const QString&,
-                                                      QWidget*)));
-
+    connect (f, SIGNAL (add_filename_to_list (
+                         const QString&, const QString&, file_editor_tab*)),
+             this, SLOT (handle_add_filename_to_list (
+                         const QString&, const QString&, file_editor_tab*)));
     connect (f, SIGNAL (editor_check_conflict_save (const QString&, bool)),
              this, SLOT (check_conflict_save (const QString&, bool)));
 
@@ -2241,9 +2361,12 @@ namespace octave
              f, SLOT (do_breakpoint_marker (bool, const QWidget*, int,
                                             const QString&)));
 
-    m_tab_widget->setCurrentWidget (f);
-
     check_actions ();
+
+    sub_win->show ();
+    m_mdi_area->setActiveSubWindow (sub_win);
+    if (m_mdi_area->viewMode () == QMdiArea::TabbedView)
+      sub_win->showMaximized ();
   }
 
   void file_editor::mru_menu_update (void)
@@ -2364,14 +2487,14 @@ namespace octave
   }
 
   // Check whether this file is already open in the editor.
-  QWidget * file_editor::find_tab_widget (const QString& file)
+  file_editor_tab * file_editor::find_tab_widget (const QString& file)
   {
     // Have all file editor tabs signal what their filenames are.
     m_editor_tab_map.clear ();
     emit fetab_file_name_query (nullptr);
 
     // Check all tabs for the given file name
-    QWidget *retval = nullptr;
+    file_editor_tab *retval = nullptr;
 
     for (auto p = m_editor_tab_map.cbegin ();
          p != m_editor_tab_map.cend (); p++)
diff -r 7dad5fa7e88e -r 156c207aa03b libgui/src/m-editor/file-editor.h
--- a/libgui/src/m-editor/file-editor.h	Sat Jun 30 20:11:05 2018 +0200
+++ b/libgui/src/m-editor/file-editor.h	Sun Jul 01 15:49:37 2018 +0200
@@ -29,6 +29,7 @@ along with Octave; see the file COPYING.
 #include <QStatusBar>
 #include <QCloseEvent>
 #include <QTabWidget>
+#include <QMdiArea>
 #include <QStackedWidget>
 
 #include <QDragEnterEvent>
@@ -67,7 +68,7 @@ namespace octave
 
     struct tab_info
     {
-      QWidget *fet_ID;
+      file_editor_tab *fet_ID;
       QString encoding;
     };
 
@@ -160,7 +161,7 @@ namespace octave
     void fetab_delete_debugger_pointer (const QWidget *ID, int line = -1);
     void fetab_do_breakpoint_marker (bool insert, const QWidget *ID,
                                      int line = -1, const QString& = "");
-    void fetab_set_focus (const QWidget *ID);
+    void fetab_set_focus (const file_editor_tab *ID);
     void fetab_scintilla_command (const QWidget *ID, unsigned int sci_msg);
 
     void fetab_zoom_in (const QWidget *ID);
@@ -178,7 +179,7 @@ namespace octave
   public slots:
 
     void focus (void);
-    void set_focus (QWidget *fet);
+    void set_focus (QMdiSubWindow *fet);
     void enable_menu_shortcuts (bool);
     bool check_closing (void);
 
@@ -242,11 +243,12 @@ namespace octave
 
     void handle_file_name_changed (const QString& fileName,
                                    const QString& toolTip);
-    void handle_tab_close_request (int index);
+    void handle_tab_close_request (file_editor_tab *widget);
     void handle_tab_remove_request (void);
     void handle_add_filename_to_list (const QString& fileName,
-                                      const QString& encoding, QWidget *ID);
-    void active_tab_changed (int index);
+                                      const QString& encoding,
+                                      file_editor_tab *ID);
+    void active_subwindow_changed (QMdiSubWindow *w);
     void handle_editor_state_changed (bool enableCopy, bool is_octave_file);
     void handle_mru_add_file (const QString& file_name, const QString& encoding);
     void check_conflict_save (const QString& fileName, bool remove_on_success);
@@ -288,6 +290,11 @@ namespace octave
     void request_preferences (bool);
     void request_styles_preferences (bool);
 
+    void tabbed_view (bool);
+    void cascade_windows (bool);
+    void v_tile_windows (bool);
+    void h_tile_windows (bool);
+
     void show_line_numbers (bool);
     void show_white_space (bool);
     void show_eol_chars (bool);
@@ -313,7 +320,7 @@ namespace octave
 
     bool is_editor_console_tabbed (void);
     void construct (void);
-    void add_file_editor_tab (file_editor_tab *f, const QString& fn);
+    void add_file_editor_tab (file_editor_tab *f);
     void mru_menu_update (void);
     bool call_custom_editor (const QString& file_name = QString (), int line = -1);
 
@@ -321,9 +328,11 @@ namespace octave
 
     void handle_dir_remove (const QString& old_name, const QString& new_name);
 
+    void disable_tabbed_view (void);
+
     bool editor_tab_has_focus (void);
 
-    QWidget * find_tab_widget (const QString& openFileName);
+    file_editor_tab * find_tab_widget (const QString& openFileName);
     QAction * add_action (QMenu *menu, const QString& text,
                           const char *member, QWidget *receiver = nullptr);
     QAction * add_action (QMenu *menu, const QIcon& icon, const QString& text,
@@ -363,6 +372,10 @@ namespace octave
     QAction *m_context_help_action;
     QAction *m_context_doc_action;
 
+    QAction *m_tabbed_view_action;
+    QAction *m_cascade_action;
+    QAction *m_v_tile_action;
+    QAction *m_h_tile_action;
     QAction *m_show_linenum_action;
     QAction *m_show_whitespace_action;
     QAction *m_show_eol_action;
@@ -433,10 +446,11 @@ namespace octave
     QMenu *m_edit_nav_menu;
     QMenu *m_fileMenu;
     QMenu *m_view_editor_menu;
+    QMenu *m_view_windows_menu;
 
     QList<QAction*> m_fetab_actions;
 
-    file_editor_tab_widget *m_tab_widget;
+    QMdiArea *m_mdi_area;
 
     int m_marker_breakpoint;
 
diff -r 7dad5fa7e88e -r 156c207aa03b libgui/src/shortcut-manager.cc
--- a/libgui/src/shortcut-manager.cc	Sat Jun 30 20:11:05 2018 +0200
+++ b/libgui/src/shortcut-manager.cc	Sun Jul 01 15:49:37 2018 +0200
@@ -420,6 +420,14 @@ namespace octave
           QKeySequence ());
 
     // view
+    init (tr ("Tabbed View"), "editor_view:tabbed_view",
+          QKeySequence (ctrl_shift + Qt::Key_T));
+    init (tr ("Cascade Windows"), "editor_view:cascade_windows",
+          QKeySequence (ctrl_shift + Qt::Key_A));
+    init (tr ("Tile Windows Vertically"), "editor_view:v_tile_windows",
+          QKeySequence (ctrl_shift + Qt::Key_V));
+    init (tr ("Tile Windows Horizontally"), "editor_view:h_tile_windows",
+          QKeySequence (ctrl_shift + Qt::Key_H));
     init (tr ("Show Line Numbers"), "editor_view:show_line_numbers",
           QKeySequence ());
     init (tr ("Show Whitespace Characters"), "editor_view:show_white_spaces",
