]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Qt2BC.C
enable Font cache only for MacOSX and inline width() for other platform.
[lyx.git] / src / frontends / qt4 / Qt2BC.C
1 /**
2  * \file Qt2BC.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Allan Rae
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "Qt2BC.h"
15 #include "qt_helpers.h"
16
17 #include <QPushButton>
18 #include <QLineEdit>
19
20 using std::string;
21
22 namespace lyx {
23 namespace frontend {
24
25 Qt2BC::Qt2BC(ButtonController const & parent,
26              string const & cancel, string const & close)
27         : GuiBC<QPushButton, QWidget>(parent, cancel, close)
28 {}
29
30
31 void Qt2BC::setButtonEnabled(QPushButton * obj, bool enabled) const
32 {
33         obj->setEnabled(enabled);
34 }
35
36
37 void Qt2BC::setWidgetEnabled(QWidget * obj, bool enabled) const
38 {
39         // yuck, rtti, but the user comes first
40         if (obj->inherits("QLineEdit")) {
41                 QLineEdit * le(static_cast<QLineEdit*>(obj));
42                 le->setReadOnly(!enabled);
43         } else {
44                 obj->setEnabled(enabled);
45         }
46
47         Qt::FocusPolicy const p =
48                 (enabled) ? Qt::StrongFocus : Qt::NoFocus;
49         obj->setFocusPolicy(p);
50 }
51
52
53 void Qt2BC::setButtonLabel(QPushButton * obj, string const & label) const
54 {
55         obj->setText(toqstr(label));
56 }
57
58 } // namespace frontend
59 } // namespace lyx