]> git.lyx.org Git - features.git/commitdiff
Citation dialog: Fix trouble with openbox, fluxbox
authorGuillaume Munch <gm@lyx.org>
Fri, 22 Apr 2016 00:55:10 +0000 (02:55 +0200)
committerGuillaume Munch <gm@lyx.org>
Sun, 24 Apr 2016 13:05:54 +0000 (14:05 +0100)
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.

src/frontends/qt4/GuiCitation.cpp

index 16c0990f7da1f0bd7a87bce1f5ce06fd6f08f4f2..55341006292afc467b20c4bd3b2acbde4a50673e 100644 (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;
 }