]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiNote.cpp
Factorize closeEvent() for GuiDialog based dialogs.
[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 namespace std;
23
24 namespace lyx {
25 namespace frontend {
26
27 GuiNote::GuiNote(GuiView & lv)
28         : GuiDialog(lv, "note", qt_("Note Settings"))
29 {
30         setupUi(this);
31
32         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
33         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
34
35         connect(noteRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
36         connect(greyedoutRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
37         connect(commentRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
38
39         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
40         bc().setOK(okPB);
41         bc().setCancel(closePB);
42 }
43
44
45 void GuiNote::change_adaptor()
46 {
47         changed();
48 }
49
50
51 void GuiNote::updateContents()
52 {
53         switch (params_.type) {
54         case InsetNoteParams::Note:
55                 noteRB->setChecked(true);
56                 break;
57         case InsetNoteParams::Comment:
58                 commentRB->setChecked(true);
59                 break;
60         case InsetNoteParams::Greyedout:
61                 greyedoutRB->setChecked(true);
62                 break;
63         }
64 }
65
66
67 void GuiNote::applyView()
68 {
69         if (greyedoutRB->isChecked())
70                 params_.type = InsetNoteParams::Greyedout;
71         else if (commentRB->isChecked())
72                 params_.type = InsetNoteParams::Comment;
73         else
74                 params_.type = InsetNoteParams::Note;
75 }
76
77
78 bool GuiNote::initialiseParams(string const & data)
79 {
80         InsetNoteMailer::string2params(data, params_);
81         return true;
82 }
83
84
85 void GuiNote::clearParams()
86 {
87         params_ = InsetNoteParams();
88 }
89
90
91 void GuiNote::dispatchParams()
92 {
93         dispatch(FuncRequest(getLfun(), InsetNoteMailer::params2string(params_)));
94 }
95
96
97 Dialog * createGuiNote(GuiView & lv) { return new GuiNote(lv); }
98
99
100 } // namespace frontend
101 } // namespace lyx
102
103 #include "GuiNote_moc.cpp"