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::setViewTitle(docstring const & title)
27 setWindowTitle("LyX: " + toqstr(title));
31 void GuiDialog::setButtonsValid(bool valid)
37 void GuiDialog::ApplyButton()
44 void GuiDialog::OKButton()
54 void GuiDialog::CancelButton()
61 void GuiDialog::RestoreButton()
63 // Tell the kernel that a request to refresh the dialog's contents
64 // has been received. It's up to the kernel to supply the necessary
65 // info by calling GuiDialog::updateView().
66 kernel().updateDialog(name_);
71 void GuiDialog::preShow()
73 bc().setReadOnly(kernel().isBufferReadonly());
77 void GuiDialog::postShow()
79 // The widgets may not be valid, so refresh the button controller
84 void GuiDialog::preUpdate()
86 bc().setReadOnly(kernel().isBufferReadonly());
90 void GuiDialog::postUpdate()
92 // The widgets may not be valid, so refresh the button controller
97 void GuiDialog::checkStatus()
99 // buffer independant dialogs are always active.
100 // This check allows us leave canApply unimplemented for some dialogs.
101 if (!controller().isBufferDependent())
104 // deactivate the dialog if we have no buffer
105 if (!kernel().isBufferAvailable()) {
106 bc().setReadOnly(true);
110 // check whether this dialog may be active
111 if (controller().canApply()) {
112 bool const readonly = kernel().isBufferReadonly();
113 bc().setReadOnly(readonly);
114 // refreshReadOnly() is too generous in _enabling_ widgets
115 // update dialog to disable disabled widgets again
118 if (!readonly || controller().canApplyToReadOnly())
122 bc().setReadOnly(true);
127 bool GuiDialog::isVisibleView() const
129 return QDialog::isVisible();
133 bool GuiDialog::readOnly() const
135 return kernel().isBufferReadonly();
139 void GuiDialog::showView()
141 QSize const hint = sizeHint();
142 if (hint.height() >= 0 && hint.width() >= 0)
143 setMinimumSize(hint);
145 updateView(); // make sure its up-to-date
146 if (controller().exitEarly())
149 if (QWidget::isVisible()) {
159 void GuiDialog::hideView()
165 bool GuiDialog::isValid()
171 void GuiDialog::changed()
175 bc().setValid(isValid());
179 void GuiDialog::slotWMHide()
185 void GuiDialog::slotApply()
191 void GuiDialog::slotOK()
197 void GuiDialog::slotClose()
203 void GuiDialog::slotRestore()
208 void GuiDialog::updateView()
210 setUpdatesEnabled(false);
212 // protect the BC from unwarranted state transitions
217 setUpdatesEnabled(true);
221 } // namespace frontend
224 #include "GuiDialog_moc.cpp"