]> git.lyx.org Git - lyx.git/blob - src/frontends/qt3/QGraphicsDialog.C
Extracted from r14281
[lyx.git] / src / frontends / qt3 / 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 "validators.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 QGraphicsDialog::QGraphicsDialog(QGraphics * form)
37         : QGraphicsDialogBase(0, 0, false, 0),
38         form_(form)
39 {
40         connect(okPB, SIGNAL(clicked()),
41                 form, SLOT(slotOK()));
42         connect(applyPB, SIGNAL(clicked()),
43                 form, SLOT(slotApply()));
44         connect(closePB, SIGNAL(clicked()),
45                 form, SLOT(slotClose()));
46         connect(restorePB, SIGNAL(clicked()),
47                 form, SLOT(slotRestore()));
48         connect(editPB, SIGNAL(clicked()),
49                 this, SLOT(edit_clicked()));
50
51         angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
52
53         lbX->setValidator(new QIntValidator(lbX));
54         lbY->setValidator(new QIntValidator(lbY));
55         rtX->setValidator(new QIntValidator(rtX));
56         rtY->setValidator(new QIntValidator(rtY));
57
58         displayscale->setValidator(new QIntValidator(displayscale));
59         height->setValidator(unsignedLengthValidator(height));
60         width->setValidator(unsignedLengthValidator(width));
61
62         filename->setValidator(new PathValidator(true, filename));
63 }
64
65
66 void QGraphicsDialog::show()
67 {
68         QGraphicsDialogBase::show();
69         filename->setFocus();
70 }
71
72
73 void QGraphicsDialog::change_adaptor()
74 {
75         form_->changed();
76 }
77
78
79 void QGraphicsDialog::change_bb()
80 {
81         form_->controller().bbChanged = true;
82         lyxerr[Debug::GRAPHICS]
83                 << "[controller().bb_Changed set to true]\n";
84         form_->changed();
85 }
86
87
88 void QGraphicsDialog::change_WUnit()
89 {
90         bool useHeight = (widthUnit->currentItem() > 0);
91         height->setEnabled(useHeight);
92         heightUnit->setEnabled(useHeight);
93         form_->changed();
94 }
95
96
97 void QGraphicsDialog::closeEvent(QCloseEvent * e)
98 {
99         form_->slotWMHide();
100         e->accept();
101 }
102
103
104 void QGraphicsDialog::browse_clicked()
105 {
106         string const str =
107                 form_->controller().browse(fromqstr(filename->text()));
108         filename->setText(toqstr(str));
109         form_->changed();
110 }
111
112
113 void QGraphicsDialog::getBB_clicked()
114 {
115         form_->getBB();
116 }
117
118
119 void QGraphicsDialog::edit_clicked()
120 {
121         form_->controller().editGraphics();
122 }
123
124 } // namespace frontend
125 } // namespace lyx