]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt4/GuiCitation.cpp
Fix broken layout of the citation dialog (#10019)
[features.git] / src / frontends / qt4 / GuiCitation.cpp
index 8856ebc8668473a79e65e6587beda75254ab8e64..16c0990f7da1f0bd7a87bce1f5ce06fd6f08f4f2 100644 (file)
@@ -625,6 +625,33 @@ 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;
 }