mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
GuiApplication::resetGui(): reset as many things as possible, including menus and toolbars (not sure about Mac global menubar yet). This means that except for already opened dialog, all ui rc settings are taken into account without the need to restart.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25390 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1d109d8c6f
commit
a54850d762
@ -898,6 +898,19 @@ bool GuiApplication::dispatch(FuncRequest const & cmd)
|
||||
|
||||
void GuiApplication::resetGui()
|
||||
{
|
||||
// Set the language defined by the user.
|
||||
LyX::ref().setRcGuiLanguage();
|
||||
|
||||
// Read menus
|
||||
if (!readUIFile(toqstr(lyxrc.ui_file)))
|
||||
// Gives some error box here.
|
||||
return;
|
||||
|
||||
// init the global menubar on Mac. This must be done after the session
|
||||
// was recovered to know the "last files".
|
||||
if (d->global_menubar_)
|
||||
d->menus_.fillMenuBar(d->global_menubar_, 0, true);
|
||||
|
||||
QHash<int, GuiView *>::iterator it;
|
||||
for (it = d->views_.begin(); it != d->views_.end(); ++it)
|
||||
(*it)->resetDialogs();
|
||||
@ -1328,9 +1341,16 @@ bool GuiApplication::readUIFile(QString const & name, bool include)
|
||||
// Ensure that a file is read only once (prevents include loops)
|
||||
static QStringList uifiles;
|
||||
if (uifiles.contains(name)) {
|
||||
LYXERR(Debug::INIT, "UI file '" << name << "' has been read already. "
|
||||
<< "Is this an include loop?");
|
||||
return false;
|
||||
if (!include) {
|
||||
// We are reading again the top uifile so reset the safeguard:
|
||||
uifiles.clear();
|
||||
d->menus_.reset();
|
||||
d->toolbars_.reset();
|
||||
} else {
|
||||
LYXERR(Debug::INIT, "UI file '" << name << "' has been read already. "
|
||||
<< "Is this an include loop?");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
LYXERR(Debug::INIT, "About to read " << name << "...");
|
||||
|
@ -404,6 +404,7 @@ void GuiView::constructToolbars()
|
||||
for (; it != d.toolbars_.end(); ++it)
|
||||
delete it->second;
|
||||
d.toolbars_.clear();
|
||||
d.layout_ = 0;
|
||||
|
||||
// extracts the toolbars from the backend
|
||||
Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
|
||||
@ -2150,14 +2151,15 @@ void GuiView::resetDialogs()
|
||||
{
|
||||
// Make sure that no LFUN uses any LyXView.
|
||||
theLyXFunc().setLyXView(0);
|
||||
// FIXME: the "math panels" toolbar takes an awful lot of time to
|
||||
// initialise so we don't do that for the time being.
|
||||
//initToolbars();
|
||||
guiApp->menus().fillMenuBar(menuBar(), this);
|
||||
saveLayout();
|
||||
menuBar()->clear();
|
||||
constructToolbars();
|
||||
guiApp->menus().fillMenuBar(menuBar(), this, true);
|
||||
if (d.layout_)
|
||||
d.layout_->updateContents(true);
|
||||
// Now update controls with current buffer.
|
||||
theLyXFunc().setLyXView(this);
|
||||
restoreLayout();
|
||||
restartCursor();
|
||||
}
|
||||
|
||||
|
@ -1453,11 +1453,20 @@ MenuDefinition & Menus::Impl::getMenu(QString const & name)
|
||||
|
||||
Menus::Menus() : d(new Impl) {}
|
||||
|
||||
|
||||
Menus::~Menus()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
void Menus::reset()
|
||||
{
|
||||
delete d;
|
||||
d = new Impl;
|
||||
}
|
||||
|
||||
|
||||
void Menus::read(Lexer & lex)
|
||||
{
|
||||
enum {
|
||||
|
@ -59,6 +59,9 @@ class Menus
|
||||
public:
|
||||
Menus();
|
||||
~Menus();
|
||||
|
||||
///
|
||||
void reset();
|
||||
|
||||
///
|
||||
bool searchMenu(FuncRequest const & func,
|
||||
@ -78,8 +81,8 @@ public:
|
||||
private:
|
||||
/// Use the Pimpl idiom to hide the internals.
|
||||
struct Impl;
|
||||
/// The pointer never changes although *d's contents may.
|
||||
Impl * const d;
|
||||
///
|
||||
Impl * d;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -190,6 +190,12 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Toolbars::reset()
|
||||
{
|
||||
toolbar_info_.clear();
|
||||
toolbar_visibility_.clear();
|
||||
}
|
||||
|
||||
|
||||
void Toolbars::readToolbars(Lexer & lex)
|
||||
{
|
||||
|
@ -112,6 +112,9 @@ public:
|
||||
|
||||
Toolbars() {}
|
||||
|
||||
///
|
||||
void reset();
|
||||
|
||||
/// iterator for all toolbars
|
||||
Infos::const_iterator begin() const { return toolbar_info_.begin(); }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user