]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QExternal.cpp
InsetListings: touch up the include dialog
[lyx.git] / src / frontends / qt4 / QExternal.cpp
1 /**
2  * \file QExternal.cpp
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 Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 // Qt defines a macro 'signals' that clashes with a boost namespace.
15 // All is well if the namespace is visible first.
16 #include "lengthcommon.h"
17 #include "LyXRC.h"
18
19 #include "controllers/ControlExternal.h"
20 #include "controllers/ButtonController.h"
21
22 #include "insets/ExternalTemplate.h"
23 #include "insets/InsetExternal.h"
24
25 #include "support/lstrings.h"
26 #include "support/convert.h"
27 #include "support/os.h"
28 #include "support/lyxlib.h"
29
30 #include "QExternal.h"
31 #include "Qt2BC.h"
32
33 #include "CheckedLineEdit.h"
34 #include "LengthCombo.h"
35 #include "qt_helpers.h"
36 #include "Validator.h"
37
38 #include <QLineEdit>
39 #include <QPushButton>
40 #include <QCheckBox>
41 #include <QTabWidget>
42 #include <QTextBrowser>
43
44 namespace external = lyx::external;
45
46 using lyx::support::isStrDbl;
47 using lyx::support::token;
48 using lyx::support::trim;
49 using lyx::support::float_equal;
50
51 using lyx::support::os::internal_path;
52
53 using std::string;
54 using std::vector;
55 using std::find;
56
57
58 namespace lyx {
59 namespace frontend {
60
61 /////////////////////////////////////////////////////////////////////
62 //
63 // QExternalDialog
64 //
65 /////////////////////////////////////////////////////////////////////
66
67
68 QExternalDialog::QExternalDialog(QExternal * form)
69         : form_(form)
70 {
71         setupUi(this);
72         connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
73         connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
74         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
75
76         connect(displayCB, SIGNAL(toggled(bool)),
77                 showCO, SLOT(setEnabled(bool)));
78         connect(displayCB, SIGNAL(toggled(bool)),
79                 displayscaleED, SLOT(setEnabled(bool)));
80         connect(showCO, SIGNAL(activated(const QString&)),
81                 this, SLOT(change_adaptor()));
82         connect(originCO, SIGNAL(activated(int)),
83                 this, SLOT(change_adaptor()));
84         connect(aspectratioCB, SIGNAL(stateChanged(int)),
85                 this, SLOT(change_adaptor()));
86         connect(browsePB, SIGNAL(clicked()),
87                 this, SLOT(browseClicked()));
88         connect(editPB, SIGNAL(clicked()),
89                 this, SLOT(editClicked()));
90         connect(externalCO, SIGNAL(activated(const QString &)),
91                 this, SLOT(templateChanged()));
92         connect(extraED, SIGNAL(textChanged(const QString &)),
93                 this, SLOT(extraChanged(const QString&)));
94         connect(extraFormatCO, SIGNAL(activated(const QString &)),
95                 this, SLOT(formatChanged(const QString&)));
96         connect(widthUnitCO, SIGNAL(activated(int)),
97                 this, SLOT(widthUnitChanged()));
98         connect(heightUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
99                 this, SLOT(change_adaptor()));
100         connect(displayCB, SIGNAL(stateChanged(int)),
101                 this, SLOT(change_adaptor()));
102         connect(displayscaleED, SIGNAL(textChanged(const QString &)),
103                 this, SLOT(change_adaptor()));
104         connect(angleED, SIGNAL(textChanged(const QString &)),
105                 this, SLOT(change_adaptor()));
106         connect(widthED, SIGNAL(textChanged(const QString &)),
107                 this, SLOT(sizeChanged()));
108         connect(heightED, SIGNAL(textChanged(const QString &)),
109                 this, SLOT(sizeChanged()));
110         connect(fileED, SIGNAL(textChanged(const QString &)),
111                 this, SLOT(change_adaptor()));
112         connect(clipCB, SIGNAL(stateChanged(int)),
113                 this, SLOT(change_adaptor()));
114         connect(getbbPB, SIGNAL(clicked()), this, SLOT(getbbClicked()));
115         connect(xrED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
116         connect(ytED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
117         connect(xlED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
118         connect(ybED, SIGNAL(textChanged(const QString &)), this, SLOT(bbChanged()));
119         connect(draftCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
120
121         QIntValidator * validator = new QIntValidator(displayscaleED);
122         validator->setBottom(1);
123         displayscaleED->setValidator(validator);
124
125         angleED->setValidator(new QDoubleValidator(-360, 360, 2, angleED));
126
127         xlED->setValidator(new QIntValidator(xlED));
128         ybED->setValidator(new QIntValidator(ybED));
129         xrED->setValidator(new QIntValidator(xrED));
130         ytED->setValidator(new QIntValidator(ytED));
131
132         widthED->setValidator(unsignedLengthValidator(widthED));
133         heightED->setValidator(unsignedLengthValidator(heightED));
134
135         fileED->setValidator(new PathValidator(true, fileED));
136         setFocusProxy(fileED);
137 }
138
139
140 void QExternalDialog::show()
141 {
142         QDialog::show();
143 }
144
145
146
147 bool QExternalDialog::activateAspectratio() const
148 {
149         if (widthUnitCO->currentIndex() == 0)
150                 return false;
151
152         string const wstr = fromqstr(widthED->text());
153         if (wstr.empty())
154                 return false;
155         bool const wIsDbl = isStrDbl(wstr);
156         if (wIsDbl && float_equal(convert<double>(wstr), 0.0, 0.05))
157                 return false;
158         Length l;
159         if (!wIsDbl && (!isValidLength(wstr, &l) || l.zero()))
160                 return false;
161
162         string const hstr = fromqstr(heightED->text());
163         if (hstr.empty())
164                 return false;
165         bool const hIsDbl = isStrDbl(hstr);
166         if (hIsDbl && float_equal(convert<double>(hstr), 0.0, 0.05))
167                 return false;
168         if (!hIsDbl && (!isValidLength(hstr, &l) || l.zero()))
169                 return false;
170
171         return true;
172 }
173
174
175 void QExternalDialog::bbChanged()
176 {
177         form_->controller().bbChanged(true);
178         form_->changed();
179 }
180
181
182 void QExternalDialog::browseClicked()
183 {
184         int const choice =  externalCO->currentIndex();
185         docstring const template_name = 
186                 from_utf8(form_->controller().getTemplate(choice).lyxName);
187         docstring const str =
188                 form_->controller().browse(qstring_to_ucs4(fileED->text()),
189                                            template_name);
190         fileED->setText(toqstr(str));
191         form_->changed();
192 }
193
194
195 void QExternalDialog::change_adaptor()
196 {
197         form_->changed();
198 }
199
200
201 void QExternalDialog::closeEvent(QCloseEvent * e)
202 {
203         form_->slotWMHide();
204         e->accept();
205 }
206
207
208 void QExternalDialog::editClicked()
209 {
210         form_->controller().editExternal();
211 }
212
213
214
215 void QExternalDialog::extraChanged(const QString& text)
216 {
217         std::string const format = fromqstr(extraFormatCO->currentText());
218         form_->extra_[format] = text;
219         form_->changed();
220 }
221
222
223 void QExternalDialog::formatChanged(const QString& format)
224 {
225         extraED->setText(form_->extra_[fromqstr(format)]);
226 }
227
228
229 void QExternalDialog::getbbClicked()
230 {
231         form_->getBB();
232 }
233
234
235 void QExternalDialog::sizeChanged()
236 {
237         aspectratioCB->setEnabled(activateAspectratio());
238         form_->changed();
239 }
240
241
242 void QExternalDialog::templateChanged()
243 {
244         form_->updateTemplate();
245         form_->changed();
246 }
247
248
249 void QExternalDialog::widthUnitChanged()
250 {
251         bool useHeight = (widthUnitCO->currentIndex() > 0);
252
253         if (useHeight)
254                 widthED->setValidator(unsignedLengthValidator(widthED));
255         else
256                 widthED->setValidator(new QDoubleValidator(0, 1000, 2, widthED));
257
258         heightED->setEnabled(useHeight);
259         heightUnitCO->setEnabled(useHeight);
260         form_->changed();
261 }
262
263
264 /////////////////////////////////////////////////////////////////////
265 //
266 // QExternal
267 //
268 /////////////////////////////////////////////////////////////////////
269
270 namespace {
271
272 Length::UNIT defaultUnit()
273 {
274         Length::UNIT default_unit = Length::CM;
275         switch (lyxrc.default_papersize) {
276         case PAPER_USLETTER:
277         case PAPER_USLEGAL:
278         case PAPER_USEXECUTIVE:
279                 default_unit = Length::IN;
280                 break;
281         default:
282                 break;
283         }
284         return default_unit;
285 }
286
287
288 void setDisplay(QCheckBox & displayCB, QComboBox & showCO, QLineEdit & scaleED,
289                 external::DisplayType display, unsigned int scale,
290                 bool read_only)
291 {
292         int item = 0;
293         switch (display) {
294         case external::DefaultDisplay:
295                 item = 0;
296                 break;
297         case external::MonochromeDisplay:
298                 item = 1;
299                 break;
300         case external::GrayscaleDisplay:
301                 item = 2;
302                 break;
303         case external::ColorDisplay:
304                 item = 3;
305                 break;
306         case external::PreviewDisplay:
307                 item = 4;
308                 break;
309         case external::NoDisplay:
310                 item = 0;
311                 break;
312         }
313
314         showCO.setCurrentIndex(item);
315         bool const no_display = display == external::NoDisplay;
316         showCO.setEnabled(!no_display && !read_only);
317         displayCB.setChecked(!no_display);
318         scaleED.setEnabled(!no_display && !read_only);
319         scaleED.setText(toqstr(convert<string>(scale)));
320 }
321
322
323 void getDisplay(external::DisplayType & display,
324                 unsigned int & scale,
325                 QCheckBox const & displayCB,
326                 QComboBox const & showCO,
327                 QLineEdit const & scaleED)
328 {
329         switch (showCO.currentIndex()) {
330         case 0:
331                 display = external::DefaultDisplay;
332                 break;
333         case 1:
334                 display = external::MonochromeDisplay;
335                 break;
336         case 2:
337                 display = external::GrayscaleDisplay;
338                 break;
339         case 3:
340                 display = external::ColorDisplay;
341                 break;
342         case 4:
343                 display = external::PreviewDisplay;
344                 break;
345         }
346
347         if (!displayCB.isChecked())
348                 display = external::NoDisplay;
349
350         scale = convert<int>(fromqstr(scaleED.text()));
351 }
352
353
354 void setRotation(QLineEdit & angleED, QComboBox & originCO,
355                  external::RotationData const & data)
356 {
357         originCO.setCurrentIndex(int(data.origin()));
358         angleED.setText(toqstr(data.angle));
359 }
360
361
362 void getRotation(external::RotationData & data,
363                  QLineEdit const & angleED, QComboBox const & originCO)
364 {
365         typedef external::RotationData::OriginType OriginType;
366
367         data.origin(static_cast<OriginType>(originCO.currentIndex()));
368         data.angle = fromqstr(angleED.text());
369 }
370
371
372 void setSize(QLineEdit & widthED, QComboBox & widthUnitCO,
373              QLineEdit & heightED, LengthCombo & heightUnitCO,
374              QCheckBox & aspectratioCB,
375              external::ResizeData const & data)
376 {
377         bool using_scale = data.usingScale();
378         std::string scale = data.scale;
379         if (data.no_resize()) {
380                 // Everything is zero, so default to this!
381                 using_scale = true;
382                 scale = "100";
383         }
384
385         if (using_scale) {
386                 widthED.setText(toqstr(scale));
387                 widthUnitCO.setCurrentIndex(0);
388         } else {
389                 widthED.setText(toqstr(convert<string>(data.width.value())));
390                 // Because 'Scale' is position 0...
391                 // Note also that width cannot be zero here, so
392                 // we don't need to worry about the default unit.
393                 widthUnitCO.setCurrentIndex(data.width.unit() + 1);
394         }
395
396         string const h = data.height.zero() ? string() : data.height.asString();
397         Length::UNIT default_unit = data.width.zero() ?
398                 defaultUnit() : data.width.unit();
399         lengthToWidgets(&heightED, &heightUnitCO, h, default_unit);
400
401         heightED.setEnabled(!using_scale);
402         heightUnitCO.setEnabled(!using_scale);
403
404         aspectratioCB.setChecked(data.keepAspectRatio);
405
406         bool const disable_aspectRatio = using_scale ||
407                 data.width.zero() || data.height.zero();
408         aspectratioCB.setEnabled(!disable_aspectRatio);
409 }
410
411
412 void getSize(external::ResizeData & data,
413              QLineEdit const & widthED, QComboBox const & widthUnitCO,
414              QLineEdit const & heightED, LengthCombo const & heightUnitCO,
415              QCheckBox const & aspectratioCB)
416 {
417         string const width = fromqstr(widthED.text());
418
419         if (widthUnitCO.currentIndex() > 0) {
420                 // Subtract one, because scale is 0.
421                 int const unit = widthUnitCO.currentIndex() - 1;
422
423                 Length w;
424                 if (isValidLength(width, &w))
425                         data.width = w;
426                 else if (isStrDbl(width))
427                         data.width = Length(convert<double>(width),
428                                            static_cast<Length::UNIT>(unit));
429                 else
430                         data.width = Length();
431
432                 data.scale = string();
433
434         } else {
435                 // scaling instead of a width
436                 data.scale = width;
437                 data.width = Length();
438         }
439
440         data.height = Length(widgetsToLength(&heightED, &heightUnitCO));
441
442         data.keepAspectRatio = aspectratioCB.isChecked();
443 }
444
445
446 void setCrop(QCheckBox & clipCB,
447              QLineEdit & xlED, QLineEdit & ybED,
448              QLineEdit & xrED, QLineEdit & ytED,
449              external::ClipData const & data)
450 {
451         clipCB.setChecked(data.clip);
452         graphics::BoundingBox const & bbox = data.bbox;
453         xlED.setText(toqstr(convert<string>(bbox.xl)));
454         ybED.setText(toqstr(convert<string>(bbox.yb)));
455         xrED.setText(toqstr(convert<string>(bbox.xr)));
456         ytED.setText(toqstr(convert<string>(bbox.yt)));
457 }
458
459
460 void getCrop(external::ClipData & data,
461              QCheckBox const & clipCB,
462              QLineEdit const & xlED, QLineEdit const & ybED,
463              QLineEdit const & xrED, QLineEdit const & ytED,
464              bool bb_changed)
465 {
466         data.clip = clipCB.isChecked();
467
468         if (!bb_changed)
469                 return;
470
471         data.bbox.xl = convert<int>(fromqstr(xlED.text()));
472         data.bbox.yb = convert<int>(fromqstr(ybED.text()));
473         data.bbox.xr = convert<int>(fromqstr(xrED.text()));
474         data.bbox.yt = convert<int>(fromqstr(ytED.text()));
475 }
476
477
478 void getExtra(external::ExtraData & data,
479               QExternal::MapType const & extra)
480 {
481         typedef QExternal::MapType MapType;
482         MapType::const_iterator it  = extra.begin();
483         MapType::const_iterator const end = extra.end();
484         for (; it != end; ++it)
485                 data.set(it->first, trim(fromqstr(it->second)));
486 }
487
488 } // namespace anon
489
490
491 typedef QController<ControlExternal, QView<QExternalDialog> >
492         ExternalBase;
493
494 QExternal::QExternal(Dialog & parent)
495         : ExternalBase(parent, _("External Material"))
496 {}
497
498
499 void QExternal::build_dialog()
500 {
501         dialog_.reset(new QExternalDialog(this));
502
503         bcview().setOK(dialog_->okPB);
504         bcview().setApply(dialog_->applyPB);
505         bcview().setCancel(dialog_->closePB);
506
507         bcview().addReadOnly(dialog_->fileED);
508         bcview().addReadOnly(dialog_->browsePB);
509         bcview().addReadOnly(dialog_->editPB);
510         bcview().addReadOnly(dialog_->externalCO);
511         bcview().addReadOnly(dialog_->draftCB);
512         bcview().addReadOnly(dialog_->displayscaleED);
513         bcview().addReadOnly(dialog_->showCO);
514         bcview().addReadOnly(dialog_->displayCB);
515         bcview().addReadOnly(dialog_->angleED);
516         bcview().addReadOnly(dialog_->originCO);
517         bcview().addReadOnly(dialog_->heightUnitCO);
518         bcview().addReadOnly(dialog_->heightED);
519         bcview().addReadOnly(dialog_->aspectratioCB);
520         bcview().addReadOnly(dialog_->widthUnitCO);
521         bcview().addReadOnly(dialog_->widthED);
522         bcview().addReadOnly(dialog_->clipCB);
523         bcview().addReadOnly(dialog_->getbbPB);
524         bcview().addReadOnly(dialog_->ytED);
525         bcview().addReadOnly(dialog_->xlED);
526         bcview().addReadOnly(dialog_->xrED);
527         bcview().addReadOnly(dialog_->ybED);
528         bcview().addReadOnly(dialog_->extraFormatCO);
529         bcview().addReadOnly(dialog_->extraED);
530
531         addCheckedLineEdit(bcview(), dialog_->angleED, dialog_->angleLA);
532         addCheckedLineEdit(bcview(), dialog_->displayscaleED, dialog_->scaleLA);
533         addCheckedLineEdit(bcview(), dialog_->heightED, dialog_->heightLA);
534         addCheckedLineEdit(bcview(), dialog_->widthED, dialog_->widthLA);
535         addCheckedLineEdit(bcview(), dialog_->xlED, dialog_->lbLA);
536         addCheckedLineEdit(bcview(), dialog_->ybED, dialog_->lbLA);
537         addCheckedLineEdit(bcview(), dialog_->xrED, dialog_->rtLA);
538         addCheckedLineEdit(bcview(), dialog_->ytED, dialog_->rtLA);
539         addCheckedLineEdit(bcview(), dialog_->fileED, dialog_->fileLA);
540
541         std::vector<string> templates(controller().getTemplates());
542
543         for (std::vector<string>::const_iterator cit = templates.begin();
544                 cit != templates.end(); ++cit) {
545                 dialog_->externalCO->addItem(toqstr(*cit));
546         }
547
548         // Fill the origins combo
549         typedef vector<external::RotationDataType> Origins;
550         Origins const & all_origins = external::all_origins();
551         for (Origins::size_type i = 0; i != all_origins.size(); ++i)
552                 dialog_->originCO->addItem(toqstr(external::origin_gui_str(i)));
553
554         // Fill the width combo
555         dialog_->widthUnitCO->addItem(qt_("Scale%"));
556         for (int i = 0; i < num_units; i++)
557                 dialog_->widthUnitCO->addItem(qt_(unit_name_gui[i]));
558 }
559
560
561 void QExternal::update_contents()
562 {
563         PathValidator * path_validator = getPathValidator(dialog_->fileED);
564         if (path_validator)
565                 path_validator->setChecker(kernel().docType(), lyxrc);
566
567         dialog_->tab->setCurrentIndex(0);
568         InsetExternalParams const & params = controller().params();
569
570         string const name =
571                 params.filename.outputFilename(kernel().bufferFilepath());
572         dialog_->fileED->setText(toqstr(name));
573
574         dialog_->externalCO->setCurrentIndex(
575                 controller().getTemplateNumber(params.templatename()));
576         updateTemplate();
577
578         dialog_->draftCB->setChecked(params.draft);
579
580         setDisplay(*dialog_->displayCB, *dialog_->showCO,
581                    *dialog_->displayscaleED,
582                    params.display, params.lyxscale, readOnly());
583
584         setRotation(*dialog_->angleED, *dialog_->originCO, params.rotationdata);
585
586         setSize(*dialog_->widthED, *dialog_->widthUnitCO,
587                 *dialog_->heightED, *dialog_->heightUnitCO,
588                 *dialog_->aspectratioCB,
589                 params.resizedata);
590
591         setCrop(*dialog_->clipCB,
592                 *dialog_->xlED, *dialog_->ybED,
593                 *dialog_->xrED, *dialog_->ytED,
594                 params.clipdata);
595         controller().bbChanged(!params.clipdata.bbox.empty());
596
597         isValid();
598 }
599
600
601 void QExternal::updateTemplate()
602 {
603         external::Template templ =
604                 controller().getTemplate(dialog_->externalCO->currentIndex());
605         dialog_->externalTB->setPlainText(toqstr(templ.helpText));
606
607         // Ascertain which (if any) transformations the template supports
608         // and disable tabs hosting unsupported transforms.
609         typedef vector<external::TransformID> TransformIDs;
610         TransformIDs const transformIds = templ.transformIds;
611         TransformIDs::const_iterator tr_begin = transformIds.begin();
612         TransformIDs::const_iterator const tr_end = transformIds.end();
613
614         bool found = find(tr_begin, tr_end, external::Rotate) != tr_end;
615         dialog_->tab->setTabEnabled(
616                 dialog_->tab->indexOf(dialog_->rotatetab), found);
617         found = find(tr_begin, tr_end, external::Resize) != tr_end;
618         dialog_->tab->setTabEnabled(
619                 dialog_->tab->indexOf(dialog_->scaletab), found);
620
621         found = find(tr_begin, tr_end, external::Clip) != tr_end;
622         dialog_->tab->setTabEnabled(
623                 dialog_->tab->indexOf(dialog_->croptab), found);
624
625         found = find(tr_begin, tr_end, external::Extra) != tr_end;
626         dialog_->tab->setTabEnabled(
627                 dialog_->tab->indexOf(dialog_->optionstab), found);
628
629         if (!found)
630                 return;
631
632         // Ascertain whether the template has any formats supporting
633         // the 'Extra' option
634         QLineEdit * const extraED = dialog_->extraED;
635         QComboBox * const extraCB = dialog_->extraFormatCO;
636
637         extra_.clear();
638         extraED->clear();
639         extraCB->clear();
640
641         external::Template::Formats::const_iterator it  = templ.formats.begin();
642         external::Template::Formats::const_iterator end = templ.formats.end();
643         for (; it != end; ++it) {
644                 if (it->second.option_transformers.find(external::Extra) ==
645                     it->second.option_transformers.end())
646                         continue;
647                 string const format = it->first;
648                 string const opt = controller().params().extradata.get(format);
649                 extraCB->addItem(toqstr(format));
650                 extra_[format] = toqstr(opt);
651         }
652
653         bool const enabled = extraCB->count()  > 0;
654
655         dialog_->tab->setTabEnabled(
656                 dialog_->tab->indexOf(dialog_->optionstab), enabled);
657         extraED->setEnabled(enabled && !kernel().isBufferReadonly());
658         extraCB->setEnabled(enabled);
659
660         if (enabled) {
661                 extraCB->setCurrentIndex(0);
662                 extraED->setText(extra_[fromqstr(extraCB->currentText())]);
663         }
664 }
665
666
667 void QExternal::apply()
668 {
669         InsetExternalParams params = controller().params();
670
671         params.filename.set(internal_path(fromqstr(dialog_->fileED->text())),
672                             kernel().bufferFilepath());
673
674         params.settemplate(controller().getTemplate(
675                                    dialog_->externalCO->currentIndex()).lyxName);
676
677         params.draft = dialog_->draftCB->isChecked();
678
679         getDisplay(params.display, params.lyxscale,
680                    *dialog_->displayCB, *dialog_->showCO,
681                    *dialog_->displayscaleED);
682
683         if (dialog_->tab->isTabEnabled(
684                 dialog_->tab->indexOf(dialog_->rotatetab)))
685                 getRotation(params.rotationdata,
686                             *dialog_->angleED, *dialog_->originCO);
687
688         if (dialog_->tab->isTabEnabled(
689                 dialog_->tab->indexOf(dialog_->scaletab)))
690                 getSize(params.resizedata,
691                         *dialog_->widthED, *dialog_->widthUnitCO,
692                         *dialog_->heightED, *dialog_->heightUnitCO,
693                         *dialog_->aspectratioCB);
694
695         if (dialog_->tab->isTabEnabled(
696                 dialog_->tab->indexOf(dialog_->croptab)))
697                 getCrop(params.clipdata,
698                         *dialog_->clipCB,
699                         *dialog_->xlED, *dialog_->ybED,
700                         *dialog_->xrED, *dialog_->ytED,
701                         controller().bbChanged());
702
703         if (dialog_->tab->isTabEnabled(
704                 dialog_->tab->indexOf(dialog_->optionstab)))
705                 getExtra(params.extradata, extra_);
706
707         controller().setParams(params);
708 }
709
710
711 void QExternal::getBB()
712 {
713         dialog_->xlED->setText("0");
714         dialog_->ybED->setText("0");
715         dialog_->xrED->setText("0");
716         dialog_->ytED->setText("0");
717
718         string const filename = fromqstr(dialog_->fileED->text());
719         if (filename.empty())
720                 return;
721
722         string const bb = controller().readBB(filename);
723         if (bb.empty())
724                 return;
725
726         dialog_->xlED->setText(toqstr(token(bb, ' ', 0)));
727         dialog_->ybED->setText(toqstr(token(bb, ' ', 1)));
728         dialog_->xrED->setText(toqstr(token(bb, ' ', 2)));
729         dialog_->ytED->setText(toqstr(token(bb, ' ', 3)));
730
731         controller().bbChanged(false);
732 }
733
734 } // namespace frontend
735 } // namespace lyx
736
737 #include "QExternal_moc.cpp"