]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiERT.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiERT.cpp
index 394a4fc7a6f9073e33251ab16642b6aff7e7b019..65a6095cee2a7ddb979fdc91ed0ca8b2769d69b6 100644 (file)
@@ -3,6 +3,8 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
+ * \author Jürgen Vigna
+ * \author Angus Leeming
  * \author John Levon
  *
  * Full author contact details are available in file CREDITS.
 #include <config.h>
 
 #include "GuiERT.h"
-#include "gettext.h"
+#include "FuncRequest.h"
+
+#include "support/gettext.h"
 
 #include <QRadioButton>
 #include <QPushButton>
-#include <QCloseEvent>
 
+using namespace std;
 
 namespace lyx {
 namespace frontend {
 
-/////////////////////////////////////////////////////////////////////
-//
-// GuiERTDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-
-GuiERTDialog::GuiERTDialog(GuiERT * form)
-       : form_(form)
+GuiERT::GuiERT(GuiView & lv)
+       : GuiDialog(lv, "ert", qt_("TeX Code Settings")), status_(InsetCollapsable::Collapsed)
 {
        setupUi(this);
-       connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
-       connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
+
+       connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
+       connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
        connect(collapsedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
        connect(openRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+
+       bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
+       bc().setOK(okPB);
+       bc().setCancel(closePB);
 }
 
 
-void GuiERTDialog::closeEvent(QCloseEvent * e)
+void GuiERT::change_adaptor()
 {
-       form_->slotWMHide();
-       e->accept();
+       changed();
 }
 
 
-void GuiERTDialog::change_adaptor()
+void GuiERT::applyView()
 {
-       form_->changed();
+       if (openRB->isChecked())
+               status_ = InsetCollapsable::Open;
+       else
+               status_ = InsetCollapsable::Collapsed;
 }
 
 
-/////////////////////////////////////////////////////////////////////
-//
-// GuiERT
-//
-/////////////////////////////////////////////////////////////////////
-
-GuiERT::GuiERT(GuiDialog & parent)
-       : GuiView<GuiERTDialog>(parent, _("TeX Code Settings"))
+void GuiERT::updateContents()
 {
+       switch (status_) {
+               case InsetCollapsable::Open: openRB->setChecked(true); break;
+               case InsetCollapsable::Collapsed: collapsedRB->setChecked(true); break;
+       }
 }
 
 
-void GuiERT::build_dialog()
+bool GuiERT::initialiseParams(string const & data)
 {
-       dialog_.reset(new GuiERTDialog(this));
-
-       bc().setOK(dialog_->okPB);
-       bc().setCancel(dialog_->closePB);
+       status_ = InsetERT::string2params(data);
+       return true;
 }
 
 
-void GuiERT::applyView()
+void GuiERT::clearParams()
 {
-       if (dialog_->openRB->isChecked())
-               controller().setStatus(Inset::Open);
-       else
-               controller().setStatus(Inset::Collapsed);
+       status_ = InsetCollapsable::Collapsed;
 }
 
 
-void GuiERT::update_contents()
+void GuiERT::dispatchParams()
 {
-       QRadioButton * rb = 0;
+       dispatch(FuncRequest(getLfun(), InsetERT::params2string(status_)));
+}
 
-       switch (controller().status()) {
-               case InsetERT::Open: rb = dialog_->openRB; break;
-               case InsetERT::Collapsed: rb = dialog_->collapsedRB; break;
-       }
 
-       rb->setChecked(true);
-}
+Dialog * createGuiERT(GuiView & lv) { return new GuiERT(lv); }
+
 
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiERT_moc.cpp"
+#include "moc_GuiERT.cpp"