]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiNote.cpp
Factorize out the way window titles are handled.
[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::closeEvent(QCloseEvent * e)
46 {
47         slotClose();
48         e->accept();
49 }
50
51
52 void GuiNote::change_adaptor()
53 {
54         changed();
55 }
56
57
58 void GuiNote::updateContents()
59 {
60         switch (params_.type) {
61         case InsetNoteParams::Note:
62                 noteRB->setChecked(true);
63                 break;
64         case InsetNoteParams::Comment:
65                 commentRB->setChecked(true);
66                 break;
67         case InsetNoteParams::Greyedout:
68                 greyedoutRB->setChecked(true);
69                 break;
70         }
71 }
72
73
74 void GuiNote::applyView()
75 {
76         if (greyedoutRB->isChecked())
77                 params_.type = InsetNoteParams::Greyedout;
78         else if (commentRB->isChecked())
79                 params_.type = InsetNoteParams::Comment;
80         else
81                 params_.type = InsetNoteParams::Note;
82 }
83
84
85 bool GuiNote::initialiseParams(string const & data)
86 {
87         InsetNoteMailer::string2params(data, params_);
88         return true;
89 }
90
91
92 void GuiNote::clearParams()
93 {
94         params_ = InsetNoteParams();
95 }
96
97
98 void GuiNote::dispatchParams()
99 {
100         dispatch(FuncRequest(getLfun(), InsetNoteMailer::params2string(params_)));
101 }
102
103
104 Dialog * createGuiNote(GuiView & lv) { return new GuiNote(lv); }
105
106
107 } // namespace frontend
108 } // namespace lyx
109
110 #include "GuiNote_moc.cpp"