2 * \file QGraphicsDialog.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * \author Abdelrazak Younes
10 * Full author contact details are available in file CREDITS.
15 #include "QGraphicsDialog.h"
16 #include "QGraphics.h"
18 #include "lengthcombo.h"
19 #include "validators.h"
20 #include "qt_helpers.h"
24 #include "controllers/ControlGraphics.h"
26 #include "insets/insetgraphicsParams.h"
28 #include <QCloseEvent>
29 #include <QPushButton>
40 QGraphicsDialog::QGraphicsDialog(QGraphics * form)
44 connect(okPB, SIGNAL(clicked()),
45 form, SLOT(slotOK()));
46 connect(applyPB, SIGNAL(clicked()),
47 form, SLOT(slotApply()));
48 connect(closePB, SIGNAL(clicked()),
49 form, SLOT(slotClose()));
50 connect(restorePB, SIGNAL(clicked()),
51 form, SLOT(slotRestore()));
52 connect(filename, SIGNAL( textChanged(const QString&) ),
53 this, SLOT( change_adaptor() ) );
54 connect(subcaption, SIGNAL( textChanged(const QString&) ),
55 this, SLOT( change_adaptor() ) );
56 connect(subfigure, SIGNAL( toggled(bool) ),
57 this, SLOT( change_adaptor() ) );
58 connect(latexoptions, SIGNAL( textChanged(const QString&) ),
59 this, SLOT( change_adaptor() ) );
60 connect(clip, SIGNAL( stateChanged(int) ),
61 this, SLOT( change_adaptor() ) );
62 connect(displayGB, SIGNAL( toggled(bool) ),
63 this, SLOT( change_adaptor() ) );
64 connect(showCB, SIGNAL( currentIndexChanged(int) ),
65 this, SLOT( change_adaptor() ) );
66 connect(displayscale, SIGNAL( textChanged(const QString&) ),
67 this, SLOT( change_adaptor() ) );
68 connect(Width, SIGNAL( textChanged(const QString&) ),
69 this, SLOT( change_adaptor() ) );
70 connect(aspectratio, SIGNAL( stateChanged(int) ),
71 this, SLOT( change_adaptor() ) );
72 connect(draftCB, SIGNAL( stateChanged(int) ),
73 this, SLOT( change_adaptor() ) );
74 connect(unzipCB, SIGNAL( stateChanged(int) ),
75 this, SLOT( change_adaptor() ) );
76 connect(Height, SIGNAL( textChanged(const QString&) ),
77 this, SLOT( change_adaptor() ) );
78 connect(heightUnit, SIGNAL( selectionChanged(lyx::LyXLength::UNIT) ),
79 this, SLOT( change_adaptor() ) );
80 connect(widthUnit, SIGNAL( selectionChanged(lyx::LyXLength::UNIT) ),
81 this, SLOT( change_adaptor() ) );
82 connect(angle, SIGNAL( textChanged(const QString&) ),
83 this, SLOT( change_adaptor() ) );
84 connect(origin, SIGNAL( activated(int) ),
85 this, SLOT( change_adaptor() ) );
86 connect(getPB, SIGNAL( clicked() ),
87 this, SLOT( change_adaptor() ) );
88 connect(scaleCB, SIGNAL(toggled(bool)),
89 this, SLOT(change_adaptor()) );
90 connect(Scale, SIGNAL( textChanged(const QString&) ),
91 this, SLOT( change_adaptor() ) );
93 connect(lbY, SIGNAL( textChanged(const QString&) ),
94 this, SLOT( change_bb() ) );
95 connect(lbYunit, SIGNAL( activated(int) ),
96 this, SLOT( change_bb() ) );
97 connect(rtY, SIGNAL( textChanged(const QString&) ),
98 this, SLOT( change_bb() ) );
99 connect(rtYunit, SIGNAL( activated(int) ),
100 this, SLOT( change_bb() ) );
102 connect(lbX, SIGNAL( textChanged(const QString&) ),
103 this, SLOT( change_bb() ) );
104 connect(lbXunit, SIGNAL( activated(int) ),
105 this, SLOT( change_bb() ) );
106 connect(rtX, SIGNAL( textChanged(const QString&) ),
107 this, SLOT( change_bb() ) );
108 connect(rtXunit, SIGNAL( activated(int) ),
109 this, SLOT( change_bb() ) );
111 angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
113 lbX->setValidator(new QDoubleValidator(lbX));
114 lbY->setValidator(new QDoubleValidator(lbY));
115 rtX->setValidator(new QDoubleValidator(rtX));
116 rtY->setValidator(new QDoubleValidator(rtY));
118 displayscale->setValidator(new QIntValidator(displayscale));
119 Height->setValidator(unsignedLengthValidator(Height));
120 Width->setValidator(unsignedLengthValidator(Width));
122 filename->setValidator(new PathValidator(true, filename));
126 void QGraphicsDialog::show()
129 if (form_->controller().params().filename.empty())
130 filename->setFocus();
134 void QGraphicsDialog::change_adaptor()
140 void QGraphicsDialog::change_bb()
142 form_->controller().bbChanged = true;
143 lyxerr[Debug::GRAPHICS]
144 << "[controller().bb_Changed set to true]\n";
149 void QGraphicsDialog::closeEvent(QCloseEvent * e)
156 void QGraphicsDialog::on_browsePB_clicked()
158 docstring const str =
159 form_->controller().browse(qstring_to_ucs4(filename->text()));
160 filename->setText(toqstr(str));
165 void QGraphicsDialog::on_getPB_clicked()
171 void QGraphicsDialog::on_editPB_clicked()
173 form_->controller().editGraphics();
177 void QGraphicsDialog::on_filename_textChanged(const QString & filename)
179 editPB->setDisabled(filename.isEmpty());
183 void QGraphicsDialog::on_scaleCB_toggled(bool setscale)
185 Scale->setEnabled(setscale);
186 widthL->setDisabled(setscale);
187 Width->setDisabled(setscale);
188 widthUnit->setDisabled(setscale);
189 aspectratio->setDisabled(setscale);
190 bool noheight = setscale || aspectratio->checkState()==Qt::Checked;
191 heightL->setDisabled(noheight);
192 Height->setDisabled(noheight);
193 heightUnit->setDisabled(noheight);
196 } // namespace frontend
199 #include "QGraphicsDialog_moc.cpp"