mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
Transfer some LFUNs from LyXFunc to GuiView and get rid of GuiView methods.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21583 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fcdc4f8a6b
commit
f8490161bd
@ -920,6 +920,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
setErrorMessage(flag.message());
|
||||
} else {
|
||||
switch (action) {
|
||||
// Let lyx_view_ dispatch its own actions.
|
||||
case LFUN_COMMAND_EXECUTE:
|
||||
case LFUN_DROP_LAYOUTS_CHOICE:
|
||||
case LFUN_MENU_OPEN:
|
||||
case LFUN_TOOLBAR_TOGGLE:
|
||||
BOOST_ASSERT(lyx_view_);
|
||||
lyx_view_->dispatch(cmd);
|
||||
break;
|
||||
|
||||
case LFUN_WORD_FIND_FORWARD:
|
||||
case LFUN_WORD_FIND_BACKWARD: {
|
||||
@ -949,11 +957,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
lyx_view_->message(keyseq.printOptions(true));
|
||||
break;
|
||||
|
||||
case LFUN_COMMAND_EXECUTE:
|
||||
BOOST_ASSERT(lyx_view_);
|
||||
lyx_view_->dispatch(cmd);
|
||||
break;
|
||||
|
||||
case LFUN_CANCEL:
|
||||
BOOST_ASSERT(lyx_view_ && lyx_view_->view());
|
||||
keyseq.reset();
|
||||
@ -1368,16 +1371,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
updateFlags = Update::None;
|
||||
break;
|
||||
|
||||
case LFUN_DROP_LAYOUTS_CHOICE:
|
||||
BOOST_ASSERT(lyx_view_);
|
||||
lyx_view_->openLayoutList();
|
||||
break;
|
||||
|
||||
case LFUN_MENU_OPEN:
|
||||
BOOST_ASSERT(lyx_view_);
|
||||
lyx_view_->openMenu(from_utf8(argument));
|
||||
break;
|
||||
|
||||
// --- lyxserver commands ----------------------------
|
||||
case LFUN_SERVER_GET_NAME:
|
||||
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
|
||||
@ -2037,30 +2030,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
LyX::ref().session().bookmarks().clear();
|
||||
break;
|
||||
|
||||
case LFUN_TOOLBAR_TOGGLE: {
|
||||
BOOST_ASSERT(lyx_view_);
|
||||
string const name = cmd.getArg(0);
|
||||
bool const allowauto = cmd.getArg(1) == "allowauto";
|
||||
lyx_view_->toggleToolbarState(name, allowauto);
|
||||
ToolbarInfo * tbi = lyx_view_->getToolbarInfo(name);
|
||||
if (!tbi) {
|
||||
setMessage(bformat(_("Unknown toolbar \"%1$s\""),
|
||||
from_utf8(name)));
|
||||
break;
|
||||
}
|
||||
docstring state;
|
||||
if (tbi->flags & ToolbarInfo::ON)
|
||||
state = _("on");
|
||||
else if (tbi->flags & ToolbarInfo::OFF)
|
||||
state = _("off");
|
||||
else if (tbi->flags & ToolbarInfo::AUTO)
|
||||
state = _("auto");
|
||||
|
||||
setMessage(bformat(_("Toolbar \"%1$s\" state set to %2$s"),
|
||||
_(tbi->gui_name), state));
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
BOOST_ASSERT(lyx_view_);
|
||||
view()->cursor().dispatch(cmd);
|
||||
|
@ -24,7 +24,6 @@ class Buffer;
|
||||
class BufferView;
|
||||
class FuncRequest;
|
||||
class Inset;
|
||||
class ToolbarInfo;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
@ -95,12 +94,8 @@ public:
|
||||
/// set a buffer to the current workarea.
|
||||
virtual void setBuffer(Buffer * b) = 0; ///< \c Buffer to set.
|
||||
|
||||
///
|
||||
virtual void openLayoutList() = 0;
|
||||
///
|
||||
virtual bool isToolbarVisible(std::string const & id) = 0;
|
||||
///
|
||||
virtual void openMenu(docstring const & name) = 0;
|
||||
|
||||
/// get access to the dialogs
|
||||
virtual Dialogs & getDialogs() = 0;
|
||||
@ -117,10 +112,6 @@ public:
|
||||
virtual void updateLayoutChoice(bool force) = 0;
|
||||
/// update the toolbar
|
||||
virtual void updateToolbars() = 0;
|
||||
/// get toolbar info
|
||||
virtual ToolbarInfo * getToolbarInfo(std::string const & name) = 0;
|
||||
/// toggle toolbar state
|
||||
virtual void toggleToolbarState(std::string const & name, bool allowauto) = 0;
|
||||
/// update the status bar
|
||||
virtual void updateStatusBar() = 0;
|
||||
/// display a message in the view
|
||||
|
@ -958,18 +958,6 @@ void GuiView::showMiniBuffer(bool visible)
|
||||
}
|
||||
|
||||
|
||||
void GuiView::openMenu(docstring const & name)
|
||||
{
|
||||
d.menubar_->openByName(toqstr(name));
|
||||
}
|
||||
|
||||
|
||||
void GuiView::openLayoutList()
|
||||
{
|
||||
d.toolbars_->openLayoutList();
|
||||
}
|
||||
|
||||
|
||||
void GuiView::updateLayoutChoice(bool force)
|
||||
{
|
||||
// Don't show any layouts without a buffer
|
||||
@ -1018,26 +1006,6 @@ void GuiView::updateToolbars()
|
||||
}
|
||||
|
||||
|
||||
ToolbarInfo * GuiView::getToolbarInfo(string const & name)
|
||||
{
|
||||
return d.toolbars_->getToolbarInfo(name);
|
||||
}
|
||||
|
||||
|
||||
void GuiView::toggleToolbarState(string const & name, bool allowauto)
|
||||
{
|
||||
// it is possible to get current toolbar status like this,...
|
||||
// but I decide to obey the order of ToolbarBackend::flags
|
||||
// and disregard real toolbar status.
|
||||
// toolbars_->saveToolbarInfo();
|
||||
//
|
||||
// toggle state on/off/auto
|
||||
d.toolbars_->toggleToolbarState(name, allowauto);
|
||||
// update toolbar
|
||||
updateToolbars();
|
||||
}
|
||||
|
||||
|
||||
Buffer * GuiView::buffer()
|
||||
{
|
||||
if (d.current_work_area_)
|
||||
@ -1211,9 +1179,48 @@ void GuiView::dispatch(FuncRequest const & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_COMMAND_EXECUTE:
|
||||
showMiniBuffer(true);
|
||||
d.toolbars_->showCommandBuffer(true);
|
||||
break;
|
||||
|
||||
case LFUN_DROP_LAYOUTS_CHOICE:
|
||||
d.toolbars_->openLayoutList();
|
||||
break;
|
||||
|
||||
case LFUN_MENU_OPEN:
|
||||
d.menubar_->openByName(toqstr(cmd.argument()));
|
||||
break;
|
||||
|
||||
case LFUN_TOOLBAR_TOGGLE: {
|
||||
string const name = cmd.getArg(0);
|
||||
bool const allowauto = cmd.getArg(1) == "allowauto";
|
||||
// it is possible to get current toolbar status like this,...
|
||||
// but I decide to obey the order of ToolbarBackend::flags
|
||||
// and disregard real toolbar status.
|
||||
// toolbars_->saveToolbarInfo();
|
||||
//
|
||||
// toggle state on/off/auto
|
||||
d.toolbars_->toggleToolbarState(name, allowauto);
|
||||
// update toolbar
|
||||
updateToolbars();
|
||||
|
||||
ToolbarInfo * tbi = d.toolbars_->getToolbarInfo(name);
|
||||
if (!tbi) {
|
||||
message(bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name)));
|
||||
break;
|
||||
}
|
||||
docstring state;
|
||||
if (tbi->flags & ToolbarInfo::ON)
|
||||
state = _("on");
|
||||
else if (tbi->flags & ToolbarInfo::OFF)
|
||||
state = _("off");
|
||||
else if (tbi->flags & ToolbarInfo::AUTO)
|
||||
state = _("auto");
|
||||
|
||||
message(bformat(_("Toolbar \"%1$s\" state set to %2$s"),
|
||||
_(tbi->gui_name), state));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
theLyXFunc().setLyXView(this);
|
||||
lyx::dispatch(cmd);
|
||||
|
@ -29,6 +29,7 @@ class QMenu;
|
||||
namespace lyx {
|
||||
|
||||
class Timeout;
|
||||
class ToolbarInfo;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
@ -74,13 +75,9 @@ public:
|
||||
virtual void message(docstring const & str);
|
||||
virtual bool hasFocus() const;
|
||||
void showMiniBuffer(bool);
|
||||
void openMenu(docstring const &);
|
||||
void openLayoutList();
|
||||
void updateLayoutChoice(bool force);
|
||||
bool isToolbarVisible(std::string const & id);
|
||||
void updateToolbars();
|
||||
ToolbarInfo * getToolbarInfo(std::string const & name);
|
||||
void toggleToolbarState(std::string const & name, bool allowauto);
|
||||
///
|
||||
QMenu * createPopupMenu();
|
||||
|
||||
@ -201,6 +198,9 @@ private:
|
||||
///
|
||||
void setIconSize(unsigned int size);
|
||||
|
||||
/// toggle toolbar state
|
||||
void toggleToolbarState(std::string const & name, bool allowauto);
|
||||
|
||||
///
|
||||
struct GuiViewPrivate;
|
||||
GuiViewPrivate & d;
|
||||
|
Loading…
Reference in New Issue
Block a user