]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiNote.cpp
Whitespace.
[lyx.git] / src / frontends / qt4 / GuiNote.cpp
index 250d2d34b615cf544ccd7a51e1897be8096bbc9c..adbb6e7425f09bbd3893116d2cc3cc34fcbe03cc 100644 (file)
@@ -3,7 +3,8 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Jürgen Spitzmüller
+ * \author Angus Leeming
+ * \author Jürgen Spitzmüller
  *
  * Full author contact details are available in file CREDITS.
  */
 #include <config.h>
 
 #include "GuiNote.h"
-#include "Qt2BC.h"
+#include "FuncRequest.h"
+#include "support/gettext.h"
 
 #include "insets/InsetNote.h"
 
-#include <QCloseEvent>
+using namespace std;
 
 namespace lyx {
 namespace frontend {
 
-/////////////////////////////////////////////////////////////////////
-//
-// GuiNoteDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-GuiNoteDialog::GuiNoteDialog(GuiNote * form)
-       : form_(form)
+GuiNote::GuiNote(GuiView & lv)
+       : GuiDialog(lv, "note", qt_("Note Settings"))
 {
        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(noteRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
        connect(greyedoutRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
        connect(commentRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
-       connect(framedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
-       connect(shadedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+
+       bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
+       bc().setOK(okPB);
+       bc().setCancel(closePB);
 }
 
 
-void GuiNoteDialog::closeEvent(QCloseEvent * e)
+void GuiNote::change_adaptor()
 {
-       form_->slotWMHide();
-       e->accept();
+       changed();
 }
 
 
-void GuiNoteDialog::change_adaptor()
+void GuiNote::updateContents()
 {
-       form_->changed();
+       switch (params_.type) {
+       case InsetNoteParams::Note:
+               noteRB->setChecked(true);
+               break;
+       case InsetNoteParams::Comment:
+               commentRB->setChecked(true);
+               break;
+       case InsetNoteParams::Greyedout:
+               greyedoutRB->setChecked(true);
+               break;
+       }
 }
 
 
-/////////////////////////////////////////////////////////////////////
-//
-// GuiNote
-//
-/////////////////////////////////////////////////////////////////////
-
-
-GuiNote::GuiNote(Dialog & parent)
-       : GuiView<GuiNoteDialog>(parent, _("Note Settings"))
-{}
+void GuiNote::applyView()
+{
+       if (greyedoutRB->isChecked())
+               params_.type = InsetNoteParams::Greyedout;
+       else if (commentRB->isChecked())
+               params_.type = InsetNoteParams::Comment;
+       else
+               params_.type = InsetNoteParams::Note;
+}
 
 
-void GuiNote::build_dialog()
+bool GuiNote::initialiseParams(string const & data)
 {
-       dialog_.reset(new GuiNoteDialog(this));
-
-       bcview().setOK(dialog_->okPB);
-       bcview().setCancel(dialog_->closePB);
+       InsetNote::string2params(data, params_);
+       return true;
 }
 
 
-void GuiNote::update_contents()
+void GuiNote::clearParams()
 {
-       QRadioButton * rb = 0;
+       params_ = InsetNoteParams();
+}
 
-       switch (controller().params().type) {
-       case InsetNoteParams::Note:
-               rb = dialog_->noteRB;
-               break;
-       case InsetNoteParams::Comment:
-               rb = dialog_->commentRB;
-               break;
-       case InsetNoteParams::Greyedout:
-               rb = dialog_->greyedoutRB;
-               break;
-       case InsetNoteParams::Framed:
-               rb = dialog_->framedRB;
-               break;
-       case InsetNoteParams::Shaded:
-               rb = dialog_->shadedRB;
-               break;
-       }
 
-       rb->setChecked(true);
+void GuiNote::dispatchParams()
+{
+       dispatch(FuncRequest(getLfun(), InsetNote::params2string(params_)));
 }
 
 
-void GuiNote::apply()
-{
-       InsetNoteParams::Type type;
-
-       if (dialog_->greyedoutRB->isChecked())
-               type = InsetNoteParams::Greyedout;
-       else if (dialog_->commentRB->isChecked())
-               type = InsetNoteParams::Comment;
-       else if (dialog_->framedRB->isChecked())
-               type = InsetNoteParams::Framed;
-       else if (dialog_->shadedRB->isChecked())
-               type = InsetNoteParams::Shaded;
-       else
-               type = InsetNoteParams::Note;
+Dialog * createGuiNote(GuiView & lv) { return new GuiNote(lv); }
 
-       controller().params().type = type;
-}
 
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiNote_moc.cpp"
+#include "moc_GuiNote.cpp"