mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 22:41:09 +00:00
Prettier view->toolbars menu.
* src/lyxfunc.C: better handle LFUN_TOOLBAR_TOGGLE_STATE * src/frontends/LyXView.h/C: add getToolbarState * src/frontends/Toolbars.h/C: add getToolbarState * src/MenuBackend.C: change display of menu item. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15692 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
eaa33dca6d
commit
b084ac0a4a
@ -768,17 +768,16 @@ void expandToolbars(Menu & tomenu, Buffer const * buf)
|
|||||||
int i = 1;
|
int i = 1;
|
||||||
for (; cit != end; ++cit, ++i) {
|
for (; cit != end; ++cit, ++i) {
|
||||||
docstring label = convert<docstring>(i) + ". " + _(cit->name);
|
docstring label = convert<docstring>(i) + ". " + _(cit->name);
|
||||||
// frontend does not update ToolbarBackend::flags when it changes toolbar
|
// frontends are not supposed to turn on/off toolbars, if they can not
|
||||||
// Therefore, I can not tell from the flags if the toolbar is on or off
|
// update ToolbarBackend::flags. That is to say, ToolbarsBackend::flags
|
||||||
// it is then less confusing to say:
|
// should reflect the true state of toolbars.
|
||||||
// this is: always on/off/auto
|
|
||||||
// frontend toolbar change is temporary.
|
|
||||||
//
|
//
|
||||||
if (cit->flags & ToolbarBackend::ON)
|
// menu is displayed as
|
||||||
label += _(" (always on)");
|
// on/off review
|
||||||
else if (cit->flags & ToolbarBackend::OFF)
|
// and
|
||||||
label += _(" (always off)");
|
// review (auto)
|
||||||
else if (cit->flags & ToolbarBackend::AUTO)
|
// in the case of auto.
|
||||||
|
if (cit->flags & ToolbarBackend::AUTO)
|
||||||
label += _(" (auto)");
|
label += _(" (auto)");
|
||||||
label += char_type('|') + convert<docstring>(i);
|
label += char_type('|') + convert<docstring>(i);
|
||||||
tomenu.add(MenuItem(MenuItem::Command, label,
|
tomenu.add(MenuItem(MenuItem::Command, label,
|
||||||
|
@ -305,6 +305,12 @@ void LyXView::updateToolbars()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ToolbarBackend::Flags LyXView::getToolbarState(string const & name)
|
||||||
|
{
|
||||||
|
return toolbars_->getToolbarState(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXView::toggleToolbarState(string const & name)
|
void LyXView::toggleToolbarState(string const & name)
|
||||||
{
|
{
|
||||||
// it is possible to get current toolbar status like this,...
|
// it is possible to get current toolbar status like this,...
|
||||||
|
@ -136,6 +136,8 @@ public:
|
|||||||
|
|
||||||
/// update the toolbar
|
/// update the toolbar
|
||||||
void updateToolbars();
|
void updateToolbars();
|
||||||
|
/// get toolbar state
|
||||||
|
ToolbarBackend::Flags getToolbarState(std::string const & name);
|
||||||
/// toggle toolbar state
|
/// toggle toolbar state
|
||||||
void toggleToolbarState(std::string const & name);
|
void toggleToolbarState(std::string const & name);
|
||||||
/// update the menubar
|
/// update the menubar
|
||||||
|
@ -129,6 +129,21 @@ void Toolbars::display(string const & name, bool show)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ToolbarBackend::Flags Toolbars::getToolbarState(string const & name)
|
||||||
|
{
|
||||||
|
ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
|
||||||
|
ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
|
||||||
|
|
||||||
|
for (; cit != end; ++cit) {
|
||||||
|
if (cit->name == name)
|
||||||
|
return cit->flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
lyxerr[Debug::GUI] << "Toolbar::display: no toolbar named "
|
||||||
|
<< name << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Toolbars::toggleToolbarState(string const & name)
|
void Toolbars::toggleToolbarState(string const & name)
|
||||||
{
|
{
|
||||||
ToolbarBackend::Toolbars::iterator cit = toolbarbackend.begin();
|
ToolbarBackend::Toolbars::iterator cit = toolbarbackend.begin();
|
||||||
@ -154,9 +169,11 @@ void Toolbars::toggleToolbarState(string const & name)
|
|||||||
TurnOnFlag(ON);
|
TurnOnFlag(ON);
|
||||||
}
|
}
|
||||||
cit->flags = static_cast<lyx::ToolbarBackend::Flags>(flags);
|
cit->flags = static_cast<lyx::ToolbarBackend::Flags>(flags);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lyxerr[Debug::GUI] << "Toolbar::display: no toolbar named "
|
||||||
|
<< name << endl;
|
||||||
}
|
}
|
||||||
#undef TurnOnFlag
|
#undef TurnOnFlag
|
||||||
#undef TurnOffFlag
|
#undef TurnOffFlag
|
||||||
|
@ -88,6 +88,9 @@ public:
|
|||||||
/// Show/hide the named toolbar.
|
/// Show/hide the named toolbar.
|
||||||
void display(std::string const & name, bool show);
|
void display(std::string const & name, bool show);
|
||||||
|
|
||||||
|
/// get toolbar state (on/off/auto)
|
||||||
|
ToolbarBackend::Flags getToolbarState(std::string const & name);
|
||||||
|
|
||||||
/// toggle the state of toolbars (on/off/auto)
|
/// toggle the state of toolbars (on/off/auto)
|
||||||
void toggleToolbarState(std::string const & name);
|
void toggleToolbarState(std::string const & name);
|
||||||
|
|
||||||
|
@ -573,6 +573,13 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case LFUN_TOOLBAR_TOGGLE_STATE: {
|
||||||
|
ToolbarBackend::Flags flags = lyx_view_->getToolbarState(to_utf8(cmd.argument()));
|
||||||
|
if (!(flags & ToolbarBackend::AUTO))
|
||||||
|
flag.setOnOff(flags & ToolbarBackend::ON);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// this one is difficult to get right. As a half-baked
|
// this one is difficult to get right. As a half-baked
|
||||||
// solution, we consider only the first action of the sequence
|
// solution, we consider only the first action of the sequence
|
||||||
case LFUN_COMMAND_SEQUENCE: {
|
case LFUN_COMMAND_SEQUENCE: {
|
||||||
@ -635,7 +642,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
|||||||
case LFUN_BUFFER_PREVIOUS:
|
case LFUN_BUFFER_PREVIOUS:
|
||||||
case LFUN_WINDOW_NEW:
|
case LFUN_WINDOW_NEW:
|
||||||
case LFUN_WINDOW_CLOSE:
|
case LFUN_WINDOW_CLOSE:
|
||||||
case LFUN_TOOLBAR_TOGGLE_STATE:
|
|
||||||
// these are handled in our dispatch()
|
// these are handled in our dispatch()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user