]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QGraphicsDialog.C
get rid of broken_header.h and some unneeded tests
[lyx.git] / src / frontends / qt2 / QGraphicsDialog.C
1 /**
2  * \file QGraphicsDialog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  * \author Herbert Voß
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "QGraphicsDialog.h"
15 #include "QGraphics.h"
16
17 #include "lengthcombo.h"
18 #include "lengthvalidator.h"
19 #include "qt_helpers.h"
20
21 #include "debug.h"
22
23 #include "controllers/ControlGraphics.h"
24
25 #include <qpushbutton.h>
26 #include <qlineedit.h>
27 #include <qvalidator.h>
28
29
30 using std::string;
31
32 namespace lyx {
33 namespace frontend {
34
35
36 namespace {
37
38 LengthValidator * unsignedLengthValidator(QLineEdit * ed)
39 {
40         LengthValidator * v = new LengthValidator(ed);
41         v->setBottom(LyXLength());
42         return v;
43 }
44
45 } // namespace anon
46
47
48 QGraphicsDialog::QGraphicsDialog(QGraphics * form)
49         : QGraphicsDialogBase(0, 0, false, 0),
50         form_(form)
51 {
52         connect(okPB, SIGNAL(clicked()),
53                 form, SLOT(slotOK()));
54         connect(applyPB, SIGNAL(clicked()),
55                 form, SLOT(slotApply()));
56         connect(closePB, SIGNAL(clicked()),
57                 form, SLOT(slotClose()));
58         connect(restorePB, SIGNAL(clicked()),
59                 form, SLOT(slotRestore()));
60         connect(editPB, SIGNAL(clicked()),
61                 this, SLOT(edit_clicked()));
62                 
63         angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
64
65         lbX->setValidator(new QIntValidator(lbX));
66         lbY->setValidator(new QIntValidator(lbY));
67         rtX->setValidator(new QIntValidator(rtX));
68         rtY->setValidator(new QIntValidator(rtY));
69                 
70         displayscale->setValidator(new QDoubleValidator(0, 1000, 2, 
71                 displayscale));
72         height->setValidator(unsignedLengthValidator(height));
73         width->setValidator(unsignedLengthValidator(width));
74 }
75
76
77 void QGraphicsDialog::show()
78 {
79         QGraphicsDialogBase::show();
80         filename->setFocus();
81 }
82
83
84 void QGraphicsDialog::change_adaptor()
85 {
86         form_->changed();
87 }
88
89
90 void QGraphicsDialog::change_bb()
91 {
92         form_->controller().bbChanged = true;
93         lyxerr[Debug::GRAPHICS]
94                 << "[controller().bb_Changed set to true]\n";
95         form_->changed();
96 }
97
98
99 void QGraphicsDialog::change_WUnit()
100 {
101         bool useHeight = (widthUnit->currentItem() > 0);
102         height->setEnabled(useHeight);
103         heightUnit->setEnabled(useHeight);
104         form_->changed();
105 }
106
107
108 void QGraphicsDialog::closeEvent(QCloseEvent * e)
109 {
110         form_->slotWMHide();
111         e->accept();
112 }
113
114
115 void QGraphicsDialog::browse_clicked()
116 {
117         string const str =
118                 form_->controller().browse(fromqstr(filename->text()));
119         filename->setText(toqstr(str));
120         form_->changed();
121 }
122
123
124 void QGraphicsDialog::getBB_clicked()
125 {
126         form_->getBB();
127 }
128
129
130 void QGraphicsDialog::edit_clicked()
131 {
132         form_->controller().editGraphics();
133 }
134
135 } // namespace frontend
136 } // namespace lyx