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
This commit is contained in:
Bo Peng 2007-01-27 20:54:17 +00:00
parent dfcc879239
commit 66b7c7eebf
4 changed files with 44 additions and 17 deletions

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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<int>(tb->second.state) << " "
<< static_cast<int>(tb->second.location) << '\n';
<< static_cast<int>(tb->second.location) << " "
<< tb->second.posx << " "
<< tb->second.posy << '\n';
}
}

View File

@ -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<State>(s)), location(static_cast<Location>(loc)) { }
ToolbarInfo(int s, int loc, int x=0, int y=0) :
state(static_cast<State>(s)),
location(static_cast<Location>(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
};