]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QDialogView.C
7e7a86191ef3e36423a6aaa21f6bda90d0f7ffc8
[lyx.git] / src / frontends / qt4 / QDialogView.C
1 /**
2  * \file QDialogView.C
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 using lyx::docstring;
20
21 namespace lyx {
22 namespace frontend {
23
24 QDialogView::QDialogView(Dialog & parent, docstring const & t)
25         : Dialog::View(parent,t), updating_(false)
26 {}
27
28
29 Qt2BC & QDialogView::bcview()
30 {
31         return static_cast<Qt2BC &>(dialog().bc().view());
32 }
33
34
35 bool QDialogView::isVisible() const
36 {
37         return form() && form()->isVisible();
38 }
39
40
41 bool QDialogView::readOnly() const
42 {
43         return kernel().isBufferReadonly();
44 }
45
46
47 void QDialogView::show()
48 {
49         if (!form()) {
50                 build();
51         }
52
53         QSize const sizeHint = form()->sizeHint();
54         if (sizeHint.height() >= 0 && sizeHint.width() >= 0)
55                 form()->setMinimumSize(sizeHint);
56
57         update();  // make sure its up-to-date
58         if (dialog().controller().exitEarly())
59                 return;
60
61         form()->setWindowTitle(toqstr("LyX: " + getTitle()));
62
63         if (form()->isVisible()) {
64                 form()->raise();
65                 form()->activateWindow();
66                 form()->setFocus();
67         } else {
68                 form()->show();
69                 form()->setFocus();
70         }
71 }
72
73
74 void QDialogView::hide()
75 {
76         if (form() && form()->isVisible())
77                 form()->hide();
78 }
79
80
81 bool QDialogView::isValid()
82 {
83         return true;
84 }
85
86
87 void QDialogView::changed()
88 {
89         if (updating_)
90                 return;
91         bc().valid(isValid());
92 }
93
94
95 void QDialogView::slotWMHide()
96 {
97         dialog().CancelButton();
98 }
99
100
101 void QDialogView::slotApply()
102 {
103         dialog().ApplyButton();
104 }
105
106
107 void QDialogView::slotOK()
108 {
109         dialog().OKButton();
110 }
111
112
113 void QDialogView::slotClose()
114 {
115         dialog().CancelButton();
116 }
117
118
119 void QDialogView::slotRestore()
120 {
121         dialog().RestoreButton();
122 }
123
124 } // namespace frontend
125 } // namespace lyx
126
127 #include "QDialogView_moc.cpp"