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"
14 #include "GuiCommand.h"
17 #include "qt_helpers.h"
18 #include "FuncRequest.h"
20 #include "insets/InsetCommand.h"
22 #include "support/debug.h"
24 #include <QCloseEvent>
31 GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title)
32 : QDialog(&lv), Dialog(lv, name, "LyX: " + title), is_closing_(false)
36 void GuiDialog::closeEvent(QCloseEvent * ev)
43 void GuiDialog::setButtonsValid(bool valid)
49 void GuiDialog::slotApply()
56 void GuiDialog::slotOK()
66 void GuiDialog::slotClose()
73 void GuiDialog::slotRestore()
75 // Tell the controller that a request to refresh the dialog's contents
76 // has been received. It's up to the controller to supply the necessary
77 // info by calling GuiDialog::updateView().
83 void GuiDialog::changed()
87 bc().setValid(isValid());
91 void GuiDialog::enableView(bool enable)
93 bc().setReadOnly(!enable);
94 bc().setValid(enable);
95 Dialog::enableView(enable);
99 void GuiDialog::updateView()
101 setUpdatesEnabled(false);
103 bc().setReadOnly(isBufferReadonly());
104 // protect the BC from unwarranted state transitions
108 // The widgets may not be valid, so refresh the button controller
111 setUpdatesEnabled(true);
115 /////////////////////////////////////////////////////////////////////
117 // Command based dialogs
119 /////////////////////////////////////////////////////////////////////
122 GuiCommand::GuiCommand(GuiView & lv, QString const & name,
123 QString const & title)
124 : GuiDialog(lv, name, title), params_(insetCode(fromqstr(name))),
125 lfun_name_(fromqstr(name))
130 bool GuiCommand::initialiseParams(string const & data)
132 // The name passed with LFUN_INSET_APPLY is also the name
133 // used to identify the mailer.
134 InsetCommand::string2params(lfun_name_, data, params_);
139 void GuiCommand::dispatchParams()
141 if (lfun_name_.empty())
144 string const lfun = InsetCommand::params2string(lfun_name_, params_);
145 dispatch(FuncRequest(getLfun(), lfun));
148 } // namespace frontend
151 #include "GuiDialog_moc.cpp"