when iconpalette detached from the math dialog, the iconpalette widget
width may become too large to fit to the screen.

when detached resized to a too small size, icons overlap.

attached patch solves these problems.

I'll be glad if somebody reviews and commits the patch.

Ugras

p.s. Abdel, have you seen my previous patch on toc dialog? it was
attached in the reply.
Index: frontends/qt4/QMathDialog.C
===================================================================
--- frontends/qt4/QMathDialog.C	(revision 15963)
+++ frontends/qt4/QMathDialog.C	(working copy)
@@ -224,12 +224,15 @@
 {
 	int const id = symbolsCO->currentIndex();
 	IconPalette * p = makePanel(0, panels[id]);
+	p->setFixedWidth(40 * 15 + 20);
 	string s = "LyX: ";
 	s += fromqstr(symbolsCO->currentText());
 	p->setWindowTitle(toqstr(s));
 	p->resize(40 * 5, p->height());
-	p->show();
-	p->setMaximumSize(p->width(), p->height());
+ 	p->show();
+	p->resize(40 * 5 + 20, 40 * p->numRows() + 20);
+	p->setMinimumSize(40 * 5 + 20, 40 * 1 + 20);
+	p->setMaximumWidth (40 * p->numButtons() + 20);
 }
 
 
Index: frontends/qt4/iconpalette.C
===================================================================
--- frontends/qt4/iconpalette.C	(revision 15963)
+++ frontends/qt4/iconpalette.C	(working copy)
@@ -89,7 +89,7 @@
 
 	int cols = max(width() / button_size, 1);
 	int rows = max(int(buttons_.size() / cols), 1);
-	if (buttons_.size() % cols)
+	if (buttons_.size() % cols )
 		++rows;
 
 	lyxerr[Debug::GUI] << "Laying out " << buttons_.size() << " widgets in a "
@@ -121,7 +121,13 @@
 
 out:
 
-	resize(cols * button_size, rows * button_size);
+	int maxrow_ = int(buttons_.size() / cols);
+	if (!maxrow_ || buttons_.size() % cols )
+		++maxrow_;
+	if(!parent())
+		setMinimumHeight(button_size * maxrow_ + 20); //prevents the detached panel becomes unreadable
+	else 
+		resize(cols * button_size, rows * button_size);
 
 	maxcol_ = cols;
 
@@ -129,7 +135,19 @@
 	update();
 }
 
+int IconPalette::numRows() 
+{
+	return maxrow_;
+}
 
+
+int IconPalette::numButtons() 
+{
+	return buttons_.size();
+}
+
+
+
 } // namespace lyx
 
 #include "iconpalette_moc.cpp"
Index: frontends/qt4/iconpalette.h
===================================================================
--- frontends/qt4/iconpalette.h	(revision 15963)
+++ frontends/qt4/iconpalette.h	(working copy)
@@ -36,6 +36,11 @@
 
 	/// add a button
 	void add(QPixmap const & pixmap, std::string name, std::string tooltip);
+	/// get required number of rows.
+	int numRows();
+	/// get number of Buttons
+	int numButtons();
+
 Q_SIGNALS:
 	void button_clicked(const std::string &);
 protected:
@@ -45,6 +50,8 @@
 private:
 	int maxcol_;
 
+	int maxrow_;
+
 	QGridLayout * layout_;
 
 	typedef std::pair<QPushButton *, std::string> Button;

Reply via email to