X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiDialog.cpp;h=7d4bf582116f11ddffcabfd8692db2870270ee27;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=80fca20fea48cc2699be8d03ad3a399ea706e3ed;hpb=e5bac2fe8892ccdfaf7e123d42ca7f31244ca850;p=lyx.git diff --git a/src/frontends/qt4/GuiDialog.cpp b/src/frontends/qt4/GuiDialog.cpp index 80fca20fea..7d4bf58211 100644 --- a/src/frontends/qt4/GuiDialog.cpp +++ b/src/frontends/qt4/GuiDialog.cpp @@ -11,26 +11,33 @@ #include #include "GuiDialog.h" + #include "GuiView.h" #include "qt_helpers.h" +#include "FuncRequest.h" #include "support/debug.h" #include -#include -#include -#include -using std::string; +using namespace std; namespace lyx { namespace frontend { -GuiDialog::GuiDialog(GuiView & lv, std::string const & name) - : DialogView(lv, name), is_closing_(false) +GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title) + : QDialog(&lv), Dialog(lv, name, "LyX: " + title), updating_(false), + is_closing_(false) {} +void GuiDialog::closeEvent(QCloseEvent * ev) +{ + slotClose(); + ev->accept(); +} + + void GuiDialog::setButtonsValid(bool valid) { bc().setValid(valid); @@ -44,19 +51,26 @@ void GuiDialog::slotApply() } +void GuiDialog::slotAutoApply() +{ + apply(); + bc().autoApply(); +} + + void GuiDialog::slotOK() { is_closing_ = true; apply(); is_closing_ = false; - QDialog::hide(); + hideView(); bc().ok(); } void GuiDialog::slotClose() { - QDialog::hide(); + hideView(); bc().cancel(); } @@ -81,9 +95,11 @@ void GuiDialog::changed() void GuiDialog::enableView(bool enable) { - bc().setReadOnly(!enable); - bc().setValid(enable); - DialogView::enableView(enable); + if (!enable) { + bc().setReadOnly(true); + bc().setValid(false); + } + Dialog::enableView(enable); } @@ -105,48 +121,4 @@ void GuiDialog::updateView() } // namespace frontend } // namespace lyx - -///////////////////////////////////////////////////////////////////// -// -// Command based dialogs -// -///////////////////////////////////////////////////////////////////// - -#include "FuncRequest.h" -#include "insets/InsetCommand.h" - - -using std::string; - -namespace lyx { -namespace frontend { - -GuiCommand::GuiCommand(GuiView & lv, string const & name) - : GuiDialog(lv, name), params_(insetCode(name)), lfun_name_(name) -{ -} - - -bool GuiCommand::initialiseParams(string const & data) -{ - // The name passed with LFUN_INSET_APPLY is also the name - // used to identify the mailer. - InsetCommandMailer::string2params(lfun_name_, data, params_); - return true; -} - - -void GuiCommand::dispatchParams() -{ - if (lfun_name_.empty()) - return; - - string const lfun = - InsetCommandMailer::params2string(lfun_name_, params_); - dispatch(FuncRequest(getLfun(), lfun)); -} - -} // namespace frontend -} // namespace lyx - -#include "GuiDialog_moc.cpp" +#include "moc_GuiDialog.cpp"