]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiNote.cpp
framed.sty goes InsetBox:
[lyx.git] / src / frontends / qt4 / GuiNote.cpp
1 /**
2  * \file GuiNote.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  * \author Jürgen Spitzmüller
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "GuiNote.h"
15 #include "FuncRequest.h"
16 #include "support/gettext.h"
17
18 #include "insets/InsetNote.h"
19
20 #include <QCloseEvent>
21
22 using std::string;
23
24
25 namespace lyx {
26 namespace frontend {
27
28 GuiNote::GuiNote(GuiView & lv)
29         : GuiDialog(lv, "note")
30 {
31         setupUi(this);
32         setViewTitle(_("Note Settings"));
33
34         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
35         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
36
37         connect(noteRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
38         connect(greyedoutRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
39         connect(commentRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
40
41         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
42         bc().setOK(okPB);
43         bc().setCancel(closePB);
44 }
45
46
47 void GuiNote::closeEvent(QCloseEvent * e)
48 {
49         slotClose();
50         e->accept();
51 }
52
53
54 void GuiNote::change_adaptor()
55 {
56         changed();
57 }
58
59
60 void GuiNote::updateContents()
61 {
62         switch (params_.type) {
63         case InsetNoteParams::Note:
64                 noteRB->setChecked(true);
65                 break;
66         case InsetNoteParams::Comment:
67                 commentRB->setChecked(true);
68                 break;
69         case InsetNoteParams::Greyedout:
70                 greyedoutRB->setChecked(true);
71                 break;
72         }
73 }
74
75
76 void GuiNote::applyView()
77 {
78         if (greyedoutRB->isChecked())
79                 params_.type = InsetNoteParams::Greyedout;
80         else if (commentRB->isChecked())
81                 params_.type = InsetNoteParams::Comment;
82         else
83                 params_.type = InsetNoteParams::Note;
84 }
85
86
87 bool GuiNote::initialiseParams(string const & data)
88 {
89         InsetNoteMailer::string2params(data, params_);
90         return true;
91 }
92
93
94 void GuiNote::clearParams()
95 {
96         params_ = InsetNoteParams();
97 }
98
99
100 void GuiNote::dispatchParams()
101 {
102         dispatch(FuncRequest(getLfun(), InsetNoteMailer::params2string(params_)));
103 }
104
105
106 Dialog * createGuiNote(GuiView & lv) { return new GuiNote(lv); }
107
108
109 } // namespace frontend
110 } // namespace lyx
111
112 #include "GuiNote_moc.cpp"