]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QDialogView.cpp
* src/frontends/qt4/ui/TextLayoutUi.ui:
[lyx.git] / src / frontends / qt4 / QDialogView.cpp
1 /**
2  * \file QDialogView.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "QDialogView.h"
14 #include "Qt2BC.h"
15 #include "qt_helpers.h"
16
17 #include "controllers/ButtonController.h"
18
19
20 namespace lyx {
21 namespace frontend {
22
23 QDialogView::QDialogView(Dialog & parent, docstring const & t)
24         : Dialog::View(parent,t), updating_(false)
25 {}
26
27
28 Qt2BC & QDialogView::bcview()
29 {
30         return static_cast<Qt2BC &>(dialog().bc().view());
31 }
32
33
34 bool QDialogView::isVisible() const
35 {
36         return form() && form()->isVisible();
37 }
38
39
40 bool QDialogView::readOnly() const
41 {
42         return kernel().isBufferReadonly();
43 }
44
45
46 void QDialogView::show()
47 {
48         if (!form()) {
49                 build();
50         }
51
52         QSize const sizeHint = form()->sizeHint();
53         if (sizeHint.height() >= 0 && sizeHint.width() >= 0)
54                 form()->setMinimumSize(sizeHint);
55
56         update();  // make sure its up-to-date
57         if (dialog().controller().exitEarly())
58                 return;
59
60         form()->setWindowTitle(toqstr("LyX: " + getTitle()));
61
62         if (form()->isVisible()) {
63                 form()->raise();
64                 form()->activateWindow();
65                 form()->setFocus();
66         } else {
67                 form()->show();
68                 form()->setFocus();
69         }
70 }
71
72
73 void QDialogView::hide()
74 {
75         if (form() && form()->isVisible())
76                 form()->hide();
77 }
78
79
80 bool QDialogView::isValid()
81 {
82         return true;
83 }
84
85
86 void QDialogView::changed()
87 {
88         if (updating_)
89                 return;
90         bc().valid(isValid());
91 }
92
93
94 void QDialogView::slotWMHide()
95 {
96         dialog().CancelButton();
97 }
98
99
100 void QDialogView::slotApply()
101 {
102         dialog().ApplyButton();
103 }
104
105
106 void QDialogView::slotOK()
107 {
108         dialog().OKButton();
109 }
110
111
112 void QDialogView::slotClose()
113 {
114         dialog().CancelButton();
115 }
116
117
118 void QDialogView::slotRestore()
119 {
120         dialog().RestoreButton();
121 }
122
123 } // namespace frontend
124 } // namespace lyx
125
126 #include "QDialogView_moc.cpp"