]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/LyXToolBox.cpp
Introduce support/Cache.h
[lyx.git] / src / frontends / qt4 / LyXToolBox.cpp
1 // -*- C++ -*-
2 /**
3  * \file LyXToolBox.cpp
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Guillaume Munch
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13 #include "LyXToolBox.h"
14
15 #include <QApplication>
16 #include <QLayout>
17
18 #include "support/debug.h"
19
20 namespace lyx {
21 namespace frontend {
22
23
24 QSize LyXToolBox::minimumSizeHint() const
25 {
26         QSize s(0,0);
27         // Compute the max of the minimal sizes of the pages
28         QWidget * page;
29         for (int i = 0; (page = widget(i)); ++i)
30                 s = s.expandedTo(page->minimumSizeHint());
31         // Add the height of the tabs
32         if (currentWidget())
33                 s.rheight() += height() - currentWidget()->height();
34         return s;
35 }
36
37 void LyXToolBox::showEvent(QShowEvent * e)
38 {
39         // Computation of the tab height might be incorrect yet (the proper sizes of
40         // the pages have only been computed now).
41         // It might still be incorrect after this. All this would be unnecessary if
42         // QToolBox made our life easier and exposed more information; for instance
43         // let us access the scroll areas enclosing the pages (from which one can
44         // deduce the real tab height).
45         layout()->invalidate();
46         // proceed with geometry update to avoid flicker
47         qApp->processEvents(QEventLoop::ExcludeUserInputEvents, 50);
48         QToolBox::showEvent(e);
49 }
50
51
52 } // namespace frontend
53 } // namespace lyx
54
55 #include "moc_LyXToolBox.cpp"
56