> I agree with you but right now, the easy solution may be what I have
> suggested. Moving frontend/MLToolbar to qt4/ is something for later.

Agreed.

Abdel,

I can not figure out how to restore toolbar position. (move does not
seem to work).

The attached patch add posx, posy to
Session::ToolbarSection::ToolbarInfo and I can verify that posx and
posy is saved correctly to the session file. Now, in
src/frontends/qt4/GuiView.C, move() to stored position does not seem
to work, and I do not know how to set toolbar position before or after
they are shown.

Interestingly, if I add move(100, 100) to line 217, qt4/QLToolbar.C

void QLToolbar::show(bool)
{
        QToolBar::show();
}

and break at this function. Every mouse click stops at this function
several times, and the toolbars are actually shifted, but then they
are shifted back. I do not know who reset the toolbars (a resize
event?).

Thanks.
Bo
Index: src/session.C
===================================================================
--- src/session.C	(revision 16875)
+++ src/session.C	(working copy)
@@ -332,11 +332,14 @@
 				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 @@
 		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';
 	}
 }
 
Index: src/frontends/qt4/QLToolbar.C
===================================================================
--- src/frontends/qt4/QLToolbar.C	(revision 16875)
+++ src/frontends/qt4/QLToolbar.C	(working copy)
@@ -241,6 +241,10 @@
 		info.location = ToolbarSection::ToolbarInfo::LEFT;
 	else
 		info.location = ToolbarSection::ToolbarInfo::NOTSET;
+	
+	// save toolbar position
+	info.posx = pos().x();
+	info.posy = pos().y();
 }
 
 
Index: src/frontends/qt4/GuiView.C
===================================================================
--- src/frontends/qt4/GuiView.C	(revision 16875)
+++ src/frontends/qt4/GuiView.C	(working copy)
@@ -694,8 +694,14 @@
 	//static QLToolbar * lastTb = 0;
 
 	if (tbb.flags & ToolbarBackend::TOP) {
-			addToolBar(Qt::TopToolBarArea, Tb);
-			addToolBarBreak(Qt::TopToolBarArea);
+		addToolBar(Qt::TopToolBarArea, Tb);
+		//
+		// This is not necessary if restore position works
+		//
+		// This is actually a bug because two top toolbars on the same line are
+		// currently restored to two lines.
+		//
+		// addToolBarBreak(Qt::TopToolBarArea);
 	}
 	if (tbb.flags & ToolbarBackend::BOTTOM) {
 		addToolBar(Qt::BottomToolBarArea, Tb);
@@ -715,6 +721,9 @@
 		addToolBar(Qt::RightToolBarArea, Tb);
 	}
 
+	// This does not work.
+	ToolbarSection::ToolbarInfo & info = LyX::ref().session().toolbars().load(tbb.name);
+	Tb->move(info.posx, info.posy);
 	return Toolbars::ToolbarPtr(Tb);
 }
 
Index: src/session.h
===================================================================
--- src/session.h	(revision 16875)
+++ src/session.h	(working copy)
@@ -258,10 +258,14 @@
 	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 @@
 
 		Location location;
 
+		/// x-position of the toolbar
+		int posx;
+
+		/// y-position of the toolbar
+		int posy;
+		
 		/// potentially, icons
 	};
 

Reply via email to