From 9d40f89b580ba15e58686ecb6c99f87322a55c46 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 20 Feb 2008 21:46:49 +0000 Subject: [PATCH] Introducing LFUN_SPLIT_VIEW git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23084 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXAction.cpp | 2 ++ src/LyXFunc.cpp | 1 + src/frontends/qt4/GuiView.cpp | 23 +++++++++++++++++------ src/frontends/qt4/GuiView.h | 3 ++- src/frontends/qt4/GuiWorkArea.cpp | 1 + src/lfuns.h | 1 + 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index e00f3be2f5..440471a8d4 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -1140,6 +1140,8 @@ void LyXAction::init() { LFUN_WINDOW_NEW, "window-new", NoBuffer, Buffer }, { LFUN_WINDOW_CLOSE, "window-close", NoBuffer, Buffer }, + { LFUN_SPLIT_VIEW, "split-view", ReadOnly, Buffer }, + { LFUN_DIALOG_SHOW, "dialog-show", NoBuffer, Edit }, { LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-new-inset", Noop, Edit }, { LFUN_DIALOG_UPDATE, "dialog-update", NoBuffer, Edit }, diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 626d2079c1..9c37060493 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -452,6 +452,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const case LFUN_INSET_APPLY: case LFUN_BUFFER_WRITE: case LFUN_BUFFER_WRITE_AS: + case LFUN_SPLIT_VIEW: if (lyx_view_) return lyx_view_->getStatus(cmd); enable = false; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index ec44d867dc..a7e02019ed 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -706,23 +706,21 @@ GuiWorkArea * GuiView::workArea(Buffer & buffer) GuiWorkArea * GuiView::addWorkArea(Buffer & buffer) { - // Automatically create a TabWorkArea if there are none yet. - if (!d.splitter_->count()) - addTabWorkArea(); - - TabWorkArea * tab_widget = d.currentTabWorkArea(); + TabWorkArea * tab_widget = d.splitter_->count() + ? d.currentTabWorkArea() : addTabWorkArea(); return tab_widget->addWorkArea(buffer, *this); } -void GuiView::addTabWorkArea() +TabWorkArea * GuiView::addTabWorkArea() { TabWorkArea * twa = new TabWorkArea; QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)), this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *))); d.splitter_->addWidget(twa); d.stack_widget_->setCurrentWidget(d.splitter_); + return twa; } @@ -967,6 +965,10 @@ FuncStatus GuiView::getStatus(FuncRequest const & cmd) enable = buf; break; + case LFUN_SPLIT_VIEW: + enable = buf; + break; + case LFUN_TOOLBAR_TOGGLE: flag.setOnOff(d.toolbars_->visible(cmd.getArg(0))); break; @@ -1814,6 +1816,15 @@ bool GuiView::dispatch(FuncRequest const & cmd) setFocus(); break; + case LFUN_SPLIT_VIEW: + if (Buffer * buf = buffer()) { + TabWorkArea * twa = addTabWorkArea(); + GuiWorkArea * wa = twa->addWorkArea(*buf, *this); + setCurrentWorkArea(wa); + connectBufferView(wa->bufferView()); + } + break; + default: return false; } diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index c2a75b49a2..d0c4298596 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -39,6 +39,7 @@ class Dialog; class GuiLayoutBox; class GuiToolbar; class GuiWorkArea; +class TabWorkArea; /** * GuiView - Qt4 implementation of LyXView @@ -160,7 +161,7 @@ private Q_SLOTS: private: /// - void addTabWorkArea(); + TabWorkArea * addTabWorkArea(); /// connect to signals in the given BufferView void connectBufferView(BufferView & bv); diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 6f930f61a4..6e48e42390 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -572,6 +572,7 @@ void GuiWorkArea::contextMenuEvent(QContextMenuEvent * e) void GuiWorkArea::focusInEvent(QFocusEvent * /*event*/) { + lyx_view_->setCurrentWorkArea(this); // Repaint the whole screen. // Note: this is different from redraw() as only the backing pixmap // will be redrawn, which is cheap. diff --git a/src/lfuns.h b/src/lfuns.h index ccb4a8ea53..c3f31b0a91 100644 --- a/src/lfuns.h +++ b/src/lfuns.h @@ -413,6 +413,7 @@ enum kb_action { LFUN_IN_MATHMACROTEMPLATE, LFUN_SCROLL, LFUN_UI_TOGGLE, + LFUN_SPLIT_VIEW, LFUN_LASTACTION // end of the table };