]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiNote.cpp
the fun begins....
[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 Jürgen Spitzmüller
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiNote.h"
14
15 #include "ControlNote.h"
16 #include "insets/InsetNote.h"
17
18 #include <QCloseEvent>
19
20 namespace lyx {
21 namespace frontend {
22
23 GuiNoteDialog::GuiNoteDialog(LyXView & lv)
24         : GuiDialog(lv, "note")
25 {
26         setupUi(this);
27         setController(new ControlNote(*this));
28         setViewTitle(_("Note Settings"));
29
30         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
31         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
32
33         connect(noteRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
34         connect(greyedoutRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
35         connect(commentRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
36         connect(framedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
37         connect(shadedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
38
39         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
40         bc().setOK(okPB);
41         bc().setCancel(closePB);
42 }
43
44
45 ControlNote & GuiNoteDialog::controller() const
46 {
47         return static_cast<ControlNote &>(Dialog::controller());
48 }
49
50
51 void GuiNoteDialog::closeEvent(QCloseEvent * e)
52 {
53         slotWMHide();
54         e->accept();
55 }
56
57
58 void GuiNoteDialog::change_adaptor()
59 {
60         changed();
61 }
62
63
64 void GuiNoteDialog::update_contents()
65 {
66         QRadioButton * rb = 0;
67
68         switch (controller().params().type) {
69         case InsetNoteParams::Note:
70                 rb = noteRB;
71                 break;
72         case InsetNoteParams::Comment:
73                 rb = commentRB;
74                 break;
75         case InsetNoteParams::Greyedout:
76                 rb = greyedoutRB;
77                 break;
78         case InsetNoteParams::Framed:
79                 rb = framedRB;
80                 break;
81         case InsetNoteParams::Shaded:
82                 rb = shadedRB;
83                 break;
84         }
85
86         rb->setChecked(true);
87 }
88
89
90 void GuiNoteDialog::applyView()
91 {
92         InsetNoteParams::Type type;
93
94         if (greyedoutRB->isChecked())
95                 type = InsetNoteParams::Greyedout;
96         else if (commentRB->isChecked())
97                 type = InsetNoteParams::Comment;
98         else if (framedRB->isChecked())
99                 type = InsetNoteParams::Framed;
100         else if (shadedRB->isChecked())
101                 type = InsetNoteParams::Shaded;
102         else
103                 type = InsetNoteParams::Note;
104
105         controller().params().type = type;
106 }
107
108 } // namespace frontend
109 } // namespace lyx
110
111 #include "GuiNote_moc.cpp"