]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Qt2BC.C
reverse last change
[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 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include "Qt2BC.h"
19 #include "debug.h"
20 #include "qt_helpers.h"
21
22 #include <qbutton.h>
23 #include <qlineedit.h>
24
25
26 Qt2BC::Qt2BC(string const & cancel, string const & close)
27         : GuiBC<QButton, QWidget>(cancel, close)
28 {}
29
30
31 void Qt2BC::setButtonEnabled(QButton * obj, bool enabled)
32 {
33         obj->setEnabled(enabled);
34 }
35
36
37 void Qt2BC::setWidgetEnabled(QWidget * obj, bool enabled)
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         QWidget::FocusPolicy const p =
48                 (enabled) ? QWidget::StrongFocus : QWidget::NoFocus;
49         obj->setFocusPolicy(p);
50 }
51
52
53 void Qt2BC::setButtonLabel(QButton * obj, string const & label)
54 {
55         obj->setText(toqstr(label));
56 }