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