]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiView.cpp
LFUN_CLOSE_TAB_GROUP: bug fixes.
[lyx.git] / src / frontends / qt4 / GuiView.cpp
index a7e02019eddead6ffa4db5745c3fcba69209e339..42b96807048a8fc66e7641e82e788306be053ae0 100644 (file)
@@ -225,11 +225,9 @@ struct GuiView::GuiViewPrivate
                        return tabWorkArea(0);
 
                for (int i = 0; i != splitter_->count(); ++i) {
-                       QWidget * w = splitter_->widget(i);
-                       if (!w->hasFocus())
-                               continue;
-                       if (TabWorkArea * tab_widget = dynamic_cast<TabWorkArea *>(w))
-                               return tab_widget;
+                       TabWorkArea * twa = tabWorkArea(i);
+                       if (current_work_area_ == twa->currentWorkArea())
+                               return twa;
                }
 
                // None has the focus so we just take the first one.
@@ -695,11 +693,8 @@ GuiToolbar * GuiView::makeToolbar(ToolbarInfo const & tbinfo, bool newline)
 
 GuiWorkArea * GuiView::workArea(Buffer & buffer)
 {
-       for (int i = 0; i != d.splitter_->count(); ++i) {
-               GuiWorkArea * wa = d.tabWorkArea(i)->workArea(buffer);
-               if (wa)
-                       return wa;
-       }
+       if (TabWorkArea * twa = d.currentTabWorkArea())
+               return twa->workArea(buffer);
        return 0;
 }
 
@@ -969,6 +964,10 @@ FuncStatus GuiView::getStatus(FuncRequest const & cmd)
                enable = buf;
                break;
 
+       case LFUN_CLOSE_TAB_GROUP:
+               enable = d.currentTabWorkArea();
+               break;
+
        case LFUN_TOOLBAR_TOGGLE:
                flag.setOnOff(d.toolbars_->visible(cmd.getArg(0)));
                break;
@@ -1818,10 +1817,24 @@ bool GuiView::dispatch(FuncRequest const & cmd)
 
                case LFUN_SPLIT_VIEW:
                        if (Buffer * buf = buffer()) {
+                               string const orientation = cmd.getArg(0);
+                               d.splitter_->setOrientation(orientation == "vertical"
+                                       ? Qt::Vertical : Qt::Horizontal);
                                TabWorkArea * twa = addTabWorkArea();
                                GuiWorkArea * wa = twa->addWorkArea(*buf, *this);
                                setCurrentWorkArea(wa);
-                               connectBufferView(wa->bufferView());
+                       }
+                       break;
+
+               case LFUN_CLOSE_TAB_GROUP:
+                       if (TabWorkArea * twa = d.currentTabWorkArea()) {
+                               delete twa;
+                               twa = d.currentTabWorkArea();
+                               // Switch to the next GuiWorkArea in the found TabWorkArea.
+                               d.current_work_area_ = twa? twa->currentWorkArea() : 0;
+                               if (d.splitter_->count() == 0)
+                                       // No more work area, switch to the background widget.
+                                       d.setBackground();
                        }
                        break;