]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiExternal.cpp
MathsUi.ui: adjust dimensions as requested
[lyx.git] / src / frontends / qt4 / GuiExternal.cpp
1 /**
2  * \file GuiExternal.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  * \author Asger Alstrup
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "GuiExternal.h"
16
17 #include "Buffer.h"
18 #include "FuncRequest.h"
19 #include "support/gettext.h"
20 #include "Length.h"
21 #include "LyXRC.h"
22
23 #include "insets/ExternalSupport.h"
24 #include "insets/ExternalTemplate.h"
25 #include "insets/InsetExternal.h"
26
27 #include "graphics/epstools.h"
28 #include "graphics/GraphicsCache.h"
29 #include "graphics/GraphicsCacheItem.h"
30 #include "graphics/GraphicsImage.h"
31
32 #include "support/convert.h"
33 #include "support/filetools.h"
34 #include "support/lstrings.h"
35 #include "support/lyxlib.h"
36 #include "support/os.h"
37
38 #include "LengthCombo.h"
39 #include "qt_helpers.h"
40 #include "Validator.h"
41
42 #include <QCheckBox>
43 #include <QGroupBox>
44 #include <QLineEdit>
45 #include <QPushButton>
46 #include <QTabWidget>
47 #include <QTextBrowser>
48
49 using namespace std;
50 using namespace lyx::support;
51
52 namespace lyx {
53 namespace frontend {
54
55 using namespace external;
56
57 namespace {
58
59 RotationDataType origins[] = {
60         RotationData::DEFAULT,
61         RotationData::TOPLEFT,
62         RotationData::BOTTOMLEFT,
63         RotationData::BASELINELEFT,
64         RotationData::CENTER,
65         RotationData::TOPCENTER,
66         RotationData::BOTTOMCENTER,
67         RotationData::BASELINECENTER,
68         RotationData::TOPRIGHT,
69         RotationData::BOTTOMRIGHT,
70         RotationData::BASELINERIGHT
71 };
72
73
74 // These are the strings, corresponding to the above, that the GUI should
75 // use. Note that they can/should be translated.
76 char const * const origin_gui_strs[] = {
77         N_("Default"),
78         N_("Top left"), N_("Bottom left"), N_("Baseline left"),
79         N_("Center"), N_("Top center"), N_("Bottom center"), N_("Baseline center"),
80         N_("Top right"), N_("Bottom right"), N_("Baseline right")
81 };
82
83 } // namespace anon
84
85
86 GuiExternal::GuiExternal(GuiView & lv)
87         : GuiDialog(lv, "external", qt_("External Material")), bbChanged_(false)
88 {
89         setupUi(this);
90
91         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
92         connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
93         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
94
95         /*
96         connect(displayGB, SIGNAL(toggled(bool)),
97                 displayscaleED, SLOT(setEnabled(bool)));
98                 */
99         connect(originCO, SIGNAL(activated(int)),
100                 this, SLOT(change_adaptor()));
101         connect(aspectratioCB, SIGNAL(stateChanged(int)),
102                 this, SLOT(change_adaptor()));
103         connect(browsePB, SIGNAL(clicked()),
104                 this, SLOT(browseClicked()));
105         connect(externalCO, SIGNAL(activated(QString)),
106                 this, SLOT(templateChanged()));
107         connect(extraED, SIGNAL(textChanged(QString)),
108                 this, SLOT(extraChanged(QString)));
109         connect(extraFormatCO, SIGNAL(activated(QString)),
110                 this, SLOT(formatChanged(QString)));
111         connect(widthUnitCO, SIGNAL(activated(int)),
112                 this, SLOT(widthUnitChanged()));
113         connect(heightUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
114                 this, SLOT(change_adaptor()));
115         connect(displayGB, SIGNAL(toggled(bool)),
116                 this, SLOT(change_adaptor()));
117         connect(displayscaleED, SIGNAL(textChanged(QString)),
118                 this, SLOT(change_adaptor()));
119         connect(angleED, SIGNAL(textChanged(QString)),
120                 this, SLOT(change_adaptor()));
121         connect(widthED, SIGNAL(textChanged(QString)),
122                 this, SLOT(sizeChanged()));
123         connect(heightED, SIGNAL(textChanged(QString)),
124                 this, SLOT(sizeChanged()));
125         connect(fileED, SIGNAL(textChanged(QString)),
126                 this, SLOT(change_adaptor()));
127         connect(clipCB, SIGNAL(stateChanged(int)),
128                 this, SLOT(change_adaptor()));
129         connect(getbbPB, SIGNAL(clicked()), this, SLOT(getbbClicked()));
130         connect(xrED, SIGNAL(textChanged(QString)), this, SLOT(bbChanged()));
131         connect(ytED, SIGNAL(textChanged(QString)), this, SLOT(bbChanged()));
132         connect(xlED, SIGNAL(textChanged(QString)), this, SLOT(bbChanged()));
133         connect(ybED, SIGNAL(textChanged(QString)), this, SLOT(bbChanged()));
134         connect(xrUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
135                 this, SLOT(bbChanged()));
136         connect(ytUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
137                 this, SLOT(bbChanged()));
138         connect(xlUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
139                 this, SLOT(bbChanged()));
140         connect(ybUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
141                 this, SLOT(bbChanged()));
142         connect(draftCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
143
144         QIntValidator * validator = new QIntValidator(displayscaleED);
145         validator->setBottom(1);
146         displayscaleED->setValidator(validator);
147
148         angleED->setValidator(new QDoubleValidator(-360, 360, 2, angleED));
149
150         xlED->setValidator(unsignedLengthValidator(xlED));
151         ybED->setValidator(unsignedLengthValidator(ybED));
152         xrED->setValidator(unsignedLengthValidator(xrED));
153         ytED->setValidator(unsignedLengthValidator(ytED));
154
155         widthED->setValidator(unsignedLengthValidator(widthED));
156         heightED->setValidator(unsignedLengthValidator(heightED));
157
158         setFocusProxy(fileED);
159
160         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
161
162         bc().setOK(okPB);
163         bc().setApply(applyPB);
164         bc().setCancel(closePB);
165
166         bc().addReadOnly(fileED);
167         bc().addReadOnly(browsePB);
168         bc().addReadOnly(externalCO);
169         bc().addReadOnly(draftCB);
170         bc().addReadOnly(displayscaleED);
171         bc().addReadOnly(displayGB);
172         bc().addReadOnly(angleED);
173         bc().addReadOnly(originCO);
174         bc().addReadOnly(heightUnitCO);
175         bc().addReadOnly(heightED);
176         bc().addReadOnly(aspectratioCB);
177         bc().addReadOnly(widthUnitCO);
178         bc().addReadOnly(widthED);
179         bc().addReadOnly(clipCB);
180         bc().addReadOnly(getbbPB);
181         bc().addReadOnly(ytED);
182         bc().addReadOnly(xlED);
183         bc().addReadOnly(xrED);
184         bc().addReadOnly(ybED);
185         bc().addReadOnly(ytUnitCO);
186         bc().addReadOnly(xlUnitCO);
187         bc().addReadOnly(xrUnitCO);
188         bc().addReadOnly(ybUnitCO);
189         bc().addReadOnly(extraFormatCO);
190         bc().addReadOnly(extraED);
191
192         bc().addCheckedLineEdit(angleED, angleLA);
193         bc().addCheckedLineEdit(displayscaleED, scaleLA);
194         bc().addCheckedLineEdit(heightED, heightLA);
195         bc().addCheckedLineEdit(widthED, widthLA);
196         bc().addCheckedLineEdit(xlED, lbLA);
197         bc().addCheckedLineEdit(ybED, lbLA);
198         bc().addCheckedLineEdit(xrED, rtLA);
199         bc().addCheckedLineEdit(ytED, rtLA);
200         bc().addCheckedLineEdit(fileED, fileLA);
201
202         external::TemplateManager::Templates::const_iterator i1, i2;
203         i1 = external::TemplateManager::get().getTemplates().begin();
204         i2 = external::TemplateManager::get().getTemplates().end();
205         for (; i1 != i2; ++i1)
206                 externalCO->addItem(qt_(i1->second.guiName), toqstr(i1->second.lyxName));
207         // Sort alphabetically by(localized) GUI name
208         externalCO->model()->sort(0);
209
210         // Fill the origins combo
211         for (size_t i = 0; i != sizeof(origins) / sizeof(origins[0]); ++i)
212                 originCO->addItem(qt_(origin_gui_strs[i]));
213
214         // add scale item
215         widthUnitCO->insertItem(0, qt_("Scale%"), "scale");
216
217         // remove all units from bb that depend on font or other dimensions
218         // we cannot use these, since we need to compare against absolute
219         // values from the image file.
220         xlUnitCO->noPercents();
221         xlUnitCO->removeFontDependent();
222         xrUnitCO->noPercents();
223         xrUnitCO->removeFontDependent();
224         ytUnitCO->noPercents();
225         ytUnitCO->removeFontDependent();
226         ybUnitCO->noPercents();
227         ybUnitCO->removeFontDependent();
228 }
229
230
231 bool GuiExternal::activateAspectratio() const
232 {
233         if (usingScale())
234                 return false;
235
236         QString const wstr = widthED->text();
237         if (wstr.isEmpty())
238                 return false;
239         bool wIsDbl;
240         double val = wstr.trimmed().toDouble(&wIsDbl);
241         if (wIsDbl && float_equal(val, 0.0, 0.05))
242                 return false;
243         Length l;
244         if (!wIsDbl && (!isValidLength(fromqstr(wstr), &l) || l.zero()))
245                 return false;
246
247         QString const hstr = heightED->text();
248         if (hstr.isEmpty())
249                 return false;
250         bool hIsDbl;
251         val = hstr.trimmed().toDouble(&hIsDbl);
252         if (hIsDbl && float_equal(val, 0.0, 0.05))
253                 return false;
254         if (!hIsDbl && (!isValidLength(fromqstr(hstr), &l) || l.zero()))
255                 return false;
256
257         return true;
258 }
259
260
261 bool GuiExternal::usingScale() const
262 {
263         return (widthUnitCO->itemData(
264                 widthUnitCO->currentIndex()).toString() == "scale");
265 }
266
267
268 void GuiExternal::bbChanged()
269 {
270         bbChanged_ = true;
271         changed();
272 }
273
274
275 void GuiExternal::browseClicked()
276 {
277         QString const template_name =
278                 externalCO->itemData(externalCO->currentIndex()).toString();
279         QString const str = browse(fileED->text(), template_name);
280         if (!str.isEmpty()) {
281                 fileED->setText(str);
282                 changed();
283         }
284 }
285
286
287 void GuiExternal::change_adaptor()
288 {
289         changed();
290 }
291
292
293 void GuiExternal::extraChanged(const QString & text)
294 {
295         extra_[extraFormatCO->currentText()] = text;
296         changed();
297 }
298
299
300 void GuiExternal::formatChanged(const QString & format)
301 {
302         extraED->setText(extra_[format]);
303 }
304
305
306 void GuiExternal::getbbClicked()
307 {
308         xlED->setText("0");
309         ybED->setText("0");
310         xrED->setText("0");
311         ytED->setText("0");
312
313         string const filename = fromqstr(fileED->text());
314         if (filename.empty())
315                 return;
316
317         FileName const abs_file(support::makeAbsPath(filename, fromqstr(bufferFilePath())));
318
319         // try to get it from the file, if possible
320         string bb = graphics::readBB_from_PSFile(abs_file);
321         if (bb.empty()) {
322                 // we don't, so ask the Graphics Cache if it has loaded the file
323                 int width = 0;
324                 int height = 0;
325
326                 graphics::Cache & gc = graphics::Cache::get();
327                 if (gc.inCache(abs_file)) {
328                         graphics::Image const * image = gc.item(abs_file)->image();
329
330                         if (image) {
331                                 width  = image->width();
332                                 height = image->height();
333                         }
334                 }
335                 bb = "0 0 " + convert<string>(width) + ' ' + convert<string>(height);
336         }
337
338         doubleToWidget(xlED, token(bb, ' ', 0));
339         doubleToWidget(ybED, token(bb, ' ', 1));
340         doubleToWidget(xrED, token(bb, ' ', 2));
341         doubleToWidget(ytED, token(bb, ' ', 3));
342         // the values from the file always have the bigpoint-unit bp
343         xlUnitCO->setCurrentIndex(0);
344         ybUnitCO->setCurrentIndex(0);
345         xrUnitCO->setCurrentIndex(0);
346         ytUnitCO->setCurrentIndex(0);
347
348         bbChanged_ = false;
349 }
350
351
352 void GuiExternal::sizeChanged()
353 {
354         aspectratioCB->setEnabled(activateAspectratio());
355         changed();
356 }
357
358
359 void GuiExternal::templateChanged()
360 {
361         updateTemplate();
362         changed();
363 }
364
365
366 void GuiExternal::widthUnitChanged()
367 {
368         if (usingScale())
369                 widthED->setValidator(new QDoubleValidator(0, 1000, 2, widthED));
370         else
371                 widthED->setValidator(unsignedLengthValidator(widthED));
372
373         heightED->setEnabled(!usingScale());
374         heightUnitCO->setEnabled(!usingScale());
375         changed();
376 }
377
378
379 static void setRotation(QLineEdit & angleED, QComboBox & originCO,
380         external::RotationData const & data)
381 {
382         originCO.setCurrentIndex(int(data.origin()));
383         doubleToWidget(&angleED, data.angle);
384 }
385
386
387 static void getRotation(external::RotationData & data,
388         QLineEdit const & angleED, QComboBox const & originCO)
389 {
390         typedef external::RotationData::OriginType OriginType;
391
392         data.origin(static_cast<OriginType>(originCO.currentIndex()));
393         data.angle = widgetToDoubleStr(&angleED);
394 }
395
396
397 static void setSize(QLineEdit & widthED, LengthCombo & widthUnitCO,
398         QLineEdit & heightED, LengthCombo & heightUnitCO,
399         QCheckBox & aspectratioCB,
400         external::ResizeData const & data)
401 {
402         bool using_scale = data.usingScale();
403         string scale = data.scale;
404         if (data.no_resize()) {
405                 // Everything is zero, so default to this!
406                 using_scale = true;
407                 scale = "100";
408         }
409
410         if (using_scale) {
411                 doubleToWidget(&widthED, scale);
412                 widthUnitCO.setCurrentItem("scale");
413         } else
414                 lengthToWidgets(&widthED, &widthUnitCO,
415                                 data.width.asString(), Length::defaultUnit());
416
417         string const h = data.height.zero() ? string() : data.height.asString();
418         Length::UNIT const default_unit = data.width.zero() ?
419                 Length::defaultUnit() : data.width.unit();
420         lengthToWidgets(&heightED, &heightUnitCO, h, default_unit);
421
422         heightED.setEnabled(!using_scale);
423         heightUnitCO.setEnabled(!using_scale);
424
425         aspectratioCB.setChecked(data.keepAspectRatio);
426
427         bool const disable_aspectRatio = using_scale ||
428                 data.width.zero() || data.height.zero();
429         aspectratioCB.setEnabled(!disable_aspectRatio);
430 }
431
432
433 static void getSize(external::ResizeData & data,
434         QLineEdit const & widthED, QComboBox const & widthUnitCO,
435         QLineEdit const & heightED, LengthCombo const & heightUnitCO,
436         QCheckBox const & aspectratioCB, bool const scaling)
437 {
438         if (scaling) {
439                 // scaling instead of a width
440                 data.scale = widgetToDoubleStr(&widthED);
441                 data.width = Length();
442         } else {
443                 data.width = Length(widgetsToLength(&widthED, &widthUnitCO));
444                 data.scale = string();
445         }
446         data.height = Length(widgetsToLength(&heightED, &heightUnitCO));
447         data.keepAspectRatio = aspectratioCB.isChecked();
448 }
449
450
451 void setCrop(QCheckBox & clipCB,
452         QLineEdit & xlED, QLineEdit & ybED,
453         QLineEdit & xrED, QLineEdit & ytED,
454         LengthCombo & xlUnitCO, LengthCombo & ybUnitCO,
455         LengthCombo & xrUnitCO, LengthCombo & ytUnitCO,
456         external::ClipData const & data)
457 {
458         clipCB.setChecked(data.clip);
459         Length::UNIT const default_unit = data.bbox.xl.zero() ?
460                 Length::defaultUnit() : data.bbox.xl.unit();
461         lengthToWidgets(&xlED, &xlUnitCO, data.bbox.xl, default_unit);
462         lengthToWidgets(&ybED, &ybUnitCO, data.bbox.yb, default_unit);
463         lengthToWidgets(&xrED, &xrUnitCO, data.bbox.xr, default_unit);
464         lengthToWidgets(&ytED, &ytUnitCO, data.bbox.yt, default_unit);
465 }
466
467
468 static void getCrop(external::ClipData & data,
469         QCheckBox const & clipCB,
470         QLineEdit const & xlED, QLineEdit const & ybED,
471         QLineEdit const & xrED, QLineEdit const & ytED,
472         LengthCombo const & xlUnitCO, LengthCombo const & ybUnitCO,
473         LengthCombo const & xrUnitCO, LengthCombo const & ytUnitCO,
474         bool bb_changed)
475 {
476         data.clip = clipCB.isChecked();
477
478         if (!bb_changed)
479                 return;
480
481         data.bbox.xl = Length(widgetsToLength(&xlED, &xlUnitCO));
482         data.bbox.yb = Length(widgetsToLength(&ybED, &ybUnitCO));
483         data.bbox.xr = Length(widgetsToLength(&xrED, &xrUnitCO));
484         data.bbox.yt = Length(widgetsToLength(&ytED, &ytUnitCO));
485 }
486
487
488 void GuiExternal::updateContents()
489 {
490         string const name =
491                 params_.filename.outputFileName(fromqstr(bufferFilePath()));
492         fileED->setText(toqstr(name));
493
494         externalCO->setCurrentIndex(
495                 externalCO->findData(toqstr(params_.templatename())));
496         updateTemplate();
497
498         draftCB->setChecked(params_.draft);
499
500         displayGB->setChecked(params_.display);
501         displayscaleED->setText(QString::number(params_.lyxscale));
502         bool scaled = params_.display && !isBufferReadonly() &&
503                         (params_.preview_mode != PREVIEW_INSTANT);
504         displayscaleED->setEnabled(scaled);
505         scaleLA->setEnabled(scaled);
506         displayGB->setEnabled(lyxrc.display_graphics);
507
508
509         setRotation(*angleED, *originCO, params_.rotationdata);
510
511         setSize(*widthED, *widthUnitCO, *heightED, *heightUnitCO,
512                 *aspectratioCB, params_.resizedata);
513
514         setCrop(*clipCB, *xlED, *ybED, *xrED, *ytED,
515                 *xlUnitCO, *ybUnitCO, *xrUnitCO, *ytUnitCO, params_.clipdata);
516         bbChanged_ = !params_.clipdata.bbox.empty();
517
518         isValid();
519 }
520
521
522 void GuiExternal::updateTemplate()
523 {
524         external::TemplateManager const & etm =
525                 external::TemplateManager::get();
526         external::Template const * const templ = etm.getTemplateByName(
527                 fromqstr(externalCO->itemData(externalCO->currentIndex()).toString()));
528         externalTB->setPlainText(toqstr(translateIfPossible(templ->helpText)));
529
530         // Ascertain which (if any) transformations the template supports
531         // and disable tabs and Group Boxes hosting unsupported transforms.
532         typedef vector<external::TransformID> TransformIDs;
533         TransformIDs const transformIds = templ->transformIds;
534         TransformIDs::const_iterator tr_begin = transformIds.begin();
535         TransformIDs::const_iterator const tr_end = transformIds.end();
536
537         bool rotate = std::find(tr_begin, tr_end, external::Rotate) != tr_end;
538         rotationGB->setEnabled(rotate);
539
540         bool resize = std::find(tr_begin, tr_end, external::Resize) != tr_end;
541         scaleGB->setEnabled(resize);
542
543         bool clip = std::find(tr_begin, tr_end, external::Clip) != tr_end;
544         cropGB->setEnabled(clip);
545
546         sizetab->setEnabled(rotate || resize || clip);
547         tab->setTabEnabled(tab->indexOf(sizetab), rotate || resize || clip);
548
549         bool found = std::find(tr_begin, tr_end, external::Extra) != tr_end;
550         optionsGB->setEnabled(found);
551
552         bool scaled = displayGB->isChecked() && displayGB->isEnabled() &&
553                         !isBufferReadonly() && (templ->preview_mode != PREVIEW_INSTANT);
554         displayscaleED->setEnabled(scaled);
555         scaleLA->setEnabled(scaled);
556
557         if (!found)
558                 return;
559
560         // Ascertain whether the template has any formats supporting
561         // the 'Extra' option
562         extra_.clear();
563         extraED->clear();
564         extraFormatCO->clear();
565
566         external::Template::Formats::const_iterator it  = templ->formats.begin();
567         external::Template::Formats::const_iterator end = templ->formats.end();
568         for (; it != end; ++it) {
569                 if (it->second.option_transformers.find(external::Extra) ==
570                     it->second.option_transformers.end())
571                         continue;
572                 string const format = it->first;
573                 string const opt = params_.extradata.get(format);
574                 extraFormatCO->addItem(toqstr(format));
575                 extra_[toqstr(format)] = toqstr(opt);
576         }
577
578         bool const enabled = extraFormatCO->count()  > 0;
579
580         optionsGB->setEnabled(enabled);
581         extraED->setEnabled(enabled && !isBufferReadonly());
582         extraFormatCO->setEnabled(enabled);
583
584         if (enabled) {
585                 extraFormatCO->setCurrentIndex(0);
586                 extraED->setText(extra_[extraFormatCO->currentText()]);
587         }
588 }
589
590
591 void GuiExternal::applyView()
592 {
593         params_.filename.set(fromqstr(fileED->text()), fromqstr(bufferFilePath()));
594         params_.settemplate(fromqstr(externalCO->itemData(externalCO->currentIndex()).toString()));
595
596         params_.draft = draftCB->isChecked();
597         params_.lyxscale = displayscaleED->text().toInt();
598         params_.display = displayGB->isChecked();
599
600         if (rotationGB->isEnabled())
601                 getRotation(params_.rotationdata, *angleED, *originCO);
602
603         if (scaleGB->isEnabled())
604                 getSize(params_.resizedata, *widthED, *widthUnitCO,
605                         *heightED, *heightUnitCO, *aspectratioCB, usingScale());
606
607         if (cropGB->isEnabled())
608                 getCrop(params_.clipdata, *clipCB, *xlED, *ybED, *xrED, *ytED,
609                         *xlUnitCO, *ybUnitCO, *xrUnitCO, *ytUnitCO, bbChanged_);
610
611         if (optionsGB->isEnabled()) {
612                 MapType::const_iterator it = extra_.begin();
613                 MapType::const_iterator const end = extra_.end();
614                 for (; it != end; ++it)
615                         params_.extradata.set(fromqstr(it.key()), fromqstr(it.value().trimmed()));
616         }
617 }
618
619
620 bool GuiExternal::initialiseParams(string const & data)
621 {
622         InsetExternal::string2params(data, buffer(), params_);
623         return true;
624 }
625
626
627 void GuiExternal::clearParams()
628 {
629         params_ = InsetExternalParams();
630 }
631
632
633 void GuiExternal::dispatchParams()
634 {
635         string const lfun = InsetExternal::params2string(params_, buffer());
636         dispatch(FuncRequest(getLfun(), lfun));
637 }
638
639
640 static QStringList templateFilters(QString const & template_name)
641 {
642         /// Determine the template file extension
643         external::TemplateManager const & etm =
644                 external::TemplateManager::get();
645         external::Template const * const et_ptr =
646                 etm.getTemplateByName(fromqstr(template_name));
647
648         string filter;
649         if (et_ptr && et_ptr->fileRegExp != "" && et_ptr->fileRegExp != "*") {
650                 filter += to_utf8(_(et_ptr->guiName));
651                 filter += " (";
652                 filter += et_ptr->fileRegExp;
653                 filter += ")";
654         }
655         return fileFilters(toqstr(filter));
656 }
657
658
659 QString GuiExternal::browse(QString const & input,
660                                      QString const & template_name) const
661 {
662         QString const title = qt_("Select external file");
663         QString const bufpath = bufferFilePath();
664         QStringList const filter = templateFilters(template_name);
665
666         QString const label1 = qt_("Documents|#o#O");
667         QString const dir1 = toqstr(lyxrc.document_path);
668
669         return browseRelToParent(input, bufpath, title, filter, false, label1, dir1);
670 }
671
672
673 Dialog * createGuiExternal(GuiView & lv) { return new GuiExternal(lv); }
674
675
676 } // namespace frontend
677 } // namespace lyx
678
679 #include "moc_GuiExternal.cpp"