]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiNote.cpp
Merge QController into individual dialogs. Also various cleanup
[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 #include "Qt2BC.h"
15
16 #include "insets/InsetNote.h"
17
18 #include <QCloseEvent>
19
20 namespace lyx {
21 namespace frontend {
22
23 /////////////////////////////////////////////////////////////////////
24 //
25 // GuiNoteDialog
26 //
27 /////////////////////////////////////////////////////////////////////
28
29 GuiNoteDialog::GuiNoteDialog(GuiNote * form)
30         : form_(form)
31 {
32         setupUi(this);
33
34         connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
35         connect(closePB, SIGNAL(clicked()), form, 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         connect(framedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
41         connect(shadedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
42 }
43
44
45 void GuiNoteDialog::closeEvent(QCloseEvent * e)
46 {
47         form_->slotWMHide();
48         e->accept();
49 }
50
51
52 void GuiNoteDialog::change_adaptor()
53 {
54         form_->changed();
55 }
56
57
58 /////////////////////////////////////////////////////////////////////
59 //
60 // GuiNote
61 //
62 /////////////////////////////////////////////////////////////////////
63
64
65 GuiNote::GuiNote(Dialog & parent)
66         : GuiView<GuiNoteDialog>(parent, _("Note Settings"))
67 {}
68
69
70 void GuiNote::build_dialog()
71 {
72         dialog_.reset(new GuiNoteDialog(this));
73
74         bcview().setOK(dialog_->okPB);
75         bcview().setCancel(dialog_->closePB);
76 }
77
78
79 void GuiNote::update_contents()
80 {
81         QRadioButton * rb = 0;
82
83         switch (controller().params().type) {
84         case InsetNoteParams::Note:
85                 rb = dialog_->noteRB;
86                 break;
87         case InsetNoteParams::Comment:
88                 rb = dialog_->commentRB;
89                 break;
90         case InsetNoteParams::Greyedout:
91                 rb = dialog_->greyedoutRB;
92                 break;
93         case InsetNoteParams::Framed:
94                 rb = dialog_->framedRB;
95                 break;
96         case InsetNoteParams::Shaded:
97                 rb = dialog_->shadedRB;
98                 break;
99         }
100
101         rb->setChecked(true);
102 }
103
104
105 void GuiNote::apply()
106 {
107         InsetNoteParams::Type type;
108
109         if (dialog_->greyedoutRB->isChecked())
110                 type = InsetNoteParams::Greyedout;
111         else if (dialog_->commentRB->isChecked())
112                 type = InsetNoteParams::Comment;
113         else if (dialog_->framedRB->isChecked())
114                 type = InsetNoteParams::Framed;
115         else if (dialog_->shadedRB->isChecked())
116                 type = InsetNoteParams::Shaded;
117         else
118                 type = InsetNoteParams::Note;
119
120         controller().params().type = type;
121 }
122
123 } // namespace frontend
124 } // namespace lyx
125
126 #include "GuiNote_moc.cpp"