mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
Fix bug 3799.
* src/LyXAction.cpp: * src/lfuns.h: remove LFUN_TOOLBAR_TOGGLE_STATE. * src/LyXFunc.cpp (getStatus, dispatch): merge LFUN_TOOLBAR_TOGGLE and LFUN_TOOLBAR_TOGGLE_STATE. Add an informational message after dispatch. * src/frontends/LyXView.cpp (toggleToolbarState): * src/frontends/Toolbars.cpp (toggleToolbarState): add allowauto parameter. * src/MenuBackend.cpp (expandToolbars): adapt. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18690 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
087e9eb578
commit
36481c2744
@ -364,7 +364,6 @@ void LyXAction::init()
|
||||
{ LFUN_WINDOW_NEW, "window-new", NoBuffer },
|
||||
{ LFUN_WINDOW_CLOSE, "window-close", NoBuffer },
|
||||
{ LFUN_UNICODE_INSERT, "unicode-insert", Noop },
|
||||
{ LFUN_TOOLBAR_TOGGLE_STATE, "", NoBuffer },
|
||||
{ LFUN_TOOLBAR_TOGGLE, "toolbar-toggle", NoBuffer },
|
||||
{ LFUN_NOMENCL_INSERT, "nomencl-insert", Noop },
|
||||
{ LFUN_NOMENCL_PRINT, "nomencl-print", Noop },
|
||||
|
@ -617,19 +617,11 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
enable = LyX::ref().session().bookmarks().size() > 0;
|
||||
break;
|
||||
|
||||
case LFUN_TOOLBAR_TOGGLE_STATE: {
|
||||
ToolbarInfo::Flags flags = lyx_view_->getToolbarState(to_utf8(cmd.argument()));
|
||||
if (!(flags & ToolbarInfo::AUTO))
|
||||
flag.setOnOff(flags & ToolbarInfo::ON);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_TOOLBAR_TOGGLE: {
|
||||
bool const current = lyx_view_->getToolbars().visible(cmd.getArg(0));
|
||||
flag.setOnOff(current);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_WINDOW_CLOSE: {
|
||||
enable = (theApp()->gui().viewIds().size() > 1);
|
||||
break;
|
||||
@ -1763,15 +1755,23 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
LyX::ref().session().bookmarks().clear();
|
||||
break;
|
||||
|
||||
case LFUN_TOOLBAR_TOGGLE_STATE:
|
||||
lyx_view_->toggleToolbarState(argument);
|
||||
break;
|
||||
|
||||
case LFUN_TOOLBAR_TOGGLE: {
|
||||
BOOST_ASSERT(lyx_view_);
|
||||
string const name = to_utf8(cmd.argument());
|
||||
bool const current = lyx_view_->getToolbars().visible(name);
|
||||
lyx_view_->getToolbars().display(name, !current);
|
||||
string const name = cmd.getArg(0);
|
||||
bool const allowauto = cmd.getArg(1) == "allowauto";
|
||||
lyx_view_->toggleToolbarState(name, allowauto);
|
||||
ToolbarInfo::Flags const flags =
|
||||
lyx_view_->getToolbarState(name);
|
||||
docstring state;
|
||||
if (flags & ToolbarInfo::ON)
|
||||
state = _("on");
|
||||
else if (flags & ToolbarInfo::OFF)
|
||||
state = _("off");
|
||||
else if (flags & ToolbarInfo::AUTO)
|
||||
state = _("auto");
|
||||
|
||||
setMessage(bformat(_("Toolbar \"%1$s\" state set to %2$s"),
|
||||
from_ascii(name), state));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -789,9 +789,10 @@ void expandToolbars(Menu & tomenu)
|
||||
|
||||
for (; cit != end; ++cit) {
|
||||
docstring label = _(cit->gui_name);
|
||||
// frontends are not supposed to turn on/off toolbars, if they cannot
|
||||
// update ToolbarBackend::flags. That is to say, ToolbarsBackend::flags
|
||||
// should reflect the true state of toolbars.
|
||||
// frontends are not supposed to turn on/off toolbars,
|
||||
// if they cannot update ToolbarBackend::flags. That
|
||||
// is to say, ToolbarsBackend::flags should reflect
|
||||
// the true state of toolbars.
|
||||
//
|
||||
// menu is displayed as
|
||||
// on/off review
|
||||
@ -801,7 +802,7 @@ void expandToolbars(Menu & tomenu)
|
||||
if (cit->flags & ToolbarInfo::AUTO)
|
||||
label += _(" (auto)");
|
||||
tomenu.add(MenuItem(MenuItem::Command, label,
|
||||
FuncRequest(LFUN_TOOLBAR_TOGGLE_STATE, cit->name)));
|
||||
FuncRequest(LFUN_TOOLBAR_TOGGLE, cit->name + " allowauto")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ ToolbarInfo::Flags LyXView::getToolbarState(string const & name)
|
||||
}
|
||||
|
||||
|
||||
void LyXView::toggleToolbarState(string const & name)
|
||||
void LyXView::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
|
||||
@ -361,7 +361,7 @@ void LyXView::toggleToolbarState(string const & name)
|
||||
// toolbars_->saveToolbarInfo();
|
||||
//
|
||||
// toggle state on/off/auto
|
||||
toolbars_->toggleToolbarState(name);
|
||||
toolbars_->toggleToolbarState(name, allowauto);
|
||||
// update toolbar
|
||||
updateToolbars();
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public:
|
||||
/// get toolbar state
|
||||
ToolbarInfo::Flags getToolbarState(std::string const & name);
|
||||
/// toggle toolbar state
|
||||
void toggleToolbarState(std::string const & name);
|
||||
void toggleToolbarState(std::string const & name, bool allowauto);
|
||||
/// update the menubar
|
||||
void updateMenubar();
|
||||
/// update the status bar
|
||||
|
@ -187,7 +187,7 @@ ToolbarInfo::Flags Toolbars::getToolbarState(string const & name)
|
||||
}
|
||||
|
||||
|
||||
void Toolbars::toggleToolbarState(string const & name)
|
||||
void Toolbars::toggleToolbarState(string const & name, bool allowauto)
|
||||
{
|
||||
ToolbarBackend::Toolbars::iterator cit = toolbarbackend.begin();
|
||||
ToolbarBackend::Toolbars::iterator end = toolbarbackend.end();
|
||||
@ -203,8 +203,10 @@ void Toolbars::toggleToolbarState(string const & name)
|
||||
} else if (flags & ToolbarInfo::AUTO) {
|
||||
TurnOffFlag(AUTO);
|
||||
TurnOnFlag(OFF);
|
||||
} else if ((flags & ToolbarInfo::MATH) || (flags & ToolbarInfo::TABLE)
|
||||
|| (flags & ToolbarInfo::REVIEW)) {
|
||||
} else if (allowauto
|
||||
&& ((flags & ToolbarInfo::MATH)
|
||||
|| (flags & ToolbarInfo::TABLE)
|
||||
|| (flags & ToolbarInfo::REVIEW))) {
|
||||
// for math etc, toggle from on -> auto
|
||||
TurnOffFlag(ON);
|
||||
TurnOnFlag(AUTO);
|
||||
@ -213,7 +215,7 @@ void Toolbars::toggleToolbarState(string const & name)
|
||||
TurnOffFlag(ON);
|
||||
TurnOnFlag(OFF);
|
||||
}
|
||||
cit->flags = static_cast<lyx::ToolbarInfo::Flags>(flags);
|
||||
cit->flags = static_cast<ToolbarInfo::Flags>(flags);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -93,8 +93,10 @@ public:
|
||||
/// get toolbar state (on/off/auto)
|
||||
ToolbarInfo::Flags getToolbarState(std::string const & name);
|
||||
|
||||
/// toggle the state of toolbars (on/off/auto)
|
||||
void toggleToolbarState(std::string const & name);
|
||||
/** toggle the state of toolbars (on/off/auto). Skip "auto"
|
||||
* when allowauto is false.
|
||||
*/
|
||||
void toggleToolbarState(std::string const & name, bool allowauto);
|
||||
|
||||
/// Update the state of the toolbars.
|
||||
void update(bool in_math, bool in_table, bool review);
|
||||
|
@ -371,15 +371,13 @@ enum kb_action {
|
||||
LFUN_WINDOW_CLOSE, // Abdel 20061023
|
||||
LFUN_UNICODE_INSERT, // Lgb 20061022
|
||||
LFUN_BOOKMARK_CLEAR, // bpeng 20061031
|
||||
LFUN_TOOLBAR_TOGGLE_STATE, // bpeng 20061101
|
||||
LFUN_NOMENCL_INSERT, // Ugras
|
||||
// 285
|
||||
LFUN_NOMENCL_PRINT, // Ugras
|
||||
// 285
|
||||
LFUN_CLEARPAGE_INSERT, // Ugras 20061125
|
||||
LFUN_CLEARDOUBLEPAGE_INSERT, // Ugras 20061125
|
||||
LFUN_LISTING_INSERT, // Herbert 20011110, bpeng 20070502
|
||||
LFUN_TOOLBAR_TOGGLE, // Edwin 20070521
|
||||
//290
|
||||
|
||||
LFUN_LASTACTION // end of the table
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user