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