]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDialog.cpp
Remove question marks from Windows dialogs
[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         // remove question marks from Windows dialogs
32         setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
33 }
34
35
36 void GuiDialog::closeEvent(QCloseEvent * ev)
37 {
38         slotClose();
39         ev->accept();
40 }
41
42
43 void GuiDialog::setButtonsValid(bool valid)
44 {
45         bc().setValid(valid);
46 }
47
48
49 void GuiDialog::slotApply()
50 {
51         apply();
52         bc().apply();
53 }
54
55
56 void GuiDialog::slotAutoApply()
57 {
58         apply();
59         bc().autoApply();
60 }
61
62
63 void GuiDialog::slotOK()
64 {
65         is_closing_ = true;
66         apply();
67         is_closing_ = false;
68         hideView();
69         bc().ok();
70 }
71
72
73 void GuiDialog::slotClose()
74 {
75         hideView();
76         bc().cancel();
77 }
78
79
80 void GuiDialog::slotRestore()
81 {
82         // Tell the controller that a request to refresh the dialog's contents
83         // has been received. It's up to the controller to supply the necessary
84         // info by calling GuiDialog::updateView().
85         updateDialog();
86         bc().restore();
87 }
88
89
90 void GuiDialog::changed()
91 {
92         if (updating_)
93                 return;
94         bc().setValid(isValid());
95 }
96
97
98 void GuiDialog::enableView(bool enable)
99 {
100         if (!enable) {
101                 bc().setReadOnly(true);
102                 bc().setValid(false);
103         }
104         Dialog::enableView(enable);
105 }
106
107
108 void GuiDialog::updateView()
109 {
110         setUpdatesEnabled(false);
111
112         bc().setReadOnly(isBufferReadonly());
113         // protect the BC from unwarranted state transitions
114         updating_ = true;
115         updateContents();
116         updating_ = false;
117         // The widgets may not be valid, so refresh the button controller
118         bc().refresh();
119
120         setUpdatesEnabled(true);
121 }
122
123 } // namespace frontend
124 } // namespace lyx
125
126 #include "moc_GuiDialog.cpp"