]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDialog.cpp
Fix the tab ordering of GuiDocument components.
[lyx.git] / src / frontends / qt4 / GuiDialog.cpp
1 /**
2  * \file Dialog.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 "GuiDialog.h"
14
15 #include "GuiView.h"
16 #include "qt_helpers.h"
17
18 #include "support/debug.h"
19
20 #include <QCloseEvent>
21
22 using namespace std;
23
24 namespace lyx {
25 namespace frontend {
26
27 GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title)
28         : QDialog(&lv), Dialog(lv, name, "LyX: " + title), updating_(false), 
29           is_closing_(false)
30 {}
31
32
33 void GuiDialog::closeEvent(QCloseEvent * ev)
34 {
35         slotClose();
36         ev->accept();
37 }
38
39
40 void GuiDialog::setButtonsValid(bool valid)
41 {
42         bc().setValid(valid);
43 }
44
45
46 void GuiDialog::slotApply()
47 {
48         apply();
49         bc().apply();
50 }
51
52
53 void GuiDialog::slotAutoApply()
54 {
55         apply();
56         bc().autoApply();
57 }
58
59
60 void GuiDialog::slotOK()
61 {
62         is_closing_ = true;
63         apply();
64         is_closing_ = false;
65         hideView();
66         bc().ok();
67 }
68
69
70 void GuiDialog::slotClose()
71 {
72         hideView();
73         bc().cancel();
74 }
75
76
77 void GuiDialog::slotRestore()
78 {
79         // Tell the controller that a request to refresh the dialog's contents
80         // has been received. It's up to the controller to supply the necessary
81         // info by calling GuiDialog::updateView().
82         updateDialog();
83         bc().restore();
84 }
85
86
87 void GuiDialog::changed()
88 {
89         if (updating_)
90                 return;
91         bc().setValid(isValid());
92 }
93
94
95 void GuiDialog::enableView(bool enable)
96 {
97         if (!enable) {
98                 bc().setReadOnly(true);
99                 bc().setValid(false);
100         }
101         Dialog::enableView(enable);
102 }
103
104
105 void GuiDialog::updateView()
106 {
107         setUpdatesEnabled(false);
108
109         bc().setReadOnly(isBufferReadonly());
110         // protect the BC from unwarranted state transitions
111         updating_ = true;
112         updateContents();
113         updating_ = false;
114         // The widgets may not be valid, so refresh the button controller
115         bc().refresh();
116
117         setUpdatesEnabled(true);
118 }
119
120 } // namespace frontend
121 } // namespace lyx
122
123 #include "moc_GuiDialog.cpp"