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"
16 #include "qt_helpers.h"
18 #include "support/debug.h"
20 #include <QCloseEvent>
21 #include <QDialogButtonBox>
28 GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title)
29 : QDialog(&lv), Dialog(lv, name, title), updating_(false),
30 is_closing_(false), apply_stopped_(false)
32 connect(&lv, SIGNAL(bufferViewChanged()),
33 this, SLOT(onBufferViewChanged()));
35 // remove question marks from Windows dialogs
36 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
40 void GuiDialog::closeEvent(QCloseEvent * ev)
47 void GuiDialog::setButtonsValid(bool valid)
53 void GuiDialog::slotApply()
55 setApplyStopped(false);
63 void GuiDialog::slotAutoApply()
70 void GuiDialog::slotOK()
73 setApplyStopped(false);
83 void GuiDialog::slotClose()
90 void GuiDialog::slotRestore()
92 // Tell the controller that a request to refresh the dialog's contents
93 // has been received. It's up to the controller to supply the necessary
94 // info by calling GuiDialog::updateView().
100 void GuiDialog::slotButtonBox(QAbstractButton * button)
102 QDialogButtonBox * bbox = qobject_cast<QDialogButtonBox*>(sender());
103 switch (bbox->standardButton(button)) {
104 case QDialogButtonBox::Ok:
107 case QDialogButtonBox::Apply:
110 case QDialogButtonBox::Cancel:
111 case QDialogButtonBox::Close:
114 case QDialogButtonBox::Reset:
117 case QDialogButtonBox::RestoreDefaults:
118 slotRestoreDefaults();
126 void GuiDialog::changed()
130 bc().setValid(isValid());
134 void GuiDialog::enableView(bool enable)
137 bc().setReadOnly(true);
138 bc().setValid(false);
140 Dialog::enableView(enable);
144 void GuiDialog::updateView()
146 setUpdatesEnabled(false);
148 bc().setReadOnly(isBufferReadonly());
149 // protect the BC from unwarranted state transitions
153 // The widgets may not be valid, so refresh the button controller
156 setUpdatesEnabled(true);
159 } // namespace frontend
162 #include "moc_GuiDialog.cpp"