From 66b7c7eebf34793059f7bb16f980b895c342ddce Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Sat, 27 Jan 2007 20:54:17 +0000 Subject: [PATCH] BUG3127 Toolbar display: restore all toolbars to different lines. Not good but better than the current situation. qt > 4.2.2 is required. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16895 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiView.C | 29 ++++++++++++++++++----------- src/frontends/qt4/QLToolbar.C | 5 +++++ src/session.C | 11 ++++++++--- src/session.h | 16 +++++++++++++--- 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/src/frontends/qt4/GuiView.C b/src/frontends/qt4/GuiView.C index 5e9653b737..0ce335d65c 100644 --- a/src/frontends/qt4/GuiView.C +++ b/src/frontends/qt4/GuiView.C @@ -691,30 +691,37 @@ void GuiView::busy(bool yes) Toolbars::ToolbarPtr GuiView::makeToolbar(ToolbarBackend::Toolbar const & tbb) { QLToolbar * Tb = new QLToolbar(tbb, *this); - //static QLToolbar * lastTb = 0; + /* NOTE: + saved toolbar position can not be restored with simple move(x,y), + Consequently, toolbars from different lines will be restore to one + line. I therefore add addToolBarBreak after each toolbar to restore + toolbars to separate lines, although toolbars in the same line can + not be restored correctly. + NOTE: qt < 4.2.2 cannot handle addToolBarBreak on non-TOP dock. + */ if (tbb.flags & ToolbarBackend::TOP) { - addToolBar(Qt::TopToolBarArea, Tb); - addToolBarBreak(Qt::TopToolBarArea); + addToolBar(Qt::TopToolBarArea, Tb); + addToolBarBreak(Qt::TopToolBarArea); } if (tbb.flags & ToolbarBackend::BOTTOM) { addToolBar(Qt::BottomToolBarArea, Tb); - /* - // Qt bug: - // http://www.trolltech.com/developer/task-tracker/index_html?id=137015&method=entry - // Doesn't work because the toolbar will evtl. be hidden. - if (lastTb) - insertToolBarBreak(lastTb); - lastTb = Tb; - */ + addToolBarBreak(Qt::BottomToolBarArea); } if (tbb.flags & ToolbarBackend::LEFT) { addToolBar(Qt::LeftToolBarArea, Tb); + addToolBarBreak(Qt::LeftToolBarArea); } if (tbb.flags & ToolbarBackend::RIGHT) { addToolBar(Qt::RightToolBarArea, Tb); + addToolBarBreak(Qt::RightToolBarArea); } + // The following does not work so saved toolbar location can not be used. + /* + ToolbarSection::ToolbarInfo & info = LyX::ref().session().toolbars().load(tbb.name); + Tb->move(info.posx, info.posy); + */ return Toolbars::ToolbarPtr(Tb); } diff --git a/src/frontends/qt4/QLToolbar.C b/src/frontends/qt4/QLToolbar.C index 79e4ca3003..da9b3f831c 100644 --- a/src/frontends/qt4/QLToolbar.C +++ b/src/frontends/qt4/QLToolbar.C @@ -241,6 +241,11 @@ void QLToolbar::saveInfo(ToolbarSection::ToolbarInfo & info) info.location = ToolbarSection::ToolbarInfo::LEFT; else info.location = ToolbarSection::ToolbarInfo::NOTSET; + + // save toolbar position. They are not used to restore toolbar position + // now because move(x,y) does not work for toolbar. + info.posx = pos().x(); + info.posy = pos().y(); } diff --git a/src/session.C b/src/session.C index fd2f26a7fc..79a72e2320 100644 --- a/src/session.C +++ b/src/session.C @@ -332,11 +332,14 @@ void ToolbarSection::read(istream & is) string key = tmp.substr(0, pos); int state; int location; + int posx; + int posy; istringstream value(tmp.substr(pos + 3)); value >> state; - value.ignore(1); // ignore " " value >> location; - toolbars[key] = ToolbarInfo(state, location); + value >> posx; + value >> posy; + toolbars[key] = ToolbarInfo(state, location, posx, posy); } else lyxerr[Debug::INIT] << "LyX: Warning: Ignore toolbar info: " << tmp << endl; } catch (...) { @@ -353,7 +356,9 @@ void ToolbarSection::write(ostream & os) const tb != toolbars.end(); ++tb) { os << tb->first << " = " << static_cast(tb->second.state) << " " - << static_cast(tb->second.location) << '\n'; + << static_cast(tb->second.location) << " " + << tb->second.posx << " " + << tb->second.posy << '\n'; } } diff --git a/src/session.h b/src/session.h index f36730b6bb..32766b0f48 100644 --- a/src/session.h +++ b/src/session.h @@ -258,10 +258,14 @@ public: public: /// ToolbarInfo() : - state(ON), location(NOTSET) { } + state(ON), location(NOTSET), posx(0), posy(0) { } /// - ToolbarInfo(int s, int loc) : - state(static_cast(s)), location(static_cast(loc)) { } + ToolbarInfo(int s, int loc, int x=0, int y=0) : + state(static_cast(s)), + location(static_cast(loc)), + posx(x), + posy(y) + { } public: enum State { @@ -284,6 +288,12 @@ public: Location location; + /// x-position of the toolbar + int posx; + + /// y-position of the toolbar + int posy; + /// potentially, icons };