Citation dialog: Fix trouble with openbox, fluxbox

http://thread.gmane.org/gmane.editors.lyx.devel/161725

These wms have trouble with the fix at b5a2f1c7, probably more precisely with
the trick to force the calculation of the actual sizes before the display
(layout->invalidate() and the code around it).

This patch gets rid of the code that forces the calculation. As a consequence,
the minimum sizes are again incorrect the first time the window is shown. They
are only correct the second time the window is shown. Now here is the trick: LyX
remembers the sizes of windows between sessions. Therefore, as soon as the good
minimum size has been set, the good size is remembered for the next
session. Thus, in the following sessions, even though the minimum size is
incorrect the first time, the dialog still opens with the good size. So the user
does not see the problem in practice, apart from the very first time.

This is meant as a temporary workaround.
This commit is contained in:
Guillaume Munch 2016-04-22 02:55:10 +02:00
parent cfafffdf25
commit 86227b196d

View File

@ -153,6 +153,25 @@ void GuiCitation::showEvent(QShowEvent * e)
{
findLE->clear();
availableLV->setFocus();
// Set the minimal size of the QToolbox. Without this, the size of the
// QToolbox is only determined by values in the ui file (e.g. computed by
// qtcreator) and therefore causes portability and localisation issues. Note
// that the page widgets must have a layout with layoutSizeContraint =
// SetMinimumSize or similar. KNOWN ISSUE: the calculations are incorrect
// the first time the dialog is shown. This problem is mitigated by the fact
// that LyX remembers the dialog sizes between sessions.
QSize minimum_size = QSize(0,0);
// Compute the max of the minimal sizes of the pages
QWidget * page;
for (int i = 0; (page = citationTB->widget(i)); ++i)
minimum_size = minimum_size.expandedTo(page->minimumSizeHint());
// Add the height of the tabs
if (citationTB->currentWidget())
minimum_size.rheight() += citationTB->height() -
citationTB->currentWidget()->height();
citationTB->setMinimumSize(minimum_size);
DialogView::showEvent(e);
}
@ -625,33 +644,6 @@ bool GuiCitation::initialiseParams(string const & data)
citeCmds_ = documentBuffer().params().citeCommands();
citeStyles_ = documentBuffer().params().citeStyles();
init();
// Set the minimal size of the QToolbox. Without this, the size of the
// QToolbox is only determined by values in the ui file (e.g. computed by
// qtcreator) and therefore causes portability and localisation issues. In
// the future, this should be integrated into a custom widget if plans are
// made to generalise such a use of QToolboxes. Note that the page widgets
// must have a layout with layoutSizeContraint = SetMinimumSize or similar.
if (!isVisible()) {
// only reliable way to get the size calculations up-to-date
show();
layout()->invalidate();
hide();
// this does not show any window since hide() is called before
// relinquishing control
}
QSize minimum_size = QSize(0,0);
// Compute the max of the minimal sizes of the pages
QWidget * page;
for (int i = 0; (page = citationTB->widget(i)); ++i)
minimum_size = minimum_size.expandedTo(page->minimumSizeHint());
// Add the height of the tabs
if (citationTB->currentWidget())
minimum_size.rheight() += citationTB->height() -
citationTB->currentWidget()->height();
citationTB->setMinimumSize(minimum_size);
updateGeometry();
return true;
}