]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QGraphicsDialog.C
* update dialog when changing lyx display settings.
[lyx.git] / src / frontends / qt4 / 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  * \author Abdelrazak Younes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "QGraphicsDialog.h"
16 #include "QGraphics.h"
17
18 #include "lengthcombo.h"
19 #include "validators.h"
20 #include "qt_helpers.h"
21
22 #include "debug.h"
23
24 #include "controllers/ControlGraphics.h"
25
26 #include <QCloseEvent>
27 #include <QPushButton>
28 #include <QLineEdit>
29 #include <QValidator>
30
31
32 using std::string;
33
34 namespace lyx {
35 namespace frontend {
36
37
38 QGraphicsDialog::QGraphicsDialog(QGraphics * form)
39         : form_(form)
40 {
41         setupUi(this);
42         connect(okPB, SIGNAL(clicked()),
43                 form, SLOT(slotOK()));
44         connect(applyPB, SIGNAL(clicked()),
45                 form, SLOT(slotApply()));
46         connect(closePB, SIGNAL(clicked()),
47                 form, SLOT(slotClose()));
48         connect(restorePB, SIGNAL(clicked()),
49                 form, SLOT(slotRestore()));
50         connect(filename, SIGNAL( textChanged(const QString&) ),
51                 this, SLOT( change_adaptor() ) );
52         connect(subcaption, SIGNAL( textChanged(const QString&) ),
53                 this, SLOT( change_adaptor() ) );
54         connect(subfigure, SIGNAL( toggled(bool) ),
55                 this, SLOT( change_adaptor() ) );
56         connect(latexoptions, SIGNAL( textChanged(const QString&) ),
57                 this, SLOT( change_adaptor() ) );
58         connect(clip, SIGNAL( stateChanged(int) ),
59                 this, SLOT( change_adaptor() ) );
60         connect(displayGB, SIGNAL( toggled(bool) ),
61                 this, SLOT( change_adaptor() ) );
62         connect(showCB, SIGNAL( currentIndexChanged(int) ),
63                 this, SLOT( change_adaptor() ) );
64         connect(displayscale, SIGNAL( textChanged(const QString&) ),
65                 this, SLOT( change_adaptor() ) );
66         connect(Width, SIGNAL( textChanged(const QString&) ),
67                 this, SLOT( change_adaptor() ) );
68         connect(aspectratio, SIGNAL( stateChanged(int) ),
69                 this, SLOT( change_adaptor() ) );
70         connect(draftCB, SIGNAL( stateChanged(int) ),
71                 this, SLOT( change_adaptor() ) );
72         connect(unzipCB, SIGNAL( stateChanged(int) ),
73                 this, SLOT( change_adaptor() ) );
74         connect(Height, SIGNAL( textChanged(const QString&) ),
75                 this, SLOT( change_adaptor() ) );
76         connect(heightUnit, SIGNAL( selectionChanged(lyx::LyXLength::UNIT) ),
77                 this, SLOT( change_adaptor() ) );
78         connect(widthUnit, SIGNAL( selectionChanged(lyx::LyXLength::UNIT) ),
79                 this, SLOT( change_adaptor() ) );
80         connect(angle, SIGNAL( textChanged(const QString&) ),
81                 this, SLOT( change_adaptor() ) );
82         connect(origin, SIGNAL( activated(int) ),
83                 this, SLOT( change_adaptor() ) );
84         connect(getPB, SIGNAL( clicked() ),
85                 this, SLOT( change_adaptor() ) );
86         connect(scaleCB, SIGNAL(toggled(bool)),
87                 this, SLOT(change_adaptor()) );
88         connect(Scale, SIGNAL( textChanged(const QString&) ),
89                 this, SLOT( change_adaptor() ) );
90
91         connect(lbY, SIGNAL( textChanged(const QString&) ),
92                 this, SLOT( change_bb() ) );
93         connect(lbYunit, SIGNAL( activated(int) ),
94                 this, SLOT( change_bb() ) );
95         connect(rtY, SIGNAL( textChanged(const QString&) ),
96                 this, SLOT( change_bb() ) );
97         connect(rtYunit, SIGNAL( activated(int) ),
98                 this, SLOT( change_bb() ) );
99
100         connect(lbX, SIGNAL( textChanged(const QString&) ),
101                 this, SLOT( change_bb() ) );
102         connect(lbXunit, SIGNAL( activated(int) ),
103                 this, SLOT( change_bb() ) );
104         connect(rtX, SIGNAL( textChanged(const QString&) ),
105                 this, SLOT( change_bb() ) );
106         connect(rtXunit, SIGNAL( activated(int) ),
107                 this, SLOT( change_bb() ) );
108
109         angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
110
111         lbX->setValidator(new QIntValidator(lbX));
112         lbY->setValidator(new QIntValidator(lbY));
113         rtX->setValidator(new QIntValidator(rtX));
114         rtY->setValidator(new QIntValidator(rtY));
115
116         displayscale->setValidator(new QIntValidator(displayscale));
117         Height->setValidator(unsignedLengthValidator(Height));
118         Width->setValidator(unsignedLengthValidator(Width));
119
120         filename->setValidator(new PathValidator(true, filename));
121 }
122
123
124 void QGraphicsDialog::show()
125 {
126         QDialog::show();
127         filename->setFocus();
128 }
129
130
131 void QGraphicsDialog::change_adaptor()
132 {
133         form_->changed();
134 }
135
136
137 void QGraphicsDialog::change_bb()
138 {
139         form_->controller().bbChanged = true;
140         lyxerr[Debug::GRAPHICS]
141                 << "[controller().bb_Changed set to true]\n";
142         form_->changed();
143 }
144
145
146 void QGraphicsDialog::closeEvent(QCloseEvent * e)
147 {
148         form_->slotWMHide();
149         e->accept();
150 }
151
152
153 void QGraphicsDialog::on_browsePB_clicked()
154 {
155         docstring const str =
156                 form_->controller().browse(qstring_to_ucs4(filename->text()));
157         filename->setText(toqstr(str));
158         form_->changed();
159 }
160
161
162 void QGraphicsDialog::on_getPB_clicked()
163 {
164         form_->getBB();
165 }
166
167
168 void QGraphicsDialog::on_editPB_clicked()
169 {
170         form_->controller().editGraphics();
171 }
172
173
174 void QGraphicsDialog::on_filename_textChanged(const QString & filename)
175 {
176         editPB->setDisabled(filename.isEmpty());
177 }
178
179
180 void QGraphicsDialog::on_scaleCB_toggled(bool setscale)
181 {
182         Scale->setEnabled(setscale);
183         widthL->setDisabled(setscale);
184         Width->setDisabled(setscale);
185         widthUnit->setDisabled(setscale);
186         aspectratio->setDisabled(setscale);
187         bool noheight = setscale || aspectratio->checkState()==Qt::Checked;
188         heightL->setDisabled(noheight);
189         Height->setDisabled(noheight);
190         heightUnit->setDisabled(noheight);
191 }
192
193 } // namespace frontend
194 } // namespace lyx
195
196 #include "QGraphicsDialog_moc.cpp"