]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QNote.C
Port of Martin Vermeer's QNote work: fix of framed and shaded note.
[lyx.git] / src / frontends / qt4 / QNote.C
1 /**
2  * \file QNote.C
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 "QNote.h"
14 #include "QNoteDialog.h"
15 #include "Qt2BC.h"
16
17 #include "controllers/ControlNote.h"
18
19 #include "insets/insetnote.h"
20
21 #include <qradiobutton.h>
22 #include <qpushbutton.h>
23
24
25 using std::string;
26
27 namespace lyx {
28 namespace frontend {
29
30 typedef QController<ControlNote, QView<QNoteDialog> > base_class;
31
32
33 QNote::QNote(Dialog & parent)
34         : base_class(parent, _("Note Settings"))
35 {}
36
37
38 void QNote::build_dialog()
39 {
40         dialog_.reset(new QNoteDialog(this));
41
42         bcview().setOK(dialog_->okPB);
43         bcview().setCancel(dialog_->closePB);
44 }
45
46
47 void QNote::update_contents()
48 {
49         QRadioButton * rb = 0;
50
51         switch (controller().params().type) {
52         case InsetNoteParams::Note:
53                 rb = dialog_->noteRB;
54                 break;
55         case InsetNoteParams::Comment:
56                 rb = dialog_->commentRB;
57                 break;
58         case InsetNoteParams::Greyedout:
59                 rb = dialog_->greyedoutRB;
60                 break;
61         case InsetNoteParams::Framed:
62                 rb = dialog_->framedRB;
63                 break;
64         case InsetNoteParams::Shaded:
65                 rb = dialog_->shadedRB;
66                 break;
67         }
68
69         rb->setChecked(true);
70 }
71
72
73 void QNote::apply()
74 {
75         InsetNoteParams::Type type;
76
77         if (dialog_->greyedoutRB->isChecked())
78                 type = InsetNoteParams::Greyedout;
79         else if (dialog_->commentRB->isChecked())
80                 type = InsetNoteParams::Comment;
81         else if (dialog_->framedRB->isChecked())
82                 type = InsetNoteParams::Framed;
83         else if (dialog_->shadedRB->isChecked())
84                 type = InsetNoteParams::Shaded;
85         else
86                 type = InsetNoteParams::Note;
87
88         controller().params().type = type;
89 }
90
91 } // namespace frontend
92 } // namespace lyx