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"
16 #include "FuncRequest.h"
18 #include "insets/InsetCommand.h"
20 #include "support/debug.h"
22 #include <QCloseEvent>
23 #include <QMainWindow>
32 GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title)
33 : QDialog(&lv), Dialog(lv, name, "LyX: " + title), is_closing_(false)
37 void GuiDialog::closeEvent(QCloseEvent * ev)
44 void GuiDialog::setButtonsValid(bool valid)
50 void GuiDialog::slotApply()
57 void GuiDialog::slotOK()
67 void GuiDialog::slotClose()
74 void GuiDialog::slotRestore()
76 // Tell the controller that a request to refresh the dialog's contents
77 // has been received. It's up to the controller to supply the necessary
78 // info by calling GuiDialog::updateView().
84 void GuiDialog::changed()
88 bc().setValid(isValid());
92 void GuiDialog::enableView(bool enable)
94 bc().setReadOnly(!enable);
95 bc().setValid(enable);
96 Dialog::enableView(enable);
100 void GuiDialog::updateView()
102 setUpdatesEnabled(false);
104 bc().setReadOnly(isBufferReadonly());
105 // protect the BC from unwarranted state transitions
109 // The widgets may not be valid, so refresh the button controller
112 setUpdatesEnabled(true);
116 /////////////////////////////////////////////////////////////////////
118 // Command based dialogs
120 /////////////////////////////////////////////////////////////////////
123 GuiCommand::GuiCommand(GuiView & lv, QString const & name,
124 QString const & title)
125 : GuiDialog(lv, name, title), params_(insetCode(fromqstr(name))),
126 lfun_name_(fromqstr(name))
131 bool GuiCommand::initialiseParams(string const & data)
133 // The name passed with LFUN_INSET_APPLY is also the name
134 // used to identify the mailer.
135 InsetCommandMailer::string2params(lfun_name_, data, params_);
140 void GuiCommand::dispatchParams()
142 if (lfun_name_.empty())
146 InsetCommandMailer::params2string(lfun_name_, params_);
147 dispatch(FuncRequest(getLfun(), lfun));
150 } // namespace frontend
153 #include "GuiDialog_moc.cpp"