]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Qt2BC.C
a9e5a700fc499dd76c2047b10cc82bd09ee192ff
[lyx.git] / src / frontends / qt2 / 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 "debug.h"
16 #include "qt_helpers.h"
17
18 #include <qbutton.h>
19 #include <qlineedit.h>
20
21
22 Qt2BC::Qt2BC(ButtonController const & parent,
23              string const & cancel, string const & close)
24         : GuiBC<QButton, QWidget>(parent, cancel, close)
25 {}
26
27
28 void Qt2BC::setButtonEnabled(QButton * obj, bool enabled)
29 {
30         obj->setEnabled(enabled);
31 }
32
33
34 void Qt2BC::setWidgetEnabled(QWidget * obj, bool enabled)
35 {
36         // yuck, rtti, but the user comes first
37         if (obj->inherits("QLineEdit")) {
38                 QLineEdit * le(static_cast<QLineEdit*>(obj));
39                 le->setReadOnly(!enabled);
40         } else {
41                 obj->setEnabled(enabled);
42         }
43
44         QWidget::FocusPolicy const p =
45                 (enabled) ? QWidget::StrongFocus : QWidget::NoFocus;
46         obj->setFocusPolicy(p);
47 }
48
49
50 void Qt2BC::setButtonLabel(QButton * obj, string const & label)
51 {
52         obj->setText(toqstr(label));
53 }