]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiNote.cpp
38...
[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 "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(LyXView & lv)
29         : GuiDialog(lv, "note"), Controller(this)
30 {
31         setupUi(this);
32         setController(this, false);
33         setViewTitle(_("Note Settings"));
34
35         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
36         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
37
38         connect(noteRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
39         connect(greyedoutRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
40         connect(commentRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
41         connect(framedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
42         connect(shadedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
43
44         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
45         bc().setOK(okPB);
46         bc().setCancel(closePB);
47 }
48
49
50 void GuiNote::closeEvent(QCloseEvent * e)
51 {
52         slotClose();
53         e->accept();
54 }
55
56
57 void GuiNote::change_adaptor()
58 {
59         changed();
60 }
61
62
63 void GuiNote::updateContents()
64 {
65         switch (params_.type) {
66         case InsetNoteParams::Note:
67                 noteRB->setChecked(true);
68                 break;
69         case InsetNoteParams::Comment:
70                 commentRB->setChecked(true);
71                 break;
72         case InsetNoteParams::Greyedout:
73                 greyedoutRB->setChecked(true);
74                 break;
75         case InsetNoteParams::Framed:
76                 framedRB->setChecked(true);
77                 break;
78         case InsetNoteParams::Shaded:
79                 shadedRB->setChecked(true);
80                 break;
81         }
82 }
83
84
85 void GuiNote::applyView()
86 {
87         if (greyedoutRB->isChecked())
88                 params_.type = InsetNoteParams::Greyedout;
89         else if (commentRB->isChecked())
90                 params_.type = InsetNoteParams::Comment;
91         else if (framedRB->isChecked())
92                 params_.type = InsetNoteParams::Framed;
93         else if (shadedRB->isChecked())
94                 params_.type = InsetNoteParams::Shaded;
95         else
96                 params_.type = InsetNoteParams::Note;
97 }
98
99
100 bool GuiNote::initialiseParams(string const & data)
101 {
102         InsetNoteMailer::string2params(data, params_);
103         return true;
104 }
105
106
107 void GuiNote::clearParams()
108 {
109         params_ = InsetNoteParams();
110 }
111
112
113 void GuiNote::dispatchParams()
114 {
115         dispatch(FuncRequest(getLfun(), InsetNoteMailer::params2string(params_)));
116 }
117
118
119 Dialog * createGuiNote(LyXView & lv) { return new GuiNote(lv); }
120
121
122 } // namespace frontend
123 } // namespace lyx
124
125 #include "GuiNote_moc.cpp"