]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiERT.cpp
Account for old versions of Pygments
[lyx.git] / src / frontends / qt4 / GuiERT.cpp
index a8648c97928ebd5b3f52cb5f85cb31f4e6b431f0..8fc92e22505ccbf4db88df349cb7fe8e3eca0846 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 "GuiApplication.h"
+#include "GuiView.h"
+
+#include "insets/InsetERT.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(QWidget * parent) : InsetParamsWidget(parent)
 {
        setupUi(this);
-       connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
-       connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
-       connect(collapsedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
-       connect(openRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
-}
 
-
-void GuiERTDialog::closeEvent(QCloseEvent * e)
-{
-       form_->slotWMHide();
-       e->accept();
+       connect(collapsedRB, SIGNAL(clicked()), this, SIGNAL(changed()));
+       connect(openRB, SIGNAL(clicked()), this, SIGNAL(changed()));
 }
 
 
-void GuiERTDialog::change_adaptor()
+docstring GuiERT::dialogToParams() const
 {
-       form_->changed();
+       InsetCollapsable::CollapseStatus const status = openRB->isChecked()
+               ? InsetCollapsable::Open : InsetCollapsable::Collapsed;
+       return from_ascii(InsetERT::params2string(status));
 }
 
 
-/////////////////////////////////////////////////////////////////////
-//
-// GuiERT
-//
-/////////////////////////////////////////////////////////////////////
-
-GuiERT::GuiERT(GuiDialog & parent)
-       : GuiView<GuiERTDialog>(parent, _("TeX Code Settings"))
+void GuiERT::paramsToDialog(Inset const * inset)
 {
+       InsetERT const * ert = static_cast<InsetERT const *>(inset);
+       // FIXME: This dialog has absolutely no value...
+       BufferView const * bv = guiApp->currentView()->currentBufferView();
+       InsetCollapsable::CollapseStatus status = ert->status(*bv);
+       switch (status) {
+               case InsetCollapsable::Open: openRB->setChecked(true); break;
+               case InsetCollapsable::Collapsed: collapsedRB->setChecked(true); break;
+       }
 }
 
 
-void GuiERT::build_dialog()
-{
-       dialog_.reset(new GuiERTDialog(this));
-
-       bc().setOK(dialog_->okPB);
-       bc().setCancel(dialog_->closePB);
-}
-
-
-void GuiERT::apply()
+bool GuiERT::checkWidgets(bool readonly) const
 {
-       if (dialog_->openRB->isChecked())
-               controller().setStatus(Inset::Open);
-       else
-               controller().setStatus(Inset::Collapsed);
+       ertBG->setEnabled(!readonly);
+       return InsetParamsWidget::checkWidgets();
 }
 
 
-void GuiERT::update_contents()
-{
-       QRadioButton * rb = 0;
-
-       switch (controller().status()) {
-               case InsetERT::Open: rb = dialog_->openRB; break;
-               case InsetERT::Collapsed: rb = dialog_->collapsedRB; break;
-       }
-
-       rb->setChecked(true);
-}
-
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiERT_moc.cpp"
+#include "moc_GuiERT.cpp"