3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
13 #include "GuiDialog.h"
15 #include "qt_helpers.h"
20 GuiDialog::GuiDialog(LyXView & lv, std::string const & name)
25 void GuiDialog::setButtonsValid(bool valid)
31 void GuiDialog::ApplyButton()
38 void GuiDialog::OKButton()
48 void GuiDialog::CancelButton()
55 void GuiDialog::RestoreButton()
57 // Tell the kernel that a request to refresh the dialog's contents
58 // has been received. It's up to the kernel to supply the necessary
59 // info by calling GuiDialog::updateView().
60 kernel().updateDialog(name_);
65 void GuiDialog::preShow()
67 bc().setReadOnly(kernel().isBufferReadonly());
71 void GuiDialog::postShow()
73 // The widgets may not be valid, so refresh the button controller
78 void GuiDialog::preUpdate()
80 bc().setReadOnly(kernel().isBufferReadonly());
84 void GuiDialog::postUpdate()
86 // The widgets may not be valid, so refresh the button controller
91 void GuiDialog::checkStatus()
93 // buffer independant dialogs are always active.
94 // This check allows us leave canApply unimplemented for some dialogs.
95 if (!controller().isBufferDependent())
98 // deactivate the dialog if we have no buffer
99 if (!kernel().isBufferAvailable()) {
100 bc().setReadOnly(true);
104 // check whether this dialog may be active
105 if (controller().canApply()) {
106 bool const readonly = kernel().isBufferReadonly();
107 bc().setReadOnly(readonly);
108 // refreshReadOnly() is too generous in _enabling_ widgets
109 // update dialog to disable disabled widgets again
112 if (!readonly || controller().canApplyToReadOnly())
116 bc().setReadOnly(true);
121 bool GuiDialog::isVisibleView() const
123 return QDialog::isVisible();
127 bool GuiDialog::readOnly() const
129 return kernel().isBufferReadonly();
133 void GuiDialog::showView()
135 QSize const hint = sizeHint();
136 if (hint.height() >= 0 && hint.width() >= 0)
137 setMinimumSize(hint);
139 updateView(); // make sure its up-to-date
140 if (controller().exitEarly())
143 setWindowTitle(toqstr("LyX: " + getViewTitle()));
145 if (QWidget::isVisible()) {
155 void GuiDialog::hideView()
161 bool GuiDialog::isValid()
167 void GuiDialog::changed()
171 bc().setValid(isValid());
175 void GuiDialog::slotWMHide()
181 void GuiDialog::slotApply()
187 void GuiDialog::slotOK()
193 void GuiDialog::slotClose()
199 void GuiDialog::slotRestore()
204 void GuiDialog::updateView()
206 setUpdatesEnabled(false);
208 // protect the BC from unwarranted state transitions
213 setUpdatesEnabled(true);
217 } // namespace frontend
220 #include "GuiDialog_moc.cpp"