Introducing LFUN_SPLIT_VIEW

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23084 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-02-20 21:46:49 +00:00
parent f9963f83c8
commit 9d40f89b58
6 changed files with 24 additions and 7 deletions

View File

@ -1140,6 +1140,8 @@ void LyXAction::init()
{ LFUN_WINDOW_NEW, "window-new", NoBuffer, Buffer }, { LFUN_WINDOW_NEW, "window-new", NoBuffer, Buffer },
{ LFUN_WINDOW_CLOSE, "window-close", 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, "dialog-show", NoBuffer, Edit },
{ LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-new-inset", Noop, Edit }, { LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-new-inset", Noop, Edit },
{ LFUN_DIALOG_UPDATE, "dialog-update", NoBuffer, Edit }, { LFUN_DIALOG_UPDATE, "dialog-update", NoBuffer, Edit },

View File

@ -452,6 +452,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
case LFUN_INSET_APPLY: case LFUN_INSET_APPLY:
case LFUN_BUFFER_WRITE: case LFUN_BUFFER_WRITE:
case LFUN_BUFFER_WRITE_AS: case LFUN_BUFFER_WRITE_AS:
case LFUN_SPLIT_VIEW:
if (lyx_view_) if (lyx_view_)
return lyx_view_->getStatus(cmd); return lyx_view_->getStatus(cmd);
enable = false; enable = false;

View File

@ -706,23 +706,21 @@ GuiWorkArea * GuiView::workArea(Buffer & buffer)
GuiWorkArea * GuiView::addWorkArea(Buffer & buffer) GuiWorkArea * GuiView::addWorkArea(Buffer & buffer)
{ {
// Automatically create a TabWorkArea if there are none yet. // Automatically create a TabWorkArea if there are none yet.
if (!d.splitter_->count()) TabWorkArea * tab_widget = d.splitter_->count()
addTabWorkArea(); ? d.currentTabWorkArea() : addTabWorkArea();
TabWorkArea * tab_widget = d.currentTabWorkArea();
return tab_widget->addWorkArea(buffer, *this); return tab_widget->addWorkArea(buffer, *this);
} }
void GuiView::addTabWorkArea() TabWorkArea * GuiView::addTabWorkArea()
{ {
TabWorkArea * twa = new TabWorkArea; TabWorkArea * twa = new TabWorkArea;
QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)), QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)),
this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *))); this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *)));
d.splitter_->addWidget(twa); d.splitter_->addWidget(twa);
d.stack_widget_->setCurrentWidget(d.splitter_); d.stack_widget_->setCurrentWidget(d.splitter_);
return twa;
} }
@ -967,6 +965,10 @@ FuncStatus GuiView::getStatus(FuncRequest const & cmd)
enable = buf; enable = buf;
break; break;
case LFUN_SPLIT_VIEW:
enable = buf;
break;
case LFUN_TOOLBAR_TOGGLE: case LFUN_TOOLBAR_TOGGLE:
flag.setOnOff(d.toolbars_->visible(cmd.getArg(0))); flag.setOnOff(d.toolbars_->visible(cmd.getArg(0)));
break; break;
@ -1814,6 +1816,15 @@ bool GuiView::dispatch(FuncRequest const & cmd)
setFocus(); setFocus();
break; 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: default:
return false; return false;
} }

View File

@ -39,6 +39,7 @@ class Dialog;
class GuiLayoutBox; class GuiLayoutBox;
class GuiToolbar; class GuiToolbar;
class GuiWorkArea; class GuiWorkArea;
class TabWorkArea;
/** /**
* GuiView - Qt4 implementation of LyXView * GuiView - Qt4 implementation of LyXView
@ -160,7 +161,7 @@ private Q_SLOTS:
private: private:
/// ///
void addTabWorkArea(); TabWorkArea * addTabWorkArea();
/// connect to signals in the given BufferView /// connect to signals in the given BufferView
void connectBufferView(BufferView & bv); void connectBufferView(BufferView & bv);

View File

@ -572,6 +572,7 @@ void GuiWorkArea::contextMenuEvent(QContextMenuEvent * e)
void GuiWorkArea::focusInEvent(QFocusEvent * /*event*/) void GuiWorkArea::focusInEvent(QFocusEvent * /*event*/)
{ {
lyx_view_->setCurrentWorkArea(this);
// Repaint the whole screen. // Repaint the whole screen.
// Note: this is different from redraw() as only the backing pixmap // Note: this is different from redraw() as only the backing pixmap
// will be redrawn, which is cheap. // will be redrawn, which is cheap.

View File

@ -413,6 +413,7 @@ enum kb_action {
LFUN_IN_MATHMACROTEMPLATE, LFUN_IN_MATHMACROTEMPLATE,
LFUN_SCROLL, LFUN_SCROLL,
LFUN_UI_TOGGLE, LFUN_UI_TOGGLE,
LFUN_SPLIT_VIEW,
LFUN_LASTACTION // end of the table LFUN_LASTACTION // end of the table
}; };