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